Prevent sign/frame check from running away.

This commit is contained in:
cnaude 2013-04-29 23:18:38 -07:00
parent 40d7a8b6ab
commit 388a27b475
2 changed files with 13 additions and 7 deletions

View File

@ -59,7 +59,7 @@ public class EventListener implements Listener {
}
private void delayedSitTask() {
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
plugin.sendSit();
@ -309,9 +309,11 @@ public class EventListener implements Listener {
private boolean checkSign(Block block, BlockFace face) {
// Go through the blocks next to the clicked block and check if are signs on the end.
for (int i = 1; true; i++) {
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 (!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 {
@ -319,17 +321,20 @@ public class EventListener implements Listener {
}
}
}
return false;
}
private boolean checkFrame(Block block, BlockFace face, Player player) {
// Go through the blocks next to the clicked block and check if are signs on the end.
for (int i = 1; true; i++) {
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 (!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)) {
@ -346,5 +351,6 @@ public class EventListener implements Listener {
}
}
}
return false;
}
}

View File

@ -1,5 +1,5 @@
name: Chairs
version: 2.0.2
version: 2.0.3
description: Let players sit on blocks.
authors:
- spoothie