mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-27 11:37:36 +01:00
Added inWorld(World.class) to IWM
This had a ripple affect through the tests because now there are two inWorld() methods - one for Location and one for World.
This commit is contained in:
parent
f110aedc69
commit
0f5ab8ab7d
@ -78,7 +78,17 @@ public class IslandWorldManager {
|
||||
* @return true if in a world or false if not
|
||||
*/
|
||||
public boolean inWorld(Location loc) {
|
||||
return worlds.containsKey(Util.getWorld(loc.getWorld()));
|
||||
return inWorld(loc.getWorld());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a world is any of the island worlds
|
||||
*
|
||||
* @param world world
|
||||
* @return true if in a world or false if not
|
||||
*/
|
||||
public boolean inWorld(World world) {
|
||||
return worlds.containsKey(Util.getWorld(world));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,7 +146,8 @@ public class TestBSkyBlock {
|
||||
// Worlds
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
Mockito.when(plugin.getIWM()).thenReturn(iwm);
|
||||
when(iwm.inWorld(any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
PowerMockito.mockStatic(Util.class);
|
||||
when(Util.getWorld(Mockito.any())).thenReturn(world);
|
||||
// We want the read tabLimit call here
|
||||
|
@ -184,7 +184,8 @@ public class CycleClickTest {
|
||||
// IslandWorldManager
|
||||
iwm = mock(IslandWorldManager.class);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(iwm.getPermissionPrefix(Mockito.any())).thenReturn("bskyblock");
|
||||
|
||||
// Util
|
||||
@ -195,7 +196,8 @@ public class CycleClickTest {
|
||||
|
||||
@Test
|
||||
public void testNotInWorld() {
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
CycleClick udc = new CycleClick("LOCK");
|
||||
assertTrue(udc.onClick(panel, user, ClickType.LEFT, 5));
|
||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.wrong-world"));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package world.bentobox.bentobox.api.flags.clicklisteners;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -55,7 +56,8 @@ public class IslandToggleClickTest {
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
// Island World Manager
|
||||
iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(iwm.getPermissionPrefix(Mockito.any())).thenReturn("bskyblock");
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
@ -93,7 +95,8 @@ public class IslandToggleClickTest {
|
||||
|
||||
@Test
|
||||
public void testOnClickWrongWorld() {
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
listener.onClick(panel, user, ClickType.LEFT, 0);
|
||||
Mockito.verify(user).sendMessage("general.errors.wrong-world");
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package world.bentobox.bentobox.api.flags.clicklisteners;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -48,7 +49,8 @@ public class WorldToggleClickTest {
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
// Island World Manager
|
||||
iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(iwm.getPermissionPrefix(Mockito.any())).thenReturn("bskyblock");
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
@ -77,7 +79,8 @@ public class WorldToggleClickTest {
|
||||
|
||||
@Test
|
||||
public void testOnClickWrongWorld() {
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
listener.onClick(panel, user, ClickType.LEFT, 0);
|
||||
Mockito.verify(user).sendMessage("general.errors.wrong-world");
|
||||
}
|
||||
|
@ -52,7 +52,8 @@ public class BannedVisitorCommandsTest {
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
// Island World Manager
|
||||
iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(iwm.getPermissionPrefix(Mockito.any())).thenReturn("bskyblock");
|
||||
when(iwm.getVisitorBannedCommands(Mockito.any())).thenReturn(new ArrayList<>());
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
@ -105,13 +106,15 @@ public class BannedVisitorCommandsTest {
|
||||
BannedVisitorCommands bvc = new BannedVisitorCommands(plugin);
|
||||
|
||||
// Not in world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
|
||||
bvc.onVisitorCommand(e);
|
||||
assertFalse(e.isCancelled());
|
||||
|
||||
// In world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
// Op
|
||||
when(player.isOp()).thenReturn(true);
|
||||
bvc.onVisitorCommand(e);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package world.bentobox.bentobox.listeners;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -41,7 +42,8 @@ public class DeathListenerTest {
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
// Island World Manager
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(iwm.getPermissionPrefix(Mockito.any())).thenReturn("bskyblock");
|
||||
when(iwm.getVisitorBannedCommands(Mockito.any())).thenReturn(new ArrayList<>());
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
@ -90,7 +90,8 @@ public class NetherPortalsTest {
|
||||
when(iwm.getEndWorld(Mockito.any())).thenReturn(end);
|
||||
when(iwm.getIslandWorld(Mockito.any())).thenReturn(world);
|
||||
when(iwm.getNetherWorld(Mockito.any())).thenReturn(nether);
|
||||
when(iwm.inWorld(any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(iwm.getNetherSpawnRadius(Mockito.any())).thenReturn(100);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
@ -147,6 +148,11 @@ public class NetherPortalsTest {
|
||||
Util.setPlugin(plugin);
|
||||
}
|
||||
|
||||
private void wrongWorld() {
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.listeners.NetherPortals#NetherPortals(world.bentobox.bentobox.BentoBox)}.
|
||||
*/
|
||||
@ -278,7 +284,7 @@ public class NetherPortalsTest {
|
||||
|
||||
// Right cause, end exists, wrong world
|
||||
when(loc.getWorld()).thenReturn(mock(World.class));
|
||||
when(iwm.inWorld(any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
PlayerPortalEvent e = new PlayerPortalEvent(null, loc, null, null, TeleportCause.END_PORTAL);
|
||||
when(iwm.isEndGenerate(world)).thenReturn(true);
|
||||
np.onEndIslandPortal(e);
|
||||
@ -321,12 +327,13 @@ public class NetherPortalsTest {
|
||||
Location from = mock(Location.class);
|
||||
when(from.getWorld()).thenReturn(mock(World.class));
|
||||
// Not in world
|
||||
when(iwm.inWorld(any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
EntityPortalEvent e = new EntityPortalEvent(ent, from, null, null);
|
||||
np.onEntityPortal(e);
|
||||
assertFalse(e.isCancelled());
|
||||
// In world
|
||||
when(iwm.inWorld(any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
e = new EntityPortalEvent(ent, from, null, null);
|
||||
np.onEntityPortal(e);
|
||||
assertTrue(e.isCancelled());
|
||||
@ -353,7 +360,7 @@ public class NetherPortalsTest {
|
||||
Location from = mock(Location.class);
|
||||
when(from.getWorld()).thenReturn(mock(World.class));
|
||||
// Not in world
|
||||
when(iwm.inWorld(any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
|
||||
EntityExplodeEvent e = new EntityExplodeEvent(en, from, affectedBlocks, 0);
|
||||
|
||||
@ -514,7 +521,7 @@ public class NetherPortalsTest {
|
||||
NetherPortals np = new NetherPortals(plugin);
|
||||
Location from = mock(Location.class);
|
||||
when(from.getWorld()).thenReturn(mock(World.class));
|
||||
when(iwm.inWorld(any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
PlayerPortalEvent e = new PlayerPortalEvent(null, from, null, null, TeleportCause.NETHER_PORTAL);
|
||||
assertFalse(np.onNetherPortal(e));
|
||||
}
|
||||
|
@ -117,7 +117,8 @@ public class ObsidianToLavaTest {
|
||||
User.setPlugin(plugin);
|
||||
|
||||
// Put player in world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
// Put player on island
|
||||
when(im.userIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(true);
|
||||
// Set as survival
|
||||
@ -165,10 +166,12 @@ public class ObsidianToLavaTest {
|
||||
PlayerInteractEvent event = new PlayerInteractEvent(who, action, item, clickedBlock, BlockFace.EAST);
|
||||
|
||||
// Test not in world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
assertFalse(listener.onPlayerInteract(event));
|
||||
// Put player in world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
|
||||
// Test different game modes
|
||||
for (GameMode gm : GameMode.values()) {
|
||||
|
@ -107,7 +107,8 @@ public class ChestDamageListenerTest {
|
||||
|
||||
// Worlds
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.inWorld(any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Monsters and animals
|
||||
|
@ -94,7 +94,8 @@ public class EnderChestListenerTest {
|
||||
Map<String, Boolean> worldFlags = new HashMap<>();
|
||||
when(ws.getWorldFlags()).thenReturn(worldFlags);
|
||||
// By default everything is in world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
|
||||
// Ender chest use is not allowed by default
|
||||
Flags.ENDER_CHEST.setSetting(world, false);
|
||||
@ -147,7 +148,8 @@ public class EnderChestListenerTest {
|
||||
BlockFace clickedBlockFace = BlockFace.EAST;
|
||||
PlayerInteractEvent e = new PlayerInteractEvent(player, action, item, clickedBlock, clickedBlockFace);
|
||||
// Not in world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
new EnderChestListener().onEnderChestOpen(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
@ -100,7 +100,8 @@ public class EndermanListenerTest {
|
||||
|
||||
// Worlds
|
||||
iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.inWorld(any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Monsters and animals
|
||||
@ -156,7 +157,8 @@ public class EndermanListenerTest {
|
||||
*/
|
||||
@Test
|
||||
public void testOnEndermanGriefWrongWorld() {
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
EndermanListener listener = new EndermanListener();
|
||||
Block to = mock(Block.class);
|
||||
Material block = Material.ACACIA_DOOR;
|
||||
|
@ -150,7 +150,8 @@ public class EnterExitListenerTest {
|
||||
|
||||
// Island World Manager
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Player's manager
|
||||
|
@ -95,7 +95,8 @@ public class FireListenerTest {
|
||||
|
||||
// Worlds
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.inWorld(any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Monsters and animals
|
||||
|
@ -2,6 +2,7 @@ package world.bentobox.bentobox.listeners.flags;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -65,7 +66,8 @@ public class InvincibleVisitorsListenerTest {
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
// Island World Manager
|
||||
iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(iwm.getPermissionPrefix(Mockito.any())).thenReturn("bskyblock");
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
@ -186,7 +188,8 @@ public class InvincibleVisitorsListenerTest {
|
||||
|
||||
@Test
|
||||
public void testOnVisitorGetDamageNotInWorld() {
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D);
|
||||
listener.onVisitorGetDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
@ -194,7 +197,8 @@ public class InvincibleVisitorsListenerTest {
|
||||
|
||||
@Test
|
||||
public void testOnVisitorGetDamageNotInIvSettings() {
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.BLOCK_EXPLOSION, 0D);
|
||||
listener.onVisitorGetDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
|
@ -4,6 +4,7 @@
|
||||
package world.bentobox.bentobox.listeners.flags;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -76,7 +77,8 @@ public class IslandRespawnListenerTest {
|
||||
// Island World Manager
|
||||
iwm = mock(IslandWorldManager.class);
|
||||
// All locations are in world by default
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
PowerMockito.mockStatic(Util.class);
|
||||
@ -152,7 +154,8 @@ public class IslandRespawnListenerTest {
|
||||
*/
|
||||
@Test
|
||||
public void testOnPlayerRespawnWrongWorld() {
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
// Die
|
||||
List<ItemStack> drops = new ArrayList<>();
|
||||
PlayerDeathEvent e = new PlayerDeathEvent(player, drops, 0, 0, 0, 0, "");
|
||||
|
@ -100,7 +100,8 @@ public class ItemFrameListenerTest {
|
||||
|
||||
// Worlds
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.inWorld(any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Monsters and animals
|
||||
|
@ -106,7 +106,8 @@ public class PVPListenerTest {
|
||||
User.setPlugin(plugin);
|
||||
// Island World Manager
|
||||
iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(iwm.getPermissionPrefix(Mockito.any())).thenReturn("bskyblock");
|
||||
// No visitor protection right now
|
||||
when(iwm.getIvSettings(Mockito.any())).thenReturn(new ArrayList<>());
|
||||
@ -194,6 +195,11 @@ public class PVPListenerTest {
|
||||
when(plugin.getNotifier()).thenReturn(notifier);
|
||||
}
|
||||
|
||||
private void wrongWorld() {
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.listeners.flags.PVPListener#onEntityDamage(org.bukkit.event.entity.EntityDamageByEntityEvent)}.
|
||||
*/
|
||||
@ -249,7 +255,7 @@ public class PVPListenerTest {
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
new PVPListener().onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
@ -282,7 +288,8 @@ public class PVPListenerTest {
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
new PVPListener().onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
@ -315,7 +322,8 @@ public class PVPListenerTest {
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
new PVPListener().onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
@ -345,7 +353,7 @@ public class PVPListenerTest {
|
||||
new PVPListener().onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
// Wrong world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
new PVPListener().onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
@ -374,7 +382,7 @@ public class PVPListenerTest {
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
new PVPListener().onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
@ -548,13 +556,14 @@ public class PVPListenerTest {
|
||||
Mockito.verify(hook).remove();
|
||||
|
||||
// Wrong world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
pfe = new PlayerFishEvent(player, player2, hook, null);
|
||||
new PVPListener().onFishing(pfe);
|
||||
assertFalse(pfe.isCancelled());
|
||||
|
||||
// Correct world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
|
||||
// Allow PVP
|
||||
when(island.isAllowed(Mockito.any())).thenReturn(true);
|
||||
@ -563,7 +572,7 @@ public class PVPListenerTest {
|
||||
assertFalse(pfe.isCancelled());
|
||||
|
||||
// Wrong world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
pfe = new PlayerFishEvent(player, player2, hook, null);
|
||||
new PVPListener().onFishing(pfe);
|
||||
assertFalse(pfe.isCancelled());
|
||||
@ -680,7 +689,7 @@ public class PVPListenerTest {
|
||||
Mockito.verify(notifier).notify(Mockito.any(), Mockito.eq(Flags.PVP_OVERWORLD.getHintReference()));
|
||||
|
||||
// Wrong world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
e = new PotionSplashEvent(tp, map);
|
||||
new PVPListener().onSplashPotionSplash(e);
|
||||
assertFalse(e.isCancelled());
|
||||
@ -707,7 +716,7 @@ public class PVPListenerTest {
|
||||
assertFalse(e.isCancelled());
|
||||
|
||||
// Wrong world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
e = new PotionSplashEvent(tp, map);
|
||||
new PVPListener().onSplashPotionSplash(e);
|
||||
assertFalse(e.isCancelled());
|
||||
@ -763,7 +772,7 @@ public class PVPListenerTest {
|
||||
Mockito.verify(notifier).notify(Mockito.any(), Mockito.eq(Flags.INVINCIBLE_VISITORS.getHintReference()));
|
||||
|
||||
// Wrong world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
e = new PotionSplashEvent(tp, map);
|
||||
new PVPListener().onSplashPotionSplash(e);
|
||||
assertFalse(e.isCancelled());
|
||||
@ -833,7 +842,7 @@ public class PVPListenerTest {
|
||||
assertFalse(ae.getAffectedEntities().contains(player2));
|
||||
Mockito.verify(notifier).notify(Mockito.any(), Mockito.eq(Flags.PVP_OVERWORLD.getHintReference()));
|
||||
// Wrong world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
listener.onLingeringPotionSplash(e);
|
||||
// No change to results
|
||||
assertEquals(3, ae.getAffectedEntities().size());
|
||||
@ -868,7 +877,7 @@ public class PVPListenerTest {
|
||||
assertEquals(4, ae.getAffectedEntities().size());
|
||||
Mockito.verify(player, Mockito.never()).sendMessage(Flags.PVP_OVERWORLD.getHintReference());
|
||||
// Wrong world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
listener.onLingeringPotionSplash(e);
|
||||
assertEquals(4, ae.getAffectedEntities().size());
|
||||
Mockito.verify(player, Mockito.never()).sendMessage(Flags.PVP_OVERWORLD.getHintReference());
|
||||
@ -908,7 +917,7 @@ public class PVPListenerTest {
|
||||
assertFalse(ae.getAffectedEntities().contains(player2));
|
||||
Mockito.verify(notifier).notify(Mockito.any(), Mockito.eq(Flags.INVINCIBLE_VISITORS.getHintReference()));
|
||||
// Wrong world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
listener.onLingeringPotionSplash(e);
|
||||
assertEquals(3, ae.getAffectedEntities().size());
|
||||
assertFalse(ae.getAffectedEntities().contains(player2));
|
||||
@ -948,7 +957,7 @@ public class PVPListenerTest {
|
||||
assertFalse(ae.getAffectedEntities().contains(player2));
|
||||
Mockito.verify(notifier).notify(Mockito.any(), Mockito.eq(Flags.INVINCIBLE_VISITORS.getHintReference()));
|
||||
// Wrong world
|
||||
when(iwm.inWorld(Mockito.any())).thenReturn(false);
|
||||
wrongWorld();
|
||||
listener.onLingeringPotionSplash(e);
|
||||
assertEquals(3, ae.getAffectedEntities().size());
|
||||
assertFalse(ae.getAffectedEntities().contains(player2));
|
||||
|
@ -110,7 +110,8 @@ public class TNTListenerTest {
|
||||
|
||||
// Worlds
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.inWorld(any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Monsters and animals
|
||||
|
@ -155,7 +155,8 @@ public class IslandsManagerTest {
|
||||
// Worlds
|
||||
iwm = mock(IslandWorldManager.class);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
when(iwm.inWorld(any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
|
||||
PowerMockito.mockStatic(Util.class);
|
||||
when(Util.getWorld(Mockito.any())).thenReturn(world);
|
||||
@ -472,7 +473,8 @@ public class IslandsManagerTest {
|
||||
assertEquals(Optional.empty(), im.getIslandAt(new Location(world, 100000, 120, -100000)));
|
||||
|
||||
// not in world
|
||||
when(iwm.inWorld(any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
assertEquals(Optional.empty(), im.getIslandAt(new Location(world, 100000, 120, -100000)));
|
||||
assertEquals(Optional.empty(), im.getIslandAt(location));
|
||||
|
||||
|
@ -83,7 +83,8 @@ public class PlayersManagerTest {
|
||||
when(nether.getName()).thenReturn("world_nether");
|
||||
end = mock(World.class);
|
||||
when(end.getName()).thenReturn("world_the_end");
|
||||
when(iwm.inWorld(any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Settings
|
||||
|
@ -52,7 +52,8 @@ public class IslandCacheTest {
|
||||
// Worlds
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
when(iwm.inWorld(any())).thenReturn(true);
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
|
||||
PowerMockito.mockStatic(Util.class);
|
||||
when(Util.getWorld(Mockito.any())).thenReturn(world);
|
||||
|
Loading…
Reference in New Issue
Block a user