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. 32
      BankEconomyMod/src/me/kaZep/Base/PlayerListener.java
  2. 15
      BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java

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

@ -425,7 +425,20 @@ public String convertToItemName(String val) {
for (Map.Entry<Enchantment,Integer> entry : map.entrySet()) { for (Map.Entry<Enchantment,Integer> entry : map.entrySet()) {
p.getItemInHand().removeEnchantment(entry.getKey()); 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 else
if (cmd.getName().equalsIgnoreCase("ticktime")) { if (cmd.getName().equalsIgnoreCase("ticktime")) {

Loading…
Cancel
Save