SteamWar/SpigotCore
Archiviert
13
0

Add Itemstack in SWInventory #91

Manuell gemergt
Lixfel hat 1 Commits von itemstack_in_swinv nach master 2021-02-04 08:29:00 +01:00 zusammengeführt

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