From 4fdc0f6ccfa838e4308664e9c2163261383c8d07 Mon Sep 17 00:00:00 2001 From: Richard Harrah Date: Tue, 29 Jan 2013 20:52:04 -0500 Subject: [PATCH] might fix #70 --- .../diablodrops/drops/DropsAPI.java | 195 +++++++++--------- 1 file changed, 100 insertions(+), 95 deletions(-) diff --git a/src/com/modcrafting/diablodrops/drops/DropsAPI.java b/src/com/modcrafting/diablodrops/drops/DropsAPI.java index aa0bcb7..37be636 100644 --- a/src/com/modcrafting/diablodrops/drops/DropsAPI.java +++ b/src/com/modcrafting/diablodrops/drops/DropsAPI.java @@ -323,31 +323,32 @@ else if (plugin.getConfig().getBoolean("Display.TierName", true) } Enchantment ench = eStack.get(plugin.getSingleRandom() .nextInt(size)); - if ((lvl != 0) && (ench != null) - && !tier.getColor().equals(ChatColor.MAGIC)) - if (safe) - { - if ((lvl >= ench.getStartLevel()) - && (lvl <= ench.getMaxLevel())) + if (!ci.containsEnchantment(ench)) + if ((lvl != 0) && (ench != null) + && !tier.getColor().equals(ChatColor.MAGIC)) + if (safe) { - try - { - ci.addEnchantment(ench, lvl); - } - catch (Exception e1) + if ((lvl >= ench.getStartLevel()) + && (lvl <= ench.getMaxLevel())) { - if (plugin.getDebug()) + try { - plugin.log.warning(e1.getMessage()); + ci.addEnchantment(ench, lvl); + } + catch (Exception e1) + { + if (plugin.getDebug()) + { + plugin.log.warning(e1.getMessage()); + } + e++; } - e++; } } - } - else - { - ci.addUnsafeEnchantment(ench, lvl); - } + else + { + ci.addUnsafeEnchantment(ench, lvl); + } } ItemMeta tool; if (ci.hasItemMeta()) @@ -466,31 +467,32 @@ public ItemStack getItem(final ItemStack oldTool) } Enchantment ench = eStack.get(plugin.getSingleRandom() .nextInt(size)); - if ((lvl != 0) && (ench != null) - && !tier.getColor().equals(ChatColor.MAGIC)) - if (safe) - { - if ((lvl >= ench.getStartLevel()) - && (lvl <= ench.getMaxLevel())) + if (!tool.containsEnchantment(ench)) + if ((lvl != 0) && (ench != null) + && !tier.getColor().equals(ChatColor.MAGIC)) + if (safe) { - try - { - tool.addEnchantment(ench, lvl); - } - catch (Exception e1) + if ((lvl >= ench.getStartLevel()) + && (lvl <= ench.getMaxLevel())) { - if (plugin.getDebug()) + try { - plugin.log.warning(e1.getMessage()); + tool.addEnchantment(ench, lvl); + } + catch (Exception e1) + { + if (plugin.getDebug()) + { + plugin.log.warning(e1.getMessage()); + } + e++; } - e++; } } - } - else - { - tool.addUnsafeEnchantment(ench, lvl); - } + else + { + tool.addUnsafeEnchantment(ench, lvl); + } } ItemMeta meta; if (tool.hasItemMeta()) @@ -601,31 +603,32 @@ else if (plugin.getConfig().getBoolean("Display.TierName", true) } Enchantment ench = eStack.get(plugin.getSingleRandom() .nextInt(size)); - if ((lvl != 0) && (ench != null) - && !tier.getColor().equals(ChatColor.MAGIC)) - if (safe) - { - if ((lvl >= ench.getStartLevel()) - && (lvl <= ench.getMaxLevel())) + if (!tool.containsEnchantment(ench)) + if ((lvl != 0) && (ench != null) + && !tier.getColor().equals(ChatColor.MAGIC)) + if (safe) { - try - { - tool.addEnchantment(ench, lvl); - } - catch (Exception e1) + if ((lvl >= ench.getStartLevel()) + && (lvl <= ench.getMaxLevel())) { - if (plugin.getDebug()) + try + { + tool.addEnchantment(ench, lvl); + } + catch (Exception e1) { - plugin.log.warning(e1.getMessage()); + if (plugin.getDebug()) + { + plugin.log.warning(e1.getMessage()); + } + e++; } - e++; } } - } - else - { - tool.addUnsafeEnchantment(ench, lvl); - } + else + { + tool.addUnsafeEnchantment(ench, lvl); + } } ItemMeta meta; if (tool.hasItemMeta()) @@ -744,31 +747,32 @@ else if (plugin.getConfig().getBoolean("Display.TierName", true) } Enchantment ench = eStack.get(plugin.getSingleRandom() .nextInt(size)); - if ((lvl != 0) && (ench != null) - && !tier.getColor().equals(ChatColor.MAGIC)) - if (safe) - { - if ((lvl >= ench.getStartLevel()) - && (lvl <= ench.getMaxLevel())) + if (!tool.containsEnchantment(ench)) + if ((lvl != 0) && (ench != null) + && !tier.getColor().equals(ChatColor.MAGIC)) + if (safe) { - try + if ((lvl >= ench.getStartLevel()) + && (lvl <= ench.getMaxLevel())) { - tool.addEnchantment(ench, lvl); - } - catch (Exception e1) - { - if (plugin.getDebug()) + try + { + tool.addEnchantment(ench, lvl); + } + catch (Exception e1) { - plugin.log.warning(e1.getMessage()); + if (plugin.getDebug()) + { + plugin.log.warning(e1.getMessage()); + } + e++; } - e++; } } - } - else - { - tool.addUnsafeEnchantment(ench, lvl); - } + else + { + tool.addUnsafeEnchantment(ench, lvl); + } } ItemMeta meta; if (tool.hasItemMeta()) @@ -885,31 +889,32 @@ else if (plugin.getConfig().getBoolean("Display.TierName", true) } Enchantment ench = eStack.get(plugin.getSingleRandom() .nextInt(size)); - if ((lvl != 0) && (ench != null) - && !tier.getColor().equals(ChatColor.MAGIC)) - if (safe) - { - if ((lvl >= ench.getStartLevel()) - && (lvl <= ench.getMaxLevel())) + if (!tool.containsEnchantment(ench)) + if ((lvl != 0) && (ench != null) + && !tier.getColor().equals(ChatColor.MAGIC)) + if (safe) { - try + if ((lvl >= ench.getStartLevel()) + && (lvl <= ench.getMaxLevel())) { - tool.addEnchantment(ench, lvl); - } - catch (Exception e1) - { - if (plugin.getDebug()) + try + { + tool.addEnchantment(ench, lvl); + } + catch (Exception e1) { - plugin.log.warning(e1.getMessage()); + if (plugin.getDebug()) + { + plugin.log.warning(e1.getMessage()); + } + e++; } - e++; } } - } - else - { - tool.addUnsafeEnchantment(ench, lvl); - } + else + { + tool.addUnsafeEnchantment(ench, lvl); + } } ItemMeta meta = tool.getItemMeta(); if (plugin.getConfig().getBoolean("Lore.Enabled", true)