mirror of
https://github.com/BentoBoxWorld/AcidIsland.git
synced 2024-11-25 20:25:37 +01:00
Prevent chest boats from causing acid damage.
Fixes #146. Added test classes too.
This commit is contained in:
parent
40b382d878
commit
198cc66319
@ -258,7 +258,7 @@ public class AcidEffect implements Listener {
|
||||
* @param player - player
|
||||
* @return true if player is safe
|
||||
*/
|
||||
private boolean isSafeFromAcid(Player player) {
|
||||
boolean isSafeFromAcid(Player player) {
|
||||
// Check for GodMode
|
||||
if (isEssentialsGodMode(player)
|
||||
// Protect visitors
|
||||
@ -275,7 +275,8 @@ public class AcidEffect implements Listener {
|
||||
return true;
|
||||
}
|
||||
// Check if player is on a boat
|
||||
if (player.getVehicle() != null && player.getVehicle().getType().equals(EntityType.BOAT)) {
|
||||
if (player.getVehicle() != null && (player.getVehicle().getType().equals(EntityType.BOAT)
|
||||
|| player.getVehicle().getType().equals(EntityType.CHEST_BOAT))) {
|
||||
// I'M ON A BOAT! I'M ON A BOAT! A %^&&* BOAT! SNL Sketch. https://youtu.be/avaSdC0QOUM.
|
||||
return true;
|
||||
}
|
||||
|
@ -60,7 +60,6 @@ import world.bentobox.bentobox.managers.CommandsManager;
|
||||
import world.bentobox.bentobox.managers.FlagsManager;
|
||||
import world.bentobox.bentobox.managers.IslandWorldManager;
|
||||
import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.managers.RanksManager;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
@ -202,11 +201,6 @@ public class AcidIslandTest {
|
||||
|
||||
// Settings
|
||||
when(plugin.getSettings()).thenReturn(settings);
|
||||
|
||||
// RanksManager
|
||||
RanksManager rm = new RanksManager();
|
||||
when(plugin.getRanksManager()).thenReturn(rm);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -648,4 +648,57 @@ public class AcidEffectTest {
|
||||
verify(player).damage(2.0d); // Reduced due to armor
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#isSafeFromAcid(Player)}.
|
||||
*/
|
||||
@Test
|
||||
public void testIsSafeFromAcid() {
|
||||
assertFalse(ae.isSafeFromAcid(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#isSafeFromAcid(Player)}.
|
||||
*/
|
||||
@Test
|
||||
public void testIsSafeFromAcidEssentialGodMode() {
|
||||
when(essentialsUser.isGodModeEnabled()).thenReturn(true);
|
||||
assertTrue(ae.isSafeFromAcid(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#isSafeFromAcid(Player)}.
|
||||
*/
|
||||
@Test
|
||||
public void testIsSafeFromAcidBoat() {
|
||||
when(player.isInsideVehicle()).thenReturn(true);
|
||||
Entity boat = mock(Entity.class);
|
||||
when(boat.getType()).thenReturn(EntityType.BOAT);
|
||||
when(player.getVehicle()).thenReturn(boat);
|
||||
assertTrue(ae.isSafeFromAcid(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#isSafeFromAcid(Player)}.
|
||||
*/
|
||||
@Test
|
||||
public void testIsSafeFromAcidChestBoat() {
|
||||
when(player.isInsideVehicle()).thenReturn(true);
|
||||
Entity boat = mock(Entity.class);
|
||||
when(boat.getType()).thenReturn(EntityType.CHEST_BOAT);
|
||||
when(player.getVehicle()).thenReturn(boat);
|
||||
assertTrue(ae.isSafeFromAcid(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#isSafeFromAcid(Player)}.
|
||||
*/
|
||||
@Test
|
||||
public void testIsSafeFromAcidFullArmor() {
|
||||
when(settings.isFullArmorProtection()).thenReturn(true);
|
||||
ItemStack[] armor = { new ItemStack(Material.CHAINMAIL_CHESTPLATE), new ItemStack(Material.CHAINMAIL_HELMET) };
|
||||
when(inv.getArmorContents()).thenReturn(armor);
|
||||
when(player.getInventory()).thenReturn(inv);
|
||||
assertTrue(ae.isSafeFromAcid(player));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user