From 25e98618b99738b0c9265ec91aa9b0c0d1f69b84 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 7 Mar 2024 21:34:25 +0100 Subject: [PATCH] feat: introduce a flag section into the config for instabreak (#4368) * Added and applied config * removed wrong return logic --- .../com/plotsquared/bukkit/listener/BlockEventListener.java | 6 +++++- .../java/com/plotsquared/core/configuration/Settings.java | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java index f2be27c88..6c65d3721 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java @@ -670,7 +670,11 @@ public class BlockEventListener implements Listener { BlockBreakEvent call = new BlockBreakEvent(block, player); Bukkit.getServer().getPluginManager().callEvent(call); if (!call.isCancelled()) { - event.getBlock().breakNaturally(); + if (Settings.Flags.INSTABREAK_CONSIDER_TOOL) { + block.breakNaturally(event.getItemInHand()); + } else { + block.breakNaturally(); + } } } // == rather than <= as we only care about the "ground level" not being destroyed diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java index 03ac33e78..859c96673 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java @@ -723,6 +723,12 @@ public class Settings extends Config { } + @Comment("Settings related to flags") + public static final class Flags { + + @Comment("If \"instabreak\" should consider the used tool.") + public static boolean INSTABREAK_CONSIDER_TOOL = false; + } @Comment({"Enable or disable parts of the plugin", "Note: A cache will use some memory if enabled"})