mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 23:13:48 +01:00
Consistent enchantment name handling between anvil and enchanting table enchanting
This commit is contained in:
parent
52547b94a5
commit
a3ee77e70d
@ -840,6 +840,19 @@ public final class JobsPaymentListener implements Listener {
|
|||||||
return a.getAmount() + b.getAmount() <= a.getType().getMaxStackSize();
|
return a.getAmount() + b.getAmount() <= a.getType().getMaxStackSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getEnchantName(Enchantment enchant) {
|
||||||
|
try {
|
||||||
|
return enchant.getKey().getKey().toLowerCase().replace("_", "").replace("minecraft:", "");
|
||||||
|
|
||||||
|
} catch (Throwable e) {
|
||||||
|
CMIEnchantment cmiEnchant = CMIEnchantment.get(enchant);
|
||||||
|
if (cmiEnchant != null)
|
||||||
|
return cmiEnchant.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onInventoryRepair(InventoryClickEvent event) {
|
public void onInventoryRepair(InventoryClickEvent event) {
|
||||||
// If event is nothing or place, do nothing
|
// If event is nothing or place, do nothing
|
||||||
@ -956,9 +969,9 @@ public final class JobsPaymentListener implements Listener {
|
|||||||
if (enchant == null)
|
if (enchant == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CMIEnchantment e = CMIEnchantment.get(enchant);
|
String enchantName = getEnchantName(enchant);
|
||||||
if (e != null)
|
if (enchantName != null)
|
||||||
Jobs.action(jPlayer, new EnchantActionInfo(e.toString(), oneEnchant.getValue(), ActionType.ENCHANT));
|
Jobs.action(jPlayer, new EnchantActionInfo(enchantName, oneEnchant.getValue(), ActionType.ENCHANT));
|
||||||
}
|
}
|
||||||
} else if (secondSlotItem == null || secondSlotItem.getType() != Material.ENCHANTED_BOOK) // Enchanted books does not have durability
|
} else if (secondSlotItem == null || secondSlotItem.getType() != Material.ENCHANTED_BOOK) // Enchanted books does not have durability
|
||||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR));
|
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR));
|
||||||
@ -1013,16 +1026,7 @@ public final class JobsPaymentListener implements Listener {
|
|||||||
if (enchant == null)
|
if (enchant == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String enchantName = null;
|
String enchantName = getEnchantName(enchant);
|
||||||
|
|
||||||
try {
|
|
||||||
enchantName = enchant.getKey().getKey().toLowerCase().replace("_", "").replace("minecraft:", "");
|
|
||||||
} catch (Throwable e) {
|
|
||||||
CMIEnchantment ench = CMIEnchantment.get(enchant);
|
|
||||||
if (ench != null)
|
|
||||||
enchantName = ench.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enchantName != null)
|
if (enchantName != null)
|
||||||
Jobs.action(jPlayer, new EnchantActionInfo(enchantName, oneEnchant.getValue(), ActionType.ENCHANT));
|
Jobs.action(jPlayer, new EnchantActionInfo(enchantName, oneEnchant.getValue(), ActionType.ENCHANT));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user