From b9f5b40b4676d3a425790a6cc81eaab989d09b5c Mon Sep 17 00:00:00 2001 From: Gamer153 Date: Wed, 27 Jul 2022 16:59:49 +0200 Subject: [PATCH] Add config option for preventing enchantments on shop items --- .../com/gamingmesh/jobs/config/GeneralConfigManager.java | 5 ++++- .../com/gamingmesh/jobs/listeners/JobsPaymentListener.java | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 7c87a5c8..f814719d 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -102,7 +102,7 @@ public class GeneralConfigManager { BossBarEnabled = false, BossBarShowOnEachAction = false, BossBarsMessageByDefault = false, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse, DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled, LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false, - payForEachVTradeItem, allowEnchantingBoostedItems, bossBarAsync = false; + payForEachVTradeItem, allowEnchantingBoostedItems, bossBarAsync = false, preventShopItemEnchanting; public ItemStack guiBackButton, guiNextButton; public CMIMaterial guiFiller; @@ -440,6 +440,9 @@ public class GeneralConfigManager { c.addComment("hide-jobsinfo-without-permission", "Hide jobs info from player if they lack the permission to join the job"); hideJobsInfoWithoutPermission = c.get("hide-jobsinfo-without-permission", false); + c.addComment("prevent-shop-item-enchanting", "Prevent players to enchant items from the shop in the anvil with enchanted books"); + preventShopItemEnchanting = c.get("prevent-shop-item-enchanting", true); + c.addComment("enable-pay-near-spawner", "Option to allow payment to be made when killing mobs from a spawner.", "Use jobs.nearspawner.[amount] to define multiplayer. Example jobs.nearspawner.-0.5 will pay half of payment, jobs.nearspawner.-1 will not pay at all"); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 75cf6ac6..94e79948 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -26,6 +26,7 @@ import java.util.Map.Entry; import java.util.UUID; import java.util.concurrent.TimeUnit; +import com.gamingmesh.jobs.config.GeneralConfigManager; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; @@ -1082,6 +1083,9 @@ public final class JobsPaymentListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void PrepareAnvilEvent(final PrepareAnvilEvent event) { + if (!Jobs.getGCManager().preventShopItemEnchanting) + return; + if (!Jobs.getPlayerManager().containsItemBoostByNBT(event.getInventory().getContents()[0])) return;