Advertisement
Guest User

Full

a guest
Apr 24th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.90 KB | None | 0 0
  1.                         int x = getConfig().getInt("x");
  2.                         int y = getConfig().getInt("y");
  3.                         int z = getConfig().getInt("z");
  4.                         World w = Bukkit.getWorld("world");
  5.                         Location chestLoc = new Location(w, x, y, z);
  6.                         chestLoc.getBlock().setType(Material.CHEST);
  7.                         Chest chest = (Chest) chestLoc.getBlock().getState();
  8.                         Inventory inv = chest.getInventory();
  9.                     for (Iterator lci = getConfig()
  10.                                 .getConfigurationSection(
  11.                                         "chestItems")
  12.                                 .getKeys(false).iterator(); lci.hasNext();) {
  13.                             items = (String) lci.next();
  14.                             if (getConfig().getString(
  15.                                     "chestItems." + items
  16.                                             + ".Item").contains(":")) {
  17.                                 material = Material.getMaterial(getConfig()
  18.                                         .getString("chestItems." + items
  19.                                             + ".Item").split(":")[0]);
  20.                             } else {
  21.                                 material = Material.getMaterial(getConfig()
  22.                                         .getString("chestItems." + items
  23.                                             + ".Item"));
  24.  
  25.                             }
  26.                             int amount = getConfig().getInt(
  27.                                     "chestItems." + items
  28.                                             + ".Amount");
  29.                             ItemStack item = new ItemStack(material, amount);
  30.                             ItemMeta itemMeta = item.getItemMeta();
  31.                             List<String> lores = new ArrayList();
  32.                             if (getConfig().getString(
  33.                                     "chestItems." + items
  34.                                             + ".Item").contains(":")) {
  35.                                 item = new ItemStack(material, amount,
  36.                                         (short) Integer.parseInt(getConfig()
  37.                                                 .getString("chestItems."+ items + ".Item")
  38.                                                 .split(":")[1]));
  39.                             }
  40.                             if ((short) getConfig().getInt(
  41.                                     "chestItems." + items
  42.                                             + ".Durability") != 0) {
  43.                                 item.setDurability((short) getConfig().getInt(
  44.                                         "chestItems." + items
  45.                                                 + ".Durability"));
  46.                             }
  47.                             if (getConfig().getStringList(
  48.                                     "chestItems." + items
  49.                                             + ".Enchantments") != null) {
  50.                                 for (String enchantments : getConfig()
  51.                                         .getStringList(chestItems." + items + ".Enchantments")) {
  52.                                     String[] split = enchantments.split(":");
  53.                                     itemMeta.addEnchant(Enchantment
  54.                                             .getByName(split[0].toUpperCase()),
  55.                                             Integer.parseInt(split[1]), true);
  56.                                 }
  57.                             }
  58.                             for (String lore : getConfig().getStringList("chestItems." + items
  59.                                             + ".Lore")) {
  60.                                 lores.add(ChatColor
  61.                                         .translateAlternateColorCodes('&', lore));
  62.                             }
  63.                             itemMeta.setLore(lores);
  64.                             if (getConfig().getString("chestItems." + items
  65.                                             + ".Name") != null) {
  66.                                 itemMeta.setDisplayName(ChatColor
  67.                                         .translateAlternateColorCodes(
  68.                                                 '&',
  69.                                                 getConfig().getString("chestItems." + items + ".Name")));
  70.                             }
  71.                             item.setItemMeta(itemMeta);
  72.                                                        inv.setItem(Integer.parseInt(items) - 1, item);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement