mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +01:00
Only pay for new enchantments when enchanting items with books on an anvil
This commit is contained in:
parent
bf58cf0766
commit
a224545d79
@ -964,7 +964,9 @@ public final class JobsPaymentListener implements Listener {
|
||||
ItemStack secondSlotItem = inv.getItem(1);
|
||||
|
||||
if (Jobs.getGCManager().PayForEnchantingOnAnvil && secondSlotItem != null && secondSlotItem.getType() == Material.ENCHANTED_BOOK) {
|
||||
for (Map.Entry<Enchantment, Integer> oneEnchant : resultStack.getEnchantments().entrySet()) {
|
||||
Map<Enchantment, Integer> newEnchantments = Util.mapUnique(resultStack.getEnchantments(), firstSlot.getEnchantments());
|
||||
|
||||
for (Map.Entry<Enchantment, Integer> oneEnchant : newEnchantments.entrySet()) {
|
||||
Enchantment enchant = oneEnchant.getKey();
|
||||
if (enchant == null)
|
||||
continue;
|
||||
|
@ -395,4 +395,14 @@ public final class Util {
|
||||
|
||||
return listOfCommands;
|
||||
}
|
||||
|
||||
public static <K, V> Map<K, V> mapUnique(Map<K, V> left, Map<K, V> right) {
|
||||
Map<K, V> difference = new HashMap<>();
|
||||
|
||||
difference.putAll(left);
|
||||
difference.putAll(right);
|
||||
difference.entrySet().removeAll(right.entrySet());
|
||||
|
||||
return difference;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user