From 26d4b33a833e586519149a35eda8ffe18324963f Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Fri, 6 Dec 2013 15:50:38 -0700 Subject: [PATCH] Logic fixes, minor typos to durability system. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 4 +- .../src/me/kaZep/Base/PlayerListener.java | 150 ++++++++++-------- 2 files changed, 84 insertions(+), 70 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index 4e464fb..d0f08fd 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -4892,7 +4892,7 @@ public void payDay(int time) } public boolean containsEnchantment(String s, String enchant) { - if (s.contains(enchant)) { + if (s.contains(enchant) && (!enchant.equals("Durability") || (enchant.equals("Durability") && !s.contains(ChatColor.RED+"-400% Durability")))) { return true; } return false; @@ -5097,7 +5097,7 @@ public void payDay(int time) public double getEnchantmentNumb(String s) { //Parse the string for spaces. String[] enchant = s.split(" "); - if (enchant[0].contains(ChatColor.YELLOW+"")) { + if (!s.contains(ChatColor.RED+"-400% Durability") && 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)); return Double.valueOf(newstring); diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index 710a77b..3fbead6 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -9515,6 +9515,14 @@ implements Listener for (int i=0;i0) { double olddmg=e.getDamage(); e.setDamage(e.getDamage()*(((100-this.plugin.getStatBonus(2, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat3")/4))/100.0d))); @@ -10345,32 +10354,32 @@ implements Listener final boolean blocked = blocked_attack; final boolean blocked_hunter = blocked_hunter_buff; final Main plug = this.plugin; - p.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - @Override - public void run() { - //This player lost durability, we will attempt to give it back based on certain conditions. - //CASE 1: The player actually loses more durability if it's weak armor. - //CASE 2: The player gains back -1 durability if they have +X% Durability. The chance of it occuring is Math.random()*X<=100 - //CASE 3: The amount lost by the blocking stat has the possibility to be gained back. - int helm_dura=-1,chest_dura=-1,legs_dura=-1,boots_dura=-1; - boolean weak_helm=false,weak_chest=false,weak_legs=false,weak_boots=false; - if (p.getEquipment().getHelmet()!=null) {helm_dura=p.getEquipment().getHelmet().getDurability();} - if (p.getEquipment().getChestplate()!=null) {chest_dura=p.getEquipment().getChestplate().getDurability();} - if (p.getEquipment().getLeggings()!=null) {legs_dura=p.getEquipment().getLeggings().getDurability();} - if (p.getEquipment().getBoots()!=null) {boots_dura=p.getEquipment().getBoots().getDurability();} - Bukkit.getLogger().info("Durability of items are: "+helm_dura+","+chest_dura+","+legs_dura+","+boots_dura); - int gained_back=0; - if (!blocked_hunter && blocked) { + if (p.getNoDamageTicks() lore = p.getEquipment().getHelmet().getItemMeta().getLore(); for (int i=0;i lore = p.getEquipment().getChestplate().getItemMeta().getLore(); for (int i=0;i lore = p.getEquipment().getLeggings().getItemMeta().getLore(); for (int i=0;i lore = p.getEquipment().getBoots().getItemMeta().getLore(); for (int i=0;i lore = p.getEquipment().getHelmet().getItemMeta().getLore(); - for (int i=0;i lore = p.getEquipment().getHelmet().getItemMeta().getLore(); + for (int i=0;i100) { helm_dura-=1; } } } - } - if (p.getEquipment().getChestplate()!=null && p.getEquipment().getChestplate().hasItemMeta() && - p.getEquipment().getChestplate().getItemMeta().hasLore()) { - List lore = p.getEquipment().getChestplate().getItemMeta().getLore(); - for (int i=0;i lore = p.getEquipment().getChestplate().getItemMeta().getLore(); + for (int i=0;i100) { chest_dura-=1; } } } - } - if (p.getEquipment().getLeggings()!=null && p.getEquipment().getLeggings().hasItemMeta() && - p.getEquipment().getLeggings().getItemMeta().hasLore()) { - List lore = p.getEquipment().getLeggings().getItemMeta().getLore(); - for (int i=0;i lore = p.getEquipment().getLeggings().getItemMeta().getLore(); + for (int i=0;i100) { legs_dura-=1; } } } - } - if (p.getEquipment().getBoots()!=null && p.getEquipment().getBoots().hasItemMeta() && - p.getEquipment().getBoots().getItemMeta().hasLore()) { - List lore = p.getEquipment().getBoots().getItemMeta().getLore(); - for (int i=0;i lore = p.getEquipment().getBoots().getItemMeta().getLore(); + for (int i=0;i100) { boots_dura-=1; } } } + if (p.getEquipment().getBoots()!=null) {ItemStack i = p.getEquipment().getBoots(); i.setDurability((short)boots_dura); p.getEquipment().setBoots(i);} + if (p.getEquipment().getLeggings()!=null) {ItemStack i = p.getEquipment().getLeggings(); i.setDurability((short)legs_dura); p.getEquipment().setLeggings(i);} + if (p.getEquipment().getChestplate()!=null) {ItemStack i = p.getEquipment().getChestplate(); i.setDurability((short)chest_dura); p.getEquipment().setChestplate(i);} + if (p.getEquipment().getHelmet()!=null) {ItemStack i = p.getEquipment().getHelmet(); i.setDurability((short)helm_dura); p.getEquipment().setHelmet(i);} + Bukkit.getLogger().info("Durability of items now are: "+helm_dura+","+chest_dura+","+legs_dura+","+boots_dura); } - if (p.getEquipment().getBoots()!=null) {ItemStack i = p.getEquipment().getBoots(); i.setDurability((short)boots_dura); p.getEquipment().setBoots(i);} - if (p.getEquipment().getLeggings()!=null) {ItemStack i = p.getEquipment().getLeggings(); i.setDurability((short)legs_dura); p.getEquipment().setLeggings(i);} - if (p.getEquipment().getChestplate()!=null) {ItemStack i = p.getEquipment().getChestplate(); i.setDurability((short)chest_dura); p.getEquipment().setChestplate(i);} - if (p.getEquipment().getHelmet()!=null) {ItemStack i = p.getEquipment().getHelmet(); i.setDurability((short)helm_dura); p.getEquipment().setHelmet(i);} - Bukkit.getLogger().info("Durability of items now are: "+helm_dura+","+chest_dura+","+legs_dura+","+boots_dura); - } - },1); + },1); + } } }