diff --git a/src/de/steamwar/bungeecore/inventory/SWInventory.java b/src/de/steamwar/bungeecore/inventory/SWInventory.java index b827e88..0d4a8d3 100644 --- a/src/de/steamwar/bungeecore/inventory/SWInventory.java +++ b/src/de/steamwar/bungeecore/inventory/SWInventory.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; public class SWInventory { @@ -39,6 +40,8 @@ public class SWInventory { private String title; private boolean next; + private final AtomicBoolean processingClick = new AtomicBoolean(); + public SWInventory(ProxiedPlayer proxiedPlayer, int size, String title) { itemMap = new HashMap<>(); InventoryCallbackHandler.inventoryHashMap.put(SteamwarUser.get(proxiedPlayer).getId(), this); @@ -101,13 +104,19 @@ public class SWInventory { } public void handleCallback(InvCallback.ClickType type, int pos) { - itemMap.get(pos).getCallback().clicked(type); + if(processingClick.compareAndSet(false, true)) { + itemMap.get(pos).getCallback().clicked(type); + processingClick.set(false); + } } public void handleClose() { - InventoryCallbackHandler.inventoryHashMap.remove(SteamwarUser.get(player).getId(), this); - if(close != null) - close.clicked(null); + if(processingClick.compareAndSet(false, true)) { + InventoryCallbackHandler.inventoryHashMap.remove(SteamwarUser.get(player).getId(), this); + if(close != null) + close.clicked(null); + processingClick.set(false); + } } public void open() {