From 5e6c741218c55c4a22680d4f238bd721c2a7e846 Mon Sep 17 00:00:00 2001 From: APickledWalrus Date: Mon, 5 Sep 2022 15:51:29 -0400 Subject: [PATCH] Don't allow cancelled events to be listened to by Skript The idea was to allow these events to still occur within Skript for skript-gui GUIs, but this is a global setting that affects all plugins (and is likely to have unintended side effects) --- .../skriptgui/gui/events/GUIEvents.java | 15 +++++---------- .../skriptgui/gui/events/RecipeEvent.java | 6 ------ 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/main/java/io/github/apickledwalrus/skriptgui/gui/events/GUIEvents.java b/src/main/java/io/github/apickledwalrus/skriptgui/gui/events/GUIEvents.java index fa8a578..98fc0a0 100644 --- a/src/main/java/io/github/apickledwalrus/skriptgui/gui/events/GUIEvents.java +++ b/src/main/java/io/github/apickledwalrus/skriptgui/gui/events/GUIEvents.java @@ -1,6 +1,5 @@ package io.github.apickledwalrus.skriptgui.gui.events; -import ch.njol.skript.SkriptEventHandler; import io.github.apickledwalrus.skriptgui.SkriptGUI; import io.github.apickledwalrus.skriptgui.gui.GUI; import org.bukkit.GameMode; @@ -8,20 +7,16 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.inventory.*; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; public class GUIEvents implements Listener { - public GUIEvents() { - // We still want these events to be processed by Skript - SkriptEventHandler.listenCancelled.add(InventoryClickEvent.class); - SkriptEventHandler.listenCancelled.add(InventoryDragEvent.class); - SkriptEventHandler.listenCancelled.add(InventoryOpenEvent.class); - SkriptEventHandler.listenCancelled.add(InventoryCloseEvent.class); - } - @EventHandler(priority = EventPriority.LOWEST) public void onInventoryClick(InventoryClickEvent event) { // Process this event if it's cancelled ONLY if the clicker is in Spectator Mode diff --git a/src/main/java/io/github/apickledwalrus/skriptgui/gui/events/RecipeEvent.java b/src/main/java/io/github/apickledwalrus/skriptgui/gui/events/RecipeEvent.java index 3984afb..44854ae 100644 --- a/src/main/java/io/github/apickledwalrus/skriptgui/gui/events/RecipeEvent.java +++ b/src/main/java/io/github/apickledwalrus/skriptgui/gui/events/RecipeEvent.java @@ -1,6 +1,5 @@ package io.github.apickledwalrus.skriptgui.gui.events; -import ch.njol.skript.SkriptEventHandler; import com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent; import io.github.apickledwalrus.skriptgui.SkriptGUI; import io.github.apickledwalrus.skriptgui.gui.GUI; @@ -10,11 +9,6 @@ public class RecipeEvent implements Listener { - public RecipeEvent() { - // We still want this event to be processed by Skript - SkriptEventHandler.listenCancelled.add(PlayerRecipeBookClickEvent.class); - } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onRecipeBookClick(PlayerRecipeBookClickEvent event) { GUI gui = SkriptGUI.getGUIManager().getGUI(event.getPlayer().getOpenInventory().getTopInventory());