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

@ -97,6 +97,15 @@ public class EventListener implements Listener {
standList.clear(); standList.clear();
} }
} }
public boolean isValidChair(Block block) {
for (ChairBlock cb : plugin.allowedBlocks) {
if (cb.getMat().equals(block.getType())) {
return true;
}
}
return false;
}
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
@ -216,6 +225,8 @@ public class EventListener implements Listener {
chairwidth += getChairWidth(block, BlockFace.NORTH); chairwidth += getChairWidth(block, BlockFace.NORTH);
chairwidth += getChairWidth(block, BlockFace.SOUTH); chairwidth += getChairWidth(block, BlockFace.SOUTH);
} }
plugin.logInfo("Width:" + chairwidth);
if (chairwidth > plugin.maxChairWidth) { if (chairwidth > plugin.maxChairWidth) {
return; return;
@ -283,8 +294,8 @@ public class EventListener implements Listener {
// Go through the blocks next to the clicked block and check if there are any further stairs. // Go through the blocks next to the clicked block and check if there are any further stairs.
for (int i = 1; i <= plugin.maxChairWidth; i++) { for (int i = 1; i <= plugin.maxChairWidth; i++) {
Block relative = block.getRelative(face, i); Block relative = block.getRelative(face, i);
if (relative.getState().getData() instanceof Stairs) { 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++; width++;
} else { } else {
break; 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. // 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; true; i++) {
Block relative = block.getRelative(face, 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())) { if (plugin.validSigns.contains(relative.getType())) {
return true; return true;
} else { } else {
@ -317,7 +328,7 @@ public class EventListener implements Listener {
int x = relative.getLocation().getBlockX(); int x = relative.getLocation().getBlockX();
int y = relative.getLocation().getBlockY(); int y = relative.getLocation().getBlockY();
int z = relative.getLocation().getBlockZ(); 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)) { if (relative.getType().equals(Material.AIR)) {
for (Entity e : player.getNearbyEntities(plugin.distance, plugin.distance, plugin.distance)) { for (Entity e : player.getNearbyEntities(plugin.distance, plugin.distance, plugin.distance)) {
if (e instanceof ItemFrame && plugin.validSigns.contains(Material.ITEM_FRAME)) { if (e instanceof ItemFrame && plugin.validSigns.contains(Material.ITEM_FRAME)) {

View File

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