Items & inventories

Below you will see a simplified Item class, Inventory class and ItemContainer for your viewing, take a look...

  1. Item
public class Item {  
  private transient int slot;  
  private short id;  
	protected int amount;  

  public int getId() { return this.id; }

  public Item(int id) { this(id, 1); }

  public Item(int id, int amount) { this(id, amount, false); }

  public ItemDefinitions getDefinitions() { return ItemDefinitions.getDefs(this.id); }
  
  public Item setAmount(int amount) { /*...*/ }

  public void setId(int id) { this.id = (short)id; }

  public int getAmount() { return this.amount; }

  public String getName() { return this.getDefinitions().getName(); }

  public int getSlot() { return this.slot; }

  public Item setSlot(int slot) { this.slot = slot; }
}
@PluginEventHandler
public final class Inventory {

	private long coins;
	private ItemsContainer<Item> items;

	private transient Player player;
	private transient double inventoryWeight;
	private transient Set<Integer> slotsToUpdate = new HashSet<>();
	private transient boolean updateAll = true;

	public static final int INVENTORY_INTERFACE = 679;

	public Inventory() {
		items = new ItemsContainer<>(28, false);
	}
}
public final class ItemsContainer<T extends Item> {
	private Item[] data;

	public ItemsContainer(int size, boolean alwaysStackable) {
		data = new Item[size];
    //...
	}
  
  public T get(int slot) { /*...*/ }
  public boolean add(T item) { /*...*/ }
  public int remove(T item) { /*...*/	}
}

Explain slots

Show functions for both

plugins used