From 25f9f4e030182d762c7b889ebadd295233f0ef02 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 9 Mar 2021 19:12:49 +0000 Subject: [PATCH] Added require-target option to display --- .../willfp/ecoenchants/display/EnchantDisplay.java | 12 ++++++++---- .../ecoenchants/display/options/DisplayOptions.java | 8 ++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java index 67f43721..a9f6fd9c 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java @@ -78,8 +78,10 @@ public class EnchantDisplay extends DisplayModule { @Override protected void display(@NotNull final ItemStack itemStack, @NotNull final Object... args) { - if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) { - return; + if (options.isRequireTarget()) { + if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) { + return; + } } ItemMeta meta = itemStack.getItemMeta(); @@ -198,8 +200,10 @@ public class EnchantDisplay extends DisplayModule { @Override protected void revert(@NotNull final ItemStack itemStack) { - if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) { - return; + if (options.isRequireTarget()) { + if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) { + return; + } } ItemMeta meta = itemStack.getItemMeta(); diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/DisplayOptions.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/DisplayOptions.java index 6a1f4374..576f1ebb 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/DisplayOptions.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/DisplayOptions.java @@ -85,6 +85,12 @@ public class DisplayOptions extends PluginDependent { @Getter private boolean usingForceHideFixer = false; + /** + * If item must be a target. + */ + @Getter + private boolean requireTarget = true; + /** * Instantiate new display options. * @@ -124,6 +130,8 @@ public class DisplayOptions extends PluginDependent { usingAggressiveExperimentalHideFixer = this.getPlugin().getConfigYml().getBool("advanced.hide-fixer.aggressive"); usingForceHideFixer = this.getPlugin().getConfigYml().getBool("advanced.hide-fixer.force"); + requireTarget = this.getPlugin().getConfigYml().getBool("lore.require-target"); + boolean byType = this.getPlugin().getConfigYml().getBool("lore.sort-by-type"); boolean byLength = this.getPlugin().getConfigYml().getBool("lore.sort-by-length"); boolean byRarity = this.getPlugin().getConfigYml().getBool("lore.sort-by-rarity");