Add in proper unenchanting. Make sure Weak armor does not lose its

properties via enchanting / unenchanting.
anvil_rework
sigonasr2 11 years ago
parent e4e6b8665e
commit 6cea6022c3
  1. 16
      BankEconomyMod/src/me/kaZep/Base/PlayerListener.java
  2. 15
      BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java

@ -461,9 +461,11 @@ public class PlayerListener
if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts.
List<String> thelore = e.getItem().getItemMeta().getLore();
for (int i=0;i<thelore.size();i++) {
if (thelore.get(i).contains(ChatColor.RED+"-400% Durability")) {
ourLore.add(thelore.get(i));
}
}
}
if (Math.random()<=0.2) {
ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Critical Chance");
} else
@ -494,9 +496,11 @@ public class PlayerListener
if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts.
List<String> thelore = e.getItem().getItemMeta().getLore();
for (int i=0;i<thelore.size();i++) {
if (thelore.get(i).contains(ChatColor.RED+"-400% Durability")) {
ourLore.add(thelore.get(i));
}
}
}
if (Math.random()<=0.2) {
ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Critical Chance");
} else
@ -529,9 +533,11 @@ public class PlayerListener
if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts.
List<String> thelore = e.getItem().getItemMeta().getLore();
for (int i=0;i<thelore.size();i++) {
if (thelore.get(i).contains(ChatColor.RED+"-400% Durability")) {
ourLore.add(thelore.get(i));
}
}
}
if (Math.random()<=0.2) {
ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+1)+"% "+ChatColor.BLUE+"Critical Chance");
} else
@ -561,9 +567,11 @@ public class PlayerListener
if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts.
List<String> thelore = e.getItem().getItemMeta().getLore();
for (int i=0;i<thelore.size();i++) {
if (thelore.get(i).contains(ChatColor.RED+"-400% Durability")) {
ourLore.add(thelore.get(i));
}
}
}
if (Math.random()<=0.2) {
ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*4)+1)+" "+ChatColor.BLUE+"Health");
} else
@ -602,9 +610,11 @@ public class PlayerListener
if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts.
List<String> thelore = e.getItem().getItemMeta().getLore();
for (int i=0;i<thelore.size();i++) {
if (thelore.get(i).contains(ChatColor.RED+"-400% Durability")) {
ourLore.add(thelore.get(i));
}
}
}
if (Math.random()<=0.2) {
ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance");
}
@ -635,9 +645,11 @@ public class PlayerListener
if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts.
List<String> thelore = e.getItem().getItemMeta().getLore();
for (int i=0;i<thelore.size();i++) {
if (thelore.get(i).contains(ChatColor.RED+"-400% Durability")) {
ourLore.add(thelore.get(i));
}
}
}
if (Math.random()<=0.2) {
ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance");
}
@ -679,9 +691,11 @@ public class PlayerListener
if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts.
List<String> thelore = e.getItem().getItemMeta().getLore();
for (int i=0;i<thelore.size();i++) {
if (thelore.get(i).contains(ChatColor.RED+"-400% Durability")) {
ourLore.add(thelore.get(i));
}
}
}
if (Math.random()<=0.2) {
ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*20)+1)+"% "+ChatColor.BLUE+"Critical Chance");
}
@ -711,9 +725,11 @@ public class PlayerListener
if (e.getItem().hasItemMeta() && e.getItem().getItemMeta().getLore()!=null) { //Check the lore for any weak item conflicts.
List<String> thelore = e.getItem().getItemMeta().getLore();
for (int i=0;i<thelore.size();i++) {
if (thelore.get(i).contains(ChatColor.RED+"-400% Durability")) {
ourLore.add(thelore.get(i));
}
}
}
if (Math.random()<=0.2) {
ourLore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*6)+1)+" "+ChatColor.BLUE+"Health");
}

@ -425,7 +425,20 @@ public String convertToItemName(String val) {
for (Map.Entry<Enchantment,Integer> entry : map.entrySet()) {
p.getItemInHand().removeEnchantment(entry.getKey());
}
p.sendMessage("Enchantments removed on this item.");
if (p.getItemInHand().hasItemMeta() && p.getItemInHand().getItemMeta().hasLore()) {
List<String> newlore = new ArrayList<String>();
for (int i=0;i<p.getItemInHand().getItemMeta().getLore().size();i++) {
//Remove all lore when unenchanting.
//Do not remove -400% durability.
if (p.getItemInHand().getItemMeta().getLore().get(i).contains(ChatColor.RED+"-400% Durability")) {
newlore.add(p.getItemInHand().getItemMeta().getLore().get(i));
}
}
ItemMeta meta = p.getItemInHand().getItemMeta();
meta.setLore(newlore);
p.getItemInHand().setItemMeta(meta);
}
p.sendMessage("Enchantments and bonuses removed on this item.");
}
else
if (cmd.getName().equalsIgnoreCase("ticktime")) {

Loading…
Cancel
Save