Canceling the useage event

This commit is contained in:
SvenjaReißaus 2019-03-18 21:56:20 -05:00
parent 2437e206b7
commit 62d37c061a
No known key found for this signature in database
GPG Key ID: E5494A03FA36D54B
2 changed files with 10 additions and 6 deletions

View File

@ -884,14 +884,18 @@ public class FactionsPlayerListener implements Listener {
if (block == null) return; // clicked in air, apparently if (block == null) return; // clicked in air, apparently
SavageFactions.plugin.log("Checking if I can use the block"); SavageFactions.plugin.log("Checking if I can use the block");
if (canPlayerUseBlock(player, block, false)) return; if (!canPlayerUseBlock(player, block, false)) {
event.setCancelled(true);
event.setUseInteractedBlock(Event.Result.DENY);
return;
}
SavageFactions.plugin.log("Checking if I can use the item"); SavageFactions.plugin.log("Checking if I can use the item");
if (playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) return; if (!playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) {
event.setCancelled(true);
SavageFactions.plugin.log("Guess we will cancel the event then"); event.setUseInteractedBlock(Event.Result.DENY);
event.setCancelled(true); return;
event.setUseInteractedBlock(Event.Result.DENY); }
} }
@EventHandler @EventHandler