diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/Version.java b/src/main/java/com/gamingmesh/jobs/CMILib/Version.java index 098d7803..4372c54b 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/Version.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/Version.java @@ -37,14 +37,14 @@ public enum Version { private Integer value; private String shortVersion; - private static Version current = null; + private static Version current; Version() { try { - this.value = Integer.valueOf(this.name().replaceAll("[^\\d.]", "")); + value = Integer.parseInt(name().replaceAll("[^\\d.]", "")); } catch (Exception e) { } - shortVersion = this.name().substring(0, this.name().length() - 3); + shortVersion = name().substring(0, name().length() - 3); } public Integer getValue() { @@ -58,6 +58,7 @@ public enum Version { public static Version getCurrent() { if (current != null) return current; + String[] v = Bukkit.getServer().getClass().getPackage().getName().split("\\."); String vv = v[v.length - 1]; for (Version one : values()) { diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 99549b2b..93bc6bee 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -897,24 +897,19 @@ public class JobsPaymentListener implements Listener { return; } - if (Jobs.getGCManager().PayForEnchantingOnAnvil && inv.getItem(1) != null && inv.getItem(1).getType() == Material.ENCHANTED_BOOK) { + ItemStack secondSlotItem = inv.getItem(1); + + if (Jobs.getGCManager().PayForEnchantingOnAnvil && secondSlotItem != null && secondSlotItem.getType() == Material.ENCHANTED_BOOK) { for (Entry oneEnchant : resultStack.getEnchantments().entrySet()) { Enchantment enchant = oneEnchant.getKey(); if (enchant == null) continue; CMIEnchantment e = CMIEnchantment.get(enchant); - String enchantName = e == null ? null : e.toString(); - if (enchantName == null) - continue; - - Integer level = oneEnchant.getValue(); - if (level == null) - continue; - - Jobs.action(jPlayer, new EnchantActionInfo(enchantName, level, ActionType.ENCHANT)); + if (e != null) + Jobs.action(jPlayer, new EnchantActionInfo(e.toString(), oneEnchant.getValue(), ActionType.ENCHANT)); } - } else + } else if (secondSlotItem == null || secondSlotItem.getType() != Material.ENCHANTED_BOOK) // Enchanted books does not have durability Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR)); }