Fixed chair width check.

Fixed chair sign check.
This commit is contained in:
cnaude 2013-03-01 13:11:00 -07:00
parent 1a3c217284
commit 358df624e9
2 changed files with 16 additions and 5 deletions

View File

@ -98,6 +98,15 @@ public class EventListener implements Listener {
}
}
public boolean isValidChair(Block block) {
for (ChairBlock cb : plugin.allowedBlocks) {
if (cb.getMat().equals(block.getType())) {
return true;
}
}
return false;
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.hasBlock() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
@ -217,6 +226,8 @@ public class EventListener implements Listener {
chairwidth += getChairWidth(block, BlockFace.SOUTH);
}
plugin.logInfo("Width:" + chairwidth);
if (chairwidth > plugin.maxChairWidth) {
return;
}
@ -284,7 +295,7 @@ public class EventListener implements Listener {
for (int i = 1; i <= plugin.maxChairWidth; i++) {
Block relative = block.getRelative(face, i);
if (relative.getState().getData() instanceof Stairs) {
if (plugin.allowedBlocks.contains(relative.getType()) && ((Stairs) relative.getState().getData()).getDescendingDirection() == ((Stairs) block.getState().getData()).getDescendingDirection()) {
if (isValidChair(relative) && ((Stairs) relative.getState().getData()).getDescendingDirection() == ((Stairs) block.getState().getData()).getDescendingDirection()) {
width++;
} else {
break;
@ -299,7 +310,7 @@ 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; true; i++) {
Block relative = block.getRelative(face, i);
if (!plugin.allowedBlocks.contains(relative.getType()) || (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 {
@ -317,7 +328,7 @@ public class EventListener implements Listener {
int x = relative.getLocation().getBlockX();
int y = relative.getLocation().getBlockY();
int z = relative.getLocation().getBlockZ();
if (!plugin.allowedBlocks.contains(relative.getType()) || (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)) {

View File

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