public RPGItem(ConfigurationSection s) { name = s.getString("name"); id = s.getInt("id"); setDisplay(s.getString("display"), false); setType( s.getString("type", Plugin.plugin.getConfig().getString("defaults.sword", "Sword")), false); setHand( s.getString("hand", Plugin.plugin.getConfig().getString("defaults.hand", "One handed")), false); setLore(s.getString("lore"), false); description = (List<String>) s.getList("description", new ArrayList<String>()); for (int i = 0; i < description.size(); i++) { description.set(i, ChatColor.translateAlternateColorCodes('&', description.get(i))); } quality = Quality.valueOf(s.getString("quality")); damageMin = s.getInt("damageMin"); damageMax = s.getInt("damageMax"); armour = s.getInt("armour", 0); item = new ItemStack(Material.valueOf(s.getString("item"))); ItemMeta meta = item.getItemMeta(); if (meta instanceof LeatherArmorMeta) { ((LeatherArmorMeta) meta).setColor(Color.fromRGB(s.getInt("item_colour", 0))); } else { item.setDurability((short) s.getInt("item_data", 0)); } for (String locale : Locale.getLocales()) { localeMeta.put(locale, meta.clone()); } ignoreWorldGuard = s.getBoolean("ignoreWorldGuard", false); // Powers ConfigurationSection powerList = s.getConfigurationSection("powers"); if (powerList != null) { for (String sectionKey : powerList.getKeys(false)) { ConfigurationSection section = powerList.getConfigurationSection(sectionKey); try { if (!Power.powers.containsKey(section.getString("powerName"))) { // Invalid power continue; } Power pow = Power.powers.get(section.getString("powerName")).newInstance(); pow.init(section); pow.item = this; addPower(pow, false); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } encodedID = getMCEncodedID(id); // Recipes hasRecipe = s.getBoolean("hasRecipe", false); if (hasRecipe) { recipe = (List<ItemStack>) s.getList("recipe"); } ConfigurationSection drops = s.getConfigurationSection("dropChances"); if (drops != null) { for (String key : drops.getKeys(false)) { double chance = drops.getDouble(key, 0.0); chance = Math.min(chance, 100.0); if (chance > 0) { dropChances.put(key, chance); if (!Events.drops.containsKey(key)) { Events.drops.put(key, new HashSet<Integer>()); } Set<Integer> set = Events.drops.get(key); set.add(getID()); } else { dropChances.remove(key); if (Events.drops.containsKey(key)) { Set<Integer> set = Events.drops.get(key); set.remove(getID()); } } dropChances.put(key, chance); } } if (item.getType().getMaxDurability() != 0) { hasBar = true; } maxDurability = s.getInt("maxDurability", item.getType().getMaxDurability()); forceBar = s.getBoolean("forceBar", false); if (maxDurability == 0) { maxDurability = -1; } rebuild(); }