From b420e44ff86910637f2a90c48bcc1a2a3462fc48 Mon Sep 17 00:00:00 2001 From: Shevchik Date: Mon, 30 Sep 2013 13:01:20 +0400 Subject: [PATCH] Move additional permission check --- src/com/cnaude/chairs/EventListener.java | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/com/cnaude/chairs/EventListener.java b/src/com/cnaude/chairs/EventListener.java index 221b3b5..17b0439 100644 --- a/src/com/cnaude/chairs/EventListener.java +++ b/src/com/cnaude/chairs/EventListener.java @@ -63,7 +63,7 @@ public class EventListener implements Listener { plugin.unSitPlayer(player); } } - + @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); @@ -79,9 +79,9 @@ public class EventListener implements Listener { Block block = event.getClickedBlock(); if (sitAllowed(player, block)) { + event.setCancelled(true); Location sitLocation = getSitLocation(block, player.getLocation().getYaw()); sitPlayer(player, sitLocation); - event.setCancelled(true); } } } @@ -114,15 +114,18 @@ public class EventListener implements Listener { continue; } } - if (blockOkay || - ( - player.hasPermission("chairs.sit." + block.getTypeId() + ":" + block.getData()) || - player.hasPermission("chairs.sit." + block.getType().toString() + ":" + block.getData()) || - player.hasPermission("chairs.sit." + block.getTypeId()) || - player.hasPermission("chairs.sit." + block.getType().toString()) - ) - ) { + if ( + player.hasPermission("chairs.sit." + block.getTypeId() + ":" + block.getData()) || + player.hasPermission("chairs.sit." + block.getType().toString() + ":" + block.getData()) || + player.hasPermission("chairs.sit." + block.getTypeId()) || + player.hasPermission("chairs.sit." + block.getType().toString()) + ) { + blockOkay = true; + } + if (blockOkay) { + System.out.println("block is okay"); + if (block.getState().getData() instanceof Stairs) { stairs = (Stairs) block.getState().getData(); } else if (block.getState().getData() instanceof Step) {