From 1d5057ec5a7132ce7f3d11f4920f0f6127d23cd5 Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 11 Feb 2019 07:39:03 -0800 Subject: [PATCH] Explicitly sets user for break blocks check. The user was not being set. Also the ordering of event handling was random because both listeners had the same priority. Should fix: https://github.com/BentoBoxWorld/BentoBox/issues/534 --- .../flags/protection/BlockInteractionListener.java | 8 ++++++-- .../listeners/flags/protection/BreakBlocksListener.java | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BlockInteractionListener.java b/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BlockInteractionListener.java index 86f988a0e..f88f995e9 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BlockInteractionListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BlockInteractionListener.java @@ -264,12 +264,16 @@ public class BlockInteractionListener extends FlagListener { } /** - * Prevents blocks that are protected from being broken, which would bypass the protection + * When breaking blocks is allowed, this protects + * specific blocks from being broken, which would bypass the protection. + * For example, player enables break blocks, but chests are still protected + * Fires after the BreakBlocks check. * * @param e - event */ - @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockBreak(final BlockBreakEvent e) { + setUser(User.getInstance(e.getPlayer())); checkClickedBlock(e, e.getBlock().getLocation(), e.getBlock().getType()); } } diff --git a/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BreakBlocksListener.java b/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BreakBlocksListener.java index 30e6b11a0..3872e3f48 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BreakBlocksListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BreakBlocksListener.java @@ -29,7 +29,7 @@ public class BreakBlocksListener extends FlagListener { */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockBreak(final BlockBreakEvent e) { - checkIsland(e, e.getBlock().getLocation(), Flags.BREAK_BLOCKS); + setUser(User.getInstance(e.getPlayer())).checkIsland(e, e.getBlock().getLocation(), Flags.BREAK_BLOCKS); } /** @@ -74,7 +74,7 @@ public class BreakBlocksListener extends FlagListener { case CAKE: case DRAGON_EGG: case SPAWNER: - checkIsland(e, e.getClickedBlock().getLocation(), Flags.BREAK_BLOCKS); + setUser(User.getInstance(e.getPlayer())).checkIsland(e, e.getClickedBlock().getLocation(), Flags.BREAK_BLOCKS); break; default: break;