use of com.bgsoftware.wildchests.objects.inventory.CraftWildInventory in project WildChests by BG-Software-LLC.
the class WRegularChest method getWildContents.
@Override
public WildItemStack<?, ?>[] getWildContents() {
WildItemStack<?, ?>[] contents = new WildItemStack[0];
int pagesAmount = getPagesAmount();
if (pagesAmount == 0)
return contents;
for (int page = 0; page < pagesAmount; page++) {
CraftWildInventory inventory = inventories.get(page);
int oldLength = contents.length;
contents = Arrays.copyOf(contents, contents.length + inventory.getSize());
System.arraycopy(inventory.getWildContents(), 0, contents, oldLength, inventory.getSize());
}
return contents;
}
use of com.bgsoftware.wildchests.objects.inventory.CraftWildInventory in project WildChests by BG-Software-LLC.
the class WRegularChest method setPage.
@Override
public Inventory setPage(int page, int size, String title) {
ChestData chestData = getData();
checkCapacity(page + 1, chestData.getDefaultSize(), chestData.getDefaultTitle());
CraftWildInventory inventory = plugin.getNMSInventory().createInventory(this, size, title, page);
inventories.set(page, inventory);
updateTitles();
return inventory;
}
use of com.bgsoftware.wildchests.objects.inventory.CraftWildInventory in project WildChests by BG-Software-LLC.
the class WRegularChest method getWildItem.
@Override
public WildItemStack<?, ?> getWildItem(int i) {
Inventory firstPage = getPage(0);
if (firstPage == null)
return WildItemStack.AIR.cloneItemStack();
int pageSize = firstPage.getSize();
int page = i / pageSize;
int slot = i % pageSize;
CraftWildInventory actualPage = (CraftWildInventory) getPage(page);
if (actualPage == null)
return WildItemStack.AIR.cloneItemStack();
return actualPage.getWildItem(slot);
}
use of com.bgsoftware.wildchests.objects.inventory.CraftWildInventory in project WildChests by BG-Software-LLC.
the class WRegularChest method setItem.
@Override
public void setItem(int i, WildItemStack<?, ?> itemStack) {
Inventory firstPage = getPage(0);
if (firstPage == null)
return;
int pageSize = firstPage.getSize();
int page = i / pageSize;
int slot = i % pageSize;
CraftWildInventory actualPage = (CraftWildInventory) getPage(page);
if (actualPage == null)
return;
actualPage.setItem(slot, itemStack);
}
use of com.bgsoftware.wildchests.objects.inventory.CraftWildInventory in project WildChests by BG-Software-LLC.
the class InventoryListener method onChestInteract.
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChestInteract(InventoryClickEvent e) {
Inventory clickedInventory = e.getView().getTopInventory();
if (!(clickedInventory instanceof CraftWildInventory))
return;
Chest chest = ((CraftWildInventory) clickedInventory).getOwner();
chest.onInteract(e);
}
Aggregations