diff --git a/src/com/me/tft_02/soulbound/config/ItemsConfig.java b/src/com/me/tft_02/soulbound/config/ItemsConfig.java index 23732c5..1e560c7 100644 --- a/src/com/me/tft_02/soulbound/config/ItemsConfig.java +++ b/src/com/me/tft_02/soulbound/config/ItemsConfig.java @@ -15,141 +15,136 @@ import com.me.tft_02.soulbound.datatypes.ActionType; import com.me.tft_02.soulbound.datatypes.SoulbindItem; public class ItemsConfig extends ConfigLoader { - private static ItemsConfig instance; + private static ItemsConfig instance; - private List soulbindOnCraft = new ArrayList(); - private List soulbindOnOpenChest = new ArrayList(); - private List soulbindOnPickupItem = new ArrayList(); - private List soulbindOnDrop = new ArrayList(); - private List soulbindOnRespawn = new ArrayList(); - private List soulbindOnKit = new ArrayList(); + private List soulbindOnCraft = new ArrayList(); + private List soulbindOnOpenChest = new ArrayList(); + private List soulbindOnPickupItem = new ArrayList(); + private List soulbindOnDrop = new ArrayList(); + private List soulbindOnRespawn = new ArrayList(); + private List soulbindOnKit = new ArrayList(); - public ItemsConfig() { - super("items.yml"); - loadKeys(); - } + public ItemsConfig() { + super("items.yml"); + loadKeys(); + } - public static ItemsConfig getInstance() { - if (instance == null) { - instance = new ItemsConfig(); - } + public static ItemsConfig getInstance() { + if (instance == null) { + instance = new ItemsConfig(); + } - return instance; - } + return instance; + } - @SuppressWarnings("deprecation") + @SuppressWarnings("deprecation") @Override - protected void loadKeys() { - ConfigurationSection configurationSection = config.getConfigurationSection("Items"); + protected void loadKeys() { + ConfigurationSection configurationSection = config.getConfigurationSection("Items"); - if (configurationSection == null) { - return; - } + if (configurationSection == null) { + return; + } - Set itemConfigSet = configurationSection.getKeys(false); + Set itemConfigSet = configurationSection.getKeys(false); - for (String itemName : itemConfigSet) { - String[] itemInfo = itemName.split("[|]"); + for (String itemName : itemConfigSet) { + String[] itemInfo = itemName.split("[|]"); - Material itemMaterial = Material.matchMaterial(itemInfo[0]); + Material itemMaterial = Material.matchMaterial(itemInfo[0]); - if (itemMaterial == null) { - plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + itemInfo[0]); - continue; - } + if (itemMaterial == null) { + plugin.getLogger().warning( + "Invalid material name. This item will be skipped. - " + itemInfo[0]); + continue; + } - byte itemData = (itemInfo.length == 2) ? Byte.valueOf(itemInfo[1]) : 0; - MaterialData itemMaterialData = new MaterialData(itemMaterial, itemData); + byte itemData = (itemInfo.length == 2) ? Byte.valueOf(itemInfo[1]) : 0; + MaterialData itemMaterialData = new MaterialData(itemMaterial, itemData); - List lore = new ArrayList(); - if (config.contains("Items." + itemName + ".Lore")) { + List lore = new ArrayList(); + if (config.contains("Items." + itemName + ".Lore")) { - for (String loreEntry : config.getStringList("Items." + itemName + ".Lore")) { - lore.add(ChatColor.translateAlternateColorCodes('&', loreEntry)); - } - } + for (String loreEntry : config.getStringList("Items." + itemName + ".Lore")) { + lore.add(ChatColor.translateAlternateColorCodes('&', loreEntry)); + } + } - String name = null; - if (config.contains("Items." + itemName + ".Name")) { - name = ChatColor.translateAlternateColorCodes('&', config.getString("Items." + itemName + ".Name")); - } + String name = null; + if (config.contains("Items." + itemName + ".Name")) { + name = ChatColor.translateAlternateColorCodes('&', + config.getString("Items." + itemName + ".Name")); + } - SoulbindItem soulbindItem = new SoulbindItem(itemMaterialData, name, lore); + SoulbindItem soulbindItem = new SoulbindItem(itemMaterialData, name, lore); - List actions = config.getStringList("Items." + itemName + ".Actions"); + List actions = config.getStringList("Items." + itemName + ".Actions"); - for (ActionType actionType : ActionType.values()) { - if (actions.contains(actionType.toString())) { - addSoulbindItem(actionType, soulbindItem); - } - } - } - } + for (ActionType actionType : ActionType.values()) { + if (actions.contains(actionType.toString())) { + addSoulbindItem(actionType, soulbindItem); + } + } + } + } - private void addSoulbindItem(ActionType actionType, SoulbindItem soulbindItem) { - switch (actionType) { - case CRAFT: - soulbindOnCraft.add(soulbindItem); - return; - case OPEN_CHEST: - soulbindOnOpenChest.add(soulbindItem); - return; - case PICKUP_ITEM: - soulbindOnPickupItem.add(soulbindItem); - return; - case DROP_ITEM: - soulbindOnDrop.add(soulbindItem); - return; - case RESPAWN: - soulbindOnRespawn.add(soulbindItem); - return; - case KIT: - soulbindOnKit.add(soulbindItem); - return; - } - } + private void addSoulbindItem(ActionType actionType, SoulbindItem soulbindItem) { + switch (actionType) { + case CRAFT: + soulbindOnCraft.add(soulbindItem); + return; + case OPEN_CHEST: + soulbindOnOpenChest.add(soulbindItem); + return; + case PICKUP_ITEM: + soulbindOnPickupItem.add(soulbindItem); + return; + case DROP_ITEM: + soulbindOnDrop.add(soulbindItem); + return; + case RESPAWN: + soulbindOnRespawn.add(soulbindItem); + return; + case KIT: + soulbindOnKit.add(soulbindItem); + return; + } + } - public List getSoulbindItems(ActionType actionType) { - switch (actionType) { - case CRAFT: - return soulbindOnCraft; - case OPEN_CHEST: - return soulbindOnOpenChest; - case PICKUP_ITEM: - return soulbindOnPickupItem; - case DROP_ITEM: - return soulbindOnDrop; - case RESPAWN: - return soulbindOnRespawn; - case KIT: - return soulbindOnKit; - default: - return null; - } - } + public List getSoulbindItems(ActionType actionType) { + switch (actionType) { + case CRAFT: + return soulbindOnCraft; + case OPEN_CHEST: + return soulbindOnOpenChest; + case PICKUP_ITEM: + return soulbindOnPickupItem; + case DROP_ITEM: + return soulbindOnDrop; + case RESPAWN: + return soulbindOnRespawn; + case KIT: + return soulbindOnKit; + default: + return null; + } + } - public boolean isActionItem(ItemStack itemStack, ActionType actionType) { - for (SoulbindItem soulbindItem : getSoulbindItems(actionType)) { - if (itemStack.getData().equals(soulbindItem.getMaterialData())) { - if (itemStack.hasItemMeta()) { - ItemMeta itemMeta = itemStack.getItemMeta(); - - if (soulbindItem.getName() != null) { - if (!itemMeta.getDisplayName().contains(soulbindItem.getName())) { - return false; - } - } - - if (soulbindItem.getLore() != null && !soulbindItem.getLore().isEmpty()) { - if (itemMeta.hasLore() || !itemMeta.getLore().containsAll(soulbindItem.getLore())) { - return false; - } - } - } - return true; - } - } - - return false; - } + public boolean isActionItem(ItemStack itemStack, ActionType actionType) { + for (SoulbindItem soulbindItem : getSoulbindItems(actionType)) { + if (itemStack.getData().equals(soulbindItem.getMaterialData())) { + if (itemStack.hasItemMeta()) { + ItemMeta itemMeta = itemStack.getItemMeta(); + if (soulbindItem.getName() != null) { + if (itemMeta.getDisplayName().contains(soulbindItem.getName())) + if (soulbindItem.getLore() != null && !soulbindItem.getLore().isEmpty()) + if (itemMeta.hasLore() + && itemMeta.getLore().containsAll(soulbindItem.getLore())) + return true; + } + } + } + } + return false; + } }