Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int x = getConfig().getInt("x");
- int y = getConfig().getInt("y");
- int z = getConfig().getInt("z");
- World w = Bukkit.getWorld("world");
- Location chestLoc = new Location(w, x, y, z);
- chestLoc.getBlock().setType(Material.CHEST);
- Chest chest = (Chest) chestLoc.getBlock().getState();
- Inventory inv = chest.getInventory();
- for (Iterator lci = getConfig()
- .getConfigurationSection(
- "chestItems")
- .getKeys(false).iterator(); lci.hasNext();) {
- items = (String) lci.next();
- if (getConfig().getString(
- "chestItems." + items
- + ".Item").contains(":")) {
- material = Material.getMaterial(getConfig()
- .getString("chestItems." + items
- + ".Item").split(":")[0]);
- } else {
- material = Material.getMaterial(getConfig()
- .getString("chestItems." + items
- + ".Item"));
- }
- int amount = getConfig().getInt(
- "chestItems." + items
- + ".Amount");
- ItemStack item = new ItemStack(material, amount);
- ItemMeta itemMeta = item.getItemMeta();
- List<String> lores = new ArrayList();
- if (getConfig().getString(
- "chestItems." + items
- + ".Item").contains(":")) {
- item = new ItemStack(material, amount,
- (short) Integer.parseInt(getConfig()
- .getString("chestItems."+ items + ".Item")
- .split(":")[1]));
- }
- if ((short) getConfig().getInt(
- "chestItems." + items
- + ".Durability") != 0) {
- item.setDurability((short) getConfig().getInt(
- "chestItems." + items
- + ".Durability"));
- }
- if (getConfig().getStringList(
- "chestItems." + items
- + ".Enchantments") != null) {
- for (String enchantments : getConfig()
- .getStringList(chestItems." + items + ".Enchantments")) {
- String[] split = enchantments.split(":");
- itemMeta.addEnchant(Enchantment
- .getByName(split[0].toUpperCase()),
- Integer.parseInt(split[1]), true);
- }
- }
- for (String lore : getConfig().getStringList("chestItems." + items
- + ".Lore")) {
- lores.add(ChatColor
- .translateAlternateColorCodes('&', lore));
- }
- itemMeta.setLore(lores);
- if (getConfig().getString("chestItems." + items
- + ".Name") != null) {
- itemMeta.setDisplayName(ChatColor
- .translateAlternateColorCodes(
- '&',
- getConfig().getString("chestItems." + items + ".Name")));
- }
- item.setItemMeta(itemMeta);
- inv.setItem(Integer.parseInt(items) - 1, item);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement