From 246205d3f5e14cbcdd8d4724d5d7c7acf439f7cb Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 18 Nov 2013 03:07:17 -0700 Subject: [PATCH 01/15] Add some descriptions for the new Jobs. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index 9cb7ee9..c203568 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -515,10 +515,10 @@ public class Main extends JavaPlugin Woodcutter_job.addData("SAPLINGS", 0.015, 1, 1); Woodcutter_job.addData("WOOD", 0.01, 0.25, 1); Woodcutter_job.addData("WOODEN PLANK", 0.00, 0.10, 1); - Woodcutter_job.setBuffData("Saplings have a higher chance of dropping from tree leaves. (+40%)", - "Axes used gain Efficiency +1 (Speed+30%)", - "Saplings have a higher chance of dropping from tree leaves. (+60%), Axes used gain Efficiency +2 (Speed+60%).", - "Axes that you use never break. Axes used gain Efficiency +3 (Speed+90%) 2-5 wood is dropped from each log. Saplings around you have a higher chance of growing quickly."); + Woodcutter_job.setBuffData("Leaves break instantly.", + "Crafting planks gives 6 planks per wood instead of 4.", + "Apples have a 400% higher rate of dropping from leaves. Breaking wood gives a Jump boost buff that lasts for 10 seconds. Axes last 200% longer.", + "Cuts down a whole tree with one whack. Crafting planks gives 20 planks per wood. Each time you cut down a tree, you get a 4 HP boost (stacks) that lasts for one minute."); Miner_job.setJobName("Miner"); Miner_job.setJobDescription("A miner's job is to venture into caves and collect precious minerals from within, eventually coming out with such treasures for use in other production."); @@ -539,10 +539,10 @@ public class Main extends JavaPlugin Miner_job.addData("GOLD ORE", 0.0975, 12, 0); Miner_job.addData("DIAMOND ORE", 0.3125, 60, 0); Miner_job.addData("EMERALD ORE", 0.7625, 160, 0); - Miner_job.setBuffData("Pickaxes used gain Efficiency +1 (Speed+30%)", - "Pickaxes have double the durability.", - "Pickaxes used gain Efficiency +2 (Speed+60%)", - "Pickaxes used give 240% more items from ore, have quadruple the durability, Efficiency +3 (Speed+90%). Minecart riding speed increased by 40%."); + Miner_job.setBuffData("Automatically mines ores next to each other when one ore is mined.", + "Gain Quadruple the experience from mining ores. Pickaxes gain Efficiency III.", + "Mining out ores will mine them out 3x3 blocks at a time when using diamond pickaxes. Pickaxes used gain Efficiency VI and Unbreaking IV.", + "Mining ores will grant x2 the normal amount of minerals. Fortune is twice as effective, granting a possible total of x4 the normal minerals from ores."); Builder_job.setJobName("Builder"); Builder_job.setJobDescription("A builder's job is to use blocks in order to create and invent new buildings using materials that look nice."); @@ -580,10 +580,10 @@ public class Main extends JavaPlugin Builder_job.addData("BRICK STAIRS", 0.065, 9, 0); Builder_job.addData("QUARTZ BLOCK", 0.07, 14, 0); Builder_job.addData("BRICK", 0.075, 11, 0); - Builder_job.setBuffData("Every 5XP gives you one torch.", - "1% of blocks placed will be replenished to your inventory.", - "5% of blocks placed will be replenished to your inventory.", - "Placing blocks gives you experience orbs. 50% of blocks placed will be replenished to your inventory."); + Builder_job.setBuffData("Builders gain access to the 'line' tool. Typing /line will make building in straight lines easier.", + "Builders gain access to the 'rectangle' tool. Typing /rectangle will make building in rectangles easier.", + "When crafting irreversible Builder blocks, 75% of the blocks used for crafting will be restored to your inventory. When cooking Builder blocks, the block results will be doubled.", + "Builders gain the ability to fly when building. They immediately lose the ability to fly if they stop building for a moment, destroy a block, or enter combat. Every 100 Builder XP gained gives the Builder 5 Glowstone blocks and a stack of torches."); Digger_job.setJobName("Digger"); Digger_job.setJobDescription("A digger's job is to collect blocks from the ground that are collectible with a shovel. The digger may also convert some blocks to other types for more XP and money."); @@ -604,10 +604,10 @@ public class Main extends JavaPlugin Digger_job.addData("GLASS", 0.015, 3, 2); Digger_job.addData("BRICK", 0.04, 8, 2); Digger_job.addData("HARDENED CLAY", 0.04, 8, 2); - Digger_job.setBuffData("Shovels used gain Efficiency +1 (Speed+30%)", - "Shovels have double the durability.", - "Shovels used gain Efficiency +2 (Speed+60%), Shovels have triple the durability.", - "Shovels have quadruple the durability. Blocks dug up are doubled in quantity. Shovels have Efficiency +4 (Speed+120%)."); + Digger_job.setBuffData("Ability to discover artifacts when digging up blocks.", + "Shovels gain Unbreaking V and Efficiency IV.", + "Destroying the bottom row of Sand or Gravel with a Wooden Shovel will destroy the whole stack instantly. Artifact discovery rate increased by 25%.", + "Artifacts will be able to be identified immediately with no identify tomes."); Farmer_job.setJobName("Farmer"); Farmer_job.setJobDescription("A farmer's job is to sustain and continue to replenish what nature provides to turn them into sustainable food items and other useful things."); @@ -872,7 +872,7 @@ public class Main extends JavaPlugin Explorer_job.setBuffData("Movement speed increased by 20%.", "Players lose no exp on death. When taking fatal damage, you will regain all health. This effect can be used once every hour.", "Don't lose any money on death. Reviving costs 75% less.", - "When dying, you only lose 25% of your items. The rest stay in your inventory. Reviving costs 90% less. Teleporting to players costs 75% less. Movement speed increased by 40%. When dying, you will be placed back where you just died. This effect can be used once every hour."); + "When holding a pickaxe, it will detect ores around you based on what the pickaxe is made of."); Support_job.setJobName("Support"); Support_job.setJobDescription("A support's job is to provide assistance and keep others alive by providing potions to heal, materials to allow others to craft things, and being useful overall."); From b2077969454f5c730337eb0cc3215fc8b136f86b Mon Sep 17 00:00:00 2001 From: yl589 Date: Wed, 20 Nov 2013 16:08:57 -0500 Subject: [PATCH 02/15] Enchanted books can now be combined. Enchanted book bonuses are now possible to transfer (it only adds 20% of the value on the book). Emeralds added as a universal repair ingredient at a 0.5 multiplier (tentative). Emerald blocks behave similarly at a 0.05 multiplier. Unenchanting items via the anvil is now possible by putting a normal book in the magic slot. This will destroy the item at least 50% of the time. It tentatively costs one level. --- .../src/me/kaZep/Base/PlayerListener.java | 676 ++++++++++-------- 1 file changed, 389 insertions(+), 287 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index ba6b8d4..aca5c48 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -9773,7 +9773,19 @@ implements Listener Bukkit.getLogger().info("Can place into inventory."); - event.getInventory().setItem(INPUT, new ItemStack(Material.AIR)); + if (event.getCurrentItem().getType() == Material.ENCHANTED_BOOK && event.getInventory().getItem(MAGIC).getType() == Material.BOOK) { + // Halve its durability + event.getInventory().getItem(INPUT).setDurability((short)(event.getInventory().getItem(INPUT).getDurability() + (event.getInventory().getItem(INPUT).getType().getMaxDurability() - event.getInventory().getItem(INPUT).getDurability()) / 2)); + + // Destroy the item if random() exceeds %remaining durability + if (Math.random() < (double)(event.getInventory().getItem(INPUT).getType().getMaxDurability() - event.getInventory().getItem(INPUT).getDurability()) / (double)event.getInventory().getItem(INPUT).getType().getMaxDurability()) { + event.getInventory().setItem(INPUT, new ItemStack(Material.AIR)); + } + + } else { + event.getInventory().setItem(INPUT, new ItemStack(Material.AIR)); + } + event.getInventory().setItem(MATERIALS, new ItemStack(Material.AIR)); event.getInventory().setItem(MAGIC, new ItemStack(Material.AIR)); @@ -9825,7 +9837,18 @@ implements Listener Bukkit.getLogger().info("Can place into inventory."); - event.getInventory().setItem(INPUT, new ItemStack(Material.AIR)); + if (event.getCurrentItem().getType() == Material.ENCHANTED_BOOK && event.getInventory().getItem(MAGIC).getType() == Material.BOOK) { + // Halve its durability + event.getInventory().getItem(INPUT).setDurability((short)(event.getInventory().getItem(INPUT).getDurability() + (event.getInventory().getItem(INPUT).getType().getMaxDurability() - event.getInventory().getItem(INPUT).getDurability()) / 2)); + + // Destroy the item if random() exceeds %remaining durability + if (Math.random() < (double)(event.getInventory().getItem(INPUT).getType().getMaxDurability() - event.getInventory().getItem(INPUT).getDurability()) / (double)event.getInventory().getItem(INPUT).getType().getMaxDurability()) { + event.getInventory().setItem(INPUT, new ItemStack(Material.AIR)); + } + + } else { + event.getInventory().setItem(INPUT, new ItemStack(Material.AIR)); + } event.getInventory().setItem(MATERIALS, new ItemStack(Material.AIR)); event.getInventory().setItem(MAGIC, new ItemStack(Material.AIR)); @@ -9856,7 +9879,18 @@ implements Listener Bukkit.getLogger().info("Normal click"); // Cursor is empty, item picked up. Subtract XP levels and remove ingredients. - event.getInventory().setItem(INPUT, new ItemStack(Material.AIR)); + if (event.getCurrentItem().getType() == Material.ENCHANTED_BOOK && event.getInventory().getItem(MAGIC).getType() == Material.BOOK) { + // Halve its durability + event.getInventory().getItem(INPUT).setDurability((short)(event.getInventory().getItem(INPUT).getDurability() + (event.getInventory().getItem(INPUT).getType().getMaxDurability() - event.getInventory().getItem(INPUT).getDurability()) / 2)); + + // Destroy the item if random() exceeds %remaining durability + if (Math.random() < (double)(event.getInventory().getItem(INPUT).getType().getMaxDurability() - event.getInventory().getItem(INPUT).getDurability()) / (double)event.getInventory().getItem(INPUT).getType().getMaxDurability()) { + event.getInventory().setItem(INPUT, new ItemStack(Material.AIR)); + } + + } else { + event.getInventory().setItem(INPUT, new ItemStack(Material.AIR)); + } event.getInventory().setItem(MATERIALS, new ItemStack(Material.AIR)); event.getInventory().setItem(MAGIC, new ItemStack(Material.AIR)); // event.getInventory().setItem(OUTPUT, new ItemStack(Material.AIR)); @@ -12850,8 +12884,8 @@ class updateInventoryTask implements Runnable { anvilInv.getItem(INPUT).getType().toString().toUpperCase().contains("LEGGINGS") || anvilInv.getItem(INPUT).getType().toString().toUpperCase().contains("BOOTS") || anvilInv.getItem(INPUT).getType().toString().toUpperCase().contains("PICKAXE") || anvilInv.getItem(INPUT).getType().toString().toUpperCase().contains("SPADE") || anvilInv.getItem(INPUT).getType().toString().toUpperCase().contains("HOE") || anvilInv.getItem(INPUT).getType().toString().toUpperCase().contains("AXE") || - anvilInv.getItem(INPUT).getType().toString().toUpperCase().contains("SWORD") || anvilInv.getItem(INPUT).getType().toString().toUpperCase().contains("FISHING") || - anvilInv.getItem(INPUT).getType().toString().toUpperCase().contentEquals("BOW"))) { + anvilInv.getItem(INPUT).getType().toString().toUpperCase().contains("SWORD") || anvilInv.getItem(INPUT).getType().toString().toUpperCase().contentEquals("FISHING") || + anvilInv.getItem(INPUT).getType().toString().toUpperCase().contentEquals("BOW") || anvilInv.getItem(INPUT).getType().toString().toUpperCase().contentEquals("ENCHANTED_BOOK"))) { sendToInventory(INPUT, anvilInv.getItem(INPUT).getAmount(), player); Bukkit.getLogger().info("Invalid input!"); @@ -12866,7 +12900,8 @@ class updateInventoryTask implements Runnable { anvilInv.getItem(MATERIALS).getType() == Material.DIAMOND_BLOCK || anvilInv.getItem(MATERIALS).getType() == Material.DIAMOND || anvilInv.getItem(MATERIALS).getType() == Material.WOOD || anvilInv.getItem(MATERIALS).getType() == Material.COBBLESTONE || anvilInv.getItem(MATERIALS).getType() == Material.LOG || anvilInv.getItem(MATERIALS).getType() == Material.STONE || - anvilInv.getItem(MATERIALS).getType() == Material.STRING)) { + anvilInv.getItem(MATERIALS).getType() == Material.STRING || anvilInv.getItem(MATERIALS).getType() == Material.EMERALD || + anvilInv.getItem(MATERIALS).getType() == Material.EMERALD_BLOCK)) { sendToInventory(MATERIALS, anvilInv.getItem(MATERIALS).getAmount(), player); @@ -12877,7 +12912,7 @@ class updateInventoryTask implements Runnable { } if (anvilInv.getItem(MAGIC) != null) { - if (!(anvilInv.getItem(MAGIC).getType() == Material.ENCHANTED_BOOK)) { + if (!(anvilInv.getItem(MAGIC).getType() == Material.ENCHANTED_BOOK || anvilInv.getItem(MAGIC).getType() == Material.BOOK)) { sendToInventory(MAGIC, anvilInv.getItem(MAGIC).getAmount(), player); @@ -13016,7 +13051,17 @@ class updateInventoryTask implements Runnable { validCombo = true; multiplier = 0.12; } + + if (anvilInv.getItem(MATERIALS).getType() == Material.EMERALD) { + validCombo = true; + multiplier = 0.5; + } + if (anvilInv.getItem(MATERIALS).getType() == Material.EMERALD_BLOCK) { + validCombo = true; + multiplier = 0.05; + } + if (validCombo) { // If materials stacked past number needed to full repair, reduce stack size and drop the rest // in the player's inventory, or if that fails, drop it on the ground. @@ -13091,349 +13136,406 @@ class updateInventoryTask implements Runnable { anvilInv.setContents(anvilInv.getContents()); player.updateInventory(); } else if (anvilInv.getItem(INPUT) != null && anvilInv.getItem(MAGIC) != null) { - // Both Magic slots are populated. - // Get the list of enchantments from both items. - Map itemEnchantments = anvilInv.getItem(INPUT).getEnchantments(); - Map bookEnchantments = new java.util.HashMap(); - - // Get enchanted book "enchantment" and enchantments. - bookEnchantments.putAll(anvilInv.getItem(MAGIC).getEnchantments()); - bookEnchantments.putAll(((EnchantmentStorageMeta)(anvilInv.getItem(MAGIC).getItemMeta())).getStoredEnchants()); - - // Get the list of bonuses from both items. - Map itemBonuses = new java.util.HashMap(); - Map bookBonuses = new java.util.HashMap(); - - if (anvilInv.getItem(INPUT).getItemMeta().hasLore()) { - for (int i = 0; i < anvilInv.getItem(INPUT).getItemMeta().getLore().size(); i++) { - // Put enchantments together for the input. Also stacks identical enchantments. - Bukkit.getLogger().info("Iterating bonus: " + anvilInv.getItem(INPUT).getItemMeta().getLore().get(i)); - - if (getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i)) != null) { - if (itemBonuses.get(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))) == null) { - - Bukkit.getLogger().info("New bonus: " + getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); - itemBonuses.put(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i)), getEnchantmentNumb(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); - } else { - - Bukkit.getLogger().info("Stacking bonus: " + itemBonuses.get(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))) + " + " + getEnchantmentNumb(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); - itemBonuses.put(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i)), itemBonuses.get(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))) + getEnchantmentNumb(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); + if (anvilInv.getItem(MAGIC).getType() == Material.ENCHANTED_BOOK) { + // Both Magic slots are populated, enchanted book is detected. + // Get the list of enchantments from both items. + Map itemEnchantments = anvilInv.getItem(INPUT).getEnchantments(); + Map bookEnchantments = new java.util.HashMap(); + + // Get enchanted book "enchantment" and enchantments. + bookEnchantments.putAll(anvilInv.getItem(MAGIC).getEnchantments()); + bookEnchantments.putAll(((EnchantmentStorageMeta)(anvilInv.getItem(MAGIC).getItemMeta())).getStoredEnchants()); + + // Get the list of bonuses from both items. + Map itemBonuses = new java.util.HashMap(); + Map bookBonuses = new java.util.HashMap(); + + if (anvilInv.getItem(INPUT).getItemMeta().hasLore()) { + for (int i = 0; i < anvilInv.getItem(INPUT).getItemMeta().getLore().size(); i++) { + // Put enchantments together for the input. Also stacks identical enchantments. + Bukkit.getLogger().info("Iterating bonus: " + anvilInv.getItem(INPUT).getItemMeta().getLore().get(i)); + + if (getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i)) != null) { + if (itemBonuses.get(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))) == null) { + + Bukkit.getLogger().info("New bonus: " + getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); + itemBonuses.put(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i)), getEnchantmentNumb(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); + } else { + + Bukkit.getLogger().info("Stacking bonus: " + itemBonuses.get(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))) + " + " + getEnchantmentNumb(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); + itemBonuses.put(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i)), itemBonuses.get(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))) + getEnchantmentNumb(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); + } } } } - } - if (anvilInv.getItem(MAGIC).getItemMeta().hasLore()) { - for (int i = 0; i < anvilInv.getItem(MAGIC).getItemMeta().getLore().size(); i++) { - // Put enchantments together for the MAGIC. Also stacks identical enchantments. - Bukkit.getLogger().info("Iterating bonus: " + anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i)); - if (bookBonuses.get(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))) == null) { + if (anvilInv.getItem(MAGIC).getItemMeta().hasLore()) { + for (int i = 0; i < anvilInv.getItem(MAGIC).getItemMeta().getLore().size(); i++) { + // Put enchantments together for the MAGIC. Also stacks identical enchantments. + Bukkit.getLogger().info("Iterating bonus: " + anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i)); + if (bookBonuses.get(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))) == null) { - Bukkit.getLogger().info("New bonus: " + getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); - bookBonuses.put(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i)), getEnchantmentNumb(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); - } else { + Bukkit.getLogger().info("New bonus: " + getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); + bookBonuses.put(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i)), getEnchantmentNumb(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); + } else { - Bukkit.getLogger().info("Stacking bonus: " + bookBonuses.get(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))) + " + " + getEnchantmentNumb(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); - bookBonuses.put(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i)), bookBonuses.get(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))) + getEnchantmentNumb(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); + Bukkit.getLogger().info("Stacking bonus: " + bookBonuses.get(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))) + " + " + getEnchantmentNumb(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); + bookBonuses.put(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i)), bookBonuses.get(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))) + getEnchantmentNumb(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); + } } } - } - // Generate appropriate possible enchantments - Map probableEnchantments = new java.util.HashMap(); + // Generate appropriate possible enchantments + Map probableEnchantments = new java.util.HashMap(); - for (Enchantment e : bookEnchantments.keySet()) { - Bukkit.getLogger().info("Iterating enchantment: " + e); + for (Enchantment e : bookEnchantments.keySet()) { + Bukkit.getLogger().info("Iterating enchantment: " + e); - if (itemEnchantments.get(e) == null || bookEnchantments.get(e) > itemEnchantments.get(e)) { - // Book enchantment is larger in magnitude. Assign it as a possible outcome. - probableEnchantments.put(e, bookEnchantments.get(e)); - } else if (bookEnchantments.get(e) == itemEnchantments.get(e)) { - // Book enchantment is same in magnitude. Upgrade by one level. - probableEnchantments.put(e, bookEnchantments.get(e) + 1); + if (itemEnchantments.get(e) == null || bookEnchantments.get(e) > itemEnchantments.get(e)) { + // Book enchantment is larger in magnitude. Assign it as a possible outcome. + probableEnchantments.put(e, bookEnchantments.get(e)); + } else if (bookEnchantments.get(e) == itemEnchantments.get(e)) { + // Book enchantment is same in magnitude. Upgrade by one level. + probableEnchantments.put(e, bookEnchantments.get(e) + 1); + } } - } - // Generate appropriate possible bonuses - Map probableBonuses = new java.util.HashMap(); + // Generate appropriate possible bonuses + Map probableBonuses = new java.util.HashMap(); - for (String e : bookBonuses.keySet()) { - Bukkit.getLogger().info("Iterating bonus: " + e); + for (String e : bookBonuses.keySet()) { + Bukkit.getLogger().info("Iterating bonus: " + e); - if (itemBonuses.get(e) == null || bookBonuses.get(e) > itemBonuses.get(e)) { - // Book enchantment is larger in magnitude. Assign it as a possible outcome. - probableBonuses.put(e, bookBonuses.get(e)); - } else if (bookBonuses.get(e) == itemBonuses.get(e)) { - // Book enchantment is same in magnitude. Upgrade by half. - probableBonuses.put(e, Math.floor(bookBonuses.get(e) * 1.5)); + if (itemBonuses.get(e) == null) { + // Book enchantment is new. Assign it as a possible outcome. + probableBonuses.put(e, (int)Math.round(bookBonuses.get(e) * 0.2)); + // The int cast appears to be needed to make it display integers and not stuff like "+5.0 Health" + // Don't remove unless workaround can be found. + } else if (bookBonuses.get(e) >= itemBonuses.get(e) * 0.2) { + // Book enchantment is large enough in magnitude to stack. Assign it as a possible outcome. + probableBonuses.put(e, (int)Math.round(itemBonuses.get(e) + bookBonuses.get(e) * 0.2)); + } } - } - if (probableEnchantments.size() == 0 && probableBonuses.size() == 0) { - // No possible valid enchantments. Output nothing - } else { - if (probableEnchantments.size() != 0) { - // Randomly select an enchantment to add. - int random = (int)(Math.random() * probableEnchantments.size()); - Bukkit.getLogger().info("Randomized to # " + (random + 1) + " out of " + probableEnchantments.size()); + if (probableEnchantments.size() == 0 && probableBonuses.size() == 0) { + // No possible valid enchantments. Output nothing + } else { + if (probableEnchantments.size() != 0) { + // Randomly select an enchantment to add. + int random = (int)(Math.random() * probableEnchantments.size()); + Bukkit.getLogger().info("Randomized to # " + (random + 1) + " out of " + probableEnchantments.size()); - int i = 0; + int i = 0; - Enchantment appliedEnchant = null; - int magnitude = 0; - for (Enchantment e : probableEnchantments.keySet()) { + Enchantment appliedEnchant = null; + int magnitude = 0; + for (Enchantment e : probableEnchantments.keySet()) { - if (i == random) { - // Rolled this one - appliedEnchant = e; - magnitude = probableEnchantments.get(e); + if (i == random) { + // Rolled this one + appliedEnchant = e; + magnitude = probableEnchantments.get(e); + } + i++; } - i++; - } - int cost = 0; + int cost = 0; - if (itemEnchantments.get(appliedEnchant) == null) { - // This enchantment doesn't exist. Calculate full cost. + if (itemEnchantments.get(appliedEnchant) == null) { + // This enchantment doesn't exist. Calculate full cost. - cost = Math.min(60, magnitude * magnitude); - cost = Math.max(cost, 1); // Make sure it's at least one level + cost = Math.min(60, magnitude * magnitude); + cost = Math.max(cost, 1); // Make sure it's at least one level - ItemStack orbs = new ItemStack(Material.SLIME_BALL); + ItemStack orbs = new ItemStack(Material.SLIME_BALL); - ItemMeta temp_meta = orbs.getItemMeta(); - temp_meta.setDisplayName(ChatColor.YELLOW + "Experience Cost"); - List temp_meta_lore = new ArrayList(); - temp_meta_lore.add(ChatColor.ITALIC + "This operation costs " + cost + " levels."); - temp_meta_lore.add(ChatColor.ITALIC + "You currently have " + player.getLevel() + " levels."); + ItemMeta temp_meta = orbs.getItemMeta(); + temp_meta.setDisplayName(ChatColor.YELLOW + "Experience Cost"); + List temp_meta_lore = new ArrayList(); + temp_meta_lore.add(ChatColor.ITALIC + "This operation costs " + cost + " levels."); + temp_meta_lore.add(ChatColor.ITALIC + "You currently have " + player.getLevel() + " levels."); - if (cost > player.getLevel()) { - orbs.setType(Material.MAGMA_CREAM); - temp_meta_lore.add(""); - temp_meta_lore.add(ChatColor.RED + "You can't afford this!"); - } else { - temp_meta_lore.add(""); - temp_meta_lore.add(ChatColor.GREEN + "Completing the operation will"); - temp_meta_lore.add(ChatColor.GREEN + "bring you to " + (player.getLevel() - cost) + " levels."); - } + if (cost > player.getLevel()) { + orbs.setType(Material.MAGMA_CREAM); + temp_meta_lore.add(""); + temp_meta_lore.add(ChatColor.RED + "You can't afford this!"); + } else { + temp_meta_lore.add(""); + temp_meta_lore.add(ChatColor.GREEN + "Completing the operation will"); + temp_meta_lore.add(ChatColor.GREEN + "bring you to " + (player.getLevel() - cost) + " levels."); + } - temp_meta.setLore(temp_meta_lore); - orbs.setItemMeta(temp_meta); + temp_meta.setLore(temp_meta_lore); + orbs.setItemMeta(temp_meta); - orbs.setAmount(cost); - anvilInv.setItem(LEVELS, orbs); - anvilInv.setItem(OUTPUT, anvilInv.getItem(INPUT).clone()); - anvilInv.getItem(OUTPUT).addUnsafeEnchantment(appliedEnchant, magnitude); + orbs.setAmount(cost); + anvilInv.setItem(LEVELS, orbs); + anvilInv.setItem(OUTPUT, anvilInv.getItem(INPUT).clone()); + anvilInv.getItem(OUTPUT).addUnsafeEnchantment(appliedEnchant, magnitude); - } else { - // This enchantment exists. Calculate incremental cost. + } else { + // This enchantment exists. Calculate incremental cost. - cost = Math.min(60, magnitude * magnitude - itemEnchantments.get(appliedEnchant) * itemEnchantments.get(appliedEnchant)); - cost = Math.max(cost, 1); // Make sure it's at least one level + cost = Math.min(60, magnitude * magnitude - itemEnchantments.get(appliedEnchant) * itemEnchantments.get(appliedEnchant)); + cost = Math.max(cost, 1); // Make sure it's at least one level - ItemStack orbs = new ItemStack(Material.SLIME_BALL); + ItemStack orbs = new ItemStack(Material.SLIME_BALL); - ItemMeta temp_meta = orbs.getItemMeta(); - temp_meta.setDisplayName(ChatColor.YELLOW + "Experience Cost"); - List temp_meta_lore = new ArrayList(); - temp_meta_lore.add(ChatColor.ITALIC + "This operation costs " + cost + " levels."); - temp_meta_lore.add(ChatColor.ITALIC + "You currently have " + player.getLevel() + " levels."); + ItemMeta temp_meta = orbs.getItemMeta(); + temp_meta.setDisplayName(ChatColor.YELLOW + "Experience Cost"); + List temp_meta_lore = new ArrayList(); + temp_meta_lore.add(ChatColor.ITALIC + "This operation costs " + cost + " levels."); + temp_meta_lore.add(ChatColor.ITALIC + "You currently have " + player.getLevel() + " levels."); - if (cost > player.getLevel()) { - orbs.setType(Material.MAGMA_CREAM); - temp_meta_lore.add(""); - temp_meta_lore.add(ChatColor.RED + "You can't afford this!"); - } else { - temp_meta_lore.add(""); - temp_meta_lore.add(ChatColor.GREEN + "Completing the operation will"); - temp_meta_lore.add(ChatColor.GREEN + "bring you to " + (player.getLevel() - cost) + " levels."); - } + if (cost > player.getLevel()) { + orbs.setType(Material.MAGMA_CREAM); + temp_meta_lore.add(""); + temp_meta_lore.add(ChatColor.RED + "You can't afford this!"); + } else { + temp_meta_lore.add(""); + temp_meta_lore.add(ChatColor.GREEN + "Completing the operation will"); + temp_meta_lore.add(ChatColor.GREEN + "bring you to " + (player.getLevel() - cost) + " levels."); + } - temp_meta.setLore(temp_meta_lore); - orbs.setItemMeta(temp_meta); + temp_meta.setLore(temp_meta_lore); + orbs.setItemMeta(temp_meta); - orbs.setAmount(cost); - anvilInv.setItem(LEVELS, orbs); + orbs.setAmount(cost); + anvilInv.setItem(LEVELS, orbs); + anvilInv.setItem(OUTPUT, anvilInv.getItem(INPUT).clone()); + anvilInv.getItem(OUTPUT).removeEnchantment(appliedEnchant); + anvilInv.getItem(OUTPUT).addUnsafeEnchantment(appliedEnchant, magnitude); + } + } else { + // Can't add enchant, but can add bonus. Prepare output for bonus. anvilInv.setItem(OUTPUT, anvilInv.getItem(INPUT).clone()); - anvilInv.getItem(OUTPUT).removeEnchantment(appliedEnchant); - anvilInv.getItem(OUTPUT).addUnsafeEnchantment(appliedEnchant, magnitude); - } - } else { - // Can't add enchant, but can add bonus. Prepare output for bonus. - anvilInv.setItem(OUTPUT, anvilInv.getItem(INPUT).clone()); - } + } - if (probableBonuses.size() != 0) { - // Randomly select a bonus to add. - int random = (int)(Math.random() * probableBonuses.size()); - Bukkit.getLogger().info("Randomized to # " + (random + 1) + " out of " + probableBonuses.size()); + boolean isTinkerer = true; // Change this to a playerInJob() call later. + + if (probableBonuses.size() != 0 && isTinkerer) { + // Randomly select a bonus to add. + int random = (int)(Math.random() * probableBonuses.size()); + Bukkit.getLogger().info("Randomized to # " + (random + 1) + " out of " + probableBonuses.size()); - int i = 0; + int i = 0; - String appliedEnchant = null; - double magnitude = 0; - for (String e : probableBonuses.keySet()) { + String appliedEnchant = null; + int magnitude = 0; + for (String e : probableBonuses.keySet()) { - if (i == random) { - // Rolled this one - appliedEnchant = e; - magnitude = probableBonuses.get(e); + if (i == random) { + // Rolled this one + appliedEnchant = e; + magnitude = probableBonuses.get(e); + } + i++; } - i++; - } - - int cost = 0; - if (itemBonuses.get(appliedEnchant) == null) { - // This bonus doesn't exist. Calculate full cost. + int cost = 0; - cost = 30; + if (itemBonuses.get(appliedEnchant) == null) { + // This bonus doesn't exist. Calculate full cost. + Bukkit.getLogger().info("Bonus doesn't exist."); + Bukkit.getLogger().info("Bonus is: " + appliedEnchant + " at magnitude " + magnitude); + + cost += 12; + cost = Math.min(60, cost); + cost = Math.max(1, cost); + + ItemStack orbs = new ItemStack(Material.SLIME_BALL); + + ItemMeta temp_meta = orbs.getItemMeta(); + temp_meta.setDisplayName(ChatColor.YELLOW + "Experience Cost"); + List temp_meta_lore = new ArrayList(); + temp_meta_lore.add(ChatColor.ITALIC + "This operation costs " + cost + " levels."); + temp_meta_lore.add(ChatColor.ITALIC + "You currently have " + player.getLevel() + " levels."); + + if (cost > player.getLevel()) { + orbs.setType(Material.MAGMA_CREAM); + temp_meta_lore.add(""); + temp_meta_lore.add(ChatColor.RED + "You can't afford this!"); + } else { + temp_meta_lore.add(""); + temp_meta_lore.add(ChatColor.GREEN + "Completing the operation will"); + temp_meta_lore.add(ChatColor.GREEN + "bring you to " + (player.getLevel() - cost) + " levels."); + } - ItemStack orbs = new ItemStack(Material.SLIME_BALL); + temp_meta.setLore(temp_meta_lore); + orbs.setItemMeta(temp_meta); - ItemMeta temp_meta = orbs.getItemMeta(); - temp_meta.setDisplayName(ChatColor.YELLOW + "Experience Cost"); - List temp_meta_lore = new ArrayList(); - temp_meta_lore.add(ChatColor.ITALIC + "This operation costs " + cost + " levels."); - temp_meta_lore.add(ChatColor.ITALIC + "You currently have " + player.getLevel() + " levels."); + orbs.setAmount(cost); + anvilInv.setItem(LEVELS, orbs); + + // Change entry matching modified lore + ItemMeta bonusesMeta = anvilInv.getItem(OUTPUT).getItemMeta(); + List bonusesLore = bonusesMeta.getLore(); - if (cost > player.getLevel()) { - orbs.setType(Material.MAGMA_CREAM); - temp_meta_lore.add(""); - temp_meta_lore.add(ChatColor.RED + "You can't afford this!"); + Bukkit.getLogger().info("Bonus enchantment string: " + appliedEnchant); + if (appliedEnchant.equalsIgnoreCase("Critical Chance")) { + bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Critical Chance"); + } + if (appliedEnchant.equalsIgnoreCase("Armor Penetration")) { + bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Armor Penetration"); + } + if (appliedEnchant.equalsIgnoreCase("Life Steal")) { + bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Life Steal"); + } + if (appliedEnchant.equalsIgnoreCase("Attack Speed")) { + bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Attack Speed"); + } + if (appliedEnchant.equalsIgnoreCase("Damage")) { + bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Damage"); + } + if (appliedEnchant.equalsIgnoreCase("Health")) { + bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Health"); + } + if (appliedEnchant.equalsIgnoreCase("Damage Reduction")) { + bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Damage Reduction"); + } + if (appliedEnchant.equalsIgnoreCase("Durability")) { + bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Durability"); + } + if (appliedEnchant.equalsIgnoreCase("Block Chance")) { + bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Block Chance"); + } + if (appliedEnchant.equalsIgnoreCase("Speed Boost Chance")) { + bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Speed Boost Chance"); + } + + bonusesMeta.setLore(bonusesLore); + anvilInv.getItem(OUTPUT).setItemMeta(bonusesMeta); + } else { - temp_meta_lore.add(""); - temp_meta_lore.add(ChatColor.GREEN + "Completing the operation will"); - temp_meta_lore.add(ChatColor.GREEN + "bring you to " + (player.getLevel() - cost) + " levels."); - } + // This enchantment exists. Calculate incremental cost. - temp_meta.setLore(temp_meta_lore); - orbs.setItemMeta(temp_meta); + cost += (int)(12 * itemBonuses.get(appliedEnchant) / probableBonuses.get(appliedEnchant)); // Make sure it's at least one level + cost = Math.min(60, cost); + cost = Math.max(1, cost); - orbs.setAmount(cost); - anvilInv.setItem(LEVELS, orbs); - - // Change entry matching modified lore - List bonusesLore = anvilInv.getItem(OUTPUT).getItemMeta().getLore(); + ItemStack orbs = new ItemStack(Material.SLIME_BALL); - for (int i1 = 0; i1 < bonusesLore.size(); i1++) { - String e = bonusesLore.get(i1); - - if (containsEnchantment(e, appliedEnchant)) { - if (appliedEnchant.equalsIgnoreCase("Critical Chance")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Critical Chance"); - } - if (appliedEnchant.equalsIgnoreCase("Armor Penetration")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Armor Penetration"); - } - if (appliedEnchant.equalsIgnoreCase("Life Steal")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Life Steal"); - } - if (appliedEnchant.equalsIgnoreCase("Attack Speed")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Attack Speed"); - } - if (appliedEnchant.equalsIgnoreCase("Damage")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Damage"); - } - if (appliedEnchant.equalsIgnoreCase("Health")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Health"); - } - if (appliedEnchant.equalsIgnoreCase("Damage Reduction")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Damage Reduction"); - } - if (appliedEnchant.equalsIgnoreCase("Durability")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Durability"); - } - if (appliedEnchant.equalsIgnoreCase("Block Chance")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Block Chance"); - } - if (appliedEnchant.equalsIgnoreCase("Speed Boost Chance")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Speed Boost Chance"); - } - } - } - - anvilInv.getItem(OUTPUT).getItemMeta().setLore(bonusesLore); - - } else { - // This enchantment exists. Calculate incremental cost. - - cost = (int)(30 * itemBonuses.get(appliedEnchant) / probableBonuses.get(appliedEnchant)); // Make sure it's at least one level - - ItemStack orbs = new ItemStack(Material.SLIME_BALL); + ItemMeta temp_meta = orbs.getItemMeta(); + temp_meta.setDisplayName(ChatColor.YELLOW + "Experience Cost"); + List temp_meta_lore = new ArrayList(); + temp_meta_lore.add(ChatColor.ITALIC + "This operation costs " + cost + " levels."); + temp_meta_lore.add(ChatColor.ITALIC + "You currently have " + player.getLevel() + " levels."); - ItemMeta temp_meta = orbs.getItemMeta(); - temp_meta.setDisplayName(ChatColor.YELLOW + "Experience Cost"); - List temp_meta_lore = new ArrayList(); - temp_meta_lore.add(ChatColor.ITALIC + "This operation costs " + cost + " levels."); - temp_meta_lore.add(ChatColor.ITALIC + "You currently have " + player.getLevel() + " levels."); + if (cost > player.getLevel()) { + orbs.setType(Material.MAGMA_CREAM); + temp_meta_lore.add(""); + temp_meta_lore.add(ChatColor.RED + "You can't afford this!"); + } else { + temp_meta_lore.add(""); + temp_meta_lore.add(ChatColor.GREEN + "Completing the operation will"); + temp_meta_lore.add(ChatColor.GREEN + "bring you to " + (player.getLevel() - cost) + " levels."); + } - if (cost > player.getLevel()) { - orbs.setType(Material.MAGMA_CREAM); - temp_meta_lore.add(""); - temp_meta_lore.add(ChatColor.RED + "You can't afford this!"); - } else { - temp_meta_lore.add(""); - temp_meta_lore.add(ChatColor.GREEN + "Completing the operation will"); - temp_meta_lore.add(ChatColor.GREEN + "bring you to " + (player.getLevel() - cost) + " levels."); - } + temp_meta.setLore(temp_meta_lore); + orbs.setItemMeta(temp_meta); - temp_meta.setLore(temp_meta_lore); - orbs.setItemMeta(temp_meta); + orbs.setAmount(cost); + anvilInv.setItem(LEVELS, orbs); - orbs.setAmount(cost); - anvilInv.setItem(LEVELS, orbs); + // Change entry matching modified lore + ItemMeta bonusesMeta = anvilInv.getItem(OUTPUT).getItemMeta(); + List bonusesLore = bonusesMeta.getLore(); - // Change entry matching modified lore - List bonusesLore = anvilInv.getItem(OUTPUT).getItemMeta().getLore(); + for (int i1 = 0; i1 < bonusesLore.size(); i1++) { + String e = bonusesLore.get(i1); + + if (containsEnchantment(e, appliedEnchant)) { + Bukkit.getLogger().info("Success! Found enchantment: " + e); + Bukkit.getLogger().info("Bonus enchantment: " + appliedEnchant); - for (int i1 = 0; i1 < bonusesLore.size(); i1++) { - String e = bonusesLore.get(i1); - - if (containsEnchantment(e, appliedEnchant)) { - if (appliedEnchant.equalsIgnoreCase("Critical Chance")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Critical Chance"); - } - if (appliedEnchant.equalsIgnoreCase("Armor Penetration")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Armor Penetration"); - } - if (appliedEnchant.equalsIgnoreCase("Life Steal")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Life Steal"); - } - if (appliedEnchant.equalsIgnoreCase("Attack Speed")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Attack Speed"); - } - if (appliedEnchant.equalsIgnoreCase("Damage")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Damage"); - } - if (appliedEnchant.equalsIgnoreCase("Health")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Health"); - } - if (appliedEnchant.equalsIgnoreCase("Damage Reduction")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Damage Reduction"); - } - if (appliedEnchant.equalsIgnoreCase("Durability")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Durability"); - } - if (appliedEnchant.equalsIgnoreCase("Block Chance")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Block Chance"); - } - if (appliedEnchant.equalsIgnoreCase("Speed Boost Chance")) { - bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Speed Boost Chance"); + if (appliedEnchant.equalsIgnoreCase("Critical Chance")) { + bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Critical Chance"); + } + if (appliedEnchant.equalsIgnoreCase("Armor Penetration")) { + bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Armor Penetration"); + } + if (appliedEnchant.equalsIgnoreCase("Life Steal")) { + bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Life Steal"); + } + if (appliedEnchant.equalsIgnoreCase("Attack Speed")) { + bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Attack Speed"); + } + if (appliedEnchant.equalsIgnoreCase("Damage")) { + bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Damage"); + } + if (appliedEnchant.equalsIgnoreCase("Health")) { + bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+" "+ChatColor.BLUE+"Health"); + } + if (appliedEnchant.equalsIgnoreCase("Damage Reduction")) { + bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Damage Reduction"); + } + if (appliedEnchant.equalsIgnoreCase("Durability")) { + bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Durability"); + } + if (appliedEnchant.equalsIgnoreCase("Block Chance")) { + bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Block Chance"); + } + if (appliedEnchant.equalsIgnoreCase("Speed Boost Chance")) { + bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Speed Boost Chance"); + } } } - } - - anvilInv.getItem(OUTPUT).getItemMeta().setLore(bonusesLore); - } + + bonusesMeta.setLore(bonusesLore); + anvilInv.getItem(OUTPUT).setItemMeta(bonusesMeta); + } + } + + } + // TRY EVERYTHING + player.getInventory().setContents(player.getInventory().getContents()); + anvilInv.setContents(anvilInv.getContents()); + player.updateInventory(); + } else if (anvilInv.getItem(MAGIC).getType() == Material.BOOK) { + // Magic slot is a book. Unenchanting logic goes here. + anvilInv.setItem(OUTPUT, anvilInv.getItem(INPUT).clone()); + anvilInv.getItem(OUTPUT).setType(Material.ENCHANTED_BOOK); + anvilInv.getItem(OUTPUT).setDurability((short)0); + + // If books stacked past 1, return all but 1 book to player inventory. + + if (anvilInv.getItem(MAGIC).getAmount() > 1) { + sendToInventory(MAGIC, anvilInv.getItem(MAGIC).getAmount() - 1, player); + } + + int cost = 1; + + ItemStack orbs = new ItemStack(Material.SLIME_BALL); + + ItemMeta temp_meta = orbs.getItemMeta(); + temp_meta.setDisplayName(ChatColor.YELLOW + "Experience Cost"); + List temp_meta_lore = new ArrayList(); + temp_meta_lore.add(ChatColor.ITALIC + "This operation costs " + cost + " levels."); + temp_meta_lore.add(ChatColor.ITALIC + "You currently have " + player.getLevel() + " levels."); + + if (cost > player.getLevel()) { + orbs.setType(Material.MAGMA_CREAM); + temp_meta_lore.add(""); + temp_meta_lore.add(ChatColor.RED + "You can't afford this!"); + } else { + temp_meta_lore.add(""); + temp_meta_lore.add(ChatColor.GREEN + "Completing the operation will"); + temp_meta_lore.add(ChatColor.GREEN + "bring you to " + (player.getLevel() - cost) + " levels."); } + temp_meta.setLore(temp_meta_lore); + orbs.setItemMeta(temp_meta); + + orbs.setAmount(cost); + anvilInv.setItem(LEVELS, orbs); + + // TRY EVERYTHING + player.getInventory().setContents(player.getInventory().getContents()); + anvilInv.setContents(anvilInv.getContents()); + player.updateInventory(); + } - // TRY EVERYTHING - player.getInventory().setContents(player.getInventory().getContents()); - anvilInv.setContents(anvilInv.getContents()); - player.updateInventory(); } } From 38e9321c1af170b92d4f8fcdaebdc81c5eaa8928 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Wed, 20 Nov 2013 15:39:09 -0700 Subject: [PATCH 03/15] Job description updates. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index d1de8ba..200cb8a 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -518,7 +518,9 @@ public class Main extends JavaPlugin Woodcutter_job.addData("WOODEN PLANK", 0.00, 0.10, 1); Woodcutter_job.setBuffData("Leaves break instantly.", "Crafting planks gives 6 planks per wood instead of 4.", - "Apples have a 400% higher rate of dropping from leaves. Breaking wood gives a Jump boost buff that lasts for 10 seconds. Axes last 200% longer.", + "Apples have a x4 higher rate of dropping from leaves. Breaking wood gives a Jump boost buff that lasts for 10 seconds. Axes last 200% longer.", + "Axes you use will never break. Making them viable weapons as well.", + "Crafting planks gives 10 planks per wood instead of 4. Saplings placed down will instantly grow trees.", "Cuts down a whole tree with one whack. Crafting planks gives 20 planks per wood. Each time you cut down a tree, you get a 4 HP boost (stacks) that lasts for one minute."); Miner_job.setJobName("Miner"); @@ -542,7 +544,8 @@ public class Main extends JavaPlugin Miner_job.addData("EMERALD ORE", 0.7625, 160, 0); Miner_job.setBuffData("Automatically mines ores next to each other when one ore is mined.", "Gain Quadruple the experience from mining ores. Pickaxes gain Efficiency III.", - "Mining out ores will mine them out 3x3 blocks at a time when using diamond pickaxes. Pickaxes used gain Efficiency VI and Unbreaking IV.", + "Mining out ores will mine them out 3x3 blocks at a time when using diamond pickaxes. Pickaxes used gain Efficiency VI and Unbreaking IV.", + "" "Mining ores will grant x2 the normal amount of minerals. Fortune is twice as effective, granting a possible total of x4 the normal minerals from ores."); Builder_job.setJobName("Builder"); From 4f219290120f287ebd5aa69a5830642044de6967 Mon Sep 17 00:00:00 2001 From: Nonoriri Date: Thu, 21 Nov 2013 01:38:51 -0500 Subject: [PATCH 04/15] Enchanting fully implemented. Unenchanting no longer buggy. Added check for halloween items so they only can be repaired by blocks at full XP cost. --- .../src/me/kaZep/Base/PlayerListener.java | 216 +++++++++++++----- 1 file changed, 155 insertions(+), 61 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index dfb9875..ff4de90 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -20,6 +20,8 @@ import net.milkbowl.vault.economy.EconomyResponse; + + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Chunk; @@ -9730,16 +9732,16 @@ implements Listener final int LEVELS = 22; boolean anvilClicked = false; - Bukkit.getLogger().info("Anvil interface CLICK at slot #" + event.getRawSlot()); + // Bukkit.getLogger().info("Anvil interface CLICK at slot #" + event.getRawSlot()); if (event.getRawSlot() == -999) { anvilClicked = false; - Bukkit.getLogger().info("Window exterior clicked."); + // Bukkit.getLogger().info("Window exterior clicked."); } else if (event.getRawSlot() < 27) { anvilClicked = true; - Bukkit.getLogger().info("Anvil clicked."); + // Bukkit.getLogger().info("Anvil clicked."); } else { - Bukkit.getLogger().info("Inventory clicked."); + // Bukkit.getLogger().info("Inventory clicked."); } if (!anvilClicked) { // Clicked the inventory. Leave the operation alone UNLESS it's a shift-click operation. @@ -9757,7 +9759,7 @@ implements Listener */ if (event.getSlot() == OUTPUT && event.getCursor() != null && event.getCursor().getType() != Material.AIR && !matches(event.getCursor(), event.getCurrentItem())){ - Bukkit.getLogger().info("Anvil OUTPUT click."); + // Bukkit.getLogger().info("Anvil OUTPUT click."); event.setCancelled(true); // Cancel the event if trying to put items into the output slot } @@ -9765,18 +9767,18 @@ implements Listener if (event.getInventory().getContents()[OUTPUT] != null && event.getSlot() == OUTPUT) { - Bukkit.getLogger().info("Anvil OUTPUT click with output populated."); + // Bukkit.getLogger().info("Anvil OUTPUT click with output populated."); if (event.getInventory().getContents()[LEVELS].getAmount() > Bukkit.getPlayer(event.getWhoClicked().getName()).getLevel()) { // Player doesn't have enough XP, abort - Bukkit.getLogger().info("Player has insufficient XP."); + // Bukkit.getLogger().info("Player has insufficient XP."); p.sendMessage(ChatColor.RED+"You don't have enough experience to do that!"); event.setCancelled(true); } else { - Bukkit.getLogger().info("Player has sufficient XP."); + // Bukkit.getLogger().info("Player has sufficient XP."); if (event.getCursor() != null && event.getCursor().getType() != Material.AIR) { - Bukkit.getLogger().info("Anvil OUTPUT click with non-null mouse. Mouse has: " + event.getCursor()); + // Bukkit.getLogger().info("Anvil OUTPUT click with non-null mouse. Mouse has: " + event.getCursor()); event.setCancelled(true); // Cancel event if cursor is not empty @@ -9784,7 +9786,7 @@ implements Listener // Attempts to store the item in the player's inventory. // If it succeeds, remove the item from the anvil // interface. - Bukkit.getLogger().info("Shift-click"); + // Bukkit.getLogger().info("Shift-click"); if (event .getWhoClicked() .getInventory() @@ -9792,12 +9794,32 @@ implements Listener event.getInventory().getContents()[OUTPUT]) .isEmpty()) { - Bukkit.getLogger().info("Can place into inventory."); + // Bukkit.getLogger().info("Can place into inventory."); if (event.getCurrentItem().getType() == Material.ENCHANTED_BOOK && event.getInventory().getItem(MAGIC).getType() == Material.BOOK) { // Halve its durability event.getInventory().getItem(INPUT).setDurability((short)(event.getInventory().getItem(INPUT).getDurability() + (event.getInventory().getItem(INPUT).getType().getMaxDurability() - event.getInventory().getItem(INPUT).getDurability()) / 2)); + // DISENCHANT BEGIN + Map map = event.getInventory().getItem(INPUT).getEnchantments(); + for (Map.Entry entry : map.entrySet()) { + event.getInventory().getItem(INPUT).removeEnchantment(entry.getKey()); + } + if (event.getInventory().getItem(INPUT).hasItemMeta() && event.getInventory().getItem(INPUT).getItemMeta().hasLore()) { + List newlore = new ArrayList(); + for (int i=0;i map = event.getInventory().getItem(INPUT).getEnchantments(); + for (Map.Entry entry : map.entrySet()) { + event.getInventory().getItem(INPUT).removeEnchantment(entry.getKey()); + } + if (event.getInventory().getItem(INPUT).hasItemMeta() && event.getInventory().getItem(INPUT).getItemMeta().hasLore()) { + List newlore = new ArrayList(); + for (int i=0;i map = event.getInventory().getItem(INPUT).getEnchantments(); + for (Map.Entry entry : map.entrySet()) { + event.getInventory().getItem(INPUT).removeEnchantment(entry.getKey()); + } + if (event.getInventory().getItem(INPUT).hasItemMeta() && event.getInventory().getItem(INPUT).getItemMeta().hasLore()) { + List newlore = new ArrayList(); + for (int i=0;i lore = anvilInv.getItem(INPUT).getItemMeta().getLore(); + for (int i=0;i maxItemsNeeded) { - // Bukkit.getLogger().info("Materials exceed " + maxItemsNeeded + " stack. Dropping " + (anvilInv.getItem(MATERIALS).getAmount() - maxItemsNeeded) + " of " + anvilInv.getItem(MATERIALS).getType()); + // // Bukkit.getLogger().info("Materials exceed " + maxItemsNeeded + " stack. Dropping " + (anvilInv.getItem(MATERIALS).getAmount() - maxItemsNeeded) + " of " + anvilInv.getItem(MATERIALS).getType()); sendToInventory(MATERIALS, anvilInv.getItem(MATERIALS).getAmount() - maxItemsNeeded, player); @@ -13101,24 +13185,24 @@ class updateInventoryTask implements Runnable { int bonus_cost = 0; ItemStack item = anvilInv.getContents()[INPUT]; - Bukkit.getLogger().warning("Repair cost calculation valid"); + // Bukkit.getLogger().warning("Repair cost calculation valid"); Map enchantments = item.getEnchantments(); - Bukkit.getLogger().warning(enchantments.keySet().toString()); + // Bukkit.getLogger().warning(enchantments.keySet().toString()); for (Enchantment e : enchantments.keySet()) { - Bukkit.getLogger().warning("BC: " + bonus_cost + " | INCR: " + 2 + enchantments.get(e)); + // Bukkit.getLogger().warning("BC: " + bonus_cost + " | INCR: " + 2 + enchantments.get(e)); bonus_cost += (2 + enchantments.get(e)); } cost += bonus_cost; - Bukkit.getLogger().info("Raw cost: " + cost); + // Bukkit.getLogger().info("Raw cost: " + cost); cost = (short) Math.floor(cost * multiplier); cost = Math.min(cost, 60); // Cap cost at 60 in case some egregiously enchanted item exists cost = Math.max(cost, 1); // Make sure it's at least one level - Bukkit.getLogger().info("Cost: " + cost); + // Bukkit.getLogger().info("Cost: " + cost); ItemStack orbs = new ItemStack(Material.SLIME_BALL); @@ -13148,7 +13232,7 @@ class updateInventoryTask implements Runnable { // anvilInv.getContents()[OUTPUT].setData(item.getData()); anvilInv.setItem(OUTPUT, item.clone()); - anvilInv.getContents()[OUTPUT].setDurability((short) (item.getDurability() - item.getType().getMaxDurability() * 0.2 * anvilInv.getContents()[MATERIALS].getAmount())); + anvilInv.getContents()[OUTPUT].setDurability((short) (item.getDurability() - item.getType().getMaxDurability() * repairMultiplier * anvilInv.getContents()[MATERIALS].getAmount())); } @@ -13174,16 +13258,16 @@ class updateInventoryTask implements Runnable { if (anvilInv.getItem(INPUT).getItemMeta().hasLore()) { for (int i = 0; i < anvilInv.getItem(INPUT).getItemMeta().getLore().size(); i++) { // Put enchantments together for the input. Also stacks identical enchantments. - Bukkit.getLogger().info("Iterating bonus: " + anvilInv.getItem(INPUT).getItemMeta().getLore().get(i)); + // Bukkit.getLogger().info("Iterating bonus: " + anvilInv.getItem(INPUT).getItemMeta().getLore().get(i)); if (getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i)) != null) { if (itemBonuses.get(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))) == null) { - Bukkit.getLogger().info("New bonus: " + getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); + // Bukkit.getLogger().info("New bonus: " + getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); itemBonuses.put(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i)), getEnchantmentNumb(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); } else { - Bukkit.getLogger().info("Stacking bonus: " + itemBonuses.get(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))) + " + " + getEnchantmentNumb(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); + // Bukkit.getLogger().info("Stacking bonus: " + itemBonuses.get(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))) + " + " + getEnchantmentNumb(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); itemBonuses.put(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i)), itemBonuses.get(getEnchantmentName(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))) + getEnchantmentNumb(anvilInv.getItem(INPUT).getItemMeta().getLore().get(i))); } } @@ -13193,14 +13277,14 @@ class updateInventoryTask implements Runnable { if (anvilInv.getItem(MAGIC).getItemMeta().hasLore()) { for (int i = 0; i < anvilInv.getItem(MAGIC).getItemMeta().getLore().size(); i++) { // Put enchantments together for the MAGIC. Also stacks identical enchantments. - Bukkit.getLogger().info("Iterating bonus: " + anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i)); + // Bukkit.getLogger().info("Iterating bonus: " + anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i)); if (bookBonuses.get(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))) == null) { - Bukkit.getLogger().info("New bonus: " + getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); + // Bukkit.getLogger().info("New bonus: " + getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); bookBonuses.put(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i)), getEnchantmentNumb(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); } else { - Bukkit.getLogger().info("Stacking bonus: " + bookBonuses.get(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))) + " + " + getEnchantmentNumb(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); + // Bukkit.getLogger().info("Stacking bonus: " + bookBonuses.get(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))) + " + " + getEnchantmentNumb(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); bookBonuses.put(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i)), bookBonuses.get(getEnchantmentName(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))) + getEnchantmentNumb(anvilInv.getItem(MAGIC).getItemMeta().getLore().get(i))); } } @@ -13210,12 +13294,12 @@ class updateInventoryTask implements Runnable { Map probableEnchantments = new java.util.HashMap(); for (Enchantment e : bookEnchantments.keySet()) { - Bukkit.getLogger().info("Iterating enchantment: " + e); + // Bukkit.getLogger().info("Iterating enchantment: " + e); if (itemEnchantments.get(e) == null || bookEnchantments.get(e) > itemEnchantments.get(e)) { // Book enchantment is larger in magnitude. Assign it as a possible outcome. probableEnchantments.put(e, bookEnchantments.get(e)); - } else if (bookEnchantments.get(e) == itemEnchantments.get(e)) { + } else if (bookEnchantments.get(e) == itemEnchantments.get(e) && bookEnchantments.get(e) <= 10) { // Book enchantment is same in magnitude. Upgrade by one level. probableEnchantments.put(e, bookEnchantments.get(e) + 1); } @@ -13225,7 +13309,7 @@ class updateInventoryTask implements Runnable { Map probableBonuses = new java.util.HashMap(); for (String e : bookBonuses.keySet()) { - Bukkit.getLogger().info("Iterating bonus: " + e); + // Bukkit.getLogger().info("Iterating bonus: " + e); if (itemBonuses.get(e) == null) { // Book enchantment is new. Assign it as a possible outcome. @@ -13244,7 +13328,7 @@ class updateInventoryTask implements Runnable { if (probableEnchantments.size() != 0) { // Randomly select an enchantment to add. int random = (int)(Math.random() * probableEnchantments.size()); - Bukkit.getLogger().info("Randomized to # " + (random + 1) + " out of " + probableEnchantments.size()); + // Bukkit.getLogger().info("Randomized to # " + (random + 1) + " out of " + probableEnchantments.size()); int i = 0; @@ -13392,8 +13476,12 @@ class updateInventoryTask implements Runnable { // Change entry matching modified lore ItemMeta bonusesMeta = anvilInv.getItem(OUTPUT).getItemMeta(); List bonusesLore = bonusesMeta.getLore(); + if (bonusesLore == null) + { + bonusesLore = new ArrayList(); + } - Bukkit.getLogger().info("Bonus enchantment string: " + appliedEnchant); + // Bukkit.getLogger().info("Bonus enchantment string: " + appliedEnchant); if (appliedEnchant.equalsIgnoreCase("Critical Chance")) { bonusesLore.add(ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Critical Chance"); } @@ -13467,8 +13555,8 @@ class updateInventoryTask implements Runnable { String e = bonusesLore.get(i1); if (containsEnchantment(e, appliedEnchant)) { - Bukkit.getLogger().info("Success! Found enchantment: " + e); - Bukkit.getLogger().info("Bonus enchantment: " + appliedEnchant); + // Bukkit.getLogger().info("Success! Found enchantment: " + e); + // Bukkit.getLogger().info("Bonus enchantment: " + appliedEnchant); if (appliedEnchant.equalsIgnoreCase("Critical Chance")) { bonusesLore.set(i1, ChatColor.YELLOW+"+"+magnitude+"% "+ChatColor.BLUE+"Critical Chance"); @@ -13513,7 +13601,7 @@ class updateInventoryTask implements Runnable { player.getInventory().setContents(player.getInventory().getContents()); anvilInv.setContents(anvilInv.getContents()); player.updateInventory(); - } else if (anvilInv.getItem(MAGIC).getType() == Material.BOOK) { + } else if (anvilInv.getItem(MAGIC).getType() == Material.BOOK && anvilInv.getItem(INPUT).getType() != Material.ENCHANTED_BOOK) { // Magic slot is a book. Unenchanting logic goes here. anvilInv.setItem(OUTPUT, anvilInv.getItem(INPUT).clone()); anvilInv.getItem(OUTPUT).setType(Material.ENCHANTED_BOOK); @@ -13525,7 +13613,13 @@ class updateInventoryTask implements Runnable { sendToInventory(MAGIC, anvilInv.getItem(MAGIC).getAmount() - 1, player); } - int cost = 1; + int cost = 12; + + Map enchantments = anvilInv.getItem(INPUT).getEnchantments(); + + for (Enchantment e : enchantments.keySet()) { + cost += (1 + enchantments.get(e)); + } ItemStack orbs = new ItemStack(Material.SLIME_BALL); @@ -13561,9 +13655,9 @@ class updateInventoryTask implements Runnable { } public void sendToInventory(int slot, int itemCount, Player player) { - Bukkit.getLogger().info("Slot: " + slot); - Bukkit.getLogger().info("Item Count: " + itemCount); - Bukkit.getLogger().info("Player: " + player.getDisplayName()); + // Bukkit.getLogger().info("Slot: " + slot); + // Bukkit.getLogger().info("Item Count: " + itemCount); + // Bukkit.getLogger().info("Player: " + player.getDisplayName()); // Get inventories Inventory anvilInventory = player.getOpenInventory().getTopInventory(); @@ -13581,16 +13675,16 @@ class updateInventoryTask implements Runnable { } - Bukkit.getLogger().info("Slot stack size is " + anvilInventory.getItem(slot).getAmount()); + // Bukkit.getLogger().info("Slot stack size is " + anvilInventory.getItem(slot).getAmount()); if (anvilInventory.getItem(slot).getAmount() - itemCount == 0) { // Should reduce stack count to zero, meaning item needs to be removed. - Bukkit.getLogger().info("Item stack size reduced to 0, " + anvilInventory.getItem(slot).getType().toString() + " removed."); + // Bukkit.getLogger().info("Item stack size reduced to 0, " + anvilInventory.getItem(slot).getType().toString() + " removed."); anvilInventory.setItem(slot, new ItemStack(Material.AIR)); } else { // Should set stack size. - Bukkit.getLogger().info("Reduced stack size from " + anvilInventory.getItem(slot).getAmount() + " by " + itemCount); + // Bukkit.getLogger().info("Reduced stack size from " + anvilInventory.getItem(slot).getAmount() + " by " + itemCount); anvilInventory.getItem(slot).setAmount(anvilInventory.getItem(slot).getAmount() - itemCount); } // player.getWorld().dropItemNaturally(player.getLocation(), new ItemStack(anvilInv.getItem(MATERIALS).getType(), anvilInv.getItem(MATERIALS).getAmount() - maxItemsNeeded)); @@ -13602,7 +13696,7 @@ class updateInventoryTask implements Runnable { String[] enchant = s.split(" "); if (enchant[0].contains(ChatColor.YELLOW+"")) { String newstring = ((enchant[0].replace(ChatColor.YELLOW.getChar(), ' ')).replace('%', ' ')).replace(Character.toString((char)0x00A7), Character.toString((char)0x0020)); - //Bukkit.getLogger().info("Enchant number is "+Double.valueOf(newstring)); + // Bukkit.getLogger().info("Enchant number is "+Double.valueOf(newstring)); return Double.valueOf(newstring); } else { return 0; From 2898e12506d880b50a30b952608b8d44a7822b9f Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Thu, 21 Nov 2013 01:28:39 -0700 Subject: [PATCH 05/15] Fixed all references of string names for account configs to have .toLowerCase() so that everything is consistent and the functions come out properly. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 38 +-- .../src/me/kaZep/Base/PlayerBuffData.java | 16 +- .../src/me/kaZep/Base/PlayerListener.java | 298 +++++++----------- .../me/kaZep/Commands/commandBankEconomy.java | 135 ++++---- 4 files changed, 218 insertions(+), 269 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index 0b5df99..654c15b 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -3652,7 +3652,7 @@ public void payDay(int time) return; } if (PlayerinJob(p,job)) { - getAccountsConfig().set(p.getName()+".jobs.ultimate", String.valueOf(ValidJobs[matchedjob])); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.ultimate", String.valueOf(ValidJobs[matchedjob])); saveAccountsConfig(); p.sendMessage(ChatColor.YELLOW+"Set Declared Ultimate job to "+job); } else { @@ -3717,9 +3717,9 @@ public void payDay(int time) hunterplayers.add(p); } Bukkit.getLogger().info("Added extra job pieces when joining."); - getAccountsConfig().set(p.getName()+".jobs.job"+(openslot+1), String.valueOf(ValidJobs[matchedjob])); - getAccountsConfig().set(p.getName()+".jobs.job"+(openslot+1)+"lv", Integer.valueOf(1)); - getAccountsConfig().set(p.getName()+".jobs.job"+(openslot+1)+"exp", Double.valueOf(0)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(openslot+1), String.valueOf(ValidJobs[matchedjob])); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(openslot+1)+"lv", Integer.valueOf(1)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(openslot+1)+"exp", Double.valueOf(0)); saveAccountsConfig(); Bukkit.getLogger().info("Set job data."); Bukkit.broadcastMessage(p.getName()+" has joined the "+JobColors[matchedjob]+ValidJobs[matchedjob]+ChatColor.WHITE+" job!"); @@ -3780,7 +3780,7 @@ public void payDay(int time) double val=0; val = economy.getBalance(p.getName()); economy.withdrawPlayer(p.getName(), val); - getAccountsConfig().set(p.getName()+".jobs.job"+(slot+1)+"exp", Double.valueOf(newexp)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp", Double.valueOf(newexp)); saveAccountsConfig(); } @@ -3807,16 +3807,16 @@ public void payDay(int time) } JobsDataInfo info = Jobsinfo[getJobSlot(job)]; economy.depositPlayer(p.getName(), amount*(1d+(info.moneymult*getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")))); - getAccountsConfig().set(p.getName()+".jobs.job"+(slot+1)+"exp", Double.valueOf(getAccountsConfig().getDouble(p.getName()+".jobs.job"+(slot+1)+"exp")+exp)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp", Double.valueOf(getAccountsConfig().getDouble(p.getName()+".jobs.job"+(slot+1)+"exp")+exp)); if (getAccountsConfig().getDouble(p.getName()+".jobs.job"+(slot+1)+"exp")<0) { //It can't be negative. - getAccountsConfig().set(p.getName()+".jobs.job"+(slot+1)+"exp", Double.valueOf(0.0)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp", Double.valueOf(0.0)); } //Check for lv up. if (getJobLv(job,p)<40 && getJobExp(job,getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv"))<=getAccountsConfig().getDouble(p.getName()+".jobs.job"+(slot+1)+"exp")) { //Level up! Level up! YEAH! - getAccountsConfig().set(p.getName()+".jobs.job"+(slot+1)+"exp", Double.valueOf(getAccountsConfig().getDouble(p.getName()+".jobs.job"+(slot+1)+"exp")-getJobExp(job,getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")))); - getAccountsConfig().set(p.getName()+".jobs.job"+(slot+1)+"lv", Integer.valueOf(getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")+1)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp", Double.valueOf(getAccountsConfig().getDouble(p.getName()+".jobs.job"+(slot+1)+"exp")-getJobExp(job,getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")))); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv", Integer.valueOf(getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")+1)); Bukkit.broadcastMessage(p.getName()+" is now a Level "+getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")+" "+getJobColor(job)+job+ChatColor.WHITE+"."); if (getJobTotalLvs(p)%5==0) { Bukkit.broadcastMessage(ChatColor.GREEN+p.getName()+" has reached Level "+getJobTotalLvs(p)+"!"); @@ -3852,7 +3852,7 @@ public void payDay(int time) if (slot!=-1) { JobsDataInfo info = Jobsinfo[getJobSlot(job)]; if (getJobLv(job,p)<40) { - getAccountsConfig().set(p.getName()+".jobs.job"+(slot+1)+"lv", Integer.valueOf(getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")+1)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv", Integer.valueOf(getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")+1)); Bukkit.broadcastMessage(p.getName()+" is now a Level "+getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")+" "+getJobColor(job)+job+ChatColor.WHITE+"."); if (getJobTotalLvs(p)%5==0) { Bukkit.broadcastMessage(ChatColor.GREEN+p.getName()+" has reached Level "+getJobTotalLvs(p)+"!"); @@ -4630,9 +4630,9 @@ public void payDay(int time) saveConfig(); //Remove from job 1. Bukkit.broadcastMessage(p.getName()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName()+".jobs.job1"))+getAccountsConfig().getString(p.getName()+".jobs.job1")+ChatColor.WHITE+" job!"); - getAccountsConfig().set(p.getName()+".jobs.job1", String.valueOf("None")); - getAccountsConfig().set(p.getName()+".jobs.job1lv", Integer.valueOf(0)); - getAccountsConfig().set(p.getName()+".jobs.job1exp", Double.valueOf(0)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1", String.valueOf("None")); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1lv", Integer.valueOf(0)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1exp", Double.valueOf(0)); saveAccountsConfig(); return true; } else @@ -4642,9 +4642,9 @@ public void payDay(int time) saveConfig(); //Remove from job 2. Bukkit.broadcastMessage(p.getName()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName()+".jobs.job2"))+getAccountsConfig().getString(p.getName()+".jobs.job2")+ChatColor.WHITE+" job!"); - getAccountsConfig().set(p.getName()+".jobs.job2", String.valueOf("None")); - getAccountsConfig().set(p.getName()+".jobs.job2lv", Integer.valueOf(0)); - getAccountsConfig().set(p.getName()+".jobs.job2exp", Double.valueOf(0)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2", String.valueOf("None")); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2lv", Integer.valueOf(0)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2exp", Double.valueOf(0)); saveAccountsConfig(); return true; } else @@ -4654,9 +4654,9 @@ public void payDay(int time) saveConfig(); //Remove from job 3. Bukkit.broadcastMessage(p.getName()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName()+".jobs.job3"))+getAccountsConfig().getString(p.getName()+".jobs.job3")+ChatColor.WHITE+" job!"); - getAccountsConfig().set(p.getName()+".jobs.job3", String.valueOf("None")); - getAccountsConfig().set(p.getName()+".jobs.job3lv", Integer.valueOf(0)); - getAccountsConfig().set(p.getName()+".jobs.job3exp", Double.valueOf(0)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3", String.valueOf("None")); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3lv", Integer.valueOf(0)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3exp", Double.valueOf(0)); saveAccountsConfig(); return true; } diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerBuffData.java b/BankEconomyMod/src/me/kaZep/Base/PlayerBuffData.java index f1d126c..7f9e64d 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerBuffData.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerBuffData.java @@ -146,8 +146,8 @@ public class PlayerBuffData { if (!p.isDead()) { //Don't even try to set things if we're dead. base_hplv=20; base_hplv+=hpbufflist.size()*10; - if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat8")>0) { - base_hplv+=this.plugin.getStatBonus(7, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat8")/2); + if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat8")>0) { + base_hplv+=this.plugin.getStatBonus(7, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat8")/2); } //Check player equipment to see if an item could possibly have a health buff. for (int i=0;i0) { + if (!hasabsorption && this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat4")>0) { p.removePotionEffect(PotionEffectType.ABSORPTION); - p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,3590,this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")/3)/4-1)); - //p.sendMessage("Absorption level is "+(this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")/4)/4-1)); + p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,3590,this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat4")/3)/4-1)); + //p.sendMessage("Absorption level is "+(this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat4")/4)/4-1)); } - if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat2")>0) { + if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat2")>0) { p.removePotionEffect(PotionEffectType.FAST_DIGGING); - p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING,399,this.plugin.getStatBonus(1, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat2")/5)/20-1)); + p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING,399,this.plugin.getStatBonus(1, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat2")/5)/20-1)); } //p.sendMessage("Health: "+p.getHealth()+"/"+p.getMaxHealth()+" Base HP Level: "+base_hplv); if (p.getHealth()>p.getMaxHealth()) { @@ -260,7 +260,7 @@ public class PlayerBuffData { } if (last_money_report_time+720000) { - p.setMaximumAir(300+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName() + ".stats.stat10"))*20); + if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase() + ".stats.stat10")>0) { + p.setMaximumAir(300+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase() + ".stats.stat10"))*20); } if (p.getLocation().getY()>78.0d && p.getLocation().getZ()>53.0d && p.getLocation().getZ()<64.0d && p.getLocation().getX()<1627.0d && p.getLocation().getX()>1616.0d) { //In a spleef zone. Kick this player out. @@ -5102,47 +5102,6 @@ implements Listener Player p = e.getPlayer(); Bukkit.getPlayer("sigonasr2").sendMessage("Extacting "+e.getItemAmount()+" "+e.getItemType()); }*/ - @EventHandler - public void onLeafDecay(LeavesDecayEvent e) { - Player[] list = Bukkit.getOnlinePlayers(); - for (int i=0;i=20) { - //Increase sapling drops by 64%. - if (e.getBlock().getData()!=3) { - //This is not a jungle leaf block. - if (Math.random()*100<=25) { - //Produce a sapling. - Bukkit.getWorld("world").dropItem(e.getBlock().getLocation(), new ItemStack(Material.SAPLING,1,e.getBlock().getData())); - //list[i].sendMessage("You got an extra spawned sapling."); - } - } else { - if (Math.random()*100<=12.5) { - //Produce a sapling. - Bukkit.getWorld("world").dropItem(e.getBlock().getLocation(), new ItemStack(Material.SAPLING,1,e.getBlock().getData())); - } - } - } else - if (this.plugin.PlayerinJob(list[i], "Woodcutter") && this.plugin.getJobLv("Woodcutter", list[i])>=5) { - //Increase sapling drops by 40%. - if (e.getBlock().getData()!=3) { - //This is not a jungle leaf block. - if (Math.random()*100<=12) { - //Produce a sapling. - Bukkit.getWorld("world").dropItem(e.getBlock().getLocation(), new ItemStack(Material.SAPLING,1,e.getBlock().getData())); - //list[i].sendMessage("You got an extra spawned sapling."); - } - } else { - if (Math.random()*100<=6) { - //Produce a sapling. - Bukkit.getWorld("world").dropItem(e.getBlock().getLocation(), new ItemStack(Material.SAPLING,1,e.getBlock().getData())); - } - } - } - } - } - } @EventHandler public void onItemChange(PlayerItemHeldEvent e) { @@ -5214,19 +5173,6 @@ implements Listener } } } - if (this.plugin.PlayerinJob(p, "Woodcutter") && this.plugin.getJobLv("Woodcutter", p)>=10) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_AXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_AXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_AXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_AXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_AXE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 1); - } - } - } } public ItemStack getGoodie() { @@ -6048,7 +5994,7 @@ implements Listener if (f.getKiller()!=null && f.getKiller().getType()==EntityType.PLAYER) { Player p = f.getKiller(); if (f.getType()==EntityType.SKELETON && ((Skeleton)f).getSkeletonType()==SkeletonType.WITHER) { - this.plugin.getAccountsConfig().set(p.getName()+".bonus.witherskeleton", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName()+".bonus.witherskeleton"))+1); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".bonus.witherskeleton", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".bonus.witherskeleton"))+1); } for (int x=-10;x<10;x++) { for (int y=-3;y<3;y++) { @@ -6157,7 +6103,7 @@ implements Listener this.plugin.gainMoneyExp(p,"Hunter",275.00,7800); } } - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify3")) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify3")) { p.sendMessage(ChatColor.DARK_GREEN+""+ChatColor.ITALIC+"Gained "+e.getDroppedExp()+" exp."); } if (this.plugin.getConfig().getBoolean("halloween-enabled") && p.getWorld().getName().equalsIgnoreCase("world") && (e.getEntity() instanceof Sheep)) { @@ -6199,8 +6145,8 @@ implements Listener p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); } },5); - if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9")>0) { - if (Math.random()<=this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9"))/100.0d) { + if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat9")>0) { + if (Math.random()<=this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat9"))/100.0d) { e.setFoodLevel(e.getFoodLevel()+1); } } @@ -6538,13 +6484,13 @@ implements Listener if (e.getInventory().getContents()[m]!=null && e.getInventory().getContents()[m].getType()==Material.PUMPKIN_PIE) { if (e.getInventory().getContents()[m].getItemMeta().getDisplayName()!=null && e.getInventory().getContents()[m].getItemMeta().getDisplayName().contains("Pie ")) { int numb = Integer.valueOf(e.getInventory().getContents()[m].getItemMeta().getDisplayName().replace("Pie ","")); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".halloween.chest"+numb)) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".halloween.chest"+numb)) { p.closeInventory(); p.sendMessage("You already got this magic pie!"); e.setCancelled(true); } else { //Show the user a fake inventory containing the magic pie. - this.plugin.getAccountsConfig().set(p.getName()+".halloween.chest"+numb, Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".halloween.chest"+numb, Boolean.valueOf(true)); this.plugin.saveAccountsConfig(); p.closeInventory(); e.setCancelled(true); @@ -6712,7 +6658,7 @@ implements Listener } } final double player_starthp = p.getHealth(); - if (p.getNoDamageTicks()0) { - p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, (this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat6"))/3)*20, 0)); + if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat6")>0) { + p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, (this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat6"))/3)*20, 0)); } } } @@ -6868,8 +6814,8 @@ implements Listener }, 1L); } } - if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")>0) { - e.setAmount(e.getAmount()+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")/6)); + if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1")>0) { + e.setAmount(e.getAmount()+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1")/6)); } } } @@ -7060,7 +7006,7 @@ implements Listener if (e.getDamager() instanceof LivingEntity) { final double player_starthp = p.getHealth(); final LivingEntity l = (LivingEntity)e.getDamager(); - if (p.getNoDamageTicks()0) { + if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat3")>0) { double olddmg=e.getDamage(); - e.setDamage(e.getDamage()*(((100-this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat3")/4))/100.0d))); + e.setDamage(e.getDamage()*(((100-this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat3")/4))/100.0d))); //p.sendMessage("Damage set from "+olddmg+" to "+e.getDamage()); } } @@ -7575,7 +7521,7 @@ implements Listener if (throughdmg>e.getDamage()/2) { if (p.getHealth()-throughdmg>0) { p.setHealth(p.getHealth()-throughdmg); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify5") && e.getDamage()!=0) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify5") && e.getDamage()!=0) { //p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"You were hurt for "+Math.round(throughdmg*10)/10+" damage from "+convertToItemName(e.getCause().name())+"."); } } else { @@ -7608,7 +7554,7 @@ implements Listener } else { if (p.getHealth()-e.getDamage()/2>0) { p.setHealth(p.getHealth()-e.getDamage()/2); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify5") && e.getDamage()!=0) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify5") && e.getDamage()!=0) { //p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"You were hurt for "+Math.round(e.getDamage()/2*10)/10+" damage from "+convertToItemName(e.getCause().name())+"."); } } else { @@ -7672,7 +7618,7 @@ implements Listener if (throughdmg>e.getDamage()) { if (p.getHealth()-throughdmg>0) { p.setHealth(p.getHealth()-throughdmg); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify5") && e.getDamage()!=0) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify5") && e.getDamage()!=0) { //p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"You were hurt for "+Math.round(throughdmg*10)/10+" damage from "+convertToItemName(e.getCause().name())+"."); } } else { @@ -7710,7 +7656,7 @@ implements Listener } else { if (p.getHealth()-e.getDamage()>0) { p.setHealth(p.getHealth()-e.getDamage()); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify5") && e.getDamage()!=0) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify5") && e.getDamage()!=0) { //p.sendMessage(ChatColor.DARK_PURPLE+""+ChatColor.ITALIC+"You were hurt for "+Math.round(e.getDamage()*10)/10+" damage from "+convertToItemName(e.getCause().name())+"."); } } else { @@ -7889,24 +7835,24 @@ implements Listener //Deal 2 extra damage. e.setDamage(e.getDamage()+2); } - if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")>0) { - e.setDamage(e.getDamage()+(this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7"))/2)); + if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7")>0) { + e.setDamage(e.getDamage()+(this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7"))/2)); } //Add Armor penetration from the stat point, if any. - if (this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)>0) { - armor_pen+=this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4); + if (this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")/4)>0) { + armor_pen+=this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")/4); } if (f.getNoDamageTicks()0) { double normaldmg=(this.plugin.DMGCALC.getDamage(f.getEquipment().getHelmet(), f.getEquipment().getChestplate(), f.getEquipment().getLeggings(), f.getEquipment().getBoots(), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); double throughdmg=(this.plugin.DMGCALC.getDamage(new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); if (throughdmg>normaldmg+armor_pen) { //This means some piercing can be done. - //e.setDamage(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)); + //e.setDamage(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")/4)); if (f.getHealth()-(normaldmg+armor_pen)>0) { f.setHealth(f.getHealth()-(normaldmg+armor_pen)); armor_pen_dmg=(normaldmg+armor_pen); if (f!=null) { - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify4")) { if (f.getCustomName()!=null) { //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(normaldmg+armor_pen)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); } else { @@ -7923,7 +7869,7 @@ implements Listener f.setHealth(f.getHealth()-throughdmg); armor_pen_dmg=throughdmg; if (f!=null) { - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify4")) { if (f.getCustomName()!=null) { //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); } else { @@ -7938,7 +7884,7 @@ implements Listener e.setDamage(0); } if (f.getNoDamageTicks()0) { - armor_pen+=this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4); + if (this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")/4)>0) { + armor_pen+=this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")/4); } if (e.getEntity() instanceof LivingEntity) { LivingEntity enemy = (LivingEntity)e.getEntity(); @@ -8063,8 +8009,8 @@ implements Listener //Deal 2 extra damage. e.setDamage(e.getDamage()+2); } - if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")>0) { - e.setDamage(e.getDamage()+(this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7"))/2)); + if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7")>0) { + e.setDamage(e.getDamage()+(this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7"))/2)); } if (f.getNoDamageTicks()0) { double normaldmg=(this.plugin.DMGCALC.getDamage(f.getEquipment().getHelmet(), f.getEquipment().getChestplate(), f.getEquipment().getLeggings(), f.getEquipment().getBoots(), e.getDamage(), DamageCause.ENTITY_ATTACK, false)); @@ -8073,11 +8019,11 @@ implements Listener if (throughdmg>normaldmg+armor_pen) { //This means some piercing can be done. - //e.setDamage(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)); + //e.setDamage(normaldmg+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")/4)); if (f.getHealth()-(normaldmg+armor_pen)>0) { f.setHealth(f.getHealth()-(normaldmg+armor_pen)); armor_pen_dmg=(normaldmg+armor_pen); - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify4")) { if (f.getCustomName()!=null) { //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(normaldmg+armor_pen)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); } else { @@ -8092,7 +8038,7 @@ implements Listener if (f.getHealth()-throughdmg>0) { f.setHealth(f.getHealth()-throughdmg); armor_pen_dmg=throughdmg; - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify4")) { if (f.getCustomName()!=null) { //p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+" Dealt "+(Math.round(throughdmg)*10)/10+" damage to "+convertToItemName(f.getCustomName())+"."); } else { @@ -8106,7 +8052,7 @@ implements Listener e.setDamage(0); } if (f.getNoDamageTicks()0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")/6)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")/6+1):ChatColor.RED+"+"+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")/6+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")/6))))+ChatColor.GREEN+" Health Regeneration."); - p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#9 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat2")/5+" - "+ChatColor.AQUA+" 5 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat2")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat2")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(1, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat2")/5)+"%"+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(1, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat2")/5+1)+"%":ChatColor.RED+"+"+this.plugin.getStatBonus(1, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat2")/5+1)+"%"):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(1, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat2")/5)+"%")))+ChatColor.GREEN+" block destroying speed."); - p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#8 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat3")/4+" - "+ChatColor.AQUA+" 4 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat3")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat3")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat3")/4)+"%"+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat3")/4+1)+"%":ChatColor.RED+"+"+this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat3")/4+1)+"%"):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat3")/4)+"%")))+ChatColor.GREEN+" damage reduction."); - p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#7 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4+" - "+ChatColor.AQUA+" 4 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4+1):ChatColor.RED+"+"+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4))))+ChatColor.GREEN+" armor penetration."); - p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#6 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")/3+" - "+ChatColor.AQUA+" 3 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")/3)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")/3+1):ChatColor.RED+"+"+this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")/3+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")/3))))+ChatColor.GREEN+" temporary health. (Regenerates every 3 minutes)"); - p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#5 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat6")/3+" - "+ChatColor.AQUA+" 3 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat6")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat6")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat6")/3)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat6")/3+1):ChatColor.RED+"+"+this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat6")/3+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat6")/3))))+ChatColor.GREEN+" seconds of fire resistance when caught on fire."); - p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#4 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")/2+" - "+ChatColor.AQUA+" 2 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")/2)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")/2+1):ChatColor.RED+"+"+this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")/2+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")/2))))+ChatColor.GREEN+" base damage."); - p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#3 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat8")/2+" - "+ChatColor.AQUA+" 2 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat8")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat8")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(7, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat8")/2)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(7, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat8")/2+1):ChatColor.RED+"+"+this.plugin.getStatBonus(7, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat8")/2+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(7, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat8")/2))))+ChatColor.GREEN+" health."); - p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#2 "+ChatColor.RESET+ChatColor.WHITE+"-"+this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9")/1+" - "+ChatColor.AQUA+" 1 pt: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9")<25 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9")>0/*Has a point in it.*/?ChatColor.YELLOW+"-"+this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9")/1)+"%"+"/"+ChatColor.RED+"-"+this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9")/1+1)+"%":ChatColor.RED+"-"+this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9")/1+1)+"%"):(ChatColor.YELLOW+"-"+this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9")/1)+"%")))+ChatColor.GREEN+" hunger decay."); - p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#1 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat10")/1+" - "+ChatColor.AQUA+" 1 pt: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat10")<25 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat10")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat10")/1)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat10")/1+1):ChatColor.RED+"+"+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat10")/1+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat10")/1))))+ChatColor.GREEN+" seconds of water breathing."); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#10 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1")/6+" - "+ChatColor.AQUA+" 6 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1")/6)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1")/6+1):ChatColor.RED+"+"+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1")/6+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1")/6))))+ChatColor.GREEN+" Health Regeneration."); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#9 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat2")/5+" - "+ChatColor.AQUA+" 5 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat2")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat2")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(1, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat2")/5)+"%"+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(1, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat2")/5+1)+"%":ChatColor.RED+"+"+this.plugin.getStatBonus(1, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat2")/5+1)+"%"):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(1, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat2")/5)+"%")))+ChatColor.GREEN+" block destroying speed."); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#8 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat3")/4+" - "+ChatColor.AQUA+" 4 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat3")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat3")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat3")/4)+"%"+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat3")/4+1)+"%":ChatColor.RED+"+"+this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat3")/4+1)+"%"):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat3")/4)+"%")))+ChatColor.GREEN+" damage reduction."); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#7 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")/4+" - "+ChatColor.AQUA+" 4 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")/4)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")/4+1):ChatColor.RED+"+"+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")/4+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")/4))))+ChatColor.GREEN+" armor penetration."); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#6 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat4")/3+" - "+ChatColor.AQUA+" 3 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat4")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat4")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat4")/3)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat4")/3+1):ChatColor.RED+"+"+this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat4")/3+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat4")/3))))+ChatColor.GREEN+" temporary health. (Regenerates every 3 minutes)"); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#5 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat6")/3+" - "+ChatColor.AQUA+" 3 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat6")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat6")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat6")/3)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat6")/3+1):ChatColor.RED+"+"+this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat6")/3+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat6")/3))))+ChatColor.GREEN+" seconds of fire resistance when caught on fire."); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#4 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7")/2+" - "+ChatColor.AQUA+" 2 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7")/2)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7")/2+1):ChatColor.RED+"+"+this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7")/2+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7")/2))))+ChatColor.GREEN+" base damage."); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#3 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat8")/2+" - "+ChatColor.AQUA+" 2 pts: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat8")<24 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat8")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(7, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat8")/2)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(7, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat8")/2+1):ChatColor.RED+"+"+this.plugin.getStatBonus(7, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat8")/2+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(7, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat8")/2))))+ChatColor.GREEN+" health."); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#2 "+ChatColor.RESET+ChatColor.WHITE+"-"+this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat9")/1+" - "+ChatColor.AQUA+" 1 pt: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat9")<25 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat9")>0/*Has a point in it.*/?ChatColor.YELLOW+"-"+this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat9")/1)+"%"+"/"+ChatColor.RED+"-"+this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat9")/1+1)+"%":ChatColor.RED+"-"+this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat9")/1+1)+"%"):(ChatColor.YELLOW+"-"+this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat9")/1)+"%")))+ChatColor.GREEN+" hunger decay."); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"#1 "+ChatColor.RESET+ChatColor.WHITE+"+"+this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat10")/1+" - "+ChatColor.AQUA+" 1 pt: "+ChatColor.YELLOW+((this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat10")<25 /*Not maxed.*/?(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat10")>0/*Has a point in it.*/?ChatColor.YELLOW+"+"+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat10")/1)+"/"+ChatColor.RED+"+"+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat10")/1+1):ChatColor.RED+"+"+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat10")/1+1)):(ChatColor.YELLOW+"+"+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat10")/1))))+ChatColor.GREEN+" seconds of water breathing."); p.sendMessage(ChatColor.ITALIC+""+ChatColor.DARK_AQUA+"Remember that 1 Health / Damage point is half a heart."); if (this.plugin.getStatPointTotal(p) temp_meta_lore = new ArrayList();temp_meta_lore.add(ChatColor.ITALIC+"Get notified whenever you pick up items.");temp_meta_lore.add(ChatColor.ITALIC+"");temp_meta_lore.add(ChatColor.ITALIC+""+ChatColor.GRAY+"Click to toggle this option on or off.");temp_meta.setLore(temp_meta_lore);temp.setItemMeta(temp_meta); on=new ItemStack(Material.REDSTONE_TORCH_ON); off=new ItemStack(Material.REDSTONE_TORCH_OFF); - i.setItem(count+=2, temp);on.setItemMeta(temp_meta);off.setItemMeta(temp_meta); i.setItem(count+=1, (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify1")?on:off)); + i.setItem(count+=2, temp);on.setItemMeta(temp_meta);off.setItemMeta(temp_meta); i.setItem(count+=1, (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify1")?on:off)); temp_meta.setDisplayName(ChatColor.YELLOW+"Craft Items");temp_meta_lore = new ArrayList();temp_meta_lore.add(ChatColor.ITALIC+"Get notified whenever you craft an item.");temp_meta_lore.add(ChatColor.ITALIC+"");temp_meta_lore.add(ChatColor.ITALIC+""+ChatColor.GRAY+"Click to toggle this option on or off.");temp_meta.setLore(temp_meta_lore); temp=new ItemStack(Material.WORKBENCH); - temp.setItemMeta(temp_meta);i.setItem(count+=3, temp);on.setItemMeta(temp_meta);off.setItemMeta(temp_meta); i.setItem(count+=1, (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify2")?on:off)); + temp.setItemMeta(temp_meta);i.setItem(count+=3, temp);on.setItemMeta(temp_meta);off.setItemMeta(temp_meta); i.setItem(count+=1, (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify2")?on:off)); temp_meta.setDisplayName(ChatColor.YELLOW+"Experience Points");temp_meta_lore = new ArrayList();temp_meta_lore.add(ChatColor.ITALIC+"Get notified whenever you gain");temp_meta_lore.add(ChatColor.ITALIC+"experience points.");temp_meta_lore.add(ChatColor.ITALIC+"");temp_meta_lore.add(ChatColor.ITALIC+""+ChatColor.GRAY+"Click to toggle this option on or off.");temp_meta.setLore(temp_meta_lore); temp=new ItemStack(Material.SLIME_BALL); - temp.setItemMeta(temp_meta);i.setItem(count+=4, temp);on.setItemMeta(temp_meta);off.setItemMeta(temp_meta); i.setItem(count+=1, (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify3")?on:off)); + temp.setItemMeta(temp_meta);i.setItem(count+=4, temp);on.setItemMeta(temp_meta);off.setItemMeta(temp_meta); i.setItem(count+=1, (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify3")?on:off)); temp_meta.setDisplayName(ChatColor.YELLOW+"Damage Dealt");temp_meta_lore = new ArrayList();temp_meta_lore.add(ChatColor.ITALIC+"Get notified whenever you deal");temp_meta_lore.add(ChatColor.ITALIC+"damage to enemies.");temp_meta_lore.add(ChatColor.ITALIC+"");temp_meta_lore.add(ChatColor.ITALIC+""+ChatColor.GRAY+"Click to toggle this option on or off.");temp_meta.setLore(temp_meta_lore); temp=new ItemStack(Material.IRON_SWORD); - temp.setItemMeta(temp_meta);i.setItem(count+=3, temp);on.setItemMeta(temp_meta);off.setItemMeta(temp_meta); i.setItem(count+=1, (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify4")?on:off)); + temp.setItemMeta(temp_meta);i.setItem(count+=3, temp);on.setItemMeta(temp_meta);off.setItemMeta(temp_meta); i.setItem(count+=1, (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify4")?on:off)); temp_meta.setDisplayName(ChatColor.YELLOW+"Damage Received");temp_meta_lore = new ArrayList();temp_meta_lore.add(ChatColor.ITALIC+"Get notified whenever you take damage");temp_meta_lore.add(ChatColor.ITALIC+" from enemies and other sources of damage.");temp_meta_lore.add(ChatColor.ITALIC+"");temp_meta_lore.add(ChatColor.ITALIC+""+ChatColor.GRAY+"Click to toggle this option on or off.");temp_meta.setLore(temp_meta_lore); temp=new ItemStack(Material.IRON_CHESTPLATE); - temp.setItemMeta(temp_meta); i.setItem(count+=4, temp);on.setItemMeta(temp_meta);off.setItemMeta(temp_meta); i.setItem(count+=1, (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify5")?on:off)); + temp.setItemMeta(temp_meta); i.setItem(count+=4, temp);on.setItemMeta(temp_meta);off.setItemMeta(temp_meta); i.setItem(count+=1, (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify5")?on:off)); temp_meta.setDisplayName(ChatColor.YELLOW+"Money Gained");temp_meta_lore = new ArrayList();temp_meta_lore.add(ChatColor.ITALIC+"Get notified of how much money you made");temp_meta_lore.add(ChatColor.ITALIC+" from your jobs in the past hour.");temp_meta_lore.add(ChatColor.ITALIC+"");temp_meta_lore.add(ChatColor.ITALIC+""+ChatColor.GRAY+"Click to toggle this option on or off.");temp_meta.setLore(temp_meta_lore); temp=new ItemStack(Material.GOLD_INGOT); - temp.setItemMeta(temp_meta);i.setItem(count+=3, temp);on.setItemMeta(temp_meta);off.setItemMeta(temp_meta); i.setItem(count+=1, (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify6")?on:off)); + temp.setItemMeta(temp_meta);i.setItem(count+=3, temp);on.setItemMeta(temp_meta);off.setItemMeta(temp_meta); i.setItem(count+=1, (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify6")?on:off)); p.openInventory(i); } else if (cmd.getName().equalsIgnoreCase("event")) { @@ -1191,7 +1191,7 @@ public String convertToItemName(String val) { double totalWithdraw = playerBankBalance - amount; double totalDeposit = amount + this.plugin.getAccountsConfig().getInt(target.getName() + ".money"); - this.plugin.getAccountsConfig().set(p.getName() + ".money", Double.valueOf(totalWithdraw)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".money", Double.valueOf(totalWithdraw)); this.plugin.getAccountsConfig().set(target.getName() + ".money", Double.valueOf(totalDeposit)); this.plugin.saveAccountsConfig(); @@ -1213,92 +1213,92 @@ public String convertToItemName(String val) { int statpoints = (this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p); if (readvalue==10) { if (statpoints>=6) { - this.plugin.getAccountsConfig().set(p.getName()+".stats.stat1", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")+6)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".stats.stat1", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1")+6)); this.plugin.saveAccountsConfig(); - p.sendMessage("You added 1 stat point to Health Regeneration! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")/6)+" of extra health regeneration! (Every time you regenerate health, you get "+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1"))+" extra hearts!) "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); + p.sendMessage("You added 1 stat point to Health Regeneration! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1")/6)+" of extra health regeneration! (Every time you regenerate health, you get "+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1"))+" extra hearts!) "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); } else { p.sendMessage(ChatColor.RED+"You do not have enough stat points to get that stat! (You need 6.)"); } } else if (readvalue==9) { if (statpoints>=5) { - this.plugin.getAccountsConfig().set(p.getName()+".stats.stat2", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat2")+5)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".stats.stat2", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat2")+5)); this.plugin.saveAccountsConfig(); - p.sendMessage("You added 1 stat point to block destroying speed! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(1, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat2")/5)+"% block destruction speed! "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); + p.sendMessage("You added 1 stat point to block destroying speed! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(1, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat2")/5)+"% block destruction speed! "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); } else { p.sendMessage(ChatColor.RED+"You do not have enough stat points to get that stat! (You need 5.)"); } } else if (readvalue==8) { if (statpoints>=4) { - this.plugin.getAccountsConfig().set(p.getName()+".stats.stat3", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat3")+4)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".stats.stat3", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat3")+4)); this.plugin.saveAccountsConfig(); - p.sendMessage("You added 1 stat point to block damage reduction! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat3")/4)+"% of damage taken reduced! "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); + p.sendMessage("You added 1 stat point to block damage reduction! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat3")/4)+"% of damage taken reduced! "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); } else { p.sendMessage(ChatColor.RED+"You do not have enough stat points to get that stat! (You need 4.)"); } } else if (readvalue==6) { if (statpoints>=3) { - this.plugin.getAccountsConfig().set(p.getName()+".stats.stat4", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")+3)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".stats.stat4", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat4")+3)); this.plugin.saveAccountsConfig(); - p.sendMessage("You added 1 stat point to temporary health! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")/4)+" extra temporary health. (Regenerates every 3 minutes.) "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); + p.sendMessage("You added 1 stat point to temporary health! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat4")/4)+" extra temporary health. (Regenerates every 3 minutes.) "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); } else { p.sendMessage(ChatColor.RED+"You do not have enough stat points to get that stat! (You need 3.)"); } } else if (readvalue==7) { if (statpoints>=4) { - this.plugin.getAccountsConfig().set(p.getName()+".stats.stat5", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")+4)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".stats.stat5", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")+4)); this.plugin.saveAccountsConfig(); - p.sendMessage("You added 1 stat point to armor penetration! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat5")/4)+" damage of armor penetration. Armor-Wearers will be more afraid of you! "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); + p.sendMessage("You added 1 stat point to armor penetration! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(4, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat5")/4)+" damage of armor penetration. Armor-Wearers will be more afraid of you! "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); } else { p.sendMessage(ChatColor.RED+"You do not have enough stat points to get that stat! (You need 4.)"); } } else if (readvalue==5) { if (statpoints>=3) { - this.plugin.getAccountsConfig().set(p.getName()+".stats.stat6", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat6")+3)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".stats.stat6", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat6")+3)); this.plugin.saveAccountsConfig(); - p.sendMessage("You added 1 stat point to fire resistance! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat6")/3)+" seconds of fire resistance when you catch on fire. (Resets when you stop burning) "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); + p.sendMessage("You added 1 stat point to fire resistance! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat6")/3)+" seconds of fire resistance when you catch on fire. (Resets when you stop burning) "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); } else { p.sendMessage(ChatColor.RED+"You do not have enough stat points to get that stat! (You need 3.)"); } } else if (readvalue==4) { if (statpoints>=2) { - this.plugin.getAccountsConfig().set(p.getName()+".stats.stat7", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")+2)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".stats.stat7", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7")+2)); this.plugin.saveAccountsConfig(); - p.sendMessage("You added 1 stat point to base damage! "+ChatColor.BLUE+"You now have +"+this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat7")/2)+" base damage. "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); + p.sendMessage("You added 1 stat point to base damage! "+ChatColor.BLUE+"You now have +"+this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7")/2)+" base damage. "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); } else { p.sendMessage(ChatColor.RED+"You do not have enough stat points to get that stat! (You need 2.)"); } } else if (readvalue==3) { if (statpoints>=2) { - this.plugin.getAccountsConfig().set(p.getName()+".stats.stat8", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat8")+2)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".stats.stat8", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat8")+2)); this.plugin.saveAccountsConfig(); - p.sendMessage("You added 1 stat point to base health! "+ChatColor.BLUE+"You now have +"+this.plugin.getStatBonus(7, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat8")/2)+" base health. "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); + p.sendMessage("You added 1 stat point to base health! "+ChatColor.BLUE+"You now have +"+this.plugin.getStatBonus(7, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat8")/2)+" base health. "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); } else { p.sendMessage(ChatColor.RED+"You do not have enough stat points to get that stat! (You need 2.)"); } } else if (readvalue==2) { if (statpoints>=1) { - this.plugin.getAccountsConfig().set(p.getName()+".stats.stat9", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9")+1)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".stats.stat9", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat9")+1)); this.plugin.saveAccountsConfig(); - p.sendMessage("You added 1 stat point to hunger decay! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9"))+"% less hunger decay "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); + p.sendMessage("You added 1 stat point to hunger decay! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat9"))+"% less hunger decay "+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); } else { p.sendMessage(ChatColor.RED+"You do not have enough stat points to get that stat! (You need 1.)"); } } else if (readvalue==1) { if (statpoints>=1) { - this.plugin.getAccountsConfig().set(p.getName()+".stats.stat10", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat10")+1)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".stats.stat10", Integer.valueOf(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat10")+1)); this.plugin.saveAccountsConfig(); - p.sendMessage("You added 1 stat point to water breathing! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat10"))+" seconds of water breathing. "+ChatColor.WHITE+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); + p.sendMessage("You added 1 stat point to water breathing! "+ChatColor.BLUE+"You now have "+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat10"))+" seconds of water breathing. "+ChatColor.WHITE+((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))+" stat point"+(((this.plugin.getJobTotalLvs(p)/5+1)-this.plugin.getStatPointTotal(p))==1?"":"s")+" left."); //Increase maximum air by 200 ticks. - p.setMaximumAir(300+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName() + ".stats.stat10"))*20); + p.setMaximumAir(300+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase() + ".stats.stat10"))*20); } else { p.sendMessage(ChatColor.RED+"You do not have enough stat points to get that stat! (You need 1.)"); } @@ -1389,7 +1389,7 @@ public String convertToItemName(String val) { double totalWithdraw = playerBankBalance - amount; double totalDeposit = amount + this.plugin.getAccountsConfig().getInt(target.getName() + ".money"); - this.plugin.getAccountsConfig().set(p.getName() + ".money", Double.valueOf(totalWithdraw)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".money", Double.valueOf(totalWithdraw)); this.plugin.getAccountsConfig().set(target.getName() + ".money", Double.valueOf(totalDeposit)); this.plugin.saveAccountsConfig(); @@ -1452,12 +1452,12 @@ public String convertToItemName(String val) { } else if (cmd.getName().equalsIgnoreCase("revive") && args[0].equalsIgnoreCase("me")) { DecimalFormat df = new DecimalFormat("#0.00"); - double deathX = this.plugin.getAccountsConfig().getDouble(p.getName() + ".deathpointX"); - double deathY = this.plugin.getAccountsConfig().getDouble(p.getName() + ".deathpointY"); - double deathZ = this.plugin.getAccountsConfig().getDouble(p.getName() + ".deathpointZ"); - String deathWorld = this.plugin.getAccountsConfig().getString(p.getName() + ".deathworld"); + double deathX = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".deathpointX"); + double deathY = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".deathpointY"); + double deathZ = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".deathpointZ"); + String deathWorld = this.plugin.getAccountsConfig().getString(p.getName().toLowerCase() + ".deathworld"); //p.sendMessage("Got 1."); - if (this.plugin.getAccountsConfig().getBoolean(p.getName() + ".revived")==false && this.plugin.SERVER_TICK_TIME-this.plugin.getAccountsConfig().getLong(p.getName() + ".revivetime")<12000) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase() + ".revived")==false && this.plugin.SERVER_TICK_TIME-this.plugin.getAccountsConfig().getLong(p.getName().toLowerCase() + ".revivetime")<12000) { double mincost = this.plugin.getConfig().getDouble("revive-cost-rate"); //p.sendMessage("Got 2."); if (p.getBedSpawnLocation()!=null) { @@ -1465,16 +1465,16 @@ public String convertToItemName(String val) { } else { mincost *= Math.abs(p.getWorld().getSpawnLocation().getX()-deathX)+Math.abs(p.getWorld().getSpawnLocation().getY()-deathY)+Math.abs(p.getWorld().getSpawnLocation().getZ()-deathZ); } - double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName() + ".money"); + double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".money"); double finalcost = (mincost*this.plugin.getConfig().getDouble("revive-cost-rate")) + (mymoney*this.plugin.getConfig().getDouble("revive-cost-tax")); if (this.plugin.PlayerinJob(p, "Explorer") && this.plugin.getJobLv("Explorer", p)>=20) { finalcost*=0.25; } //p.sendMessage("Got 3."); if (mymoney>=finalcost) { - this.plugin.getAccountsConfig().set(p.getName() + ".revived", Boolean.valueOf(true)); - this.plugin.getAccountsConfig().set(p.getName() + ".money", mymoney-finalcost); - this.plugin.getAccountsConfig().set(p.getName() + ".revivetime", Long.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".revived", Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".money", mymoney-finalcost); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".revivetime", Long.valueOf(0)); this.plugin.saveAccountsConfig(); //p.sendMessage("Got 4."); p.sendMessage("You spent $"+df.format(finalcost)+" to revive. New Bank Balance: $"+ChatColor.YELLOW+df.format(mymoney-finalcost)); @@ -1535,7 +1535,7 @@ public String convertToItemName(String val) { } else { mincost *= Math.abs(p.getWorld().getSpawnLocation().getX()-deathX)+Math.abs(p.getWorld().getSpawnLocation().getY()-deathY)+Math.abs(p.getWorld().getSpawnLocation().getZ()-deathZ); } - double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName() + ".money"); + double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".money"); double finalcost = (mincost*this.plugin.getConfig().getDouble("revive-cost-rate")) + (mymoney*this.plugin.getConfig().getDouble("revive-cost-tax")); if (this.plugin.PlayerinJob(p, "Explorer") && this.plugin.getJobLv("Explorer", p)>=20) { finalcost*=0.25; @@ -1545,7 +1545,7 @@ public String convertToItemName(String val) { } else if (cmd.getName().equalsIgnoreCase("tele") && (args[0].equalsIgnoreCase("to"))) { DecimalFormat df = new DecimalFormat("#0.00"); - if (p.getPlayerTime()-this.plugin.getAccountsConfig().getDouble(p.getName() + ".teletime")<400) { + if (p.getPlayerTime()-this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".teletime")<400) { if (args.length==1) { p.sendMessage("Usage: "+ChatColor.RED+"/tele to "+ChatColor.GREEN+" "+ChatColor.WHITE+" - Teleport to a player for a cost."); } else if (args.length==2) { @@ -1560,19 +1560,19 @@ public String convertToItemName(String val) { is_in_vehicle=true; vehicle = p.getVehicle(); } - if (target.getName() == this.plugin.getAccountsConfig().getString(p.getName() + ".teleplayer")) { + if (target.getName() == this.plugin.getAccountsConfig().getString(p.getName().toLowerCase() + ".teleplayer")) { //Determine distance of player to other player. double otherx = target.getLocation().getX(); double othery = target.getLocation().getY(); double otherz = target.getLocation().getZ(); - double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName() + ".money"); + double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".money"); double finalcost = Math.abs(p.getLocation().getX()-otherx)+Math.abs(p.getLocation().getY()-othery)+Math.abs(p.getLocation().getZ()-otherz); finalcost *= this.plugin.getConfig().getDouble("teleport-cost-rate"); //finalcost += mymoney*this.plugin.getConfig().getDouble("teleport-cost-tax"); if (mymoney>=finalcost) { //Allow teleport to occur. - this.plugin.getAccountsConfig().set(p.getName() + ".money", mymoney-finalcost); - this.plugin.getAccountsConfig().set(p.getName() + ".teletime", Double.valueOf(0.0d)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".money", mymoney-finalcost); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".teletime", Double.valueOf(0.0d)); this.plugin.saveAccountsConfig(); if (this.plugin.PlayerinJob(p, "Support")) { //Give exp for doing so. @@ -1611,15 +1611,15 @@ public String convertToItemName(String val) { double otherx = target.getLocation().getX(); double othery = target.getLocation().getY(); double otherz = target.getLocation().getZ(); - double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName() + ".money"); + double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".money"); double finalcost = Math.abs(p.getLocation().getX()-otherx)+Math.abs(p.getLocation().getY()-othery)+Math.abs(p.getLocation().getZ()-otherz); finalcost *= this.plugin.getConfig().getDouble("teleport-cost-rate"); //finalcost += mymoney*this.plugin.getConfig().getDouble("teleport-cost-tax"); if (mymoney>=finalcost) { //Allow teleport to occur. p.sendMessage("Teleporting to "+ChatColor.GREEN+target.getName()+ChatColor.WHITE+" costs $"+ChatColor.YELLOW+df.format(finalcost)+". Type the command again to teleport."); - this.plugin.getAccountsConfig().set(p.getName() + ".teletime", Double.valueOf(p.getPlayerTime())); - this.plugin.getAccountsConfig().set(p.getName() + ".teleplayer", String.valueOf(target.getName())); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".teletime", Double.valueOf(p.getPlayerTime())); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".teleplayer", String.valueOf(target.getName())); } else { p.sendMessage("Teleporting to "+ChatColor.GREEN+target.getName()+ChatColor.WHITE+" costs $"+ChatColor.YELLOW+df.format(finalcost)+". You do not have enough in the bank for that."); } @@ -1640,15 +1640,15 @@ public String convertToItemName(String val) { double otherx = target.getLocation().getX(); double othery = target.getLocation().getY(); double otherz = target.getLocation().getZ(); - double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName() + ".money"); + double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".money"); double finalcost = Math.abs(p.getLocation().getX()-otherx)+Math.abs(p.getLocation().getY()-othery)+Math.abs(p.getLocation().getZ()-otherz); finalcost *= this.plugin.getConfig().getDouble("teleport-cost-rate"); //finalcost += mymoney*this.plugin.getConfig().getDouble("teleport-cost-tax"); if (mymoney>=finalcost) { //Allow teleport to occur. p.sendMessage("Teleporting to "+ChatColor.GREEN+target.getName()+ChatColor.WHITE+" costs $"+ChatColor.YELLOW+df.format(finalcost)+". Type the command again to teleport."); - this.plugin.getAccountsConfig().set(p.getName() + ".teletime", Double.valueOf(p.getPlayerTime())); - this.plugin.getAccountsConfig().set(p.getName() + ".teleplayer", String.valueOf(target.getName())); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".teletime", Double.valueOf(p.getPlayerTime())); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".teleplayer", String.valueOf(target.getName())); } else { p.sendMessage("Teleporting to "+ChatColor.GREEN+target.getName()+ChatColor.WHITE+" costs $"+ChatColor.YELLOW+df.format(finalcost)+". You do not have enough in the bank for that."); } @@ -1706,7 +1706,7 @@ public String convertToItemName(String val) { } } if (this.plugin.PlayerinJob(p, args[1])) { - Jobsinfo[i].sendOutput(p,this.plugin.getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")); + Jobsinfo[i].sendOutput(p,this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv")); } else { Jobsinfo[i].sendOutput(p); } @@ -1779,12 +1779,12 @@ public String convertToItemName(String val) { String[] joblist=this.plugin.getJobs(p); for (int i=0;i=5?"+Lv5 Buff":"")+ChatColor.GREEN+(mylv>=10?" +Lv10 Buff":"")+ChatColor.GOLD+(mylv>=20?" +Lv20 Buff":"")); + p.sendMessage("Lv"+mylv+" "+this.plugin.getJobColor(joblist[i])+joblist[i]+ChatColor.WHITE+": "+Math.round(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(i+1)+"exp"))+"xp "+ChatColor.BLUE+(mylv>=5?"+Lv5 Buff":"")+ChatColor.GREEN+(mylv>=10?" +Lv10 Buff":"")+ChatColor.GOLD+(mylv>=20?" +Lv20 Buff":"")); } else { - p.sendMessage("Lv"+mylv+" "+this.plugin.getJobColor(joblist[i])+joblist[i]+ChatColor.WHITE+": "+Math.round(this.plugin.getAccountsConfig().getInt(p.getName()+".jobs.job"+(i+1)+"exp"))+"/"+Math.round(this.plugin.getJobExp(joblist[i], this.plugin.getAccountsConfig().getInt(p.getName()+".jobs.job"+(i+1)+"lv")))+"xp "+ChatColor.BLUE+(mylv>=5?"+Lv5 Buff":"")+ChatColor.GREEN+(mylv>=10?" +Lv10 Buff":"")+ChatColor.GOLD+(mylv>=20?" +Lv20 Buff":"")); + p.sendMessage("Lv"+mylv+" "+this.plugin.getJobColor(joblist[i])+joblist[i]+ChatColor.WHITE+": "+Math.round(this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(i+1)+"exp"))+"/"+Math.round(this.plugin.getJobExp(joblist[i], this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(i+1)+"lv")))+"xp "+ChatColor.BLUE+(mylv>=5?"+Lv5 Buff":"")+ChatColor.GREEN+(mylv>=10?" +Lv10 Buff":"")+ChatColor.GOLD+(mylv>=20?" +Lv20 Buff":"")); } if (joblist[i].equalsIgnoreCase("Explorer") && this.plugin.getJobLv(joblist[i], p)>=10) { @@ -1848,6 +1848,9 @@ public String convertToItemName(String val) { p.sendMessage(q.getName()+"'s jobs:"); String[] joblist=this.plugin.getJobs(q.getName()); for (int i=0;i Date: Thu, 21 Nov 2013 02:59:07 -0700 Subject: [PATCH 06/15] Added '/jobs members' function. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 81 ++++++++++++------- .../src/me/kaZep/Base/PlayerListener.java | 12 +-- .../me/kaZep/Commands/commandBankEconomy.java | 65 +++++++++++++-- 3 files changed, 114 insertions(+), 44 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index 654c15b..09124ca 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -3624,13 +3624,13 @@ public void payDay(int time) public int getPlayerJobCount(Player p) { int count=0; - if (getAccountsConfig().getString(p.getName()+".jobs.job1").compareTo("None")!=0) { + if (getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1").compareTo("None")!=0) { count++; } - if (getAccountsConfig().getString(p.getName()+".jobs.job2").compareTo("None")!=0) { + if (getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2").compareTo("None")!=0) { count++; } - if (getAccountsConfig().getString(p.getName()+".jobs.job3").compareTo("None")!=0) { + if (getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3").compareTo("None")!=0) { count++; } return count; @@ -3691,6 +3691,13 @@ public void payDay(int time) if (getConfig().getInt("jobs."+ValidJobs[matchedjob])>=getConfig().getInt("jobs.MAX_JOBS")) { p.sendMessage(ChatColor.GOLD+"Sorry, there are already "+getConfig().getInt("jobs.MAX_JOBS")+" people in this job!"); return false; + } + if (getConfig().getInt("jobs."+ValidJobs[matchedjob])==0) { + //Simply set the string. + getConfig().set("jobs."+ValidJobs[matchedjob]+"_members",String.valueOf(p.getName().toLowerCase())); + } else { + //Append to list. + getConfig().set("jobs."+ValidJobs[matchedjob]+"_members",String.valueOf(getConfig().getString("jobs."+ValidJobs[matchedjob]+"_members")+", "+p.getName().toLowerCase())); } Bukkit.getLogger().info("Well, they are allowed to join this job."); //Add 1 to main config. @@ -3701,7 +3708,7 @@ public void payDay(int time) //Check for the slot we have "None" job in first. int openslot=0; for (int i=0;i<3;i++) { - if (getAccountsConfig().getString(p.getName()+".jobs.job"+(i+1)).equalsIgnoreCase("None")) { + if (getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job"+(i+1)).equalsIgnoreCase("None")) { openslot=i; Bukkit.getLogger().info("Found a None job slot."); break; @@ -3728,7 +3735,7 @@ public void payDay(int time) } public String[] getJobs(Player p) { - String[] string= {getAccountsConfig().getString(p.getName()+".jobs.job1"),getAccountsConfig().getString(p.getName()+".jobs.job2"),getAccountsConfig().getString(p.getName()+".jobs.job3")}; + String[] string= {getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"),getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"),getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3")}; return string; } @@ -3806,18 +3813,18 @@ public void payDay(int time) } } JobsDataInfo info = Jobsinfo[getJobSlot(job)]; - economy.depositPlayer(p.getName(), amount*(1d+(info.moneymult*getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")))); - getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp", Double.valueOf(getAccountsConfig().getDouble(p.getName()+".jobs.job"+(slot+1)+"exp")+exp)); - if (getAccountsConfig().getDouble(p.getName()+".jobs.job"+(slot+1)+"exp")<0) { + economy.depositPlayer(p.getName(), amount*(1d+(info.moneymult*getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv")))); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp", Double.valueOf(getAccountsConfig().getDouble(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp")+exp)); + if (getAccountsConfig().getDouble(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp")<0) { //It can't be negative. getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp", Double.valueOf(0.0)); } //Check for lv up. - if (getJobLv(job,p)<40 && getJobExp(job,getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv"))<=getAccountsConfig().getDouble(p.getName()+".jobs.job"+(slot+1)+"exp")) { + if (getJobLv(job,p)<40 && getJobExp(job,getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv"))<=getAccountsConfig().getDouble(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp")) { //Level up! Level up! YEAH! - getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp", Double.valueOf(getAccountsConfig().getDouble(p.getName()+".jobs.job"+(slot+1)+"exp")-getJobExp(job,getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")))); - getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv", Integer.valueOf(getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")+1)); - Bukkit.broadcastMessage(p.getName()+" is now a Level "+getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")+" "+getJobColor(job)+job+ChatColor.WHITE+"."); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp", Double.valueOf(getAccountsConfig().getDouble(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp")-getJobExp(job,getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv")))); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv", Integer.valueOf(getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv")+1)); + Bukkit.broadcastMessage(p.getName()+" is now a Level "+getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv")+" "+getJobColor(job)+job+ChatColor.WHITE+"."); if (getJobTotalLvs(p)%5==0) { Bukkit.broadcastMessage(ChatColor.GREEN+p.getName()+" has reached Level "+getJobTotalLvs(p)+"!"); if ((((getJobTotalLvs(p)/5+1)-getStatPointTotal(p)))>0) { @@ -3852,8 +3859,8 @@ public void payDay(int time) if (slot!=-1) { JobsDataInfo info = Jobsinfo[getJobSlot(job)]; if (getJobLv(job,p)<40) { - getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv", Integer.valueOf(getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")+1)); - Bukkit.broadcastMessage(p.getName()+" is now a Level "+getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv")+" "+getJobColor(job)+job+ChatColor.WHITE+"."); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv", Integer.valueOf(getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv")+1)); + Bukkit.broadcastMessage(p.getName()+" is now a Level "+getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv")+" "+getJobColor(job)+job+ChatColor.WHITE+"."); if (getJobTotalLvs(p)%5==0) { Bukkit.broadcastMessage(ChatColor.GREEN+p.getName()+" has reached Level "+getJobTotalLvs(p)+"!"); if ((((getJobTotalLvs(p)/5+1)-getStatPointTotal(p)))>0) { @@ -3894,7 +3901,7 @@ public void payDay(int time) } } JobsDataInfo info = Jobsinfo[getJobSlot(job)]; - economy.depositPlayer(p.getName(), amount*(1d+(info.moneymult*getAccountsConfig().getInt(p.getName()+".jobs.job"+slot+"lv")))); + economy.depositPlayer(p.getName(), amount*(1d+(info.moneymult*getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+slot+"lv")))); } public ChatColor getJobColor(String job) { @@ -3940,13 +3947,13 @@ public void payDay(int time) int slot=-1; //Check which slot contains our job. for (int i=0;i<3;i++) { - if (getAccountsConfig().getString(p.getName()+".jobs.job"+(i+1)).equalsIgnoreCase(job)) { + if (getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job"+(i+1)).equalsIgnoreCase(job)) { slot=i; break; } } if (slot!=-1) { - return getAccountsConfig().getDouble(p.getName()+".jobs.job"+(slot+1)+"exp"); + return getAccountsConfig().getDouble(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp"); } else { return 0; } @@ -4215,13 +4222,13 @@ public void payDay(int time) int slot=-1; //Check which slot contains our job. for (int i=0;i<3;i++) { - if (getAccountsConfig().getString(p.getName()+".jobs.job"+(i+1)).equalsIgnoreCase(job)) { + if (getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job"+(i+1)).equalsIgnoreCase(job)) { slot=i; break; } } if (slot!=-1) { - return getAccountsConfig().getInt(p.getName()+".jobs.job"+(slot+1)+"lv"); + return getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv"); } else { return 0; } @@ -4233,7 +4240,7 @@ public void payDay(int time) int totallv=0; //Check which slot contains our job. for (int i=0;i<3;i++) { - totallv+=getAccountsConfig().getInt(p.getName()+".jobs.job"+(i+1)+"lv"); + totallv+=getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(i+1)+"lv"); } return totallv; } @@ -4241,7 +4248,7 @@ public void payDay(int time) public int getStatPointTotal(Player p) { int total=0; for (int i=0;i<10;i++) { - total+=getAccountsConfig().getInt(p.getName()+".stats.stat"+(i+1)); + total+=getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat"+(i+1)); } return total; } @@ -4624,43 +4631,55 @@ public void payDay(int time) //Get their jobs. String[] jobs = getJobs(p); //We can remove them from this job. - if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName()+".jobs.job1"))) { + if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))) { + //Remove from job members list. + getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+"_members").replace(", "+p.getName().toLowerCase(), "")); + /*Try again in case it's the only entry.*/ + getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+"_members").replace(p.getName().toLowerCase(), "")); //Remove 1 from main config. - getConfig().set("jobs."+getAccountsConfig().getString(p.getName()+".jobs.job1"), Integer.valueOf(getConfig().getInt("jobs."+getAccountsConfig().getString(p.getName()+".jobs.job1"))-1)); + getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"), Integer.valueOf(getConfig().getInt("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))-1)); saveConfig(); //Remove from job 1. - Bukkit.broadcastMessage(p.getName()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName()+".jobs.job1"))+getAccountsConfig().getString(p.getName()+".jobs.job1")+ChatColor.WHITE+" job!"); + Bukkit.broadcastMessage(p.getName()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1")+ChatColor.WHITE+" job!"); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1", String.valueOf("None")); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1lv", Integer.valueOf(0)); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1exp", Double.valueOf(0)); saveAccountsConfig(); return true; } else - if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName()+".jobs.job2"))) { + if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))) { + //Remove from job members list. + getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+"_members").replace(", "+p.getName().toLowerCase(), "")); + /*Try again in case it's the only entry.*/ + getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+"_members").replace(p.getName().toLowerCase(), "")); //Remove 1 from main config. - getConfig().set("jobs."+getAccountsConfig().getString(p.getName()+".jobs.job2"), Integer.valueOf(getConfig().getInt("jobs."+getAccountsConfig().getString(p.getName()+".jobs.job2"))-1)); + getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"), Integer.valueOf(getConfig().getInt("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))-1)); saveConfig(); //Remove from job 2. - Bukkit.broadcastMessage(p.getName()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName()+".jobs.job2"))+getAccountsConfig().getString(p.getName()+".jobs.job2")+ChatColor.WHITE+" job!"); + Bukkit.broadcastMessage(p.getName()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2")+ChatColor.WHITE+" job!"); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2", String.valueOf("None")); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2lv", Integer.valueOf(0)); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2exp", Double.valueOf(0)); saveAccountsConfig(); return true; } else - if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName()+".jobs.job3"))) { + if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))) { + //Remove from job members list. + getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+"_members").replace(", "+p.getName().toLowerCase(), "")); + /*Try again in case it's the only entry.*/ + getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+"_members").replace(p.getName().toLowerCase(), "")); //Remove 1 from main config. - getConfig().set("jobs."+getAccountsConfig().getString(p.getName()+".jobs.job3"), Integer.valueOf(getConfig().getInt("jobs."+getAccountsConfig().getString(p.getName()+".jobs.job3"))-1)); + getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"), Integer.valueOf(getConfig().getInt("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))-1)); saveConfig(); //Remove from job 3. - Bukkit.broadcastMessage(p.getName()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName()+".jobs.job3"))+getAccountsConfig().getString(p.getName()+".jobs.job3")+ChatColor.WHITE+" job!"); + Bukkit.broadcastMessage(p.getName()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3")+ChatColor.WHITE+" job!"); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3", String.valueOf("None")); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3lv", Integer.valueOf(0)); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3exp", Double.valueOf(0)); saveAccountsConfig(); return true; } - Bukkit.broadcastMessage(ChatColor.RED+"[SEVERE]An internal error occurred, triggered by "+p.getName()+"."); + Bukkit.broadcastMessage(ChatColor.RED+"[SEVERE]An internal error occurred, triggered by "+p.getName().toLowerCase()+"."); return false; } diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index 46c0adb..a96e268 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -9137,12 +9137,12 @@ implements Listener if (e.getInventory().getTitle().equalsIgnoreCase("Notification Options")) { //We have to save the notification settings for this player. FileConfiguration savefile = this.plugin.getAccountsConfig(); - savefile.set(p.getName()+".settings.notify1", Boolean.valueOf(e.getInventory().getItem(2).getType()==Material.REDSTONE_TORCH_ON)); - savefile.set(p.getName()+".settings.notify2", Boolean.valueOf(e.getInventory().getItem(6).getType()==Material.REDSTONE_TORCH_ON)); - savefile.set(p.getName()+".settings.notify3", Boolean.valueOf(e.getInventory().getItem(11).getType()==Material.REDSTONE_TORCH_ON)); - savefile.set(p.getName()+".settings.notify4", Boolean.valueOf(e.getInventory().getItem(15).getType()==Material.REDSTONE_TORCH_ON)); - savefile.set(p.getName()+".settings.notify5", Boolean.valueOf(e.getInventory().getItem(20).getType()==Material.REDSTONE_TORCH_ON)); - savefile.set(p.getName()+".settings.notify6", Boolean.valueOf(e.getInventory().getItem(24).getType()==Material.REDSTONE_TORCH_ON)); + savefile.set(p.getName().toLowerCase()+".settings.notify1", Boolean.valueOf(e.getInventory().getItem(2).getType()==Material.REDSTONE_TORCH_ON)); + savefile.set(p.getName().toLowerCase()+".settings.notify2", Boolean.valueOf(e.getInventory().getItem(6).getType()==Material.REDSTONE_TORCH_ON)); + savefile.set(p.getName().toLowerCase()+".settings.notify3", Boolean.valueOf(e.getInventory().getItem(11).getType()==Material.REDSTONE_TORCH_ON)); + savefile.set(p.getName().toLowerCase()+".settings.notify4", Boolean.valueOf(e.getInventory().getItem(15).getType()==Material.REDSTONE_TORCH_ON)); + savefile.set(p.getName().toLowerCase()+".settings.notify5", Boolean.valueOf(e.getInventory().getItem(20).getType()==Material.REDSTONE_TORCH_ON)); + savefile.set(p.getName().toLowerCase()+".settings.notify6", Boolean.valueOf(e.getInventory().getItem(24).getType()==Material.REDSTONE_TORCH_ON)); this.plugin.saveAccountsConfig(); } if (e.getInventory().getTitle().equalsIgnoreCase("Repair and Enchant")) { diff --git a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java index c142cf0..b9fa5d9 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java +++ b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java @@ -1665,20 +1665,23 @@ public String convertToItemName(String val) { if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("join")) { p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs join [JobName]"+ChatColor.WHITE+" - Join a job. Type /jobs to see the jobs."); } else + if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("members")) { + p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs members [JobName]"+ChatColor.WHITE+" - Check all members in a job."); + } else if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("leave")) { p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs leave [JobName]"+ChatColor.WHITE+" - Leave a job. Type /jobs stats to see your jobs."); } else - if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("buffs")) { - p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs buffs [JobName]"+ChatColor.WHITE+" - Get buffs information about a job. Type /jobs to see the jobs."); - } else + if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("buffs")) { + p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs buffs [JobName]"+ChatColor.WHITE+" - Get buffs information about a job. Type /jobs to see the jobs."); + } else if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("ultimate")) { //Attempt to join the job. this.plugin.setUltimate(p,args[1]); } else - if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("boost")) { - //Attempt to level up the job. - this.plugin.levelUpJob(p,args[1]); - } else + if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("boost")) { + //Attempt to level up the job. + this.plugin.levelUpJob(p,args[1]); + } else if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("join")) { //Attempt to join the job. this.plugin.joinJob(p,args[1]); @@ -1687,6 +1690,54 @@ public String convertToItemName(String val) { //Attempt to join the job. this.plugin.leaveJob(p,args[1]); } else + if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("members")) { + JobsDataInfo[] Jobsinfo = {this.plugin.Woodcutter_job,this.plugin.Miner_job,this.plugin.Builder_job,this.plugin.Digger_job,this.plugin.Farmer_job,this.plugin.Hunter_job,this.plugin.Fisherman_job,this.plugin.Weaponsmith_job,this.plugin.Blacksmith_job,this.plugin.Cook_job,this.plugin.Brewer_job,this.plugin.Enchanter_job,this.plugin.Breeder_job,this.plugin.Explorer_job,this.plugin.Support_job}; + boolean found=false; + String job = ""; + ChatColor job_color = null; + for (int i=0;i sorted_players = new ArrayList(); + for (int i=0;i sorted_list_players = new ArrayList(); + int lowest_slot = -1; + while (sorted_players.size()>0) { + for (int i=0;i Date: Thu, 21 Nov 2013 03:39:18 -0700 Subject: [PATCH 07/15] Finished all job descriptions. Farmer is not a valid job anymore. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 77 ++++++++++++++----- .../src/me/kaZep/Base/PlayerListener.java | 2 +- .../me/kaZep/Commands/commandBankEconomy.java | 1 - 3 files changed, 60 insertions(+), 20 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index 200cb8a..cad2969 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -173,7 +173,7 @@ public class Main extends JavaPlugin long GLOBAL_villagetimer=0,GLOBAL_templetimer=0,GLOBAL_cavetimer=0,GLOBAL_undergroundtimer=0,GLOBAL_nethertimer=0; - public String[] ValidJobs = {"Woodcutter","Miner","Builder","Digger","Farmer","Hunter","Fisherman","Weaponsmith","Blacksmith","Cook","Brewer","Enchanter","Breeder","Explorer","Support"}; + public String[] ValidJobs = {"Woodcutter","Miner","Builder","Digger","Hunter","Fisherman","Weaponsmith","Blacksmith","Cook","Brewer","Enchanter","Breeder","Explorer","Support"}; public ChatColor[] JobColors = {ChatColor.GREEN,ChatColor.GRAY,ChatColor.WHITE,ChatColor.GOLD,ChatColor.BLUE,ChatColor.RED,ChatColor.AQUA,ChatColor.DARK_PURPLE,ChatColor.GOLD, ChatColor.YELLOW,ChatColor.LIGHT_PURPLE,ChatColor.DARK_BLUE,ChatColor.DARK_GREEN,ChatColor.WHITE,ChatColor.DARK_RED}; @@ -545,7 +545,8 @@ public class Main extends JavaPlugin Miner_job.setBuffData("Automatically mines ores next to each other when one ore is mined.", "Gain Quadruple the experience from mining ores. Pickaxes gain Efficiency III.", "Mining out ores will mine them out 3x3 blocks at a time when using diamond pickaxes. Pickaxes used gain Efficiency VI and Unbreaking IV.", - "" + "When holding a pickaxe, mobs that hit you only deal 25% damage.", + "Mining multiple ores will stack a haste buff up to Haste V for 10 seconds.", "Mining ores will grant x2 the normal amount of minerals. Fortune is twice as effective, granting a possible total of x4 the normal minerals from ores."); Builder_job.setJobName("Builder"); @@ -586,7 +587,9 @@ public class Main extends JavaPlugin Builder_job.addData("BRICK", 0.075, 11, 0); Builder_job.setBuffData("Builders gain access to the 'line' tool. Typing /line will make building in straight lines easier.", "Builders gain access to the 'rectangle' tool. Typing /rectangle will make building in rectangles easier.", - "When crafting irreversible Builder blocks, 75% of the blocks used for crafting will be restored to your inventory. When cooking Builder blocks, the block results will be doubled.", + "When crafting irreversible Builder blocks, 75% of the blocks used for crafting will be restored to your inventory. When cooking Builder blocks, the block results will be doubled.", + "Gain experience orbs (equivalent to the job XP you get) as you build.", + "Building will stack a jump boost buff up to Jump Boost seconds.", "Builders gain the ability to fly when building. They immediately lose the ability to fly if they stop building for a moment, destroy a block, or enter combat. Every 100 Builder XP gained gives the Builder 5 Glowstone blocks and a stack of torches."); Digger_job.setJobName("Digger"); @@ -610,9 +613,12 @@ public class Main extends JavaPlugin Digger_job.addData("HARDENED CLAY", 0.04, 8, 2); Digger_job.setBuffData("Ability to discover artifacts when digging up blocks.", "Shovels gain Unbreaking V and Efficiency IV.", - "Destroying the bottom row of Sand or Gravel with a Wooden Shovel will destroy the whole stack instantly. Artifact discovery rate increased by 25%.", + "Destroying the bottom row of Sand or Gravel with a Wooden Shovel will destroy the whole stack instantly. Artifact discovery rate increased by 25%.", + "Shovels you use will not break.", + "Diggers can craft a Battle Shovel (Use a Lapis block with sticks to build it). Any blocks you destroy with it will shoot 10 arrows rapidly from the destroyed block's position in the direction you are facing.", "Artifacts will be able to be identified immediately with no identify tomes."); - + + /* Farmer_job.setJobName("Farmer"); Farmer_job.setJobDescription("A farmer's job is to sustain and continue to replenish what nature provides to turn them into sustainable food items and other useful things."); Farmer_job.setAction(0, "BREAK"); @@ -637,7 +643,8 @@ public class Main extends JavaPlugin "Killing skeletons yields triple the amount of bones.", "Nearby crops grow 30% faster.", "Nearby crops grow 200% faster. Bonemeal grows things instantly. (Just like before the bonemeal nerf) in one use."); - + */ + Hunter_job.setJobName("Hunter"); Hunter_job.setJobDescription("A hunter's job is to take care of the threats at night and protect others who may be in danger. Hunters that kill innocent creatures will be punished, thus they must resort to other methods for food."); Hunter_job.setAction(0, "HURT"); @@ -648,8 +655,15 @@ public class Main extends JavaPlugin Hunter_job.addData("ZOMBIE", 0.01, 2, 0); Hunter_job.addData("SPIDER", 0.01, 2, 0); Hunter_job.addData("SKELETON", 0.015, 3, 0); + Hunter_job.addData("CHARGE ZOMBIE", 0.02, 4, 0); + Hunter_job.addData("ZOMBIE NINJA", 0.025, 5, 0); + Hunter_job.addData("SNIPER", 0.025, 5, 0); Hunter_job.addData("CREEPER", 0.025, 5, 0); + Hunter_job.addData("VENOMOUS SPIDER", 0.025, 5, 0); + Hunter_job.addData("SNARING SPIDER", 0.025, 5, 0); Hunter_job.addData("PIG ZOMBIE", 0.03, 6, 0); + Hunter_job.addData("EXPLOSIVE CREEPER", 0.035, 7, 0); + Hunter_job.addData("DESTRUCTIVE CREEPER", 0.035, 7, 0); Hunter_job.addData("GHAST", 0.04, 8, 0); Hunter_job.addData("ENDERMAN", 0.04, 8, 0); Hunter_job.addData("BLAZE", 0.05, 10, 0); @@ -667,16 +681,25 @@ public class Main extends JavaPlugin Hunter_job.addData("SPIDER", 0.02, 4, 1); Hunter_job.addData("ZOMBIE", 0.025, 5, 1); Hunter_job.addData("SKELETON", 0.035, 7, 1); + Hunter_job.addData("CHARGE ZOMBIE", 0.05, 10, 1); + Hunter_job.addData("ZOMBIE NINJA", 0.05, 10, 1); + Hunter_job.addData("SNIPER", 0.05, 10, 1); + Hunter_job.addData("VENOMOUS SPIDER", 0.05, 10, 1); + Hunter_job.addData("SNARING SPIDER", 0.05, 10, 1); Hunter_job.addData("CREEPER", 0.05, 10, 1); Hunter_job.addData("PIG ZOMBIE", 0.08, 16, 1); + Hunter_job.addData("EXPLOSIVE CREEPER", 0.08, 16, 1); + Hunter_job.addData("DESTRUCTIVE CREEPER", 0.08, 16, 1); Hunter_job.addData("GHAST", 0.10, 12, 1); Hunter_job.addData("ENDERMAN", 0.125, 16, 1); Hunter_job.addData("BLAZE", 0.15, 20, 1); Hunter_job.addData("ENDER DRAGON", 100.00, 3000, 1); Hunter_job.addData("WITHER", 550.00, 7800, 1); - Hunter_job.setBuffData("Damage dealt increased by 2.", - "Sneaking gives you invisibility.", - "Swords gain Fire Aspect II. Movement speed increased by 20%.", + Hunter_job.setBuffData("Damage dealt increased by 4.", + "Sneaking gives you invisibility. Anything targeting you loses aggro.", + "Swords inflict Poison II on mobs. Movement speed increased by 20%.", + "Each time you get hit, the next hit has a 10% stacking chance of blocking for 10 seconds.", + "Attacks deal an additional 10 armor penetration damage.", "Damage dealt increased by 4, damage taken decreased by 30%, at night you are invisible. Health increased by 20."); Fisherman_job.setJobName("Fisherman"); @@ -688,7 +711,9 @@ public class Main extends JavaPlugin Fisherman_job.addData("COOKED FISH", 0.125, 2, 1); Fisherman_job.setBuffData("Fishing rods have double the durability.", "Fish give double the exp orbs, two fish can be caught at the same time (25% chance)", - "Up to four fish can be caught at one time. Sometimes fish will be automatically cooked. (Will gain exp and money for the cooked ones as well)", + "Up to four fish can be caught at one time. Sometimes fish will be automatically cooked. (Will gain exp and money for the cooked ones as well)", + "Fish Catching Rate increased by 30%. You will always catch at least two fish (And gain the amount of money and xp earned for them). Fishing rods last 4x as long.", + "Each successful catch will increase the fishing catch rate multiplicatively by 5%. Missing a fish will reset this rate.", "Fishing rods do 10 damage when hooking an enemy mob. Fishing rods do not run out of durability. Chance of catching fish increased by 50%. Holding a fishing rod gives the ability to fly for 5 seconds at a time."); Weaponsmith_job.setJobName("Weaponsmith"); @@ -704,7 +729,9 @@ public class Main extends JavaPlugin Weaponsmith_job.addData("DIAMOND SWORD", 3.60, 280, 0); Weaponsmith_job.setBuffData("Crafting Weaponsmith items have a 10% chance of preserving materials used.", "Weapons crafted gain a free level 5 enchantment.", - "Crafting Weaponsmith items have a 25% chance of preserving materials used.", + "Crafting Weaponsmith items have a 25% chance of preserving materials used.", + "All weaponsmith items crafted gain +X Damage bonus enchantments. (Increases by weaponsmithing level)", + "All weaponsmith items have your name engraved on your weapons, and your soul implanted in them...", "Weapons crafted gain free level 25 enchantments. Materials used in crafting have a 50% chance of being preserved. Weapons crafted have a 30% chance of stacking (duplicated), and 30% chance for every extra addition to the weapon stack."); Blacksmith_job.setJobName("Blacksmith"); @@ -759,16 +786,18 @@ public class Main extends JavaPlugin Blacksmith_job.addData("DIAMOND CHESTPLATE", 1.50*10, 750*10, 0); Blacksmith_job.setBuffData("All crafted items are buffed with a Lv5 enchantment.", "All crafted items are buffed with a Lv10 enchantment.", - "Crafting Blacksmith items have a 30% chance of preserving materials used.", + "Crafting Blacksmith items have a 30% chance of preserving materials used.", + "All blacksmith items crafted gain +4 Health bonus enchantments. (Increases by +4 per blacksmithing level after 30.)", + "Blacksmiths gain the ability to craft armor they find back into ingots / materials, based on the remaining durability. (About 50% lossy)", "All crafted Blacksmith items stack between 2 and 5 of the same item, effectively multiplying the amount you craft. Items are buffed with a Lv20 enchantment and have a 50% chance to be enchanted with a level 30 enchantment."); Cook_job.setJobName("Cook"); Cook_job.setJobDescription("A cook's job is to provide food for others and themselves through cooking and crafting together ingredients."); Cook_job.setAction(0, "CRAFT"); Cook_job.setAction(1, "SMELT"); - Cook_job.setExp(250, 200, 40, 1.04); + Cook_job.setExp(400, 250, 40, 1.04); Cook_job.addData("BREAD", 0.003125, 1.25, 0); - Cook_job.addData("COOKIE", 0.016875, 1.50, 0); + Cook_job.addData("COOKIE", 0.016875, 0.45, 0); Cook_job.addData("MUSHROOM SOUP", 0.009375, 3.75, 0); Cook_job.addData("PUMPKIN PIE", 0.0375, 15, 0); Cook_job.addData("GOLDEN CARROT", 0.0875, 35, 0); @@ -782,6 +811,8 @@ public class Main extends JavaPlugin Cook_job.setBuffData("Double the amount of cooking time with one fuel item in the furnace.", "Results of crafting food is double the normal amount.", "Results of cooking food is double the normal amount.", + "Increases buff strength of all food items by 1.", + "Increases bonus effect duration of all food items by x4.", "Cooking and crafting food gives 4x the normal amount. Cooking and crafting food gives exp orbs and has a chance of giving Golden Apples and Golden Carrots sometimes. (15% per crafted/cooked item.)"); Brewer_job.setJobName("Brewer"); @@ -803,6 +834,8 @@ public class Main extends JavaPlugin Brewer_job.setBuffData("Decrease brewing wait time by half.", "Potions obtained are doubled. (Stacks of two)", "Potions created by you have double the duration.", + "Gain the ability to brew Night Vision and Invisibility potions.", + "Potions created by you stack to 8.", "Potions created by you last for 30 minutes. Potions automatically stack up together in your inventory when grabbed. Splash potions provide full power regardless of how far from the splash the affected entities are. Potions obtained are quadrupled. Brewing wait time decreased by 4x the normal time."); Enchanter_job.setJobName("Enchanter"); @@ -836,7 +869,9 @@ public class Main extends JavaPlugin Enchanter_job.addData("SILK TOUCH", 0.50, 40, 0); Enchanter_job.setBuffData("Whenever you gain experience, the amount you gain is doubled.", "Enchantments consume 25% less of your exp. (Lv20 enchantment costs 15 levels) Enchantments gain an extra stat enchantment bonus.", - "Enchantments are more potent. (Gain extra enchantments, bonus enchantments, and higher levels than normal.)", + "Enchantments are more potent. (Gain extra enchantments, bonus enchantments, and higher levels than normal.)", + "Gain the ability to choose one type of enchantment/bonus enchantment to add to an item when enchanting.", + "Gain the ability to enchant legendary-tier items. (Has an unusually higher level of enchantment than normal)", "Enchanters receive quadruple the amount of experience from orbs. Enchanting consumes 75% less of your exp. (Lv20 enchantment costs 5 levels) Enchantments are at least level 5 or higher. Extra bonus enchantments are very likely, and super enchantments are added as well."); Breeder_job.setJobName("Breeder"); @@ -860,6 +895,8 @@ public class Main extends JavaPlugin Breeder_job.setBuffData("Nearby Sheep and Chickens reproduce wool and eggs at double the rate.", "Breeding animals may yield twins and triplets half the time.", "Feeding animals will give you the item back half the time.", + "Animals will become enticed by you whenever you are nearby, requiring no food to breed animals. Animals will be able to breed again at double the normal rate.", + "Wolves and horses you tame gain +150 Health, making these companions much more useful in fighting, and surviving longer. Feeding them one time will heal them completely. For each wolf and horse near you, you gain +2 Health.", "Breeding animals will give between 2-5 of that animal, all of them will be grown up. Sheep will always regrow their wool instantly after shearing them, shears do not break. Chickens will give 64 eggs if you kill one. Cows and Pigs drop a stack of meat when killing them. Feeding pigs will give them a saddle."); Explorer_job.setJobName("Explorer"); @@ -875,7 +912,9 @@ public class Main extends JavaPlugin Explorer_job.addData("Creating maps and uncovering new areas on them (Underground rewards more!): ", 0.01, 8, 0); Explorer_job.setBuffData("Movement speed increased by 20%.", "Players lose no exp on death. When taking fatal damage, you will regain all health. This effect can be used once every hour.", - "Don't lose any money on death. Reviving costs 75% less.", + "Don't lose any money on death. Reviving costs 75% less.", + "When crafting maps, you will also gain 32 paper to zoom the map out completely. (Or use to create more maps.)", + "Increased movement speed to 40%.", "When holding a pickaxe, it will detect ores around you based on what the pickaxe is made of."); Support_job.setJobName("Support"); @@ -913,8 +952,10 @@ public class Main extends JavaPlugin Support_job.addData("-Dousing or using a fire resistance potion on someone burning.", 4.80, 240, 0); Support_job.setBuffData("Everyone around you gains +2 Armor.", "Everyone around you gains +10 more Maximum Health.", - "Everyone around you gains +4 Armor. Everyone's hunger degrades at half the speed. Players with 8 HP or less take half the damage from hits.", - "Everyone around you gains Regeneration. You gain +10 Armor. Everyone around you gains +20 more Maximum Health. You gain +50 more maximum health. Everyone around you including yourself moves 20% faster."); + "Everyone around you gains +4 Armor. Everyone's hunger degrades at half the speed. Players with 8 HP or less take half the damage from hits.", + "When a nearby player is low in health, if you have health splash potions, one of your potions will be automatically consumed to heal them.", + "Provide a Fire Resistance buff to everyone around you.", + "Everyone around you gains Regeneration. You gain +5 Armor. Everyone around you gains +20 more Health. You gain +10 more health. Everyone around you including yourself moves 20% faster."); } public void onDisable() diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index aca5c48..40d7801 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -10303,7 +10303,7 @@ implements Listener crafteditem=true; } if (item.getType()==Material.COOKIE) { - this.plugin.gainMoneyExp(p,"Cook",0.016875*amount,1.50*amount); + this.plugin.gainMoneyExp(p,"Cook",0.016875*amount,0.45*amount); crafteditem=true; } if (item.getType()==Material.MUSHROOM_SOUP) { diff --git a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java index ad9562b..c7d1e41 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java +++ b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java @@ -456,7 +456,6 @@ public String convertToItemName(String val) { p.sendMessage(ChatColor.GOLD+" Digger ("+config.getInt("jobs.Digger")+"/"+MAXJOBS+")"); p.sendMessage(ChatColor.DARK_BLUE+" Enchanter ("+config.getInt("jobs.Enchanter")+"/"+MAXJOBS+")"); p.sendMessage(ChatColor.WHITE+" Explorer ("+config.getInt("jobs.Explorer")+"/"+MAXJOBS+")"); - p.sendMessage(ChatColor.BLUE+" Farmer ("+config.getInt("jobs.Farmer")+"/"+MAXJOBS+")"); p.sendMessage(ChatColor.AQUA+" Fisherman ("+config.getInt("jobs.Fisherman")+"/"+MAXJOBS+")"); p.sendMessage(ChatColor.RED+" Hunter ("+config.getInt("jobs.Hunter")+"/"+MAXJOBS+")"); p.sendMessage(ChatColor.GRAY+" Miner ("+config.getInt("jobs.Miner")+"/"+MAXJOBS+")"); From 4f2fd3f962d88507eaee0474b148fc7a77e91ff1 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Thu, 21 Nov 2013 03:53:25 -0700 Subject: [PATCH 08/15] Added Lv30 A & B Buff listings. --- .../src/me/kaZep/Commands/JobsDataInfo.java | 38 +++++++++++++++++++ .../me/kaZep/Commands/commandBankEconomy.java | 4 ++ 2 files changed, 42 insertions(+) diff --git a/BankEconomyMod/src/me/kaZep/Commands/JobsDataInfo.java b/BankEconomyMod/src/me/kaZep/Commands/JobsDataInfo.java index af32055..bedec28 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/JobsDataInfo.java +++ b/BankEconomyMod/src/me/kaZep/Commands/JobsDataInfo.java @@ -8,6 +8,7 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; public class JobsDataInfo { + enum Job {JOB5,JOB10,JOB20,JOB30A,JOB30B,JOB40}; String jobname; String introstring; String actionname1; @@ -22,6 +23,8 @@ public class JobsDataInfo { String lv5buff; String lv10buff; String lv20buff; + String lv30_1buff; + String lv30_2buff; String lv40buff; List dataprice1; List dataprice2; @@ -50,6 +53,8 @@ public class JobsDataInfo { lv5buff = ""; lv10buff = ""; lv20buff = ""; + lv30_1buff = ""; + lv30_2buff = ""; lv40buff = ""; dataprice1 = new ArrayList(); dataprice2 = new ArrayList(); @@ -73,6 +78,7 @@ public class JobsDataInfo { public void addExtraData(String info) { extrainfo.add(info); } + @Deprecated public String getBuffData(int lv) { switch (lv) { case 5:{ @@ -90,12 +96,44 @@ public class JobsDataInfo { } return ""; } + public String getBuffData(Job job) { + switch (job) { + case JOB5:{ + return this.lv5buff; + } + case JOB10:{ + return this.lv10buff; + } + case JOB20:{ + return this.lv20buff; + } + case JOB30A:{ + return this.lv30_1buff; + } + case JOB30B:{ + return this.lv30_2buff; + } + case JOB40:{ + return this.lv40buff; + } + } + return ""; + } + @Deprecated public void setBuffData(String lv5,String lv10,String lv20,String lv40) { this.lv5buff=lv5; this.lv10buff=lv10; this.lv20buff=lv20; this.lv40buff=lv40; } + public void setBuffData(String lv5,String lv10,String lv20,String lv30_1,String lv30_2,String lv40) { + this.lv5buff=lv5; + this.lv10buff=lv10; + this.lv20buff=lv20; + this.lv30_1buff=lv30_1; + this.lv30_2buff=lv30_1; + this.lv40buff=lv40; + } public void setAction(int numb, String name) { switch (numb) { case 0:{ diff --git a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java index 0a16306..07507fd 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java +++ b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java @@ -1816,6 +1816,10 @@ public String convertToItemName(String val) { p.sendMessage(""); p.sendMessage(ChatColor.GOLD+"Lv20 BUFF: "+ChatColor.WHITE+Jobsinfo[slot].lv20buff); p.sendMessage(""); + p.sendMessage(ChatColor.LIGHT_PURPLE+"Lv30 BUFF A: "+ChatColor.WHITE+Jobsinfo[slot].lv30_1buff); + p.sendMessage(ChatColor.YELLOW+""+ChatColor.BOLD+" - OR -"); + p.sendMessage(ChatColor.LIGHT_PURPLE+"Lv30 BUFF B: "+ChatColor.WHITE+Jobsinfo[slot].lv30_2buff); + p.sendMessage(""); p.sendMessage(ChatColor.RED+"Lv40 ULTI: "+ChatColor.WHITE+Jobsinfo[slot].lv40buff); p.sendMessage(""); p.sendMessage(ChatColor.ITALIC+"Note that only one ultimate buff can be chosen. And CANNOT BE CHANGED."); From 6387e121a2b46c1f3eaf59b3df9a72ac86ddd517 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Thu, 21 Nov 2013 03:58:43 -0700 Subject: [PATCH 09/15] Whoops, missed a few things. Now Farmer is officially gone. Mwahaha. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 2 +- .../src/me/kaZep/Commands/commandBankEconomy.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index c7f76e4..0d468ec 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -174,7 +174,7 @@ public class Main extends JavaPlugin public String[] ValidJobs = {"Woodcutter","Miner","Builder","Digger","Hunter","Fisherman","Weaponsmith","Blacksmith","Cook","Brewer","Enchanter","Breeder","Explorer","Support"}; - public ChatColor[] JobColors = {ChatColor.GREEN,ChatColor.GRAY,ChatColor.WHITE,ChatColor.GOLD,ChatColor.BLUE,ChatColor.RED,ChatColor.AQUA,ChatColor.DARK_PURPLE,ChatColor.GOLD, + public ChatColor[] JobColors = {ChatColor.GREEN,ChatColor.GRAY,ChatColor.WHITE,ChatColor.GOLD,ChatColor.RED,ChatColor.AQUA,ChatColor.DARK_PURPLE,ChatColor.GOLD, ChatColor.YELLOW,ChatColor.LIGHT_PURPLE,ChatColor.DARK_BLUE,ChatColor.DARK_GREEN,ChatColor.WHITE,ChatColor.DARK_RED}; private FileConfiguration accountsConfig = null; diff --git a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java index 07507fd..a4f0d60 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java +++ b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java @@ -1690,7 +1690,7 @@ public String convertToItemName(String val) { this.plugin.leaveJob(p,args[1]); } else if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("members")) { - JobsDataInfo[] Jobsinfo = {this.plugin.Woodcutter_job,this.plugin.Miner_job,this.plugin.Builder_job,this.plugin.Digger_job,this.plugin.Farmer_job,this.plugin.Hunter_job,this.plugin.Fisherman_job,this.plugin.Weaponsmith_job,this.plugin.Blacksmith_job,this.plugin.Cook_job,this.plugin.Brewer_job,this.plugin.Enchanter_job,this.plugin.Breeder_job,this.plugin.Explorer_job,this.plugin.Support_job}; + JobsDataInfo[] Jobsinfo = {this.plugin.Woodcutter_job,this.plugin.Miner_job,this.plugin.Builder_job,this.plugin.Digger_job,this.plugin.Hunter_job,this.plugin.Fisherman_job,this.plugin.Weaponsmith_job,this.plugin.Blacksmith_job,this.plugin.Cook_job,this.plugin.Brewer_job,this.plugin.Enchanter_job,this.plugin.Breeder_job,this.plugin.Explorer_job,this.plugin.Support_job}; boolean found=false; String job = ""; ChatColor job_color = null; @@ -1738,7 +1738,7 @@ public String convertToItemName(String val) { } } else if (cmd.getName().equalsIgnoreCase("jobs") && (args.length == 2 || args.length==3) && args[0].equalsIgnoreCase("info")) { - JobsDataInfo[] Jobsinfo = {this.plugin.Woodcutter_job,this.plugin.Miner_job,this.plugin.Builder_job,this.plugin.Digger_job,this.plugin.Farmer_job,this.plugin.Hunter_job,this.plugin.Fisherman_job,this.plugin.Weaponsmith_job,this.plugin.Blacksmith_job,this.plugin.Cook_job,this.plugin.Brewer_job,this.plugin.Enchanter_job,this.plugin.Breeder_job,this.plugin.Explorer_job,this.plugin.Support_job}; + JobsDataInfo[] Jobsinfo = {this.plugin.Woodcutter_job,this.plugin.Miner_job,this.plugin.Builder_job,this.plugin.Digger_job,this.plugin.Hunter_job,this.plugin.Fisherman_job,this.plugin.Weaponsmith_job,this.plugin.Blacksmith_job,this.plugin.Cook_job,this.plugin.Brewer_job,this.plugin.Enchanter_job,this.plugin.Breeder_job,this.plugin.Explorer_job,this.plugin.Support_job}; boolean found=false; int matchedjob=0; boolean error=false; @@ -1792,7 +1792,7 @@ public String convertToItemName(String val) { p.sendMessage(""); } else if (cmd.getName().equalsIgnoreCase("jobs") && (args.length == 2) && args[0].equalsIgnoreCase("buffs")) { - JobsDataInfo[] Jobsinfo = {this.plugin.Woodcutter_job,this.plugin.Miner_job,this.plugin.Builder_job,this.plugin.Digger_job,this.plugin.Farmer_job,this.plugin.Hunter_job,this.plugin.Fisherman_job,this.plugin.Weaponsmith_job,this.plugin.Blacksmith_job,this.plugin.Cook_job,this.plugin.Brewer_job,this.plugin.Enchanter_job,this.plugin.Breeder_job,this.plugin.Explorer_job,this.plugin.Support_job}; + JobsDataInfo[] Jobsinfo = {this.plugin.Woodcutter_job,this.plugin.Miner_job,this.plugin.Builder_job,this.plugin.Digger_job,this.plugin.Hunter_job,this.plugin.Fisherman_job,this.plugin.Weaponsmith_job,this.plugin.Blacksmith_job,this.plugin.Cook_job,this.plugin.Brewer_job,this.plugin.Enchanter_job,this.plugin.Breeder_job,this.plugin.Explorer_job,this.plugin.Support_job}; boolean found=false; int slot=0; for (int i=0;i Date: Thu, 21 Nov 2013 04:23:29 -0700 Subject: [PATCH 10/15] All irrelevant old job buffs have been removed and are inactive. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 10 +- .../src/me/kaZep/Base/PlayerListener.java | 678 +----------------- .../me/kaZep/Commands/commandBankEconomy.java | 18 +- 3 files changed, 18 insertions(+), 688 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index 0d468ec..fe8779f 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -3784,7 +3784,7 @@ public void payDay(int time) } public String[] getJobs(String p) { - String[] string= {getAccountsConfig().getString(p+".jobs.job1"),getAccountsConfig().getString(p+".jobs.job2"),getAccountsConfig().getString(p+".jobs.job3")}; + String[] string= {getAccountsConfig().getString(p.toLowerCase()+".jobs.job1"),getAccountsConfig().getString(p.toLowerCase()+".jobs.job2"),getAccountsConfig().getString(p.toLowerCase()+".jobs.job3")}; return string; } @@ -3820,7 +3820,7 @@ public void payDay(int time) public void setMoneyExp(Player p,String job,double newamount,double newexp) { String[] jobs = getJobs(p); int slot=-1; - JobsDataInfo[] Jobsinfo = {Woodcutter_job,Miner_job,Builder_job,Digger_job,Farmer_job,Hunter_job,Fisherman_job,Weaponsmith_job,Blacksmith_job,Cook_job,Brewer_job,Enchanter_job,Breeder_job,Explorer_job,Support_job}; + JobsDataInfo[] Jobsinfo = {Woodcutter_job,Miner_job,Builder_job,Digger_job,Hunter_job,Fisherman_job,Weaponsmith_job,Blacksmith_job,Cook_job,Brewer_job,Enchanter_job,Breeder_job,Explorer_job,Support_job}; for (int i=0;i=20 && crafteditem) { - ItemStack result = e.getResult(); - result.setAmount(result.getAmount()+1); - e.setResult(result); - } } } @@ -3421,21 +3416,6 @@ implements Listener } } if (this.plugin.PlayerinJob(p, "Miner")) { - if (this.plugin.getJobLv("Miner", p)>=10) { - //Half chance to set the durability back by one. - if (p.getItemInHand().getType()==Material.WOOD_PICKAXE || - p.getItemInHand().getType()==Material.STONE_PICKAXE || - p.getItemInHand().getType()==Material.GOLD_PICKAXE || - p.getItemInHand().getType()==Material.IRON_PICKAXE || - p.getItemInHand().getType()==Material.DIAMOND_PICKAXE) { - if (p.getItemInHand().getDurability()>0) { - if (Math.random()>=0.5) { - p.getItemInHand().setDurability((short)(p.getItemInHand().getDurability()-1)); - p.updateInventory(); - } - } - } - } if (this.plugin.playerdata_list.get(myData).GoodInteract()) { if (e.getBlock().getType()==Material.STONE) { this.plugin.gainMoneyExp(p,"Miner",0.0025,1); @@ -3485,36 +3465,6 @@ implements Listener } } if (this.plugin.PlayerinJob(p, "Digger")) { - if (this.plugin.getJobLv("Digger", p)>=20) { - //Half chance to set the durability back by one. - if (p.getItemInHand().getType()==Material.WOOD_SPADE || - p.getItemInHand().getType()==Material.STONE_SPADE || - p.getItemInHand().getType()==Material.GOLD_SPADE || - p.getItemInHand().getType()==Material.IRON_SPADE || - p.getItemInHand().getType()==Material.DIAMOND_SPADE) { - if (p.getItemInHand().getDurability()>0) { - if (Math.random()>=0.66) { - p.getItemInHand().setDurability((short)(p.getItemInHand().getDurability()-1)); - p.updateInventory(); - } - } - } - } else - if (this.plugin.getJobLv("Digger", p)>=10) { - //Half chance to set the durability back by one. - if (p.getItemInHand().getType()==Material.WOOD_SPADE || - p.getItemInHand().getType()==Material.STONE_SPADE || - p.getItemInHand().getType()==Material.GOLD_SPADE || - p.getItemInHand().getType()==Material.IRON_SPADE || - p.getItemInHand().getType()==Material.DIAMOND_SPADE) { - if (p.getItemInHand().getDurability()>0) { - if (Math.random()>=0.5) { - p.getItemInHand().setDurability((short)(p.getItemInHand().getDurability()-1)); - p.updateInventory(); - } - } - } - } if (this.plugin.playerdata_list.get(myData).GoodInteract()) { if (e.getBlock().getType()==Material.DIRT) { this.plugin.gainMoneyExp(p,"Digger",0.005,1); @@ -5104,79 +5054,12 @@ implements Listener Player p = e.getPlayer(); Bukkit.getPlayer("sigonasr2").sendMessage("Extacting "+e.getItemAmount()+" "+e.getItemType()); }*/ - +/* @EventHandler public void onItemChange(PlayerItemHeldEvent e) { Player p = e.getPlayer(); - if (this.plugin.PlayerinJob(p, "Miner") && this.plugin.getJobLv("Miner", p)>=20) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_PICKAXE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 2); - } else { - //if (currentitem.getEnchantmentLevel()) - } - } - } else - if (this.plugin.PlayerinJob(p, "Miner") && this.plugin.getJobLv("Miner", p)>=5) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_PICKAXE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 1); - } - } - } - if (this.plugin.PlayerinJob(p, "Digger") && this.plugin.getJobLv("Digger", p)>=5) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_SPADE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 1); - } - } - } else - if (this.plugin.PlayerinJob(p, "Digger") && this.plugin.getJobLv("Digger", p)>=20) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_SPADE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 2); - } - } - } - if (this.plugin.PlayerinJob(p, "Hunter") && this.plugin.getJobLv("Hunter", p)>=20) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_SWORD || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_SWORD || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_SWORD || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_SWORD || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_SWORD)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("FIRE_ASPECT"))) { - currentitem.addEnchantment(Enchantment.getByName("FIRE_ASPECT"), 2); - } - } - } } - +*/ public ItemStack getGoodie() { ItemStack item = null; if (Math.random()<0.33) { @@ -7835,7 +7718,7 @@ implements Listener } if (this.plugin.PlayerinJob((Player)e.getDamager(), "Hunter") && this.plugin.getJobLv("Hunter", (Player)e.getDamager())>=5) { //Deal 2 extra damage. - e.setDamage(e.getDamage()+2); + e.setDamage(e.getDamage()+4); } if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7")>0) { e.setDamage(e.getDamage()+(this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7"))/2)); @@ -8009,7 +7892,7 @@ implements Listener } if (this.plugin.PlayerinJob((Player)((Projectile)e.getDamager()).getShooter(), "Hunter") && this.plugin.getJobLv("Hunter", (Player)((Projectile)e.getDamager()).getShooter())>=5) { //Deal 2 extra damage. - e.setDamage(e.getDamage()+2); + e.setDamage(e.getDamage()+4); } if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7")>0) { e.setDamage(e.getDamage()+(this.plugin.getStatBonus(6, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat7"))/2)); @@ -8307,374 +8190,126 @@ implements Listener } if (this.plugin.PlayerinJob(p, "Builder")) { if (this.plugin.playerdata_list.get(myData).GoodInteract()) { - if (this.plugin.getJobLv("Builder", p)>=20) { - if (Math.random()<=0.05) { - ItemStack replenishitem = e.getItemInHand().clone(); - replenishitem.setAmount(1); - p.getInventory().addItem(replenishitem); - p.updateInventory(); - } - } else - if (this.plugin.getJobLv("Builder", p)>=10) { - if (Math.random()<=0.01) { - ItemStack replenishitem = e.getItemInHand().clone(); - replenishitem.setAmount(1); - p.getInventory().addItem(replenishitem); - p.updateInventory(); - } - } if (e.getBlockPlaced().getType()==Material.COBBLESTONE) { this.plugin.gainMoneyExp(p,"Builder",0.005,1); - if (this.plugin.getJobLv("Builder", p)>=5 && (int)this.plugin.getcurrentJobExp("Builder", p)%5==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } } if (e.getBlockPlaced().getType()==Material.WOOD) { this.plugin.gainMoneyExp(p,"Builder",0.005,2); - for (int i=0;i<2;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.LOG) { this.plugin.gainMoneyExp(p,"Builder",0.01,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.WOOD_STEP) { this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<2;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.COBBLESTONE_STAIRS) { this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<2;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.STONE) { this.plugin.gainMoneyExp(p,"Builder",0.015,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.FENCE) { this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.STEP) { switch (e.getBlockPlaced().getData()) { case 0:{ this.plugin.gainMoneyExp(p,"Builder",0.02,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 1:{ this.plugin.gainMoneyExp(p,"Builder",0.025,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 3:{ this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 4:{ this.plugin.gainMoneyExp(p,"Builder",0.05,9); - for (int i=0;i<9;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 5:{ this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 6:{ this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 7:{ this.plugin.gainMoneyExp(p,"Builder",0.06,12); - for (int i=0;i<12;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 8:{ this.plugin.gainMoneyExp(p,"Builder",0.02,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 9:{ this.plugin.gainMoneyExp(p,"Builder",0.025,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 10:{ this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 11:{ this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 12:{ this.plugin.gainMoneyExp(p,"Builder",0.05,9); - for (int i=0;i<9;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 13:{ this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 14:{ this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; case 15:{ this.plugin.gainMoneyExp(p,"Builder",0.06,12); - for (int i=0;i<12;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } }break; } } if (e.getBlockPlaced().getType()==Material.WOOD_STAIRS) { this.plugin.gainMoneyExp(p,"Builder",0.02,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.LAPIS_BLOCK) { this.plugin.gainMoneyExp(p,"Builder",0.02,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.COBBLE_WALL) { this.plugin.gainMoneyExp(p,"Builder",0.025,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.NETHER_BRICK_STAIRS) { this.plugin.gainMoneyExp(p,"Builder",0.025,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.NETHER_BRICK) { this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.NETHER_FENCE) { this.plugin.gainMoneyExp(p,"Builder",0.03,6); - for (int i=0;i<6;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.WOOL) { this.plugin.gainMoneyExp(p,"Builder",0.035,7); - for (int i=0;i<7;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.getMaterial(109)) { this.plugin.gainMoneyExp(p,"Builder",0.04,8); - for (int i=0;i<8;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.getMaterial(98)) { this.plugin.gainMoneyExp(p,"Builder",0.04,8); - for (int i=0;i<8;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.GLASS) { this.plugin.gainMoneyExp(p,"Builder",0.04,8); - for (int i=0;i<8;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.GLOWSTONE) { this.plugin.gainMoneyExp(p,"Builder",0.05,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.HARD_CLAY) { this.plugin.gainMoneyExp(p,"Builder",0.05,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.STAINED_CLAY) { this.plugin.gainMoneyExp(p,"Builder",0.05,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.SANDSTONE_STAIRS) { this.plugin.gainMoneyExp(p,"Builder",0.05,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.SANDSTONE) { this.plugin.gainMoneyExp(p,"Builder",0.06,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.QUARTZ_STAIRS) { this.plugin.gainMoneyExp(p,"Builder",0.06,12); - for (int i=0;i<12;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.IRON_FENCE) { this.plugin.gainMoneyExp(p,"Builder",0.06,12); - for (int i=0;i<12;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.BRICK_STAIRS) { this.plugin.gainMoneyExp(p,"Builder",0.065,9); @@ -8687,21 +8322,9 @@ implements Listener } if (e.getBlockPlaced().getType()==Material.QUARTZ_BLOCK) { this.plugin.gainMoneyExp(p,"Builder",0.07,14); - for (int i=0;i<14;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } if (e.getBlockPlaced().getType()==Material.BRICK) { this.plugin.gainMoneyExp(p,"Builder",0.075,11); - for (int i=0;i<11;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } } } } @@ -8821,294 +8444,6 @@ implements Listener } } - /* - @EventHandler - public void onInventoryMove(InventoryClickEvent e) { - if (e.getView().getPlayer()!=null) { - Player p = (Player)e.getView().getPlayer(); - if ((e.getView().getPlayer().getOpenInventory().getType()==InventoryType.WORKBENCH || e.getView().getPlayer().getOpenInventory().getType()==InventoryType.CRAFTING) && e.getSlotType()==SlotType.RESULT) { - //This is something we just crafted. - //Bukkit.getPlayer("sigonasr2").sendMessage("Inventory Type: "+e.getView().getPlayer().getOpenInventory().getType()+" Action:"+e.getAction().name()); - - //this.plugin.tempinventory = Bukkit.getPlayer(e.getWhoClicked().getName()).getInventory().getContents(); - ItemStack result = e.getCurrentItem(); - int craftamt = e.getCurrentItem().getAmount(); - //Bukkit.getPlayer("sigonasr2").sendMessage("Resulting item is "+result.getResult().getAmount()+" "+result.getResult().getType()); - if (this.plugin.PlayerinJob(p,"Digger")) { - if (result.getType()==Material.SANDSTONE) { - this.plugin.gainMoneyExp(p,"Digger",0.02*craftamt,6*craftamt); - } - if (result.getType()==Material.BRICK) { - this.plugin.gainMoneyExp(p,"Digger",0.04*craftamt,8*craftamt); - } - } - if (this.plugin.PlayerinJob(p,"Weaponsmith")) { - boolean crafteditem=false; - if (result.getType()==Material.ARROW) { - this.plugin.gainMoneyExp(p,"Weaponsmith",0.025*craftamt,4*craftamt); - crafteditem=true; - } - if (result.getType()==Material.WOOD_SWORD) { - this.plugin.gainMoneyExp(p,"Weaponsmith",0.05*craftamt,10*craftamt); - crafteditem=true; - } - if (result.getType()==Material.FLINT_AND_STEEL) { - this.plugin.gainMoneyExp(p,"Weaponsmith",0.06*craftamt,12*craftamt); - crafteditem=true; - } - if (result.getType()==Material.BOW) { - this.plugin.gainMoneyExp(p,"Weaponsmith",0.075*craftamt,12*craftamt); - crafteditem=true; - } - if (result.getType()==Material.IRON_SWORD) { - this.plugin.gainMoneyExp(p,"Weaponsmith",0.375*craftamt,75*craftamt); - crafteditem=true; - } - if (result.getType()==Material.GOLD_SWORD) { - this.plugin.gainMoneyExp(p,"Weaponsmith",0.50*craftamt,100*craftamt); - crafteditem=true; - } - if (result.getType()==Material.DIAMOND_SWORD) { - this.plugin.gainMoneyExp(p,"Weaponsmith",0.975*craftamt,175*craftamt); - crafteditem=true; - } - } - if (this.plugin.PlayerinJob(p,"Blacksmith")) { - boolean crafteditem=false; - if (result.getType()==Material.STONE_HOE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.04*craftamt,7*craftamt); - crafteditem=true; - } - if (result.getType()==Material.STONE_SPADE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.05,8); - crafteditem=true; - } - if (result.getType()==Material.STONE_PICKAXE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.075,15); - crafteditem=true; - } - if (result.getType()==Material.LEATHER_BOOTS) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.125,8); - crafteditem=true; - } - if (result.getType()==Material.LEATHER_HELMET) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.15,14); - crafteditem=true; - } - if (result.getType()==Material.LEATHER_LEGGINGS) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.175,15); - crafteditem=true; - } - if (result.getType()==Material.LEATHER_CHESTPLATE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.20,18); - crafteditem=true; - } - if (result.getType()==Material.IRON_SPADE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.25,18); - crafteditem=true; - } - if (result.getType()==Material.IRON_HOE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.325,24); - crafteditem=true; - } - if (result.getType()==Material.IRON_BOOTS) { - int mult=1; - if ((result.getItemMeta().getDisplayName()!=null && !result.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getItemMeta().getDisplayName()==null) { - mult=8; - } - this.plugin.gainMoneyExp(p,"Blacksmith",0.375*mult,27*mult); - crafteditem=true; - } - if (result.getType()==Material.IRON_PICKAXE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.40,30); - crafteditem=true; - } - if (result.getType()==Material.IRON_HELMET) { - int mult=1; - if ((result.getItemMeta().getDisplayName()!=null && !result.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getItemMeta().getDisplayName()==null) { - mult=8; - } - this.plugin.gainMoneyExp(p,"Blacksmith",0.50*mult,45*mult); - crafteditem=true; - } - if (result.getType()==Material.GOLD_SPADE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.625,55); - crafteditem=true; - } - if (result.getType()==Material.GOLD_HOE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.65,60); - crafteditem=true; - } - if (result.getType()==Material.IRON_LEGGINGS) { - int mult=1; - if ((result.getItemMeta().getDisplayName()!=null && !result.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getItemMeta().getDisplayName()==null) { - mult=8; - } - this.plugin.gainMoneyExp(p,"Blacksmith",0.725*mult,60*mult); - crafteditem=true; - } - if (result.getType()==Material.DIAMOND_SPADE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.75,65); - crafteditem=true; - } - if (result.getType()==Material.DIAMOND_HOE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.80,70); - crafteditem=true; - } - if (result.getType()==Material.GOLD_BOOTS) { - int mult=1; - if ((result.getItemMeta().getDisplayName()!=null && !result.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getItemMeta().getDisplayName()==null) { - mult=8; - } - this.plugin.gainMoneyExp(p,"Blacksmith",0.825*mult,50*mult); - crafteditem=true; - } - if (result.getType()==Material.IRON_CHESTPLATE) { - int mult=1; - if ((result.getItemMeta().getDisplayName()!=null && !result.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getItemMeta().getDisplayName()==null) { - mult=8; - } - this.plugin.gainMoneyExp(p,"Blacksmith",0.875*mult,70*mult); - crafteditem=true; - } - if (result.getType()==Material.GOLD_HELMET) { - int mult=1; - if ((result.getItemMeta().getDisplayName()!=null && !result.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getItemMeta().getDisplayName()==null) { - mult=8; - } - this.plugin.gainMoneyExp(p,"Blacksmith",0.925*mult,80*mult); - crafteditem=true; - } - if (result.getType()==Material.DIAMOND_PICKAXE) { - this.plugin.gainMoneyExp(p,"Blacksmith",0.925,80); - crafteditem=true; - } - if (result.getType()==Material.DIAMOND_BOOTS) { - int mult=1; - if ((result.getItemMeta().getDisplayName()!=null && !result.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getItemMeta().getDisplayName()==null) { - mult=8; - } - this.plugin.gainMoneyExp(p,"Blacksmith",1.00*mult,85*mult); - crafteditem=true; - } - if (result.getType()==Material.GOLD_LEGGINGS) { - int mult=1; - if ((result.getItemMeta().getDisplayName()!=null && !result.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getItemMeta().getDisplayName()==null) { - mult=8; - } - this.plugin.gainMoneyExp(p,"Blacksmith",1.025*mult,100*mult); - crafteditem=true; - } - if (result.getType()==Material.GOLD_CHESTPLATE) { - int mult=1; - if ((result.getItemMeta().getDisplayName()!=null && !result.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getItemMeta().getDisplayName()==null) { - mult=8; - } - this.plugin.gainMoneyExp(p,"Blacksmith",1.15*mult,130*mult); - crafteditem=true; - } - if (result.getType()==Material.DIAMOND_HELMET) { - int mult=1; - if ((result.getItemMeta().getDisplayName()!=null && !result.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getItemMeta().getDisplayName()==null) { - mult=8; - } - this.plugin.gainMoneyExp(p,"Blacksmith",1.15*mult,125*mult); - crafteditem=true; - } - if (result.getType()==Material.DIAMOND_LEGGINGS) { - int mult=1; - if ((result.getItemMeta().getDisplayName()!=null && !result.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getItemMeta().getDisplayName()==null) { - mult=8; - } - this.plugin.gainMoneyExp(p,"Blacksmith",1.325*mult,145*mult); - crafteditem=true; - } - if (result.getType()==Material.DIAMOND_CHESTPLATE) { - int mult=1; - if ((result.getItemMeta().getDisplayName()!=null && !result.getItemMeta().getDisplayName().contains(ChatColor.DARK_AQUA+"Weak ")) || result.getItemMeta().getDisplayName()==null) { - mult=8; - } - this.plugin.gainMoneyExp(p,"Blacksmith",1.50*mult,175*mult); - crafteditem=true; - } - } - if (this.plugin.PlayerinJob(p,"Cook")) { - boolean crafteditem=false; - if (result.getType()==Material.BREAD) { - this.plugin.gainMoneyExp(p,"Cook",0.0125,5); - crafteditem=true; - } - if (result.getType()==Material.MUSHROOM_SOUP) { - this.plugin.gainMoneyExp(p,"Cook",0.0375,15); - crafteditem=true; - } - if (result.getType()==Material.COOKIE) { - this.plugin.gainMoneyExp(p,"Cook",0.0675,25); - crafteditem=true; - } - if (result.getType()==Material.GOLDEN_CARROT) { - this.plugin.gainMoneyExp(p,"Cook",0.0875,35); - crafteditem=true; - } - if (result.getType()==Material.GOLDEN_APPLE) { - this.plugin.gainMoneyExp(p,"Cook",0.1125,45); - crafteditem=true; - } - if (result.getType()==Material.PUMPKIN_PIE) { - this.plugin.gainMoneyExp(p,"Cook",0.15,60); - crafteditem=true; - } - if (result.getType()==Material.CAKE) { - this.plugin.gainMoneyExp(p,"Cook",0.2125,85); - crafteditem=true; - } - if (this.plugin.getJobLv("Cook", p)>=10 && crafteditem==true) { - ItemStack resultingitem = result; - resultingitem.setAmount(resultingitem.getAmount()*2); - } - } - if (this.plugin.PlayerinJob(p,"Support")) { - if (result.getType()==Material.BREAD) { - this.plugin.gainMoneyExp(p,"Support",0.015,2); - } - if (result.getType()==Material.MUSHROOM_SOUP) { - this.plugin.gainMoneyExp(p,"Support",0.015,2); - } - if (result.getType()==Material.COOKIE) { - this.plugin.gainMoneyExp(p,"Support",0.015,2); - } - if (result.getType()==Material.GOLDEN_CARROT) { - this.plugin.gainMoneyExp(p,"Support",0.015,2); - } - if (result.getType()==Material.GOLDEN_APPLE) { - this.plugin.gainMoneyExp(p,"Support",0.015,2); - } - if (result.getType()==Material.PUMPKIN_PIE) { - this.plugin.gainMoneyExp(p,"Support",0.015,2); - } - if (result.getType()==Material.CAKE) { - this.plugin.gainMoneyExp(p,"Support",0.015,2); - } - if (result.getType()==Material.IRON_SWORD) { - this.plugin.gainMoneyExp(p,"Support",0.015,3); - } - if (result.getType()==Material.IRON_CHESTPLATE || result.getType()==Material.IRON_HELMET || result.getType()==Material.IRON_BOOTS || result.getType()==Material.IRON_LEGGINGS) { - this.plugin.gainMoneyExp(p,"Support",0.025,5); - } - if (result.getType()==Material.DIAMOND_SWORD) { - this.plugin.gainMoneyExp(p,"Support",0.075,8); - } - if (result.getType()==Material.DIAMOND_CHESTPLATE || result.getType()==Material.DIAMOND_HELMET || result.getType()==Material.DIAMOND_BOOTS || result.getType()==Material.DIAMOND_LEGGINGS) { - this.plugin.gainMoneyExp(p,"Support",0.20,20); - } - if (result.getType()==Material.CAKE) { - this.plugin.gainMoneyExp(p,"Support",0.03,2); - } - } - } - } - }*/ - @EventHandler public void onInventoryCloseEvent(InventoryCloseEvent e) { Player p = (Player)e.getPlayer(); @@ -10356,11 +9691,6 @@ implements Listener this.plugin.gainMoneyExp(p,"Cook",0.1125*amount,45*amount); crafteditem=true; } - if (this.plugin.getJobLv("Cook", p)>=10 && crafteditem==true) { - //This is an ugly fix for the problem...But it works somehow. - //Player newp = Bukkit.getPlayer(p.getName()); - p.getInventory().addItem(new ItemStack(item.getType(),amount,item.getDurability(),item.getData().getData())); - } } /* if (this.plugin.PlayerinJob(p,"Support")) { diff --git a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java index a4f0d60..af501f1 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java +++ b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java @@ -1706,25 +1706,25 @@ public String convertToItemName(String val) { if (this.plugin.getConfig().contains("jobs."+job+"_members")) { p.sendMessage("Players in the "+job_color+job+" job:"); String[] players = this.plugin.getConfig().getString("jobs."+job+"_members").split(", "); - char lowest = 'z'+1; + int highest = 0; List sorted_players = new ArrayList(); for (int i=0;i sorted_list_players = new ArrayList(); - int lowest_slot = -1; + int highest_slot = -1; while (sorted_players.size()>0) { for (int i=0;ihighest) { + highest=this.plugin.getJobLv(job, sorted_players.get(i)); + highest_slot=i; } } - sorted_list_players.add(sorted_players.get(lowest_slot)); - sorted_players.remove(lowest_slot); - lowest_slot=-1; - lowest='z'+1; + sorted_list_players.add(sorted_players.get(highest_slot)); + sorted_players.remove(highest_slot); + highest_slot=-1; + highest=0; } for (int i=0;i Date: Thu, 21 Nov 2013 18:50:58 -0500 Subject: [PATCH 11/15] Trivial logic fixing for harrowing item disabling --- .../src/me/kaZep/Base/PlayerListener.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index a6add57..726b2e5 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -12271,7 +12271,7 @@ class updateInventoryTask implements Runnable { sendToInventory(MATERIALS, anvilInv.getItem(MATERIALS).getAmount(), player); // Bukkit.getLogger().info("Invalid materials!"); - } else if (anvilInv.getItem(MATERIALS).getType() == Material.ENCHANTED_BOOK && anvilInv.getItem(MAGIC) == null) { + } else if ((anvilInv.getItem(MATERIALS).getType() == Material.ENCHANTED_BOOK || anvilInv.getItem(MATERIALS).getType() == Material.BOOK) && anvilInv.getItem(MAGIC) == null) { anvilInv.setItem(MAGIC, anvilInv.getItem(MATERIALS).clone()); anvilInv.setItem(MATERIALS, new ItemStack(Material.AIR)); // Bukkit.getLogger().info("Valid materials, " + anvilInv.getItem(MATERIALS).toString().toUpperCase() + " with durability " + anvilInv.getItem(MATERIALS).getDurability()); @@ -12407,11 +12407,11 @@ class updateInventoryTask implements Runnable { multiplier = 0.3; } - if (anvilInv.getItem(MATERIALS).getType() == Material.DIAMOND && (anvilInv.getItem(INPUT).getType() == Material.DIAMOND_BOOTS || + if ((anvilInv.getItem(MATERIALS).getType() == Material.DIAMOND && (anvilInv.getItem(INPUT).getType() == Material.DIAMOND_BOOTS || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_CHESTPLATE || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_HELMET || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_LEGGINGS || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_AXE || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_SWORD || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_HOE || - anvilInv.getItem(INPUT).getType() == Material.DIAMOND_PICKAXE || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_SPADE && + anvilInv.getItem(INPUT).getType() == Material.DIAMOND_PICKAXE || anvilInv.getItem(INPUT).getType() == Material.DIAMOND_SPADE) && !isHalloweenItem)) { validCombo = true; @@ -12879,9 +12879,12 @@ class updateInventoryTask implements Runnable { player.updateInventory(); } else if (anvilInv.getItem(MAGIC).getType() == Material.BOOK && anvilInv.getItem(INPUT).getType() != Material.ENCHANTED_BOOK) { // Magic slot is a book. Unenchanting logic goes here. - anvilInv.setItem(OUTPUT, anvilInv.getItem(INPUT).clone()); + anvilInv.setItem(OUTPUT, new ItemStack(Material.ENCHANTED_BOOK)); anvilInv.getItem(OUTPUT).setType(Material.ENCHANTED_BOOK); - anvilInv.getItem(OUTPUT).setDurability((short)0); + + ItemMeta bookMeta = anvilInv.getItem(INPUT).getItemMeta(); + bookMeta.setDisplayName(null); + anvilInv.getItem(OUTPUT).setItemMeta(bookMeta); // If books stacked past 1, return all but 1 book to player inventory. From 979e0c497d5e7b5eb5cc8ca231b4ec86856ed780 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Thu, 21 Nov 2013 20:17:31 -0700 Subject: [PATCH 12/15] Implement all Woodcutter job buffs. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 208 ++++++++++- .../src/me/kaZep/Base/PlayerListener.java | 327 ++++++++++++++++-- .../src/me/kaZep/Commands/JobsDataInfo.java | 4 +- .../me/kaZep/Commands/commandBankEconomy.java | 6 +- 4 files changed, 496 insertions(+), 49 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index fe8779f..b3ee0a9 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -21,6 +21,7 @@ import java.util.logging.Logger; import java.text.*; import me.kaZep.Commands.JobsDataInfo; +import me.kaZep.Commands.JobsDataInfo.Job; import me.kaZep.Commands.commandBankEconomy; import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; @@ -3696,9 +3697,19 @@ public void payDay(int time) return; } if (PlayerinJob(p,job)) { - getAccountsConfig().set(p.getName().toLowerCase()+".jobs.ultimate", String.valueOf(ValidJobs[matchedjob])); - saveAccountsConfig(); - p.sendMessage(ChatColor.YELLOW+"Set Declared Ultimate job to "+job); + if (getJobLv(job,p)>=40) { + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.ultimate", String.valueOf(ValidJobs[matchedjob])); + saveAccountsConfig(); + p.sendMessage(ChatColor.YELLOW+"Set Declared Ultimate job to "+job); + p.sendMessage(""); + p.sendMessage(ChatColor.GOLD+""+ChatColor.ITALIC+"Unlike other buffs, you do not just receive the buff immediately. You have to earn it."); + p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+"Earn enough job exp to be proven worthy, and then search mob drops for a special trinket. The more exp you have built up, the better the chance you'll find one."); + p.sendMessage(""); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"(Note you can still change your declared ultimate at any time during this time.)"); + } else { + p.sendMessage(ChatColor.GOLD+"Sorry, you are not a high enough level in that job yet!"); + return; + } } else { p.sendMessage(ChatColor.GOLD+"Sorry, you are not in that job!"); return; @@ -3779,8 +3790,7 @@ public void payDay(int time) } public String[] getJobs(Player p) { - String[] string= {getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"),getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"),getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3")}; - return string; + return getJobs(p.getName()); } public String[] getJobs(String p) { @@ -3799,13 +3809,7 @@ public void payDay(int time) } public boolean PlayerinJob(Player p,String job) { - String[] jobs = getJobs(p); - for (int i=0;i=5) { + return true; + } else { + return false; + } + } + case JOB10: { + if (level>=10) { + return true; + } else { + return false; + } + } + case JOB20: { + if (level>=20) { + return true; + } else { + return false; + } + } + case JOB30A: { + if (level>=30 && getAccountsConfig().getInt(p.toLowerCase()+".jobs.job"+(slot+1)+"_30")==1) { + return true; + } else { + return false; + } + } + case JOB30B: { + if (level>=30 && getAccountsConfig().getInt(p.toLowerCase()+".jobs.job"+(slot+1)+"_30")==2) { + return true; + } else { + return false; + } + } + case JOB40: { + if (level>=40 && getAccountsConfig().getString(p.toLowerCase()+".jobs.ultimate").equalsIgnoreCase(job) && getAccountsConfig().getBoolean(p.toLowerCase()+".jobs.ultimatesealed")) { + return true; + } else { + return false; + } + } + default: { + return false; + } + } + } else { + return false; + } + } + return false; + } + public int getPlayerDataSlot(Player p) { //Find my data. for (int i=0;i=30) { + if (arg2.equals("1") || arg2.equals("2")) { + if (getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(getJobSlot(arg1)+1)+"_30")==0) { + //We are making a valid choice. + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(getJobSlot(arg1)+1)+"_30",Integer.valueOf(arg2)); + saveAccountsConfig(); + p.sendMessage(ChatColor.GREEN+"You have set your Lv30 Buff choice for your "+arg1+" job to the "+((Integer.valueOf(arg2)==1)?"first":"second")+" version."); + } else { + p.sendMessage(ChatColor.RED+"Sorry, you already picked your Lv30 Buff Choice for that job! You can't change it."); + } + } else { + p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs [JobName] 1"+ChatColor.WHITE+" or "+ChatColor.GREEN+"/jobs [JobName] 2"+ChatColor.WHITE+" - Set Lv30 Buff Choice."); + } + } else { + p.sendMessage(ChatColor.RED+"Sorry, you are not a high enough level in that job to set your buff choice yet!"); + } + } + + public void notifyBuffMessages(Player p) { + notifyBuffMessages(p, 20); + } + + public void notifyBuffMessages(final Player p, int tick_delay) { + //Same as notifyBuffMessages(), but waits a number of ticks before displaying it. + //See which messages we have to display. + int total_tick_delay=tick_delay; + if (getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job1lv")>=30 && getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job1_30")==0) { + //Have not selected first job's buff. + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + String job = getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"); + int color_slot = 0; + for (int i=0;i=30 && getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job2_30")==0) { + //Have not selected first job's buff. + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + String job = getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"); + int color_slot = 0; + for (int i=0;i=30 && getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job3_30")==0) { + //Have not selected first job's buff. + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + String job = getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"); + int color_slot = 0; + for (int i=0;i=30 && getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job3_30")==0) { + //Have not selected first job's buff. + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + String job = getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"); + int color_slot = 0; + for (int i=0;i=40 || getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job2lv")>=40 || getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job3lv")>=40) && !getAccountsConfig().getBoolean(p.getName().toLowerCase()+".jobs.ultimate")) { + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + String job = getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"); + int color_slot = 0; + for (int i=0;i"+ChatColor.RESET+ChatColor.ITALIC+" replacing it with the ultimate job you want!"); + } + },total_tick_delay+=tick_delay); + } + } } diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index a6add57..11f9eb5 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -33,6 +33,7 @@ import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.Sound; import org.bukkit.World; +import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BrewingStand; @@ -165,6 +166,7 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.material.MaterialData; import org.bukkit.material.Pumpkin; +import org.bukkit.material.Tree; import org.bukkit.material.Wool; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; @@ -186,6 +188,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.data.DataException; import com.sk89q.worldedit.schematic.SchematicFormat; +import com.sk89q.worldedit.util.TreeGenerator.TreeType; import me.kaZep.Base.BrewingStandData; import me.kaZep.Base.FurnaceData; @@ -200,6 +203,7 @@ import me.kaZep.Base.PersistentExplorerList; import me.kaZep.Base.PlayerData; import me.kaZep.Base.SupportEntity; import me.kaZep.Base.SupportPlayer; +import me.kaZep.Commands.JobsDataInfo.Job; public class PlayerListener implements Listener @@ -1375,7 +1379,7 @@ implements Listener @EventHandler public void onPlayerJoin(PlayerJoinEvent e) { - Player p = e.getPlayer(); + final Player p = e.getPlayer(); Team tempteam; if (this.plugin.getConfig().getBoolean("halloween-enabled")) { Bukkit.getWorld("world").setDifficulty(Difficulty.EASY); @@ -1486,31 +1490,10 @@ implements Listener playerwhitelisted=true; } } - /* - //Boss platform is created +,+ coordinates from the location specified. - File file = new File("plugins/WorldEdit/schematics/boss.schematic"); - if (file.exists()) { - try { - com.sk89q.worldedit.Vector v = new com.sk89q.worldedit.Vector(p.getLocation().getX()-8, p.getLocation().getY(), p.getLocation().getZ()-8); - World worldf = Bukkit.getWorld("world"); - BukkitWorld BWf = new BukkitWorld(worldf); - EditSession es = new EditSession(BWf, 2000000); - CuboidClipboard c1 = SchematicFormat.MCEDIT.load(file); - c1.place(es, v, true); - } catch (DataException ex) { - Bukkit.getLogger().warning("DataException while trying to create structure."); - } catch (IOException ex) { - Bukkit.getLogger().warning("IOException while trying to create structure."); - } catch (MaxChangedBlocksException ex) { - Bukkit.getLogger().warning("MaxChangedBlocksException while trying to create structure."); - } - } else { - Bukkit.getLogger().warning(("File does not exist.")); - } - */ + //System.out.println("Whitelisted Players: "+playerslist); //System.out.println("Maximum Air: "+p.getMaximumAir()); - if (!this.plugin.getAccountsConfig().contains(p.getName())) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase().toLowerCase())) { //This is a brand new player. Main.economy.withdrawPlayer(p.getName(), Main.economy.getBalance(p.getName())); Main.economy.depositPlayer(p.getName(), 70); @@ -1523,12 +1506,15 @@ implements Listener this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job1", String.valueOf("None")); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job1lv", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job1exp", Double.valueOf(0.0d)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job1_30", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job2", String.valueOf("None")); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job2lv", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job2exp", Double.valueOf(0.0d)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job2_30", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job3", String.valueOf("None")); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job3lv", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job3exp", Double.valueOf(0.0d)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job3_30", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimate", String.valueOf("None")); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimatesealed", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat1", Integer.valueOf(0)); @@ -1579,11 +1565,19 @@ implements Listener p.sendMessage("----------------------------"); p.sendMessage(ChatColor.YELLOW+"Current Money Balance: $ "+df.format(Main.economy.bankBalance(p.getName()).balance)+", Bank Balance: $"+df.format(this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase()+".money"))); //Update account information for the stat point update. - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".bonus.witherskeleton")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".jobs.job1_30")) { + //Update account information for Jobs 2.1 + Bukkit.getLogger().info("Update player "+p.getName()+" to Jobs 2.1 account format."); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1_30", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2_30", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3_30", Integer.valueOf(0)); + this.plugin.saveAccountsConfig(); + } + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".bonus.witherskeleton")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".bonus.witherskeleton", Integer.valueOf(0)); this.plugin.saveAccountsConfig(); } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".stats.stat1")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".stats.stat1")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat1", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat2", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat3", Integer.valueOf(0)); @@ -1598,7 +1592,7 @@ implements Listener System.out.println("Updated " + p.getName() + "'s data with stat point update."); } //Update account information for notification settings. - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".settings.notify1")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".settings.notify1")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify1", Boolean.valueOf(true)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify2", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify3", Boolean.valueOf(true)); @@ -1619,7 +1613,7 @@ implements Listener } } if (!full) { - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".join.halloween_book")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".join.halloween_book")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".join.halloween_book", Boolean.valueOf(true)); this.plugin.saveAccountsConfig(); System.out.println("Updated " + p.getName() + "'s data with a Halloween Book."); @@ -1637,7 +1631,7 @@ implements Listener book.setItemMeta(bookdata); p.getInventory().addItem(book); } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".join.halloween_vote_signs")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".join.halloween_vote_signs")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".join.halloween_vote_signs", Boolean.valueOf(true)); this.plugin.saveAccountsConfig(); ItemStack sign = new ItemStack(Material.SIGN,2); @@ -1648,11 +1642,11 @@ implements Listener p.sendMessage("You have received 2 vote signs. Go vote at the Pumpkin Patch for the best pumpkin! (Note that voting for yourself does not count. Please vote the best of the others' pumpkins.)"); } } else { - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".join.halloween_vote_signs")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".join.halloween_vote_signs")) { p.sendMessage("You do not have enough room in your inventory to receive Pumpkin vote signs. Clear some of your inventory and then rejoin."); } } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".halloween.chest1")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".halloween.chest1")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest1", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest2", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest3", Boolean.valueOf(false)); @@ -1665,12 +1659,12 @@ implements Listener this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest10", Boolean.valueOf(false)); this.plugin.saveAccountsConfig(); } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".jobs.ultimate")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".jobs.ultimate")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimate", String.valueOf("None")); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimatesealed", Boolean.valueOf(false)); this.plugin.saveAccountsConfig(); } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".halloween.wand")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".halloween.wand")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.wand", Long.valueOf(Main.SERVER_TICK_TIME)); this.plugin.saveAccountsConfig(); } @@ -1737,6 +1731,9 @@ implements Listener Bukkit.getLogger().warning("Potion Effect Collection not accessible while trying to slow down player."); } updateTopSPLEEFSigns(); + + + this.plugin.notifyBuffMessages(p); } /* @@ -3175,6 +3172,60 @@ implements Listener } } } + + private void destroyNearbyTree(World w, Location treeNode, Location checkloc, byte type, boolean silk_touch) { + //treeNode is where the original tree is located. checkloc is the current checking location. + //Code for destroying a tree. This iterates on itself. Using a base point to determine how far out it can go. + if (treeNode.distance(checkloc)<3) { + //Loop around and find all leaves/logs. + Location newloc = null; + for (int i=-1;i<2;i++) { + for (int j=-1;j<2;j++) { + for (int k=-1;k<2;k++) { + newloc = checkloc.clone().add(i,j,k); + if (w.getBlockAt(newloc).getType()==Material.LOG && w.getBlockAt(newloc).getData()%4==type) { + //logs.add(newloc.getBlock()); + w.dropItemNaturally(newloc, new ItemStack(w.getBlockAt(newloc).getType(),1,(short)(w.getBlockAt(newloc).getData()%4))); + newloc.getBlock().setType(Material.AIR); + destroyNearbyTree(w, newloc, newloc, type, silk_touch); + } else + if (w.getBlockAt(newloc).getType()==Material.LEAVES && w.getBlockAt(newloc).getData()%4==type) { + //leaves.add(newloc.getBlock()); + //Emulate apples / saplings dropping. + if (w.getBlockAt(newloc).getData()==3) { + //Jungle sapling. + if (silk_touch) { + w.dropItemNaturally(newloc, new ItemStack(Material.LEAVES,1)); + } else + if (Math.random()<=0.025) { + ItemStack item = new ItemStack(Material.SAPLING,1); + item.setDurability((short)(w.getBlockAt(newloc).getData()%4)); + w.dropItemNaturally(newloc, item); + } + } else { + if (w.getBlockAt(newloc).getData()%4==0) { + //Chance to drop an apple. + if (Math.random()<=0.02) { + w.dropItemNaturally(newloc, new ItemStack(Material.APPLE,1)); + } + } + if (silk_touch) { + w.dropItemNaturally(newloc, new ItemStack(Material.LEAVES,1)); + } else + if (Math.random()<=0.05) { + ItemStack item = new ItemStack(Material.SAPLING,1); + item.setDurability((short)(w.getBlockAt(newloc).getData()%4)); + w.dropItemNaturally(newloc, item); + } + } + newloc.getBlock().setType(Material.AIR); + destroyNearbyTree(w, treeNode, newloc, type, silk_touch); + } + } + } + } + } + } @EventHandler public void onBlockBreak(BlockBreakEvent e) { @@ -3182,6 +3233,51 @@ implements Listener //p.sendMessage("Block broke."); //p.sendMessage("Has name: "+p.getItemInHand().getItemMeta().hasDisplayName()); //p.sendMessage("Name is: "+p.getItemInHand().getItemMeta().getDisplayName()); + + //*******************************//Job Buffs Begin here! + if (this.plugin.hasJobBuff("Woodcutter", p, Job.JOB20)) { + if (p.getItemInHand().getType().name().toLowerCase().contains("axe") && !p.getItemInHand().getType().name().toLowerCase().contains("pickaxe")) { + //Make sure it's not a pickaxe before reducing durability. + if (this.plugin.hasJobBuff("Woodcutter", p, Job.JOB30A)) { + p.getItemInHand().setDurability((short)0); + } else { + if (Math.random()<=0.5) { + p.getItemInHand().setDurability((short)(p.getItemInHand().getDurability()>=1?p.getItemInHand().getDurability()-1:0)); + } + } + } + if ((e.getBlock().getType()==Material.LOG || e.getBlock().getType()==Material.WOOD)) { + p.removePotionEffect(PotionEffectType.JUMP); + p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,200,10)); + } + } + if (e.getBlock().getType()==Material.LOG && this.plugin.hasJobBuff("Woodcutter", p, Job.JOB40)) { + //Cut down the whole tree if you hit a log. Make sure it's a tree. + boolean findleaves=false; + boolean findground=false; + Location currentpos = e.getBlock().getLocation(); + //Look straight up, look on the sides for leaves. + while (!findleaves && currentpos.getWorld().getBlockAt(currentpos).getType()==Material.LOG) { + Location checktemp = currentpos.clone().add(0,1,0); + if (e.getBlock().getWorld().getBlockAt(checktemp).getType()==Material.LEAVES || + e.getBlock().getWorld().getBlockAt(checktemp).getType()==Material.LEAVES || + e.getBlock().getWorld().getBlockAt(checktemp).getType()==Material.LEAVES || + e.getBlock().getWorld().getBlockAt(checktemp).getType()==Material.LEAVES || + e.getBlock().getWorld().getBlockAt(checktemp).getType()==Material.LEAVES || + e.getBlock().getWorld().getBlockAt(checktemp).getType()==Material.LEAVES) { + findleaves=true; //This is considered a tree. Make sure the ground below it is dirt. + //Bukkit.getLogger().info("Found leaves."); + } + currentpos=currentpos.add(0,1,0); + } + if (findleaves) { + //This is definitely a tree we can chop down. Destroy it then. + //Bukkit.getLogger().info("Identified as tree. Start Destroying."); + destroyNearbyTree(e.getBlock().getWorld() ,e.getBlock().getLocation(), e.getBlock().getLocation(), (byte)(e.getBlock().getData()%4), p.getItemInHand().getEnchantmentLevel(Enchantment.SILK_TOUCH)>0); + } + } + //*******************************//Job Buffs end here! + int myData=this.plugin.getPlayerDataSlot(p); boolean has_silktouch=false; if (!p.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { @@ -4001,9 +4097,39 @@ implements Listener } } + @EventHandler + public void onLeavesDecay(LeavesDecayEvent e) { + if (e.getBlock().getData()==0/*Has to be oak.*/) { + //We will check for nearby players. + for (int i=0;i7) && e.getClickedBlock().getData()%4==0) { + //This is Oak Leaves that were NOT placed by a player. + //Bukkit.getLogger().info("A Valid oak leaf! Apple!"); + if (this.plugin.hasJobBuff("Woodcutter", p, Job.JOB20)) { + if (Math.random()<=0.02) { + p.getWorld().dropItemNaturally(e.getClickedBlock().getLocation(), new ItemStack(Material.APPLE)); + } + } + } + e.getClickedBlock().setType(Material.AIR); + p.playSound(e.getClickedBlock().getLocation(), Sound.DIG_GRASS, 1, 1); + p.getWorld().playEffect(e.getClickedBlock().getLocation(), Effect.STEP_SOUND, Material.LEAVES.getId()); + //Randomly drop a sapling based on type. + if (e.getClickedBlock().getData()%4==3) { + //This is a jungle leaf. + if (Math.random()<=0.025) { + e.getClickedBlock().getWorld().dropItemNaturally(e.getClickedBlock().getLocation(), new ItemStack(Material.SAPLING,1,(short)(e.getClickedBlock().getData()%4))); + } + } else { + if (Math.random()<=0.05) { + e.getClickedBlock().getWorld().dropItemNaturally(e.getClickedBlock().getLocation(), new ItemStack(Material.SAPLING,1,(short)(e.getClickedBlock().getData()%4))); + } + } + } + } + if (e.getAction()==Action.RIGHT_CLICK_BLOCK && p.getItemInHand().getType()==Material.SAPLING && (e.getClickedBlock().getType()==Material.GRASS || e.getClickedBlock().getType()==Material.DIRT) && this.plugin.hasJobBuff("Woodcutter", p, Job.JOB30B)) { + //Instantly grow the tree! + //Check out the data value of the sapling. + Byte data = p.getItemInHand().getData().getData(); + //Bukkit.getLogger().info("Data value for this sapling: "+data.toString()); + int tries=0; + BukkitWorld BWf = new BukkitWorld(p.getWorld()); + EditSession es = new EditSession(BWf, 1000); //STart a new editing session to create trees. + switch (data) { + case (byte)0: { + //This is a normal sapling. see if we're in a swamp biome. + //Bukkit.getLogger().info("This is a normal sapling!"); + if (e.getClickedBlock().getWorld().getBiome(e.getClickedBlock().getLocation().getBlockX(), e.getClickedBlock().getLocation().getBlockZ())==Biome.SWAMPLAND) { + if (Math.random()<=0.90) { + while (tries<100) { + //e.getClickedBlock().getWorld().generateTree(e.getClickedBlock().getLocation().add(0,1,0), TreeType.SWAMP); + BWf.generateTree(TreeType.SWAMP, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + } else { + while (tries<100) { + BWf.generateTree(TreeType.TREE, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + } + } else { + if (Math.random()<=0.90) { + while (tries<100) { + BWf.generateTree(TreeType.TREE, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + } else { + while (tries<100) { + BWf.generateTree(TreeType.BIG_TREE, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + } + } + }break; + case (byte)1: { + while (tries<100) { + /* + e.getClickedBlock().getWorld().generateTree(e.getClickedBlock().getLocation().add(0,1,0), TreeType.REDWOOD); + e.getClickedBlock().getWorld().generateTree(e.getClickedBlock().getLocation().add(0,1,0), com.sk89q.worldedit.blocks.tr);*/ + BWf.generateTree(TreeType.PINE, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + BWf.generateTree(TreeType.REDWOOD, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + BWf.generateTree(TreeType.TALL_REDWOOD, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + }break; + case (byte)2: { + while (tries<100) { + BWf.generateTree(TreeType.BIRCH, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + }break; + case (byte)3: { + if (Math.random()<=0.90) { + while (tries<100) { + BWf.generateTree(TreeType.SHORT_JUNGLE, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + } else { + while (tries<100) { + BWf.generateTree(TreeType.JUNGLE, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + } + }break; + } + } + //*****************// End Job Buffs section. + if (e.getAction()==Action.RIGHT_CLICK_AIR || e.getAction()==Action.RIGHT_CLICK_BLOCK) { if (p.getItemInHand()!=null && (p.getItemInHand().getType()==Material.FLINT_AND_STEEL || p.getItemInHand().getType()==Material.LAVA_BUCKET)) { if (this.plugin.PlayerinJob(p, "Support")) { diff --git a/BankEconomyMod/src/me/kaZep/Commands/JobsDataInfo.java b/BankEconomyMod/src/me/kaZep/Commands/JobsDataInfo.java index bedec28..2805541 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/JobsDataInfo.java +++ b/BankEconomyMod/src/me/kaZep/Commands/JobsDataInfo.java @@ -8,7 +8,7 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; public class JobsDataInfo { - enum Job {JOB5,JOB10,JOB20,JOB30A,JOB30B,JOB40}; + public enum Job {JOB5,JOB10,JOB20,JOB30A,JOB30B,JOB40}; String jobname; String introstring; String actionname1; @@ -131,7 +131,7 @@ public class JobsDataInfo { this.lv10buff=lv10; this.lv20buff=lv20; this.lv30_1buff=lv30_1; - this.lv30_2buff=lv30_1; + this.lv30_2buff=lv30_2; this.lv40buff=lv40; } public void setAction(int numb, String name) { diff --git a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java index af501f1..b8d557a 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java +++ b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java @@ -1936,7 +1936,11 @@ public String convertToItemName(String val) { p.sendMessage(ChatColor.GOLD+"Could not find player!"); } } - } + } else + if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 2) { + //Attempt to set the level 30 aspect of the job. + this.plugin.setLv30Choice(p,args[0],args[1]); + } else { p.sendMessage(this.invARGT2); } From b18840755968fa6a5343ccbab266be645d42db9c Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Thu, 21 Nov 2013 20:32:50 -0700 Subject: [PATCH 13/15] Forgot HP boost part of the woodcutter buff. --- .../src/me/kaZep/Base/PlayerListener.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index 11f9eb5..7a30bee 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -3273,6 +3273,23 @@ implements Listener if (findleaves) { //This is definitely a tree we can chop down. Destroy it then. //Bukkit.getLogger().info("Identified as tree. Start Destroying."); + try { + Iterator effects = p.getActivePotionEffects().iterator(); + //Figure out potion effects when player joins. + while (effects.hasNext()) { + PotionEffect nexteffect = effects.next(); + if (nexteffect.getType().getName().compareTo(PotionEffectType.HEALTH_BOOST.getName())==0) { + double myhealth = p.getHealth(); + p.removePotionEffect(PotionEffectType.HEALTH_BOOST); + p.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST,1200,nexteffect.getAmplifier()+1)); + p.setHealth(myhealth); + } + effects.remove(); + } + } catch (ConcurrentModificationException ex_e) { + Bukkit.getLogger().warning("Potion Effect Collection not accessible while initializing player speed."); + } + p.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST,1200,0)); destroyNearbyTree(e.getBlock().getWorld() ,e.getBlock().getLocation(), e.getBlock().getLocation(), (byte)(e.getBlock().getData()%4), p.getItemInHand().getEnchantmentLevel(Enchantment.SILK_TOUCH)>0); } } @@ -3640,8 +3657,9 @@ implements Listener p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 360000, nexteffect.getAmplifier()+2, true)); } if (nexteffect.getType().getName().compareTo(PotionEffectType.HEALTH_BOOST.getName())==0) { - p.removePotionEffect(PotionEffectType.HEALTH_BOOST); + double myhealth = p.getHealth(); p.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 360000, nexteffect.getAmplifier()+1, true)); + p.setHealth(myhealth); } /*if (nexteffect.getType().getName().compareTo(PotionEffectType.JUMP.getName())==0) { p.removePotionEffect(PotionEffectType.JUMP); From 32cde13d79b6e720a634f56fb9d61afb8c5d3343 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Fri, 22 Nov 2013 05:00:00 -0700 Subject: [PATCH 14/15] Miner job buffs completed. Moved account saving to a periodic interval to increase speed. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 53 +- .../src/me/kaZep/Base/PlayerListener.java | 509 +++++++++++++----- 2 files changed, 411 insertions(+), 151 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index b3ee0a9..5b373d2 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -242,7 +242,7 @@ public class Main extends JavaPlugin SERVER_TICK_TIME = getConfig().getLong("server-tick-time"); getAccountsConfig().options().copyDefaults(true); - saveAccountsConfig(); + //saveAccountsConfig() //Commented out; getConfig().set("spleefrequestatime", Integer.valueOf(0)); getConfig().set("spleefrequestbtime", Integer.valueOf(0)); @@ -545,9 +545,9 @@ public class Main extends JavaPlugin Miner_job.addData("EMERALD ORE", 0.7625, 160, 0); Miner_job.setBuffData("Automatically mines ores next to each other when one ore is mined.", "Gain Quadruple the experience from mining ores. Pickaxes gain Efficiency III.", - "Mining out ores will mine them out 3x3 blocks at a time when using diamond pickaxes. Pickaxes used gain Efficiency VI and Unbreaking IV.", + "Mining with a diamond pickaxe will mine out 3x3 blocks at a time when using diamond pickaxes. Pickaxes used gain Efficiency VI and Unbreaking IV.", "When holding a pickaxe, mobs that hit you only deal 25% damage.", - "Mining multiple ores will stack a haste buff up to Haste V for 10 seconds.", + "Mining blocks will stack a haste buff up to Haste V for 10 seconds.", "Mining ores will grant x2 the normal amount of minerals. Fortune is twice as effective, granting a possible total of x4 the normal minerals from ores."); Builder_job.setJobName("Builder"); @@ -963,6 +963,7 @@ public class Main extends JavaPlugin { getConfig().set("server-tick-time", Long.valueOf(SERVER_TICK_TIME)); saveConfig(); + saveAccountsConfig(); PluginDescriptionFile pdf = getDescription(); System.out.println("[" + pdf.getName() + "] The plugin has been disabled succesfully."); } @@ -1918,6 +1919,7 @@ public void runTick() { } } if (Main.SERVER_TICK_TIME%600==0) { + saveAccountsConfig(); if (turnedon==false && Bukkit.getWorld("world").getTime()>13000) { //Bukkit.getPlayer("sigonasr2").sendMessage("It's night now..."); turnedon=true; @@ -2330,7 +2332,7 @@ public void runTick() { newloc.setZ(51.65d); winningplayer.teleport(newloc); updateTopSPLEEFSigns(); - saveAccountsConfig(); + //saveAccountsConfig() //Commented out; } else { //We're player B. //Bukkit.broadcastMessage(ChatColor.RED+"[SPLEEF] "+ChatColor.YELLOW+getConfig().getString("spleefrequestaplayer")+" is the winner of this spleef game! "+getConfig().getString("spleefrequestbplayer")+" loses."); @@ -2380,7 +2382,7 @@ public void runTick() { newloc.setZ(51.65d); winningplayer.teleport(newloc); updateTopSPLEEFSigns(); - saveAccountsConfig(); + //saveAccountsConfig() //Commented out; } //Look for the special shovel. /* @@ -3515,7 +3517,7 @@ public void payDay(int time) } //Main.economy.depositPlayer(allOnlineP.getName(), (Main.this.getConfig().getDouble("payday.amount")*Main.economy.bankBalance(allOnlineP.getName()).balance)); } - saveAccountsConfig(); + //saveAccountsConfig() //Commented out; List expired_uuids = new ArrayList(); String moblist = getConfig().getString("fed.mobs"); String finalstring = ""; @@ -3699,7 +3701,7 @@ public void payDay(int time) if (PlayerinJob(p,job)) { if (getJobLv(job,p)>=40) { getAccountsConfig().set(p.getName().toLowerCase()+".jobs.ultimate", String.valueOf(ValidJobs[matchedjob])); - saveAccountsConfig(); + //saveAccountsConfig() //Commented out; p.sendMessage(ChatColor.YELLOW+"Set Declared Ultimate job to "+job); p.sendMessage(""); p.sendMessage(ChatColor.GOLD+""+ChatColor.ITALIC+"Unlike other buffs, you do not just receive the buff immediately. You have to earn it."); @@ -3782,7 +3784,7 @@ public void payDay(int time) getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(openslot+1), String.valueOf(ValidJobs[matchedjob])); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(openslot+1)+"lv", Integer.valueOf(1)); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(openslot+1)+"exp", Double.valueOf(0)); - saveAccountsConfig(); + //saveAccountsConfig() //Commented out; Bukkit.getLogger().info("Set job data."); Bukkit.broadcastMessage(p.getName()+" has joined the "+JobColors[matchedjob]+ValidJobs[matchedjob]+ChatColor.WHITE+" job!"); p.sendMessage("You can check out your job progress anytime with "+ChatColor.GOLD+"/jobs stats"+ChatColor.WHITE+"."); @@ -3836,7 +3838,7 @@ public void payDay(int time) val = economy.getBalance(p.getName()); economy.withdrawPlayer(p.getName(), val); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp", Double.valueOf(newexp)); - saveAccountsConfig(); + //saveAccountsConfig() //Commented out; } public void gainMoneyExp(Player p,String job,double amount,double exp) { @@ -3880,7 +3882,7 @@ public void payDay(int time) } } } - saveAccountsConfig(); + //saveAccountsConfig() //Commented out; } public void levelUpJob(Player p, String job) { @@ -3915,7 +3917,7 @@ public void payDay(int time) p.sendMessage(ChatColor.GOLD+"You have earned 1 stat point! You now have "+(((getJobTotalLvs(p)/5+1)-getStatPointTotal(p)))+" stat point"+((((getJobTotalLvs(p)/5+1)-getStatPointTotal(p)))==1?"":"s")+" to spend. "+ChatColor.ITALIC+ChatColor.BLUE+" Type /sp to spend them!"); } } - saveAccountsConfig(); + //saveAccountsConfig() //Commented out; p.getInventory().removeItem(j); } else { p.sendMessage(ChatColor.GOLD+"You can't level this job. It is already at max level."); @@ -4260,7 +4262,8 @@ public void payDay(int time) } public boolean hasJobBuff(String job, String p, Job j) { - if (PlayerinJob(p,job)) { + if (PlayerinJob(p,job) || j==Job.JOB40) { + //Bukkit.getLogger().info("Inside 1."); int slot=-1; //Check which slot contains our job. for (int i=0;i<3;i++) { @@ -4269,7 +4272,8 @@ public void payDay(int time) break; } } - if (slot!=-1) { + if (slot!=-1 || j==Job.JOB40) { + //Bukkit.getLogger().info("Inside 2. j is "+j.toString()+". ultimate: "+getAccountsConfig().getString(p.toLowerCase()+".jobs.ultimate")+", Sealed ulti:"+ getAccountsConfig().getBoolean(p.toLowerCase()+".jobs.ultimatesealed")); int level = getAccountsConfig().getInt(p.toLowerCase()+".jobs.job"+(slot+1)+"lv"); switch (j) { case JOB5: { @@ -4308,7 +4312,8 @@ public void payDay(int time) } } case JOB40: { - if (level>=40 && getAccountsConfig().getString(p.toLowerCase()+".jobs.ultimate").equalsIgnoreCase(job) && getAccountsConfig().getBoolean(p.toLowerCase()+".jobs.ultimatesealed")) { + if (getAccountsConfig().getString(p.toLowerCase()+".jobs.ultimate").equalsIgnoreCase(job) && getAccountsConfig().getBoolean(p.toLowerCase()+".jobs.ultimatesealed")) { + //Bukkit.getLogger().info("Inside 3."); return true; } else { return false; @@ -4751,9 +4756,9 @@ public void payDay(int time) //We can remove them from this job. if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))) { //Remove from job members list. - getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+"_members").replace(", "+p.getName().toLowerCase(), "")); + getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1")+"_members", getConfig().getString("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1")+"_members").replace(", "+p.getName().toLowerCase(), "")); /*Try again in case it's the only entry.*/ - getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+"_members").replace(p.getName().toLowerCase(), "")); + getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1")+"_members", getConfig().getString("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1")+"_members").replace(p.getName().toLowerCase(), "")); //Remove 1 from main config. getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"), Integer.valueOf(getConfig().getInt("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))-1)); saveConfig(); @@ -4763,14 +4768,14 @@ public void payDay(int time) getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1lv", Integer.valueOf(0)); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1_30", Integer.valueOf(0)); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1exp", Double.valueOf(0)); - saveAccountsConfig(); + //saveAccountsConfig() //Commented out; return true; } else if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))) { //Remove from job members list. - getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+"_members").replace(", "+p.getName().toLowerCase(), "")); + getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2")+"_members", getConfig().getString("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2")+"_members").replace(", "+p.getName().toLowerCase(), "")); /*Try again in case it's the only entry.*/ - getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+"_members").replace(p.getName().toLowerCase(), "")); + getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2")+"_members", getConfig().getString("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2")+"_members").replace(p.getName().toLowerCase(), "")); //Remove 1 from main config. getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"), Integer.valueOf(getConfig().getInt("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))-1)); saveConfig(); @@ -4780,14 +4785,14 @@ public void payDay(int time) getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2lv", Integer.valueOf(0)); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2_30", Integer.valueOf(0)); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2exp", Double.valueOf(0)); - saveAccountsConfig(); + //saveAccountsConfig() //Commented out; return true; } else if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))) { //Remove from job members list. - getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+"_members").replace(", "+p.getName().toLowerCase(), "")); + getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3")+"_members", getConfig().getString("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3")+"_members").replace(", "+p.getName().toLowerCase(), "")); /*Try again in case it's the only entry.*/ - getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+"_members").replace(p.getName().toLowerCase(), "")); + getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3")+"_members", getConfig().getString("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3")+"_members").replace(p.getName().toLowerCase(), "")); //Remove 1 from main config. getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"), Integer.valueOf(getConfig().getInt("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))-1)); saveConfig(); @@ -4797,7 +4802,7 @@ public void payDay(int time) getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3lv", Integer.valueOf(0)); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3_30", Integer.valueOf(0)); getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3exp", Double.valueOf(0)); - saveAccountsConfig(); + //saveAccountsConfig() //Commented out; return true; } Bukkit.broadcastMessage(ChatColor.RED+"[SEVERE]An internal error occurred, triggered by "+p.getName().toLowerCase()+"."); @@ -4913,7 +4918,7 @@ public void payDay(int time) if (getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(getJobSlot(arg1)+1)+"_30")==0) { //We are making a valid choice. getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(getJobSlot(arg1)+1)+"_30",Integer.valueOf(arg2)); - saveAccountsConfig(); + //saveAccountsConfig() //Commented out; p.sendMessage(ChatColor.GREEN+"You have set your Lv30 Buff choice for your "+arg1+" job to the "+((Integer.valueOf(arg2)==1)?"first":"second")+" version."); } else { p.sendMessage(ChatColor.RED+"Sorry, you already picked your Lv30 Buff Choice for that job! You can't change it."); diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index 6f041e7..9a96598 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -1544,7 +1544,7 @@ implements Listener this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest9", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest10", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".bonus.witherskeleton", Integer.valueOf(0)); - this.plugin.saveAccountsConfig(); + //this.plugin.saveAccountsConfig() //Commented out; System.out.println("[BankEconomy] Bank account created for " + p.getName() + "."); if (playerwhitelisted) { Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE+"New player "+ChatColor.ITALIC+ChatColor.GOLD+p.getName()+ChatColor.RESET+ChatColor.LIGHT_PURPLE+" has joined the game."); @@ -1571,11 +1571,11 @@ implements Listener this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1_30", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2_30", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3_30", Integer.valueOf(0)); - this.plugin.saveAccountsConfig(); + //this.plugin.saveAccountsConfig() //Commented out; } if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".bonus.witherskeleton")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".bonus.witherskeleton", Integer.valueOf(0)); - this.plugin.saveAccountsConfig(); + //this.plugin.saveAccountsConfig() //Commented out; } if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".stats.stat1")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat1", Integer.valueOf(0)); @@ -1588,7 +1588,7 @@ implements Listener this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat8", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat9", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat10", Integer.valueOf(0)); - this.plugin.saveAccountsConfig(); + //this.plugin.saveAccountsConfig() //Commented out; System.out.println("Updated " + p.getName() + "'s data with stat point update."); } //Update account information for notification settings. @@ -1599,7 +1599,7 @@ implements Listener this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify4", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify5", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify6", Boolean.valueOf(false)); - this.plugin.saveAccountsConfig(); + //this.plugin.saveAccountsConfig() //Commented out; System.out.println("Updated " + p.getName() + "'s data with nofitications update."); } if (this.plugin.getConfig().getBoolean("halloween-enabled")) { @@ -1615,7 +1615,7 @@ implements Listener if (!full) { if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".join.halloween_book")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".join.halloween_book", Boolean.valueOf(true)); - this.plugin.saveAccountsConfig(); + //this.plugin.saveAccountsConfig() //Commented out; System.out.println("Updated " + p.getName() + "'s data with a Halloween Book."); ItemStack book = new ItemStack(Material.WRITTEN_BOOK); BookMeta bookdata = (BookMeta)book.getItemMeta(); @@ -1633,7 +1633,7 @@ implements Listener } if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".join.halloween_vote_signs")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".join.halloween_vote_signs", Boolean.valueOf(true)); - this.plugin.saveAccountsConfig(); + //this.plugin.saveAccountsConfig() //Commented out; ItemStack sign = new ItemStack(Material.SIGN,2); ItemMeta meta = sign.getItemMeta(); meta.setDisplayName(ChatColor.BLUE+p.getName()); @@ -1657,16 +1657,16 @@ implements Listener this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest8", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest9", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest10", Boolean.valueOf(false)); - this.plugin.saveAccountsConfig(); + //this.plugin.saveAccountsConfig() //Commented out; } if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".jobs.ultimate")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimate", String.valueOf("None")); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimatesealed", Boolean.valueOf(false)); - this.plugin.saveAccountsConfig(); + //this.plugin.saveAccountsConfig() //Commented out; } if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".halloween.wand")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.wand", Long.valueOf(Main.SERVER_TICK_TIME)); - this.plugin.saveAccountsConfig(); + //this.plugin.saveAccountsConfig() //Commented out; } } //Check if this player has unallocated stat points. @@ -3172,6 +3172,215 @@ implements Listener } } } + + private void breakOreBlock(Player p, Block b) { + breakOreBlock(p, b, false); + } + + private void breakOreBlock(Player p, Block b, boolean silk_touch) { + breakOreBlock(p, b, false, 1); + } + + private void breakOreBlock(Player p, Block b, boolean silk_touch, double xp_mult) { + if (this.plugin.PlayerinJob(p, "Miner")) { + Bukkit.getLogger().info("This player is a miner."); + int myData=this.plugin.getPlayerDataSlot(p); + if (this.plugin.playerdata_list.get(myData).GoodInteract()) { + Bukkit.getLogger().info("Good interact."); + if (b.getType()==Material.STONE) { + this.plugin.gainMoneyExp(p,"Miner",0.0025,1); + } else + if (b.getType()==Material.NETHERRACK) { + this.plugin.gainMoneyExp(p,"Miner",0.005,1); + } else + if (b.getType()==Material.COAL_ORE && !silk_touch) { + this.plugin.gainMoneyExp(p,"Miner",0.0125,3); + Bukkit.getLogger().info("Coal Ore."); + } else + if (b.getType()==Material.GLOWSTONE && !silk_touch) { + this.plugin.gainMoneyExp(p,"Miner",0.015,3); + } else + if (b.getType()==Material.SANDSTONE) { + this.plugin.gainMoneyExp(p,"Miner",0.015,4); + } else + if (b.getType()==Material.NETHER_BRICK) { + this.plugin.gainMoneyExp(p,"Miner",0.02,3); + } else + if (b.getType()==Material.QUARTZ_ORE && !silk_touch) { + this.plugin.gainMoneyExp(p,"Miner",0.025,4); + } else + if (b.getType()==Material.LAPIS_ORE && !silk_touch) { + this.plugin.gainMoneyExp(p,"Miner",0.03,5); + } else + if (b.getType()==Material.MOSSY_COBBLESTONE) { + this.plugin.gainMoneyExp(p,"Miner",0.0375,8); + } else + if (b.getType()==Material.IRON_ORE && !silk_touch) { + this.plugin.gainMoneyExp(p,"Miner",0.0375,6); + } else + if ((b.getType()==Material.REDSTONE_ORE || b.getType()==Material.GLOWING_REDSTONE_ORE) && !silk_touch) { + this.plugin.gainMoneyExp(p,"Miner",0.05,9); + } else + if (b.getType()==Material.OBSIDIAN) { + this.plugin.gainMoneyExp(p,"Miner",0.0625,10); + } else + if (b.getType()==Material.GOLD_ORE && !silk_touch) { + this.plugin.gainMoneyExp(p,"Miner",0.0975,12); + } else + if (b.getType()==Material.DIAMOND_ORE && !silk_touch) { + this.plugin.gainMoneyExp(p,"Miner",0.3125,60); + } else + if (b.getType()==Material.EMERALD_ORE && !silk_touch) { + this.plugin.gainMoneyExp(p,"Miner",0.7625,160); + } + } + } + Material[] fortune_materials = {Material.EMERALD_ORE,Material.COAL_ORE,Material.DIAMOND_ORE,Material.REDSTONE_ORE,Material.GLOWING_REDSTONE_ORE,Material.LAPIS_ORE,Material.QUARTZ_ORE}; //An array of all blocks that multiply via fortune. + Material[] result_materials = {Material.EMERALD,Material.COAL,Material.DIAMOND,Material.REDSTONE,Material.REDSTONE,Material.INK_SACK,Material.QUARTZ}; //The resulting materials corresponding to the fortune blocks being broken. + boolean fortune_material=false; + int fortune_material_slot=0; + int mult = 1; + short WOOD_PICKAXE = 0, STONE_PICKAXE = 1, GOLD_PICKAXE = 2, IRON_PICKAXE = 3, DIAMOND_PICKAXE = 4; //Constants that define the pickaxe strength. + + short[] material_pickaxe_requirements = {IRON_PICKAXE,WOOD_PICKAXE,IRON_PICKAXE,IRON_PICKAXE,IRON_PICKAXE,STONE_PICKAXE,WOOD_PICKAXE}; + + short my_pickaxe_strength=-1; //-1 is some other random item / your hand. + switch (p.getItemInHand().getType()) { + case WOOD_PICKAXE:{my_pickaxe_strength = WOOD_PICKAXE;}break; + case STONE_PICKAXE:{my_pickaxe_strength = STONE_PICKAXE;}break; + case GOLD_PICKAXE:{my_pickaxe_strength = GOLD_PICKAXE;}break; + case IRON_PICKAXE:{my_pickaxe_strength = IRON_PICKAXE;}break; + case DIAMOND_PICKAXE:{my_pickaxe_strength = DIAMOND_PICKAXE;}break; + } + for (int i=0;i=WOOD_PICKAXE) { + ExperienceOrb exp = (ExperienceOrb)p.getWorld().spawnEntity(b.getLocation(), EntityType.EXPERIENCE_ORB); + exp.setExperience((int)(1*xp_mult)); + } + if (b.getType()==Material.IRON_ORE && my_pickaxe_strength>=STONE_PICKAXE) { + ExperienceOrb exp = (ExperienceOrb)p.getWorld().spawnEntity(b.getLocation(), EntityType.EXPERIENCE_ORB); + exp.setExperience((int)(1*xp_mult)); + } + if (b.getType()==Material.GOLD_ORE && my_pickaxe_strength>=IRON_PICKAXE) { + ExperienceOrb exp = (ExperienceOrb)p.getWorld().spawnEntity(b.getLocation(), EntityType.EXPERIENCE_ORB); + exp.setExperience((int)(1*xp_mult)); + } + if ((b.getType()==Material.REDSTONE_ORE || b.getType()==Material.GLOWING_REDSTONE_ORE) && my_pickaxe_strength>=IRON_PICKAXE) { + ExperienceOrb exp = (ExperienceOrb)p.getWorld().spawnEntity(b.getLocation(), EntityType.EXPERIENCE_ORB); + exp.setExperience((int)(3*xp_mult)); + } + if (b.getType()==Material.LAPIS_ORE && my_pickaxe_strength>=STONE_PICKAXE) { + ExperienceOrb exp = (ExperienceOrb)p.getWorld().spawnEntity(b.getLocation(), EntityType.EXPERIENCE_ORB); + exp.setExperience((int)(3*xp_mult)); + } + if (b.getType()==Material.DIAMOND_ORE && my_pickaxe_strength>=IRON_PICKAXE) { + ExperienceOrb exp = (ExperienceOrb)p.getWorld().spawnEntity(b.getLocation(), EntityType.EXPERIENCE_ORB); + exp.setExperience((int)(12*xp_mult)); + } + if (b.getType()==Material.EMERALD_ORE && my_pickaxe_strength>=IRON_PICKAXE) { + ExperienceOrb exp = (ExperienceOrb)p.getWorld().spawnEntity(b.getLocation(), EntityType.EXPERIENCE_ORB); + exp.setExperience((int)(28*xp_mult)); + } + if (b.getType()==Material.QUARTZ_ORE && my_pickaxe_strength>=WOOD_PICKAXE) { + ExperienceOrb exp = (ExperienceOrb)p.getWorld().spawnEntity(b.getLocation(), EntityType.EXPERIENCE_ORB); + exp.setExperience((int)(4*xp_mult)); + } + } + if (this.plugin.hasJobBuff("Miner", p, Job.JOB40)) { + mult=2; + } + if (p.getItemInHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS)>0) { //Check if the player has fortune. + if (fortune_material && my_pickaxe_strength>=material_pickaxe_requirements[fortune_material_slot]) { //If this is a fortune material, we have to account for the new fortune enchantment algorithm. Make sure we have a good enough pickaxe too. + //e.setCancelled(true); + p.getWorld().getBlockAt(b.getLocation()).setType(Material.AIR); + int fortune_level = p.getItemInHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS); + int drop_chance=50; + for (int i=1;i=material_pickaxe_requirements[fortune_material_slot]) { + //Bukkit.getLogger().info("No fortune, drop "+result_materials[fortune_material_slot].name()+" manually."); + p.getWorld().getBlockAt(b.getLocation()).setType(Material.AIR); + boolean drop_extra=false; + if (result_materials[fortune_material_slot]!=Material.REDSTONE && + result_materials[fortune_material_slot]!=Material.INK_SACK) { + //This is an item that actually just drops one of per ore. Drop normally. + p.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(result_materials[fortune_material_slot],((drop_extra)?2:1)*mult)); + } else { + if (result_materials[fortune_material_slot]==Material.REDSTONE) { //Drop redstone + p.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(result_materials[fortune_material_slot],((drop_extra)?(((int)(Math.random()*2))+4)*2:((int)(Math.random()*2))+4)*mult)); + } else {//Drop Lapis. + Item lapis = p.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(result_materials[fortune_material_slot],((drop_extra)?(((int)(Math.random()*5))+4)*2:((int)(Math.random()*5))+4)*mult,(byte)4)); + } + } + } + } + if (b.getType()==Material.IRON_ORE && !silk_touch) { + //e.setCancelled(true); + p.getWorld().getBlockAt(b.getLocation()).setType(Material.AIR); + if (my_pickaxe_strength>=STONE_PICKAXE) { + p.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.IRON_INGOT)); + } + } + if (b.getType()==Material.GOLD_ORE && !silk_touch) { + //e.setCancelled(true); + p.getWorld().getBlockAt(b.getLocation()).setType(Material.AIR); + if (my_pickaxe_strength>=IRON_PICKAXE) { + p.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.GOLD_INGOT)); + } + } + } + + private void destroyNearbyOres(World w, Player p, Location currentloc) { + destroyNearbyOres(w, p, currentloc, false, 1); + } + + private void destroyNearbyOres(World w, Player p, Location currentloc, boolean silk_touch, double xp_mult) { + //Check surrounding ores. + if (w.getBlockAt(currentloc).getType().name().toLowerCase().contains("ore")) { + breakOreBlock(p, w.getBlockAt(currentloc), silk_touch, xp_mult); + } + Location newloc = null; + for (int x=-1;x<2;x++) { + for (int y=-1;y<2;y++) { + for (int z=-1;z<2;z++) { + if (x!=0 || y!=0 || z!=0) { + //Bukkit.getLogger().info("Destroy block."); + newloc = currentloc.clone().add(x,y,z); + if (w.getBlockAt(newloc).getType().name().toLowerCase().contains("ore")) { + //Bukkit.getLogger().info("New ore, set block break."); + breakOreBlock(p, w.getBlockAt(newloc), silk_touch, xp_mult); + destroyNearbyOres(w, p, newloc, silk_touch, xp_mult); + } + } + } + } + } + } private void destroyNearbyTree(World w, Location treeNode, Location checkloc, byte type, boolean silk_touch) { //treeNode is where the original tree is located. checkloc is the current checking location. @@ -3195,7 +3404,7 @@ implements Listener if (w.getBlockAt(newloc).getData()==3) { //Jungle sapling. if (silk_touch) { - w.dropItemNaturally(newloc, new ItemStack(Material.LEAVES,1)); + w.dropItemNaturally(newloc, new ItemStack(Material.LEAVES,1,(short)(w.getBlockAt(newloc).getData()%4))); } else if (Math.random()<=0.025) { ItemStack item = new ItemStack(Material.SAPLING,1); @@ -3210,7 +3419,7 @@ implements Listener } } if (silk_touch) { - w.dropItemNaturally(newloc, new ItemStack(Material.LEAVES,1)); + w.dropItemNaturally(newloc, new ItemStack(Material.LEAVES,1,(short)(w.getBlockAt(newloc).getData()%4))); } else if (Math.random()<=0.05) { ItemStack item = new ItemStack(Material.SAPLING,1); @@ -3234,6 +3443,13 @@ implements Listener //p.sendMessage("Has name: "+p.getItemInHand().getItemMeta().hasDisplayName()); //p.sendMessage("Name is: "+p.getItemInHand().getItemMeta().getDisplayName()); + boolean has_silktouch=false; + if (!p.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { + has_silktouch=false; + } else { + has_silktouch=true; + } + //*******************************//Job Buffs Begin here! if (this.plugin.hasJobBuff("Woodcutter", p, Job.JOB20)) { if (p.getItemInHand().getType().name().toLowerCase().contains("axe") && !p.getItemInHand().getType().name().toLowerCase().contains("pickaxe")) { @@ -3293,15 +3509,104 @@ implements Listener destroyNearbyTree(e.getBlock().getWorld() ,e.getBlock().getLocation(), e.getBlock().getLocation(), (byte)(e.getBlock().getData()%4), p.getItemInHand().getEnchantmentLevel(Enchantment.SILK_TOUCH)>0); } } - //*******************************//Job Buffs end here! - int myData=this.plugin.getPlayerDataSlot(p); - boolean has_silktouch=false; - if (!p.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { - has_silktouch=false; + + if (this.plugin.hasJobBuff("Miner", p, Job.JOB5)) { + if (e.getBlock().getType().name().toLowerCase().contains("ore")) { + //Break all consecutive ores next to this ore. + //Bukkit.getLogger().info("Destroy nearby"); + e.setCancelled(true); + if (this.plugin.hasJobBuff("Miner", p, Job.JOB10)) { + destroyNearbyOres(e.getBlock().getWorld(), p, e.getBlock().getLocation(), has_silktouch, 4); + } else { + destroyNearbyOres(e.getBlock().getWorld(), p, e.getBlock().getLocation(), has_silktouch, 1); + } + if (this.plugin.hasJobBuff("Miner", p, Job.JOB30B)) { + try { + Iterator effects = p.getActivePotionEffects().iterator(); + //Figure out potion effects when player joins. + while (effects.hasNext()) { + PotionEffect nexteffect = effects.next(); + if (nexteffect.getType().getName().compareTo(PotionEffectType.FAST_DIGGING.getName())==0 && nexteffect.getAmplifier()<4) { + p.removePotionEffect(PotionEffectType.FAST_DIGGING); + p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 200, nexteffect.getAmplifier()+1, true)); + } + /*if (nexteffect.getType().getName().compareTo(PotionEffectType.JUMP.getName())==0) { + p.removePotionEffect(PotionEffectType.JUMP); + p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 360000, nexteffect.getAmplifier()+2, true)); + }*/ + effects.remove(); + } + } catch (ConcurrentModificationException ex_e) { + Bukkit.getLogger().warning("Potion Effect Collection not accessible while initializing player speed."); + } + p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 200, 0, true)); + } + } else { + if (e.getBlock().getType()==Material.STONE || e.getBlock().getType()==Material.COBBLESTONE) { + if (this.plugin.hasJobBuff("Miner", p, Job.JOB30B)) { + try { + Iterator effects = p.getActivePotionEffects().iterator(); + //Figure out potion effects when player joins. + while (effects.hasNext()) { + PotionEffect nexteffect = effects.next(); + if (nexteffect.getType().getName().compareTo(PotionEffectType.FAST_DIGGING.getName())==0 && nexteffect.getAmplifier()<4) { + p.removePotionEffect(PotionEffectType.FAST_DIGGING); + p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 200, nexteffect.getAmplifier()+1, true)); + } + /*if (nexteffect.getType().getName().compareTo(PotionEffectType.JUMP.getName())==0) { + p.removePotionEffect(PotionEffectType.JUMP); + p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 360000, nexteffect.getAmplifier()+2, true)); + }*/ + effects.remove(); + } + } catch (ConcurrentModificationException ex_e) { + Bukkit.getLogger().warning("Potion Effect Collection not accessible while initializing player speed."); + } + p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 200, 0, true)); + } + } + if (this.plugin.hasJobBuff("Miner", p, Job.JOB20)) { + if (p.getItemInHand().getType()==Material.DIAMOND_PICKAXE && (e.getBlock().getType()==Material.STONE || e.getBlock().getType()==Material.COBBLESTONE)) { + for (int i=-1;i<2;i++) { + for (int j=-1;j<2;j++) { + for (int k=-1;k<2;k++) { + if (e.getBlock().getLocation().add(i,j,k).getBlock().getType().name().toLowerCase().contains("ore")) { + destroyNearbyOres(e.getBlock().getWorld(), p, e.getBlock().getLocation(), has_silktouch, 4); + } else { + if (this.plugin.PlayerinJob(p, "Miner")) { + int myData=this.plugin.getPlayerDataSlot(p); + if (this.plugin.playerdata_list.get(myData).GoodInteract()) { + if (e.getBlock().getType()==Material.STONE) { + this.plugin.gainMoneyExp(p,"Miner",0.0025,1); + } + } + } + if (e.getBlock().getLocation().add(i,j,k).getBlock().getType()==Material.STONE || e.getBlock().getLocation().add(i,j,k).getBlock().getType()==Material.COBBLESTONE) { + if (has_silktouch) { + e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().add(i,j,k), new ItemStack(e.getBlock().getLocation().add(i,j,k).getBlock().getType())); + } else { + e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().add(i,j,k), new ItemStack(Material.COBBLESTONE)); + } + e.getBlock().getLocation().add(i,j,k).getBlock().setType(Material.AIR); + } + } + } + } + } + } + } + } } else { - has_silktouch=true; + if (e.getBlock().getType().name().toLowerCase().contains("ore")) { + //Mine it out normally for other players. + e.setCancelled(true); + breakOreBlock(p, e.getBlock(), has_silktouch); + } } + //*******************************//Job Buffs end here! + + int myData=this.plugin.getPlayerDataSlot(p); if (p!=null) { if (e.getBlock().getType()==Material.COMMAND) { e.setCancelled(true); @@ -3518,13 +3823,15 @@ implements Listener this.plugin.playerdata_list.get(myData).BadInteract(e.getBlock().getType()); } if (this.plugin.PlayerinJob(p, "Woodcutter")) { - if (e.getBlock().getType()==Material.LOG) { - if (p.getItemInHand().getType()==Material.WOOD_AXE || p.getItemInHand().getType()==Material.STONE_AXE || p.getItemInHand().getType()==Material.IRON_AXE || p.getItemInHand().getType()==Material.GOLD_AXE || p.getItemInHand().getType()==Material.DIAMOND_AXE) { - //p.sendMessage("Cut down wood w/axe."); - this.plugin.gainMoneyExp(p,"Woodcutter",0.025,2); - } else { - //p.sendMessage("Cut down wood."); - this.plugin.gainMoneyExp(p,"Woodcutter",0.01,1); + if (this.plugin.playerdata_list.get(myData).GoodInteract()) { + if (e.getBlock().getType()==Material.LOG) { + if (p.getItemInHand().getType()==Material.WOOD_AXE || p.getItemInHand().getType()==Material.STONE_AXE || p.getItemInHand().getType()==Material.IRON_AXE || p.getItemInHand().getType()==Material.GOLD_AXE || p.getItemInHand().getType()==Material.DIAMOND_AXE) { + //p.sendMessage("Cut down wood w/axe."); + this.plugin.gainMoneyExp(p,"Woodcutter",0.025,2); + } else { + //p.sendMessage("Cut down wood."); + this.plugin.gainMoneyExp(p,"Woodcutter",0.01,1); + } } } } @@ -3667,7 +3974,6 @@ implements Listener }*/ effects.remove(); } - } catch (ConcurrentModificationException ex_e) { Bukkit.getLogger().warning("Potion Effect Collection not accessible while initializing player speed."); } @@ -3706,83 +4012,6 @@ implements Listener p.updateInventory(); } } - Material[] fortune_materials = {Material.EMERALD_ORE,Material.COAL_ORE,Material.DIAMOND_ORE,Material.REDSTONE_ORE,Material.LAPIS_ORE,Material.QUARTZ_ORE}; //An array of all blocks that multiply via fortune. - Material[] result_materials = {Material.EMERALD,Material.COAL,Material.DIAMOND,Material.REDSTONE,Material.INK_SACK,Material.QUARTZ}; //The resulting materials corresponding to the fortune blocks being broken. - boolean fortune_material=false; - int fortune_material_slot=0; - for (int i=0;i0) { //Check if the player has fortune. - if (fortune_material) { //If this is a fortune material, we have to account for the new fortune enchantment algorithm. - e.setCancelled(true); - e.getPlayer().getWorld().getBlockAt(e.getBlock().getLocation()).setType(Material.AIR); - int fortune_level = p.getItemInHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS); - int drop_chance=50; - for (int i=1;i Date: Sat, 23 Nov 2013 02:09:20 -0700 Subject: [PATCH 15/15] Starting Builder job buff updates. --- BankEconomyMod/plugin.yml | 6 ++- BankEconomyMod/src/me/kaZep/Base/Main.java | 2 + .../src/me/kaZep/Base/PlayerListener.java | 9 ++-- .../me/kaZep/Commands/commandBankEconomy.java | 42 +++++++++++++++++++ 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/BankEconomyMod/plugin.yml b/BankEconomyMod/plugin.yml index 21ee3a0..e295dcb 100644 --- a/BankEconomyMod/plugin.yml +++ b/BankEconomyMod/plugin.yml @@ -24,4 +24,8 @@ commands: event: description: Toggles or untoggles events. ticktime: - description: Displays the server tick time. \ No newline at end of file + description: Displays the server tick time. + line: + description: Gives the player a line builder tool. + rectangle: + description: Gives the player a rectangle builder tool. \ No newline at end of file diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index 5b373d2..175eb2a 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -224,6 +224,8 @@ public class Main extends JavaPlugin getCommand("event").setExecutor(new commandBankEconomy(this)); //getCommand("dungeon").setExecutor(new commandBankEconomy(this)); getCommand("ticktime").setExecutor(new commandBankEconomy(this)); + getCommand("line").setExecutor(new commandBankEconomy(this)); + getCommand("rectangle").setExecutor(new commandBankEconomy(this)); setupEconomy(); diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index 9a96598..4b285f7 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -19,9 +19,6 @@ import net.milkbowl.vault.economy.EconomyResponse; //import net.minecraft.server.v1_4_R1.EntityWolf; - - - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Chunk; @@ -3183,10 +3180,10 @@ implements Listener private void breakOreBlock(Player p, Block b, boolean silk_touch, double xp_mult) { if (this.plugin.PlayerinJob(p, "Miner")) { - Bukkit.getLogger().info("This player is a miner."); + //Bukkit.getLogger().info("This player is a miner."); int myData=this.plugin.getPlayerDataSlot(p); if (this.plugin.playerdata_list.get(myData).GoodInteract()) { - Bukkit.getLogger().info("Good interact."); + //Bukkit.getLogger().info("Good interact."); if (b.getType()==Material.STONE) { this.plugin.gainMoneyExp(p,"Miner",0.0025,1); } else @@ -3195,7 +3192,7 @@ implements Listener } else if (b.getType()==Material.COAL_ORE && !silk_touch) { this.plugin.gainMoneyExp(p,"Miner",0.0125,3); - Bukkit.getLogger().info("Coal Ore."); + //Bukkit.getLogger().info("Coal Ore."); } else if (b.getType()==Material.GLOWSTONE && !silk_touch) { this.plugin.gainMoneyExp(p,"Miner",0.015,3); diff --git a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java index b8d557a..4e5fdab 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java +++ b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import me.kaZep.Base.Main; +import me.kaZep.Commands.JobsDataInfo.Job; import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; @@ -441,6 +442,47 @@ public String convertToItemName(String val) { p.sendMessage("Enchantments and bonuses removed on this item."); } else + if (cmd.getName().equalsIgnoreCase("line")) { + if (this.plugin.hasJobBuff("Builder", p, Job.JOB5)) { + p.sendMessage("You have received a line builder tool."); + ItemStack i = new ItemStack(Material.getMaterial(141)); + ItemMeta meta = i.getItemMeta(); + meta.setDisplayName(ChatColor.GRAY+"Line Builder Tool"); + List newlore = new ArrayList(); + newlore.add(ChatColor.YELLOW+"Can only be used by Lv5+ Builders."); + newlore.add(ChatColor.YELLOW+""); + newlore.add("Left-click one block and another"); + newlore.add("of the same type to create a line"); + newlore.add("of blocks. "+ChatColor.BLUE+"(Max Range: 500 blocks)"); + meta.setLore(newlore); + i.setItemMeta(meta); + p.getInventory().addItem(i); + } else { + p.sendMessage(ChatColor.RED+"You do not have the Lv5 Builder Buff!"); + } + } + else + if (cmd.getName().equalsIgnoreCase("rectangle")) { + if (this.plugin.hasJobBuff("Builder", p, Job.JOB10)) { + p.sendMessage("You have received a rectangle builder tool."); + ItemStack i = new ItemStack(Material.getMaterial(142)); + ItemMeta meta = i.getItemMeta(); + meta.setDisplayName(ChatColor.GRAY+"Rectangle Builder Tool"); + List newlore = new ArrayList(); + newlore.add(ChatColor.YELLOW+"Can only be used by Lv10+ Builders."); + newlore.add(ChatColor.YELLOW+""); + newlore.add("Left-click one block and another"); + newlore.add("of the same type to fill a"); + newlore.add("rectangle of blocks."); + newlore.add(ChatColor.BLUE+" (Max Range: 500 blocks)"); + meta.setLore(newlore); + i.setItemMeta(meta); + p.getInventory().addItem(i); + } else { + p.sendMessage(ChatColor.RED+"You do not have the Lv10 Builder Buff!"); + } + } + else if (cmd.getName().equalsIgnoreCase("ticktime")) { p.sendMessage("Current Server Time: "+ChatColor.GRAY+""+ChatColor.ITALIC+Main.SERVER_TICK_TIME); }