Fix casting error.

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

View File

@ -70,7 +70,7 @@ public class EventListener implements Listener {
public void run() {
plugin.sendSit();
}
}, 20 );
}, 20);
}
@EventHandler
@ -335,14 +335,24 @@ 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 (plugin.validSigns.contains(relative.getType())) {
return true;
} else {
return false;
}
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,26 +363,26 @@ public class EventListener implements Listener {
for (int i = 1; i <= 100; i++) {
Block relative = block.getRelative(face, i);
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();
int y2 = e.getLocation().getBlockY();
int z2 = e.getLocation().getBlockZ();
if (x == x2 && y == y2 && z == z2) {
return true;
}
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();
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();
int y2 = e.getLocation().getBlockY();
int z2 = e.getLocation().getBlockZ();
if (x == x2 && y == y2 && z == z2) {
return true;
}
}
} else {
return false;
}
return false;
} else {
return false;
}
}
return false;