Exemplo n.º 1
0
  public static void setContentsAll(Inventory inventory, ItemStack[] all) {
    if (inventory == null) return;
    ItemStack[] contents = inventory.getContents();

    PlayerInventory playerInventory = asPlayerInventory(inventory);
    if (playerInventory == null) {
      inventory.setContents(range(all, 0, contents.length));
      return;
    }

    if (all.length < INDEX_PLAYER_STORAGE_TO) return;
    ItemStack[] storage = range(all, INDEX_PLAYER_STORAGE_FROM, INDEX_PLAYER_STORAGE_TO);
    setContentsStorage(playerInventory, storage);

    if (all.length < INDEX_PLAYER_ARMOR_TO) return;
    ItemStack[] armor = range(all, INDEX_PLAYER_ARMOR_FROM, INDEX_PLAYER_ARMOR_TO);
    setContentsArmor(playerInventory, armor);

    if (all.length < INDEX_PLAYER_EXTRA_TO) return;
    ItemStack[] extra = range(all, INDEX_PLAYER_EXTRA_FROM, INDEX_PLAYER_EXTRA_TO);
    setContentsExtra(playerInventory, extra);
  }