From 426a709e430a67f3a76d41dbfc56cc1ada1474eb Mon Sep 17 00:00:00 2001 From: wizjany Date: Sun, 2 Jun 2019 19:33:42 -0400 Subject: [PATCH] Fire off block place for items that modify blocks. --- .../bukkit/listener/EventAbstractionListener.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java index 2decdeb9..ff4e3dae 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java @@ -423,7 +423,9 @@ public void onPlayerInteract(PlayerInteractEvent event) { placed = clicked.getRelative(event.getBlockFace()); // Only fire events for blocks that are modified when right clicked - modifiesWorld = isBlockModifiedOnClick(clicked, event.getAction() == Action.RIGHT_CLICK_BLOCK) || (item != null && isItemAppliedToBlock(item, clicked)); + final boolean hasItemInteraction = item != null && isItemAppliedToBlock(item, clicked); + modifiesWorld = isBlockModifiedOnClick(clicked, event.getAction() == Action.RIGHT_CLICK_BLOCK) + || hasItemInteraction; if (Events.fireAndTestCancel(new UseBlockEvent(event, cause, clicked).setAllowed(!modifiesWorld))) { event.setUseInteractedBlock(Result.DENY); @@ -437,6 +439,12 @@ public void onPlayerInteract(PlayerInteractEvent event) { } } + if (hasItemInteraction) { + if (Events.fireAndTestCancel(new PlaceBlockEvent(event, cause, clicked.getLocation(), clicked.getType()))) { + event.setUseItemInHand(Result.DENY); + } + } + // Special handling of putting out fires if (event.getAction() == Action.LEFT_CLICK_BLOCK && placed.getType() == Material.FIRE) { if (Events.fireAndTestCancel(new BreakBlockEvent(event, create(event.getPlayer()), placed))) {