diff --git a/src/main/java/world/bentobox/parkour/commands/RemoveWarpCommand.java b/src/main/java/world/bentobox/parkour/commands/RemoveWarpCommand.java index a6ba496..b72c4da 100644 --- a/src/main/java/world/bentobox/parkour/commands/RemoveWarpCommand.java +++ b/src/main/java/world/bentobox/parkour/commands/RemoveWarpCommand.java @@ -7,6 +7,7 @@ import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.database.objects.Island; +import world.bentobox.bentobox.managers.RanksManager; import world.bentobox.parkour.Parkour; import world.bentobox.parkour.ParkourManager; @@ -39,7 +40,7 @@ public boolean canExecute(User user, String label, List args) { // Check rank to use command int rank = Objects.requireNonNull(island).getRank(user); if (rank < island.getRankCommand(getUsage())) { - user.sendMessage("general.errors.insufficient-rank", TextVariables.RANK, user.getTranslation(getPlugin().getRanksManager().getRank(rank))); + user.sendMessage("general.errors.insufficient-rank", TextVariables.RANK, user.getTranslation(RanksManager.getInstance().getRank(rank))); return false; } diff --git a/src/test/java/world/bentobox/parkour/AbstractParkourTest.java b/src/test/java/world/bentobox/parkour/AbstractParkourTest.java index 90ac0da..d929ac3 100644 --- a/src/test/java/world/bentobox/parkour/AbstractParkourTest.java +++ b/src/test/java/world/bentobox/parkour/AbstractParkourTest.java @@ -55,8 +55,7 @@ * */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ Bukkit.class, BentoBox.class, User.class, Config.class, DatabaseSetup.class, Util.class, - RanksManager.class }) +@PrepareForTest({ Bukkit.class, BentoBox.class, User.class, Config.class, DatabaseSetup.class, Util.class }) public abstract class AbstractParkourTest { @Mock @@ -172,9 +171,6 @@ public void setUp() throws Exception { when(plugin.getFlagsManager()).thenReturn(fm); when(fm.getFlags()).thenReturn(Collections.emptyList()); - // RanksManager - Whitebox.setInternalState(RanksManager.class, "instance", rm); - when(rm.getRank(any())).thenReturn("ranks.member"); } } diff --git a/src/test/java/world/bentobox/parkour/commands/SetWarpCommandTest.java b/src/test/java/world/bentobox/parkour/commands/SetWarpCommandTest.java index 8a4ca3c..8dc45f4 100644 --- a/src/test/java/world/bentobox/parkour/commands/SetWarpCommandTest.java +++ b/src/test/java/world/bentobox/parkour/commands/SetWarpCommandTest.java @@ -26,7 +26,6 @@ import org.mockito.Mock; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.localization.TextVariables; @@ -116,10 +115,6 @@ public void setUp() throws Exception { Settings settings = new Settings(); when(addon.getSettings()).thenReturn(settings); - // RanksManager - Whitebox.setInternalState(RanksManager.class, "instance", rm); - when(rm.getRank(any())).thenReturn("ranks.member"); - // DUT cmd = new SetWarpCommand(ac); } diff --git a/src/test/java/world/bentobox/parkour/listeners/CourseRunnerListenerTest.java b/src/test/java/world/bentobox/parkour/listeners/CourseRunnerListenerTest.java index 84caa9e..be2f56b 100644 --- a/src/test/java/world/bentobox/parkour/listeners/CourseRunnerListenerTest.java +++ b/src/test/java/world/bentobox/parkour/listeners/CourseRunnerListenerTest.java @@ -30,8 +30,6 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.damage.DamageSource; -import org.bukkit.damage.DamageType; import org.bukkit.entity.Creeper; import org.bukkit.entity.Player; import org.bukkit.event.block.Action; @@ -283,8 +281,7 @@ public void testOnVisitorLeaveNotRuning() { */ @Test public void testOnPlayerDeath() { - PlayerDeathEvent e = new PlayerDeathEvent(player, DamageSource.builder(DamageType.ARROW).build(), - new ArrayList<>(), 0, 0, 0, 0, null); + PlayerDeathEvent e = new PlayerDeathEvent(player, null, null, 0, 0, 0, 0, null); crl.onPlayerDeath(e); assertFalse(prm.timers().containsKey(uuid)); assertFalse(prm.checkpoints().containsKey(uuid)); @@ -311,7 +308,7 @@ public void testOnVisitorFall() { PowerMockito.mockStatic(Util.class, RETURNS_MOCKS); prm.timers().put(uuid, System.currentTimeMillis() - 20000); // ~ 20 seconds ago prm.checkpoints().put(uuid, location); - EntityDamageEvent e = new EntityDamageEvent(player, null, null, null); + EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.VOID, null, 0); crl.onVisitorFall(e); verify(player).playEffect(EntityEffect.ENTITY_POOF); verify(player).setVelocity(new Vector(0, 0, 0)); @@ -328,7 +325,7 @@ public void testOnVisitorFall() { public void testOnVisitorFallNotVoid() { prm.timers().put(uuid, System.currentTimeMillis() - 20000); // ~ 20 seconds ago prm.checkpoints().put(uuid, location); - EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.BLOCK_EXPLOSION, 1D); + EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.BLOCK_EXPLOSION, null, 0); crl.onVisitorFall(e); verify(player, never()).playEffect(EntityEffect.ENTITY_POOF); verify(player, never()).setVelocity(new Vector(0, 0, 0)); @@ -342,7 +339,7 @@ public void testOnVisitorFallNotVoid() { */ @Test public void testOnVisitorFallNotRunning() { - EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.VOID, 1D); + EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.VOID, null, 1D); crl.onVisitorFall(e); verify(player, never()).playEffect(EntityEffect.ENTITY_POOF); verify(player, never()).setVelocity(new Vector(0, 0, 0)); @@ -357,7 +354,7 @@ public void testOnVisitorFallNotRunning() { @Test public void testOnVisitorFallNotPlayer() { Creeper creeper = mock(Creeper.class); - EntityDamageEvent e = new EntityDamageEvent(creeper, DamageCause.VOID, 1D); + EntityDamageEvent e = new EntityDamageEvent(creeper, DamageCause.VOID, null, 1D); crl.onVisitorFall(e); verify(creeper, never()).playEffect(EntityEffect.ENTITY_POOF); }