Removed deprecated calls from IslandsManager for trapdoor check

This commit is contained in:
tastybento 2018-08-02 19:01:23 -07:00
parent d3b5411b1b
commit 4a1dede795
2 changed files with 13 additions and 19 deletions

View File

@ -14,14 +14,13 @@ import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Openable;
import org.bukkit.entity.Boat; import org.bukkit.entity.Boat;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.material.SimpleAttachableMaterialData;
import org.bukkit.material.TrapDoor;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
@ -197,17 +196,12 @@ public class IslandsManager {
return false; return false;
} }
MaterialData md = ground.getState().getData(); // Check for trapdoors
if (md instanceof SimpleAttachableMaterialData) { BlockData bd = ground.getBlockData();
if (md instanceof TrapDoor) { if (bd instanceof Openable) {
TrapDoor trapDoor = (TrapDoor) md; return !((Openable)bd).isOpen();
if (trapDoor.isOpen()) {
return false;
}
} else {
return false;
}
} }
if (ground.getType().equals(Material.CACTUS) || ground.getType().toString().contains("BOAT") || ground.getType().toString().contains("FENCE") if (ground.getType().equals(Material.CACTUS) || ground.getType().toString().contains("BOAT") || ground.getType().toString().contains("FENCE")
|| ground.getType().equals(Material.SIGN) || ground.getType().equals(Material.WALL_SIGN)) { || ground.getType().equals(Material.SIGN) || ground.getType().equals(Material.WALL_SIGN)) {
return false; return false;

View File

@ -27,6 +27,8 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Openable;
import org.bukkit.entity.Cow; import org.bukkit.entity.Cow;
import org.bukkit.entity.Creeper; import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -35,8 +37,6 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Slime; import org.bukkit.entity.Slime;
import org.bukkit.entity.Wither; import org.bukkit.entity.Wither;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.material.MaterialData;
import org.bukkit.material.TrapDoor;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -146,8 +146,8 @@ public class IslandsManagerTest {
// Neutral BlockState // Neutral BlockState
blockState = mock(BlockState.class); blockState = mock(BlockState.class);
when(ground.getState()).thenReturn(blockState); when(ground.getState()).thenReturn(blockState);
MaterialData md = mock(MaterialData.class); BlockData bd = mock(BlockData.class);
when(blockState.getData()).thenReturn(md); when(blockState.getBlockData()).thenReturn(bd);
// Online players // Online players
// Return a set of online players // Return a set of online players
@ -271,9 +271,9 @@ public class IslandsManagerTest {
when(ground.getType()).thenReturn(Material.OAK_TRAPDOOR); when(ground.getType()).thenReturn(Material.OAK_TRAPDOOR);
// Open trapdoor // Open trapdoor
TrapDoor trapDoor = mock(TrapDoor.class); Openable trapDoor = mock(Openable.class);
when(trapDoor.isOpen()).thenReturn(true); when(trapDoor.isOpen()).thenReturn(true);
when(blockState.getData()).thenReturn(trapDoor); when(ground.getBlockData()).thenReturn(trapDoor);
assertFalse("Open trapdoor", manager.isSafeLocation(location)); assertFalse("Open trapdoor", manager.isSafeLocation(location));