From 6822508631bb69cc6a88735dc8bd968fc2948b55 Mon Sep 17 00:00:00 2001 From: Zrips Date: Fri, 24 Jun 2022 13:02:58 +0300 Subject: [PATCH] Disabling item enchant for boosted items in anvils --- .../jobs/listeners/JobsPaymentListener.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 15c416d0..75cf6ac6 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -71,6 +71,7 @@ import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareAnvilEvent; import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; @@ -88,6 +89,7 @@ import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; import org.bukkit.permissions.PermissionAttachmentInfo; +import org.checkerframework.checker.nullness.qual.Nullable; import com.bgsoftware.wildstacker.api.enums.StackSplit; import com.gamingmesh.jobs.ItemBoostManager; @@ -1078,6 +1080,17 @@ public final class JobsPaymentListener implements Listener { Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT)); } + @EventHandler(priority = EventPriority.NORMAL) + public void PrepareAnvilEvent(final PrepareAnvilEvent event) { + if (!Jobs.getPlayerManager().containsItemBoostByNBT(event.getInventory().getContents()[0])) + return; + + if (!CMIMaterial.get(event.getInventory().getContents()[1]).equals(CMIMaterial.ENCHANTED_BOOK)) + return; + + event.setResult(null); + } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInventoryMoveItemEventToFurnace(InventoryMoveItemEvent event) { if (!Jobs.getGCManager().PreventHopperFillUps || event.getItem().getType() == Material.AIR)