mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +01:00
Fix when enchanting an elytra with a book get paid without Enchant action
Fixes #1104
This commit is contained in:
parent
fc5c5bfd08
commit
846e04539a
@ -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()) {
|
||||
|
@ -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<Enchantment, Integer> 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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user