SteamWar/SpigotCore
Archiviert
13
0

Add Support for Itemstack

Dieser Commit ist enthalten in:
Chaoscaot 2021-02-02 23:26:01 +01:00
Ursprung 905fd00dec
Commit 0327eb37c4

Datei anzeigen

@ -28,11 +28,9 @@ 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.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
public class SWInventory implements Listener {
@ -55,9 +53,13 @@ public class SWInventory implements Listener {
callbacks.put(-1, c);
}
public void setItem(int pos, ItemStack itemStack, InvCallback c){
inventory.setItem(pos, itemStack);
callbacks.put(pos, c);
}
public void setItem(int pos, SWItem item){
inventory.setItem(pos, item.getItemStack());
callbacks.put(pos, item.getCallback());
setItem(pos, item.getItemStack(), item.getCallback());
}
public void setItem(int pos, Material m, String name, InvCallback c){
@ -91,9 +93,10 @@ public class SWInventory implements Listener {
if(!player.equals(e.getWhoClicked()))
return;
e.setCancelled(true);
if(callbacks.containsKey(e.getRawSlot()) && callbacks.get(e.getRawSlot()) != null)
if(callbacks.containsKey(e.getRawSlot()) && callbacks.get(e.getRawSlot()) != null) {
e.setCancelled(true);
callbacks.get(e.getRawSlot()).clicked(e.getClick());
}
}
@EventHandler