public void populateChest(Chest chest, String chestfile) { Inventory inventory = chest.getBlockInventory(); inventory.clear(); int added = 0; Collections.shuffle(randomLoc); if (chestfile.equalsIgnoreCase("op")) { for (ChestItem chestItem : opChestItemList) { if (random.nextInt(100) + 1 <= chestItem.getChance()) { inventory.setItem(randomLoc.get(added), chestItem.getItem()); if (added++ >= inventory.getSize() - 1) { break; } } } } else if (chestfile.equalsIgnoreCase("basic")) { for (ChestItem chestItem : basicChestItemList) { if (random.nextInt(100) + 1 <= chestItem.getChance()) { inventory.setItem(randomLoc.get(added), chestItem.getItem()); if (added++ >= inventory.getSize() - 1) { break; } } } } else { for (ChestItem chestItem : chestItemList) { if (random.nextInt(100) + 1 <= chestItem.getChance()) { inventory.setItem(randomLoc.get(added), chestItem.getItem()); if (added++ >= inventory.getSize() - 1) { break; } } } } }
public void fromSectionValue(Object aValue) { if (aValue instanceof ArrayList) { for (Object lItem : ((ArrayList) aValue)) { ChestItem lMat = new ChestItem(); lMat.quest = quest; if (lItem instanceof HashMap) { lMat.fromSectionValue(lItem); } else if (lItem instanceof String) { String lStr = lItem.toString().toUpperCase(); lMat.material = Material.getMaterial(lStr); if (lMat.material == null) { lMat.material = Material.getMaterial(Integer.parseInt(lStr)); } } add(lMat); } } }
public void populateDoubleChest(DoubleChest chest, String chestfile) { String type = chestfile; if (SkyWarsReloaded.getCfg().doubleChestAlwaysOP()) type = "op"; Inventory inventory = chest.getInventory(); inventory.clear(); int added = 0; Collections.shuffle(randomDLoc); if (type.equalsIgnoreCase("op")) { for (ChestItem chestItem : opChestItemList) { if (random.nextInt(100) + 1 <= chestItem.getChance()) { inventory.setItem(randomDLoc.get(added), chestItem.getItem()); if (added++ >= inventory.getSize() - 1) { break; } } } } else if (type.equalsIgnoreCase("basic")) { for (ChestItem chestItem : basicChestItemList) { if (random.nextInt(100) + 1 <= chestItem.getChance()) { inventory.setItem(randomDLoc.get(added), chestItem.getItem()); if (added++ >= inventory.getSize() - 1) { break; } } } } else { for (ChestItem chestItem : chestItemList) { if (random.nextInt(100) + 1 <= chestItem.getChance()) { inventory.setItem(randomDLoc.get(added), chestItem.getItem()); if (added++ >= inventory.getSize() - 1) { break; } } } } }