Archiviert
1
0

Prevent ProcessingSpam

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.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() {