From b142bc60a26ac1fb9c1cd29a619beea0c8d1dc7f Mon Sep 17 00:00:00 2001 From: JustAHuman-xD <65748158+JustAHuman-xD@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:54:39 -0500 Subject: [PATCH] ignore own events --- .../slimefun4/implementation/items/tools/LumberAxe.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java index 1c1e823de7..daf3329681 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java @@ -1,6 +1,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -39,6 +41,7 @@ */ public class LumberAxe extends SlimefunItem implements NotPlaceable { + private static final Set IGNORE_EVENTS = new HashSet<>(); private static final int MAX_BROKEN = 100; private static final int MAX_STRIPPED = 20; @@ -52,6 +55,10 @@ public LumberAxe(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeT @Nonnull private ToolUseHandler onBlockBreak() { return (e, tool, fortune, drops) -> { + if (IGNORE_EVENTS.contains(e)) { + return; + } + if (!e.getPlayer().isSneaking() && Tag.LOGS.isTagged(e.getBlock().getType())) { List logs = Vein.find(e.getBlock(), MAX_BROKEN, b -> Tag.LOGS.isTagged(b.getType())); logs.remove(e.getBlock()); @@ -59,6 +66,7 @@ private ToolUseHandler onBlockBreak() { for (Block b : logs) { if (!BlockStorage.hasBlockInfo(b) && Slimefun.getProtectionManager().hasPermission(e.getPlayer(), b, Interaction.BREAK_BLOCK)) { BlockBreakEvent event = new BlockBreakEvent(b, e.getPlayer()); + IGNORE_EVENTS.add(event); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { breakLog(b, event.isDropItems());