Fixed casting issues for BlockBreakListener
This commit is contained in:
parent
0a69a63f3a
commit
110c5cbfd5
2 changed files with 14 additions and 6 deletions
|
@ -45,12 +45,7 @@ public class BlockBreakListener implements Listener {
|
|||
}
|
||||
|
||||
for (LiftBlock lb : f.getRealDoorBlocks()) {
|
||||
Location loc;
|
||||
if (lb.getMat().toString().contains("DOOR")) {
|
||||
loc = DoorUtil.getLowerLocationOfDoor(b);
|
||||
} else {
|
||||
loc = b.getLocation();
|
||||
}
|
||||
Location loc = DoorUtil.getLowerLocationOfDoor(b);
|
||||
if (lb.getWorld().equals(Objects.requireNonNull(loc.getWorld(), "World is null at BlockBreakListener").getName())
|
||||
&& lb.getX() == loc.getBlockX()
|
||||
&& lb.getY() == loc.getBlockY()
|
||||
|
|
|
@ -86,6 +86,8 @@ public class DoorUtil {
|
|||
}
|
||||
|
||||
public static Location getLowerLocationOfDoor(@Nonnull Block block) {
|
||||
if (!isDoor(block)) return block.getLocation();
|
||||
|
||||
if (XMaterial.isNewVersion()) {
|
||||
org.bukkit.block.data.type.Door door = (org.bukkit.block.data.type.Door) block.getBlockData();
|
||||
Location lower;
|
||||
|
@ -119,4 +121,15 @@ public class DoorUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isDoor(Block b) {
|
||||
if (b == null) {
|
||||
return false;
|
||||
}
|
||||
if (XMaterial.isNewVersion()) {
|
||||
return b.getBlockData() instanceof org.bukkit.block.data.type.Door;
|
||||
} else {
|
||||
return b.getState().getData() instanceof org.bukkit.material.Door;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue