Fix casting error.

This commit is contained in:
cnaude 2013-07-01 21:19:29 -07:00
parent e659eca5be
commit 4cc71ae667

View File

@ -335,15 +335,25 @@ public class EventListener implements Listener {
// Go through the blocks next to the clicked block and check if are signs on the end.
for (int i = 1; i <= 100; i++) {
Block relative = block.getRelative(face, i);
if (!isValidChair(relative) || (block.getState().getData() instanceof Stairs
&& ((Stairs) relative.getState().getData()).getDescendingDirection()
!= ((Stairs) block.getState().getData()).getDescendingDirection())) {
if (checkDirection(block, relative)) {
continue;
}
if (plugin.validSigns.contains(relative.getType())) {
return true;
} else {
return false;
}
}
return false;
}
private boolean checkDirection(Block block1, Block block2) {
if (block1.getState().getData() instanceof Stairs
&& block2.getState().getData() instanceof Stairs) {
if (((Stairs) block1.getState().getData()).getDescendingDirection()
.equals(((Stairs) block2.getState().getData()).getDescendingDirection())) {
return true;
}
}
return false;
}
@ -353,13 +363,13 @@ public class EventListener implements Listener {
for (int i = 1; i <= 100; i++) {
Block relative = block.getRelative(face, i);
if (checkDirection(block, relative)) {
continue;
}
if (relative.getType().equals(Material.AIR)) {
int x = relative.getLocation().getBlockX();
int y = relative.getLocation().getBlockY();
int z = relative.getLocation().getBlockZ();
if (!isValidChair(relative) || (block.getState().getData() instanceof Stairs
&& ((Stairs) relative.getState().getData()).getDescendingDirection()
!= ((Stairs) block.getState().getData()).getDescendingDirection())) {
if (relative.getType().equals(Material.AIR)) {
for (Entity e : player.getNearbyEntities(plugin.distance, plugin.distance, plugin.distance)) {
if (e instanceof ItemFrame && plugin.validSigns.contains(Material.ITEM_FRAME)) {
int x2 = e.getLocation().getBlockX();
@ -370,11 +380,11 @@ public class EventListener implements Listener {
}
}
}
return false;
} else {
return false;
}
}
}
return false;
}
}