Skip to content

Commit

Permalink
Don't allow cancelled events to be listened to by Skript
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
APickledWalrus committed Sep 5, 2022
1 parent ddb3a7f commit 5e6c741
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
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;
import org.bukkit.Material;
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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());
Expand Down

0 comments on commit 5e6c741

Please sign in to comment.