diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 2e9f924e..8fbd1604 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -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 oneEnchant : resultStack.getEnchantments().entrySet()) { + Map newEnchantments = Util.mapUnique(resultStack.getEnchantments(), firstSlot.getEnchantments()); + + for (Map.Entry oneEnchant : newEnchantments.entrySet()) { Enchantment enchant = oneEnchant.getKey(); if (enchant == null) continue; diff --git a/src/main/java/com/gamingmesh/jobs/stuff/Util.java b/src/main/java/com/gamingmesh/jobs/stuff/Util.java index 902fcfb8..76bcc2d1 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/Util.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/Util.java @@ -395,4 +395,14 @@ public final class Util { return listOfCommands; } + + public static Map mapUnique(Map left, Map right) { + Map difference = new HashMap<>(); + + difference.putAll(left); + difference.putAll(right); + difference.entrySet().removeAll(right.entrySet()); + + return difference; + } }