Logic fixes, minor typos to durability system.

dev
sigonasr2 11 years ago
parent a53cfaf67b
commit 26d4b33a83
  1. 4
      BankEconomyMod/src/me/kaZep/Base/Main.java
  2. 70
      BankEconomyMod/src/me/kaZep/Base/PlayerListener.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);

@ -9515,6 +9515,14 @@ implements Listener
for (int i=0;i<p.getEquipment().getArmorContents().length;i++) {
if (p.getEquipment().getArmorContents()[i]!=null && !this.plugin.isBroken(p.getEquipment().getArmorContents()[i]) && p.getEquipment().getArmorContents()[i].getItemMeta()!=null && p.getEquipment().getArmorContents()[i].getItemMeta().getLore()!=null) {
for (int j=0;j<p.getEquipment().getArmorContents()[i].getItemMeta().getLore().size();j++) {
if (this.plugin.containsEnchantment(p.getEquipment().getArmorContents()[i].getItemMeta().getLore().get(j), "Block Chance")) {
Bukkit.getLogger().info("Block chance check is "+this.plugin.getEnchantmentNumb(p.getEquipment().getArmorContents()[i].getItemMeta().getLore().get(j)));
if (block_chance==0) {
block_chance+=this.plugin.getEnchantmentNumb(p.getEquipment().getArmorContents()[i].getItemMeta().getLore().get(j));
} else {
block_chance+=(100-block_chance)*(this.plugin.getEnchantmentNumb(p.getEquipment().getArmorContents()[i].getItemMeta().getLore().get(j))/100.0d);
}
}
if (this.plugin.containsEnchantment(p.getEquipment().getArmorContents()[i].getItemMeta().getLore().get(j), "Damage Reduction")) {
e.setDamage(e.getDamage()*(1-(this.plugin.getEnchantmentNumb(p.getEquipment().getArmorContents()[i].getItemMeta().getLore().get(j))/100.0d)));
}
@ -9572,10 +9580,11 @@ implements Listener
}break;
}
}*/
p.playSound(p.getLocation(), Sound.ANVIL_LAND, 0.1f, 3.6f);
e.setCancelled(true);
}
//Bukkit.getLogger().info("Made it through 4.");
p.updateInventory();
//p.updateInventory();
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().toLowerCase()+".stats.stat3")/4))/100.0d)));
@ -10345,7 +10354,8 @@ 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() {
if (p.getNoDamageTicks()<p.getMaximumNoDamageTicks()/2.0f) {
p.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() {
@Override
public void run() {
//This player lost durability, we will attempt to give it back based on certain conditions.
@ -10360,17 +10370,16 @@ implements Listener
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.getEquipment().getHelmet()!=null && p.getEquipment().getHelmet().hasItemMeta() &&
p.getEquipment().getHelmet().getItemMeta().hasLore()) {
List<String> lore = p.getEquipment().getHelmet().getItemMeta().getLore();
for (int i=0;i<lore.size();i++) {
if (plug.containsEnchantment(lore.get(i), ChatColor.RED+"-400% Durability")) {
if (lore.get(i).contains(ChatColor.RED+"-400% Durability")) {
helm_dura+=3;
weak_helm=true;
}
if (plug.containsEnchantment(lore.get(i), "Block Chance")) {
helm_dura+=1;
if (!blocked_hunter && blocked && plug.containsEnchantment(lore.get(i), "Block Chance")) {
helm_dura+=3;
}
}
}
@ -10378,12 +10387,12 @@ implements Listener
p.getEquipment().getChestplate().getItemMeta().hasLore()) {
List<String> lore = p.getEquipment().getChestplate().getItemMeta().getLore();
for (int i=0;i<lore.size();i++) {
if (plug.containsEnchantment(lore.get(i), ChatColor.RED+"-400% Durability")) {
if (lore.get(i).contains(ChatColor.RED+"-400% Durability")) {
chest_dura+=3;
weak_chest=true;
}
if (plug.containsEnchantment(lore.get(i), "Block Chance")) {
chest_dura+=1;
if (!blocked_hunter && blocked && plug.containsEnchantment(lore.get(i), "Block Chance")) {
chest_dura+=3;
}
}
}
@ -10391,12 +10400,13 @@ implements Listener
p.getEquipment().getLeggings().getItemMeta().hasLore()) {
List<String> lore = p.getEquipment().getLeggings().getItemMeta().getLore();
for (int i=0;i<lore.size();i++) {
if (plug.containsEnchantment(lore.get(i), ChatColor.RED+"-400% Durability")) {
if (lore.get(i).contains(ChatColor.RED+"-400% Durability")) {
legs_dura+=3;
weak_legs=true;
}
if (plug.containsEnchantment(lore.get(i), "Block Chance")) {
legs_dura+=1;
if (!blocked_hunter && blocked && plug.containsEnchantment(lore.get(i), "Block Chance")) {
Bukkit.getLogger().info("Leggings Block Chance.");
legs_dura+=3;
}
}
}
@ -10404,13 +10414,12 @@ implements Listener
p.getEquipment().getBoots().getItemMeta().hasLore()) {
List<String> lore = p.getEquipment().getBoots().getItemMeta().getLore();
for (int i=0;i<lore.size();i++) {
if (plug.containsEnchantment(lore.get(i), ChatColor.RED+"-400% Durability")) {
if (lore.get(i).contains(ChatColor.RED+"-400% Durability")) {
boots_dura+=3;
weak_boots=true;
}
if (plug.containsEnchantment(lore.get(i), "Block Chance")) {
boots_dura+=1;
}
if (!blocked_hunter && blocked && plug.containsEnchantment(lore.get(i), "Block Chance")) {
boots_dura+=3;
}
}
}
@ -10418,54 +10427,58 @@ implements Listener
p.getEquipment().getHelmet().getItemMeta().hasLore()) {
List<String> lore = p.getEquipment().getHelmet().getItemMeta().getLore();
for (int i=0;i<lore.size();i++) {
double dura_numb=0;
if (plug.containsEnchantment(lore.get(i), "Durability")) {
double dura_numb=plug.getEnchantmentNumb("Durability");
if (!weak_helm) {dura_numb+=300;}
dura_numb+=plug.getEnchantmentNumb("Durability");
}
if (!weak_helm) {dura_numb+=300; /*Bukkit.getLogger().info("1 not weak.");*/}
if (Math.random()*dura_numb>100) {
helm_dura-=1;
}
}
}
}
if (p.getEquipment().getChestplate()!=null && p.getEquipment().getChestplate().hasItemMeta() &&
p.getEquipment().getChestplate().getItemMeta().hasLore()) {
List<String> lore = p.getEquipment().getChestplate().getItemMeta().getLore();
for (int i=0;i<lore.size();i++) {
double dura_numb=0;
if (plug.containsEnchantment(lore.get(i), "Durability")) {
double dura_numb=plug.getEnchantmentNumb("Durability");
if (!weak_chest) {dura_numb+=300;}
dura_numb+=plug.getEnchantmentNumb("Durability");
}
if (!weak_chest) {dura_numb+=300; /*Bukkit.getLogger().info("2 not weak.");*/}
if (Math.random()*dura_numb>100) {
chest_dura-=1;
}
}
}
}
if (p.getEquipment().getLeggings()!=null && p.getEquipment().getLeggings().hasItemMeta() &&
p.getEquipment().getLeggings().getItemMeta().hasLore()) {
List<String> lore = p.getEquipment().getLeggings().getItemMeta().getLore();
for (int i=0;i<lore.size();i++) {
double dura_numb=0;
if (plug.containsEnchantment(lore.get(i), "Durability")) {
double dura_numb=plug.getEnchantmentNumb("Durability");
if (!weak_legs) {dura_numb+=300;}
dura_numb+=plug.getEnchantmentNumb("Durability");
}
if (!weak_legs) {dura_numb+=300; /*Bukkit.getLogger().info("3 not weak.");*/}
if (Math.random()*dura_numb>100) {
legs_dura-=1;
}
}
}
}
if (p.getEquipment().getBoots()!=null && p.getEquipment().getBoots().hasItemMeta() &&
p.getEquipment().getBoots().getItemMeta().hasLore()) {
List<String> lore = p.getEquipment().getBoots().getItemMeta().getLore();
for (int i=0;i<lore.size();i++) {
double dura_numb=0;
if (plug.containsEnchantment(lore.get(i), "Durability")) {
double dura_numb=plug.getEnchantmentNumb("Durability");
if (!weak_boots) {dura_numb+=300;}
dura_numb+=plug.getEnchantmentNumb("Durability");
}
if (!weak_boots) {dura_numb+=300; /*Bukkit.getLogger().info("4 not weak.");*/}
if (Math.random()*dura_numb>100) {
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);}
@ -10475,6 +10488,7 @@ implements Listener
},1);
}
}
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {

Loading…
Cancel
Save