Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @param itemStacks count number of itemstacks and return
- * a number of stacks some you put in.
- */
- public int countItemStacks(ItemStack[] itemStacks) {
- if (itemStacks == null)
- return 0;
- return itemStacks.length;
- }
- /**
- * @param location Set items in the chest on this cords,
- * if you have more an one page, it will
- * set items on this too (if slots not has items
- * it will return air (slots will be empty)).
- */
- public void setContents(Location location) {
- ItemStack[] itemStacks = ChestRegistry.getInstance().getcontents(location);
- if (itemStacks == null)
- itemStacks = new ItemStack[0];
- //System.out.println("itemstack orginal" + Arrays.toString(itemStacks1));
- int currentInventory = 0;
- int conterItems = 0;
- //System.out.println("Itemstacks before" + Arrays.toString(itemStacks1));
- try {
- do {
- for (int i = 0; i < countItemStacks(itemStacks); i++) {
- Inventory inventory = getPage(currentInventory, location);
- if (i < GuiSize) {
- inventory.setItem(i, itemStacks[conterItems]);
- conterItems++;
- //System.out.println("itemstack " + itemStacks[i] + "value i = " + conterItems);
- }
- }
- currentInventory++;
- } while (currentInventory < getPageIndex);
- } catch (ArrayIndexOutOfBoundsException ex) {
- Common.log("&4Warning!!&c you has change gui size of the chest from " + (conterItems - GuiSize) + " to " + GuiSize
- + " if you made gui size smaller you can lose items");
- }
- }
Add Comment
Please, Sign In to add comment