From 6ddc045968146d7dc87745a26417eb8d48d9384d Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 27 Sep 2021 17:18:57 +0200 Subject: [PATCH 1/2] Runable --- SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java b/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java index be75f28..e653ba8 100644 --- a/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java @@ -68,7 +68,7 @@ public class SWInventory implements Listener { callbacks.put(-1, inventoryClickEvent -> c.clicked(null)); } - public void addCloseRunable(Runnable c) { + public void addCloseRunnable(Runnable c) { callbacks.put(-1, inventoryClickEvent -> c.run()); } From 441286613b47e5770f0fd954800da095db2d3d2b Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 28 Sep 2021 21:26:44 +0200 Subject: [PATCH 2/2] Remove Listener --- SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java b/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java index e653ba8..83314b4 100644 --- a/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SWInventory.java @@ -74,7 +74,11 @@ public class SWInventory implements Listener { public void setItem(int pos, ItemStack itemStack, InvCallback c) { inventory.setItem(pos, itemStack); - callbacks.put(pos, inventoryClickEvent -> c.clicked(inventoryClickEvent.getClick())); + if(c != null) { + callbacks.put(pos, inventoryClickEvent -> c.clicked(inventoryClickEvent.getClick())); + } else { + callbacks.remove(pos); + } } public void setItem(int pos, SWItem item) {