SteamWar/BungeeCore
Archiviert
13
2

Prevent ProcessingSpam
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-04-08 13:21:45 +02:00
Ursprung 4f6bf71f82
Commit 1bc5011d4f

Datei anzeigen

@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
public class SWInventory { public class SWInventory {
@ -39,6 +40,8 @@ public class SWInventory {
private String title; private String title;
private boolean next; private boolean next;
private final AtomicBoolean processingClick = new AtomicBoolean();
public SWInventory(ProxiedPlayer proxiedPlayer, int size, String title) { public SWInventory(ProxiedPlayer proxiedPlayer, int size, String title) {
itemMap = new HashMap<>(); itemMap = new HashMap<>();
InventoryCallbackHandler.inventoryHashMap.put(SteamwarUser.get(proxiedPlayer).getId(), this); InventoryCallbackHandler.inventoryHashMap.put(SteamwarUser.get(proxiedPlayer).getId(), this);
@ -101,13 +104,19 @@ public class SWInventory {
} }
public void handleCallback(InvCallback.ClickType type, int pos) { 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() { public void handleClose() {
InventoryCallbackHandler.inventoryHashMap.remove(SteamwarUser.get(player).getId(), this); if(processingClick.compareAndSet(false, true)) {
if(close != null) InventoryCallbackHandler.inventoryHashMap.remove(SteamwarUser.get(player).getId(), this);
close.clicked(null); if(close != null)
close.clicked(null);
processingClick.set(false);
}
} }
public void open() { public void open() {