From 3361f762c678c7d210c25c349dd5524b496ddc9e Mon Sep 17 00:00:00 2001 From: darksaid98 Date: Sat, 16 Mar 2024 16:28:18 +0100 Subject: [PATCH] fix: interact events being cancelled --- .../listener/EnderChestListener.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/github/milkdrinkers/enderchester/listener/EnderChestListener.java b/src/main/java/io/github/milkdrinkers/enderchester/listener/EnderChestListener.java index 433b481..9625fb4 100644 --- a/src/main/java/io/github/milkdrinkers/enderchester/listener/EnderChestListener.java +++ b/src/main/java/io/github/milkdrinkers/enderchester/listener/EnderChestListener.java @@ -6,6 +6,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; +import org.bukkit.event.Event; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -40,8 +41,8 @@ public void onInteract(InventoryClickEvent e) { if (item == null) return; - openEnderChest(p, item); - e.setCancelled(true); + if (openEnderChest(p, item)) + e.setCancelled(true); } /** @@ -60,27 +61,29 @@ public void onRightClick(PlayerInteractEvent e) { if (item == null) return; - openEnderChest(p, item); - e.setCancelled(true); + if (openEnderChest(p, item)) + e.setCancelled(true); } - private void openEnderChest(Player p, ItemStack item) { + private boolean openEnderChest(Player p, ItemStack item) { if (!item.getType().equals(Material.ENDER_CHEST)) - return; + return false; if (Cfg.get().getOrDefault("check.permission", true) && !p.hasPermission("enderchester.use")) - return; + return false; if (Cfg.get().getOrDefault("check.creative", false) && p.getGameMode().equals(GameMode.CREATIVE)) - return; + return false; if (Cfg.get().getOrDefault("check.blacklist.enabled", false) && Cfg.get().getStringList("check.blacklist.worlds").contains(p.getWorld().getName())) - return; + return false; Enderchester.getInstance().getMorePaperLib().scheduling().regionSpecificScheduler(p.getLocation()).run(() -> { p.openInventory(p.getEnderChest()); if (Cfg.get().getOrDefault("sound.opening", true)) p.playSound(p.getLocation(), Sound.BLOCK_ENDER_CHEST_OPEN, 1.0f, 1.0f); }); + + return true; } }