SteamWar/SpigotCore
Archiviert
13
0

Merge pull request 'Add Itemstack in SWInventory' (#91) from itemstack_in_swinv into master

Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2021-02-04 08:28:59 +01:00
Commit a212883351

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,10 +93,11 @@ public class SWInventory implements Listener {
if(!player.equals(e.getWhoClicked()))
return;
if(callbacks.containsKey(e.getRawSlot()) && callbacks.get(e.getRawSlot()) != null) {
e.setCancelled(true);
if(callbacks.containsKey(e.getRawSlot()) && callbacks.get(e.getRawSlot()) != null)
callbacks.get(e.getRawSlot()).clicked(e.getClick());
}
}
@EventHandler
public void onInventoryClose(InventoryCloseEvent e){