SteamWar/SpigotCore
Archiviert
13
0

Add Inventory Logging
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Chaoscaot 2023-07-25 21:35:10 +02:00
Ursprung c6bc8a41ab
Commit a2a1884677
Signiert von: Chaoscaot
GPG-Schlüssel-ID: BDF8FADD7D5EDB7A

Datei anzeigen

@ -28,6 +28,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
@ -42,6 +43,7 @@ public class SWInventory implements Listener {
final Player player;
final Map<Integer, Consumer<InventoryClickEvent>> callbacks = new HashMap<>();
final Inventory inventory;
String title;
boolean open = false;
public SWInventory(Player p, int size, String t) {
@ -135,7 +137,9 @@ public class SWInventory implements Listener {
}
public void open() {
player.openInventory(inventory);
InventoryView view = player.openInventory(inventory);
title = view.getTitle();
Core.getInstance().getLogger().info("[SWINV] Opened " + title + " for " + player.getName());
if(!open) {
Bukkit.getPluginManager().registerEvents(this, Core.getInstance());
open = true;
@ -149,6 +153,7 @@ public class SWInventory implements Listener {
if (callbacks.containsKey(e.getRawSlot()) && callbacks.get(e.getRawSlot()) != null) {
e.setCancelled(true);
Core.getInstance().getLogger().info("[SWINV] " + e.getWhoClicked().getName() + " " + e.getClick().name() + " clicked " + e.getRawSlot() + " on " + e.getCurrentItem().getItemMeta().getDisplayName() + " in " + e.getView().getTitle());
callbacks.get(e.getRawSlot()).accept(e);
}
}
@ -160,6 +165,7 @@ public class SWInventory implements Listener {
InventoryClickEvent.getHandlerList().unregister(this);
InventoryCloseEvent.getHandlerList().unregister(this);
Core.getInstance().getLogger().info("[SWINV] " + player.getName() + " closed " + title);
if(callbacks.containsKey(-1))
callbacks.get(-1).accept(null);
open = false;