diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index f3049a98..b9b827ac 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -103,7 +103,7 @@ public class GeneralConfigManager { BossBarEnabled, BossBarShowOnEachAction, BossBarsMessageByDefault, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse, DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled, LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, - payForEachVTradeItem, titleMessageMaxLevelReached; + payForEachVTradeItem, titleMessageMaxLevelReached, allowEnchantingBoostedItems; public ItemStack guiBackButton, guiNextButton, guiFiller; @@ -716,6 +716,9 @@ public class GeneralConfigManager { c.addComment("Economy.Enchant.PayForEnchantingOnAnvil", "Do you want to give money for enchanting items in anvil?"); PayForEnchantingOnAnvil = c.get("Economy.Enchant.PayForEnchantingOnAnvil", false); + c.addComment("Economy.Enchant.AllowEnchantingBoostedItems", "Do you want to allow players to enchant their boosted items?"); + allowEnchantingBoostedItems = c.get("Economy.Enchant.AllowEnchantingBoostedItems", true); + c.addComment("Economy.Crafting.PayForEachCraft", "With this true, player will get money for all crafted items instead of each crafting action (like with old payment mechanic)", "By default its false, as you can make ALOT of money if prices kept from old payment mechanics"); diff --git a/src/main/java/com/gamingmesh/jobs/container/JobItems.java b/src/main/java/com/gamingmesh/jobs/container/JobItems.java index 64172db0..beec3b2b 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobItems.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobItems.java @@ -45,36 +45,34 @@ public class JobItems { public JobItems(String node, CMIMaterial mat, int amount, String name, List lore, HashMap enchants, BoostMultiplier boostMultiplier, List jobs) { mat = mat == null ? CMIMaterial.STONE : mat; - try { - this.enchants = enchants; - item = mat.newItemStack(); - ItemMeta meta = item.getItemMeta(); + this.enchants = enchants; + item = mat.newItemStack(); - if (name != null) - meta.setDisplayName(CMIChatColor.translate(name)); - if (lore != null) - meta.setLore(lore); + ItemMeta meta = item.getItemMeta(); - if (enchants != null) { - if (mat == CMIMaterial.ENCHANTED_BOOK) { - EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta) meta; - for (Entry oneEnch : enchants.entrySet()) { - bookMeta.addStoredEnchant(oneEnch.getKey(), oneEnch.getValue(), true); - } - } else { - for (Entry oneEnchant : enchants.entrySet()) { - meta.addEnchant(oneEnchant.getKey(), oneEnchant.getValue(), true); - } + if (name != null) + meta.setDisplayName(CMIChatColor.translate(name)); + if (lore != null) + meta.setLore(lore); + + if (enchants != null) { + if (mat == CMIMaterial.ENCHANTED_BOOK) { + EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta) meta; + for (Entry oneEnch : enchants.entrySet()) { + bookMeta.addStoredEnchant(oneEnch.getKey(), oneEnch.getValue(), true); + } + } else { + for (Entry oneEnchant : enchants.entrySet()) { + meta.addEnchant(oneEnchant.getKey(), oneEnchant.getValue(), true); } } - item.setItemMeta(meta); - item.setAmount(amount); - item = CMIReflections.setNbt(item, "JobsItemBoost", node); - } catch (Throwable e) { - e.printStackTrace(); } + item.setItemMeta(meta); + item.setAmount(amount); + item = CMIReflections.setNbt(item, "JobsItemBoost", node); + this.node = node; this.boostMultiplier = boostMultiplier; setJobs(jobs); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 76eb79d5..c8250a70 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -19,6 +19,7 @@ package com.gamingmesh.jobs.listeners; import com.gamingmesh.jobs.CMILib.*; +import com.gamingmesh.jobs.ItemBoostManager; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.actions.*; import com.gamingmesh.jobs.api.JobsChunkChangeEvent; @@ -950,6 +951,17 @@ public class JobsPaymentListener implements Listener { if (jPlayer == null) return; + if (!Jobs.getGCManager().allowEnchantingBoostedItems) { + for (JobProgression prog : jPlayer.getJobProgression()) { + for (JobItems jobItem : ItemBoostManager.getItemsByJob(prog.getJob())) { + if (event.getItem().isSimilar(jobItem.getItemStack(jPlayer.getPlayer()))) { + event.setCancelled(true); + return; + } + } + } + } + Map enchants = event.getEnchantsToAdd(); for (Entry oneEnchant : enchants.entrySet()) { Enchantment enchant = oneEnchant.getKey(); @@ -967,8 +979,8 @@ public class JobsPaymentListener implements Listener { Jobs.action(jPlayer, new EnchantActionInfo(enchantName, level, ActionType.ENCHANT)); } - Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT)); + Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT)); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)