diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index a7dc023..c5a3d9e 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -21,12 +21,15 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.text.*; +import me.kaZep.Base.BonusEnchantment.ItemType; import me.kaZep.Commands.JobsDataInfo; import me.kaZep.Commands.JobsDataInfo.Job; import me.kaZep.Commands.commandBankEconomy; import net.jmhertlein.mctowns.MCTowns; import net.milkbowl.vault.economy.Economy; +import org.apache.commons.lang.math.IntRange; +import org.apache.commons.lang.math.Range; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Chunk; @@ -189,10 +192,16 @@ public class Main extends JavaPlugin public List revive_inventory_list = null; public List chunk_queue_list = null; public static List recycling_center_list = null; + public static List bonus_enchantment_list = null; public DamageAPI DMGCALC = null; public long lastMessage = 0; public static ItemSetList ItemSetList = null; + + public static BonusEnchantment ENCHANT_CRITICAL_CHANCE, ENCHANT_ARMOR_PENETRATION, ENCHANT_LIFE_STEAL, + ENCHANT_ATTACK_SPEED, ENCHANT_DAMAGE, ENCHANT_HEALTH, ENCHANT_DAMAGE_REDUCTION, ENCHANT_DURABILITY, + ENCHANT_BLOCK_CHANCE, ENCHANT_SPEED_BOOST_CHANCE, ENCHANT_STURDY, ENCHANT_REPAIR, ENCHANT_EXECUTE; + public FileWriter outputStream = null; @@ -779,6 +788,21 @@ public class Main extends JavaPlugin "When jumping, you cannot be hit."); ItemSetList.addSet(set); + //Add in custom enchantments. + ENCHANT_CRITICAL_CHANCE = new BonusEnchantment("Critical Chance",true,false,ItemType.WEAPONS,new IntRange(0,100)); + ENCHANT_ARMOR_PENETRATION = new BonusEnchantment("Armor Penetration",false,false,ItemType.WEAPONS,new IntRange(0,100)); + ENCHANT_LIFE_STEAL = new BonusEnchantment("Life Steal",true,false,ItemType.WEAPONS,new IntRange(0,100)); + ENCHANT_ATTACK_SPEED = new BonusEnchantment("Attack Speed",true,false,ItemType.WEAPONS,new IntRange(0,500)); + ENCHANT_DAMAGE = new BonusEnchantment("Damage",false,false,ItemType.WEAPONS,new IntRange(0,1000)); + ENCHANT_HEALTH = new BonusEnchantment("Health",false,false,ItemType.ARMOR,new IntRange(0,1000)); + ENCHANT_DAMAGE_REDUCTION = new BonusEnchantment("Damage Reduction",true,false,ItemType.ARMOR,new IntRange(0,100)); + ENCHANT_DURABILITY = new BonusEnchantment("Durability",false,false,ItemType.ARMOR,new IntRange(0,9999999)); + ENCHANT_BLOCK_CHANCE = new BonusEnchantment("Block Chance",true,false,ItemType.ARMOR,new IntRange(0,100)); + ENCHANT_SPEED_BOOST_CHANCE = new BonusEnchantment("Speed Boost Chance",true,false,ItemType.ARMOR,new IntRange(0,100)); + ENCHANT_STURDY = new BonusEnchantment("Sturdy",false,true,ItemType.ARMOR,new IntRange(0,1000)); + ENCHANT_REPAIR = new BonusEnchantment("Repair",false,true,ItemType.ARMOR,new IntRange(0,1000)); + ENCHANT_EXECUTE = new BonusEnchantment("Execute",false,true,ItemType.WEAPONS,new IntRange(0,1000)); + DMGCALC = new DamageAPI(); //System.out.println("Running BankEconomy in "+this.getDataFolder().getAbsolutePath()); //System.out.println("File size: "+f.length()); @@ -5271,6 +5295,120 @@ public void payDay(int time) return finalval; } + /** + * Removes a bonus enchantment from the item. + * If the enchantment does not exist on the item, + * the same exact copy of the item is returned. + * If you want to instead lower the enchantment + * level that exists on the item, use addEnchantment() + * with the override argument turned on to do so. + * @param item The item to remove the bonus enchant from. + * @param enchant The bonus enchantment to remove. (See Main.ENCHANT_) + * @return The new item with the given enchantment removed. + */ + public ItemStack removeBonusEnchantment(ItemStack item, BonusEnchantment enchant) { + if (item.hasItemMeta() && item.getItemMeta().hasLore()) { + List newlore = item.getItemMeta().getLore(); + for (int i=0;i lore = null; + String enchant_string = enchant.name; + boolean percent=enchant.percent, enchant_format=enchant.enchant_format; + if (item.hasItemMeta() && item.getItemMeta().hasLore()) { + ItemMeta meta = item.getItemMeta(); + lore = item.getItemMeta().getLore(); + //Make sure the lore doesn't already exist. If it does, we have to actually + //replace it. + boolean added=false; + for (int i=0;i(); + ItemMeta meta = item.getItemMeta(); + //Add onto the lore. + if (!enchant_format) { + lore.add(ChatColor.YELLOW+"+"+(int)amt+((percent)?"% ":" ")+ChatColor.BLUE+enchant_string); + } else { + lore.add(ChatColor.GRAY+enchant_string+" "+toRomanNumeral((int)amt)); + } + meta.setLore(lore); + item.setItemMeta(meta); + return sortEnchantments(item); //Sort all enchants before returning. + } + } + /** * * @param item The item to sort Enchantments on. @@ -5869,4 +6007,67 @@ public void payDay(int time) },total_tick_delay+=tick_delay); } } + + /** + * A helper function for Bonus Enchantments. + * @return Returns all bonus enchantments in a list. + */ + public static List getBonusEnchantments() { + return bonus_enchantment_list; + } + + /** + * A helper function for Bonus Enchantments. + * @return Returns all enchantments in a list that weapons can use. + */ + public static List getBonusWeaponEnchantments() { + List finallist = new ArrayList(); + for (int i=0;i getBonusArmorEnchantments() { + List finallist = new ArrayList(); + for (int i=0;ip.getMaxHealth()) { p.setHealth(p.getMaxHealth()); } diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index bf4dd90..7eb3929 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -454,10 +454,168 @@ implements Listener } } + /** + * Opens the bonus inventory for Enchanters who have + * the Level 30 A buff. + * @param input The input item that determines what bonuses exist. + * @return The Inventory containing all the appropriate bonuses. + */ + private Inventory openBonusInventory(Player p, ItemStack input, int lvs) { + //Determine what the bonus sets are via the input. + Inventory inv = Bukkit.createInventory(p, 18, "Choose an additional bonus:"); + if (input.getType().name().toLowerCase().contains("helmet")) { + ItemStack base = input.clone();base.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, base.getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, base.getEnchantmentLevel(Enchantment.PROTECTION_FIRE)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, base.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, base.getEnchantmentLevel(Enchantment.PROTECTION_PROJECTILE)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.OXYGEN, base.getEnchantmentLevel(Enchantment.OXYGEN)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.WATER_WORKER, base.getEnchantmentLevel(Enchantment.WATER_WORKER)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.THORNS, base.getEnchantmentLevel(Enchantment.THORNS)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.DURABILITY, base.getEnchantmentLevel(Enchantment.DURABILITY)+lvs/10+1);inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_HEALTH, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DAMAGE_REDUCTION, 3*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DURABILITY, 200*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_BLOCK_CHANCE, 5*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_SPEED_BOOST_CHANCE, 20*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_STURDY, lvs/10+1);inv.addItem(base); + if (lvs==30) {base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_REPAIR, lvs/10+1);inv.addItem(base);} + } else + if (input.getType().name().toLowerCase().contains("chestplate") || input.getType().name().toLowerCase().contains("leggings")) { + ItemStack base = input.clone();base.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, base.getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, base.getEnchantmentLevel(Enchantment.PROTECTION_FIRE)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, base.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, base.getEnchantmentLevel(Enchantment.PROTECTION_PROJECTILE)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.THORNS, base.getEnchantmentLevel(Enchantment.THORNS)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.DURABILITY, base.getEnchantmentLevel(Enchantment.DURABILITY)+lvs/10+1);inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_HEALTH, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DAMAGE_REDUCTION, 3*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DURABILITY, 200*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_BLOCK_CHANCE, 5*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_SPEED_BOOST_CHANCE, 20*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_STURDY, lvs/10+1);inv.addItem(base); + if (lvs==30) {base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_REPAIR, lvs/10+1);inv.addItem(base);} + } else + if (input.getType().name().toLowerCase().contains("boots")) { + ItemStack base = input.clone();base.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, base.getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, base.getEnchantmentLevel(Enchantment.PROTECTION_FIRE)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, base.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, base.getEnchantmentLevel(Enchantment.PROTECTION_PROJECTILE)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.THORNS, base.getEnchantmentLevel(Enchantment.THORNS)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, base.getEnchantmentLevel(Enchantment.PROTECTION_FALL)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.DURABILITY, base.getEnchantmentLevel(Enchantment.DURABILITY)+lvs/10+1);inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_HEALTH, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DAMAGE_REDUCTION, 3*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DURABILITY, 200*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_BLOCK_CHANCE, 5*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_SPEED_BOOST_CHANCE, 20*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_STURDY, lvs/10+1);inv.addItem(base); + if (lvs==30) {base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_REPAIR, lvs/10+1);inv.addItem(base);} + } else + if (input.getType().name().toLowerCase().contains("sword")) { + ItemStack base = input.clone();base.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, base.getEnchantmentLevel(Enchantment.DAMAGE_ALL)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, base.getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, base.getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.KNOCKBACK, base.getEnchantmentLevel(Enchantment.KNOCKBACK)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, base.getEnchantmentLevel(Enchantment.FIRE_ASPECT)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, base.getEnchantmentLevel(Enchantment.LOOT_BONUS_MOBS)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.DURABILITY, base.getEnchantmentLevel(Enchantment.DURABILITY)+lvs/10+1);inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_CRITICAL_CHANCE, 5*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ARMOR_PENETRATION, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_LIFE_STEAL, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ATTACK_SPEED, 10*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DAMAGE, 2*(lvs/10+1));inv.addItem(base); + if (lvs==30) {base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_EXECUTE, lvs/10+1);inv.addItem(base);} + } else + if (input.getType().name().toLowerCase().contains("axe") && !input.getType().name().toLowerCase().contains("pickaxe")) { + ItemStack base = input.clone();base.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, base.getEnchantmentLevel(Enchantment.DAMAGE_ALL)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, base.getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, base.getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.DIG_SPEED, base.getEnchantmentLevel(Enchantment.DIG_SPEED)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.SILK_TOUCH, base.getEnchantmentLevel(Enchantment.SILK_TOUCH)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, base.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS)+lvs/10+1);inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_CRITICAL_CHANCE, 5*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ARMOR_PENETRATION, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_LIFE_STEAL, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ATTACK_SPEED, 10*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DAMAGE, 2*(lvs/10+1));inv.addItem(base); + if (lvs==30) {base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_EXECUTE, lvs/10+1);inv.addItem(base);} + } else + if (input.getType().name().toLowerCase().contains("spade") || input.getType().name().toLowerCase().contains("pickaxe")) { + ItemStack base = input.clone();base.addUnsafeEnchantment(Enchantment.DIG_SPEED, base.getEnchantmentLevel(Enchantment.DIG_SPEED)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.SILK_TOUCH, base.getEnchantmentLevel(Enchantment.SILK_TOUCH)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, base.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.DURABILITY, base.getEnchantmentLevel(Enchantment.DURABILITY)+lvs/10+1);inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_CRITICAL_CHANCE, 5*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ARMOR_PENETRATION, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_LIFE_STEAL, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ATTACK_SPEED, 10*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DAMAGE, 2*(lvs/10+1));inv.addItem(base); + if (lvs==30) {base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_EXECUTE, lvs/10+1);inv.addItem(base);} + } else + if (input.getType().name().toLowerCase().contains("bow")) { + ItemStack base = input.clone();base.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, base.getEnchantmentLevel(Enchantment.ARROW_DAMAGE)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, base.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.ARROW_FIRE, base.getEnchantmentLevel(Enchantment.ARROW_FIRE)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, base.getEnchantmentLevel(Enchantment.ARROW_INFINITE)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.DURABILITY, base.getEnchantmentLevel(Enchantment.DURABILITY)+lvs/10+1);inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_CRITICAL_CHANCE, 5*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ARMOR_PENETRATION, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_LIFE_STEAL, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ATTACK_SPEED, 10*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DAMAGE, 2*(lvs/10+1));inv.addItem(base); + if (lvs==30) {base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_EXECUTE, lvs/10+1);inv.addItem(base);} + } else + if (input.getType().name().toLowerCase().contains("hoe")) { + ItemStack base = input.clone();base.addUnsafeEnchantment(Enchantment.DURABILITY, base.getEnchantmentLevel(Enchantment.DURABILITY)+lvs/10+1);inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_CRITICAL_CHANCE, 5*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ARMOR_PENETRATION, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_LIFE_STEAL, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ATTACK_SPEED, 10*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DAMAGE, 2*(lvs/10+1));inv.addItem(base); + if (lvs==30) {base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_EXECUTE, lvs/10+1);inv.addItem(base);} + } else + if (input.getType().name().toLowerCase().contains("shears")) { + ItemStack base = input.clone();base.addUnsafeEnchantment(Enchantment.DIG_SPEED, base.getEnchantmentLevel(Enchantment.DIG_SPEED)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.SILK_TOUCH, base.getEnchantmentLevel(Enchantment.SILK_TOUCH)+lvs/10+1);inv.addItem(base); + base = input.clone();base.addUnsafeEnchantment(Enchantment.DURABILITY, base.getEnchantmentLevel(Enchantment.DURABILITY)+lvs/10+1);inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_CRITICAL_CHANCE, 5*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ARMOR_PENETRATION, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_LIFE_STEAL, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ATTACK_SPEED, 10*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DAMAGE, 2*(lvs/10+1));inv.addItem(base); + if (lvs==30) {base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_EXECUTE, lvs/10+1);inv.addItem(base);} + } else + if (input.getType().name().toLowerCase().contains("flint")) { + ItemStack base = input.clone();base.addUnsafeEnchantment(Enchantment.DURABILITY, base.getEnchantmentLevel(Enchantment.DURABILITY)+lvs/10+1);inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_CRITICAL_CHANCE, 5*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ARMOR_PENETRATION, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_LIFE_STEAL, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ATTACK_SPEED, 10*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DAMAGE, 2*(lvs/10+1));inv.addItem(base); + if (lvs==30) {base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_EXECUTE, lvs/10+1);inv.addItem(base);} + } else + if (input.getType().name().toLowerCase().contains("carrot")) { + ItemStack base = input.clone();base.addUnsafeEnchantment(Enchantment.DURABILITY, base.getEnchantmentLevel(Enchantment.DURABILITY)+lvs/10+1);inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_CRITICAL_CHANCE, 5*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ARMOR_PENETRATION, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_LIFE_STEAL, 2*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_ATTACK_SPEED, 10*(lvs/10+1));inv.addItem(base); + base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_DAMAGE, 2*(lvs/10+1));inv.addItem(base); + if (lvs==30) {base = input.clone();this.plugin.addBonusEnchantment(base, Main.ENCHANT_EXECUTE, lvs/10+1);inv.addItem(base);} + } else { + return null; + } + return inv; + } + /** + * DO NOT use e.getItem() to get the final results! It gets + * manually handled and will not return what you want in terms + * of enchantments! The variable "finalitem" stores the correct + * resulting ItemStack after all adjustments are made. + */ @EventHandler public void onEnchantItem(EnchantItemEvent e) { - Map map = e.getEnchantsToAdd(); Player p = e.getEnchanter(); /*e.getEnchanter().sendMessage("Enchantments are:"); for (Map.Entry entry : map.entrySet()) { @@ -523,10 +681,10 @@ implements Listener p.sendMessage(ChatColor.LIGHT_PURPLE+"You feel a magical presence get inserted into your inventory."); }*/ + ItemStack finalitem=e.getItem().clone(); if (this.plugin.PlayerinJob(p, "Enchanter")) { if (this.plugin.getJobLv("Enchanter", p)>=10) { - e.setExpLevelCost((int)(e.getExpLevelCost()*0.75)); if (e.getItem().getType()==Material.BOW) { int enchants[] = {48,49,50,51}; for (int j=0;j entry : map.entrySet()) { - if (this.plugin.getJobLv("Enchanter", p)>=20) { - if (entry.getKey().getMaxLevel() ourLore = new ArrayList(); + if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. + List thelore = e.getItem().getItemMeta().getLore(); + for (int i=0;i ourLore = new ArrayList(); @@ -710,123 +904,177 @@ implements Listener ItemMeta meta = e.getItem().getItemMeta(); meta.setLore(ourLore); e.getItem().setItemMeta(meta); - } else { - if (e.getItem().getType().toString().toLowerCase().contains("sword")) { - int enchants[] = {16,17,18,19,20,21,34}; - for (int j=0;j ourLore = new ArrayList(); - if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. - List thelore = e.getItem().getItemMeta().getLore(); - for (int i=0;i ourLore = new ArrayList(); - if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. - List thelore = e.getItem().getItemMeta().getLore(); - for (int i=0;i ourLore = new ArrayList(); + if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. + List thelore = e.getItem().getItemMeta().getLore(); + for (int i=0;i ourLore = new ArrayList(); - if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. - List thelore = e.getItem().getItemMeta().getLore(); - for (int i=0;i ourLore = new ArrayList(); + if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts. + List thelore = e.getItem().getItemMeta().getLore(); + for (int i=0;i map = finalitem.getEnchantments(); + for (Map.Entry entry : map.entrySet()) { + if (this.plugin.getJobLv("Enchanter", p)>=20) { + if (entry.getKey().getMaxLevel() map2 = e.getEnchantsToAdd(); + for (Map.Entry entry : map2.entrySet()) { + if (this.plugin.getJobLv("Enchanter", p)>=20) { + if (entry.getKey().getMaxLevel()