diff --git a/build.gradle b/build.gradle
index 9867cbf7..8230b5e2 100644
--- a/build.gradle
+++ b/build.gradle
@@ -49,7 +49,7 @@ allprojects {
}
dependencies {
- compileOnly 'com.willfp:eco:3.8.0'
+ compileOnly 'com.willfp:eco:4.0.0'
compileOnly 'org.jetbrains:annotations:19.0.0'
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java
index 81556130..aea24cbe 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java
@@ -1,11 +1,10 @@
package com.willfp.ecoenchants;
+import com.willfp.eco.util.bukkit.scheduling.TimedRunnable;
import com.willfp.eco.util.command.AbstractCommand;
-import com.willfp.eco.util.display.Display;
import com.willfp.eco.util.display.DisplayModule;
import com.willfp.eco.util.drops.telekinesis.TelekinesisUtils;
import com.willfp.eco.util.integrations.IntegrationLoader;
-import com.willfp.eco.util.interfaces.EcoRunnable;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.eco.util.protocollib.AbstractPacketAdapter;
import com.willfp.ecoenchants.command.commands.CommandEcodebug;
@@ -38,8 +37,7 @@ import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.generator.BlockPopulator;
-import org.bukkit.inventory.ItemFlag;
-import org.bukkit.inventory.meta.ItemMeta;
+import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
@@ -66,21 +64,6 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
*/
@Override
public void enable() {
- Display.registerDisplayModule(new DisplayModule(itemStack -> {
- ItemMeta meta = itemStack.getItemMeta();
- if (meta == null) {
- return itemStack;
- }
- boolean hideEnchants = false;
- if (meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS) || meta.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) {
- hideEnchants = true;
- }
-
- return EnchantDisplay.displayEnchantments(itemStack, hideEnchants);
- }, 500, this.getPluginName()));
-
- Display.registerRevertModule(EnchantDisplay::revertDisplay);
-
this.getExtensionLoader().loadExtensions();
if (this.getExtensionLoader().getLoadedExtensions().isEmpty()) {
@@ -132,8 +115,8 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
if (ecoEnchant.isEnabled()) {
this.getEventManager().registerListener(ecoEnchant);
- if (ecoEnchant instanceof EcoRunnable) {
- this.getScheduler().syncRepeating((EcoRunnable) ecoEnchant, 5, ((EcoRunnable) ecoEnchant).getTime());
+ if (ecoEnchant instanceof TimedRunnable) {
+ this.getScheduler().syncRepeating((TimedRunnable) ecoEnchant, 5, ((TimedRunnable) ecoEnchant).getTime());
}
}
}, 1);
@@ -204,7 +187,7 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
new AnvilListeners(this),
new WatcherTriggers(this),
new VillagerListeners(this),
- new HoldItemListener()
+ new HoldItemListener(this)
);
}
@@ -221,4 +204,10 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
EnchantmentType.class
);
}
+
+ @Override
+ @Nullable
+ protected DisplayModule createDisplayModule() {
+ return new EnchantDisplay(this);
+ }
}
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandRandomenchant.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandRandomenchant.java
index b016f950..a9bd3dc7 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandRandomenchant.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandRandomenchant.java
@@ -56,7 +56,7 @@ public class CommandRandomenchant extends AbstractCommand {
for (EcoEnchant ecoEnchant : ecoEnchants) {
if (ecoEnchant.canEnchantItem(itemStack)) {
if (!ecoEnchant.conflictsWithAny(onItem)) {
- if (!onItem.stream().anyMatch(enchantment -> enchantment.conflictsWith(ecoEnchant))) {
+ if (onItem.stream().noneMatch(enchantment -> enchantment.conflictsWith(ecoEnchant))) {
if (!onItem.contains(ecoEnchant)) {
boolean conflicts = false;
for (Enchantment enchantment : onItem) {
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 f70805f5..8ea41888 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
@@ -2,16 +2,17 @@ package com.willfp.ecoenchants.display;
import com.google.common.collect.Lists;
import com.willfp.eco.util.NumberUtils;
-import com.willfp.eco.util.config.updating.annotations.ConfigUpdater;
+import com.willfp.eco.util.display.Display;
+import com.willfp.eco.util.display.DisplayModule;
+import com.willfp.eco.util.display.DisplayPriority;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
-import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.display.options.DisplayOptions;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
import com.willfp.ecoenchants.proxy.proxies.FastGetEnchantsProxy;
import com.willfp.ecoenchants.util.ProxyUtils;
-import lombok.experimental.UtilityClass;
+import lombok.Getter;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
@@ -19,7 +20,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
-import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
@@ -29,116 +30,63 @@ import java.util.List;
/**
* All methods and fields pertaining to showing players the enchantments on their items.
*/
-@UtilityClass
-public class EnchantDisplay {
- /**
- * Instance of EcoEnchants.
- */
- private static final AbstractEcoPlugin PLUGIN = EcoEnchantsPlugin.getInstance();
-
+public class EnchantDisplay extends DisplayModule {
/**
* The meta key to hide enchantments in lore.
*
* EcoEnchants packet lore implementation of HideEnchants.
*/
- public static final NamespacedKey KEY_SKIP = PLUGIN.getNamespacedKeyFactory().create("ecoenchantlore-skip");
-
- /**
- * The prefix for all enchantment lines to have in lore.
- */
- public static final String PREFIX = "§w";
+ @Getter
+ private final NamespacedKey keySkip = this.getPlugin().getNamespacedKeyFactory().create("ecoenchantlore-skip");
/**
* The configurable options for displaying enchantments.
*/
- public static final DisplayOptions OPTIONS = new DisplayOptions(PLUGIN);
+ @Getter
+ private final DisplayOptions options = new DisplayOptions(this.getPlugin());
+
+ /**
+ * Create EcoEnchants display module.
+ *
+ * @param plugin Instance of EcoEnchants.
+ */
+ public EnchantDisplay(@NotNull final AbstractEcoPlugin plugin) {
+ super(plugin, DisplayPriority.HIGH);
+ }
/**
* Update config values.
*/
- @ConfigUpdater
- public static void update() {
- OPTIONS.update();
+ public void update() {
+ options.update();
EnchantmentCache.update();
}
- /**
- * Revert display.
- *
- * @param item The item to revert.
- * @return The item, updated.
- */
- public static ItemStack revertDisplay(@Nullable final ItemStack item) {
- if (item == null || !EnchantmentTarget.ALL.getMaterials().contains(item.getType()) || item.getItemMeta() == null) {
- return item;
+ @Override
+ protected void display(@NotNull final ItemStack itemStack) {
+ if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
+ return;
}
- ItemMeta meta = item.getItemMeta();
- List itemLore;
+ ItemMeta meta = itemStack.getItemMeta();
- if (meta.hasLore()) {
- itemLore = meta.getLore();
- } else {
- itemLore = new ArrayList<>();
+ assert meta != null;
+
+ boolean hide = false;
+ if (meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS) || meta.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) {
+ hide = true;
}
- if (itemLore == null) {
- itemLore = new ArrayList<>();
- }
+ List itemLore = null;
- itemLore.removeIf(s -> s.startsWith(PREFIX));
-
- if (!meta.getPersistentDataContainer().has(KEY_SKIP, PersistentDataType.INTEGER)) {
- meta.removeItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
- meta.removeItemFlags(ItemFlag.HIDE_ENCHANTS);
- }
- meta.getPersistentDataContainer().remove(KEY_SKIP);
- meta.setLore(itemLore);
- item.setItemMeta(meta);
-
- return item;
- }
-
- /**
- * Show all enchantments in item lore.
- *
- * @param item The item to update.
- * @return The item, updated.
- */
- public static ItemStack displayEnchantments(@Nullable final ItemStack item) {
- return displayEnchantments(item, false);
- }
-
- /**
- * Show all enchantments in item lore.
- *
- * @param item The item to update.
- * @param hide If enchantments should be hidden.
- * @return The item, updated.
- */
- public static ItemStack displayEnchantments(@Nullable final ItemStack item,
- final boolean hide) {
- if (item == null || item.getItemMeta() == null || !EnchantmentTarget.ALL.getMaterials().contains(item.getType())) {
- return item;
- }
-
- revertDisplay(item);
-
- ItemMeta meta = item.getItemMeta();
- if (meta == null) {
- return item;
- }
-
- List itemLore = new ArrayList<>();
-
- if (hide || meta.getPersistentDataContainer().has(KEY_SKIP, PersistentDataType.INTEGER)) {
+ if (hide || meta.getPersistentDataContainer().has(keySkip, PersistentDataType.INTEGER)) {
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
if (meta instanceof EnchantmentStorageMeta) {
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
}
- meta.getPersistentDataContainer().set(KEY_SKIP, PersistentDataType.INTEGER, 1);
- item.setItemMeta(meta);
- return item;
+ meta.getPersistentDataContainer().set(keySkip, PersistentDataType.INTEGER, 1);
+ itemStack.setItemMeta(meta);
+ return;
}
if (meta.hasLore()) {
@@ -167,7 +115,7 @@ public class EnchantDisplay {
HashMap tempEnchantments = new HashMap<>(enchantments);
- OPTIONS.getSorter().sortEnchantments(unsorted);
+ options.getSorter().sortEnchantments(unsorted);
enchantments.clear();
unsorted.forEach(enchantment -> enchantments.put(enchantment, tempEnchantments.get(enchantment)));
@@ -196,21 +144,21 @@ public class EnchantDisplay {
String name = EnchantmentCache.getEntry(enchantment).getName();
if (!(enchantment.getMaxLevel() == 1 && level == 1)) {
- if (OPTIONS.getNumbersOptions().isUseNumerals() && ProxyUtils.getProxy(FastGetEnchantsProxy.class).getLevelOnItem(item, enchantment) < OPTIONS.getNumbersOptions().getThreshold()) {
+ if (options.getNumbersOptions().isUseNumerals() && ProxyUtils.getProxy(FastGetEnchantsProxy.class).getLevelOnItem(itemStack, enchantment) < options.getNumbersOptions().getThreshold()) {
name += " " + NumberUtils.toNumeral(level);
} else {
name += " " + level;
}
}
- lore.add(PREFIX + name);
- if (enchantments.size() <= OPTIONS.getDescriptionOptions().getThreshold() && OPTIONS.getDescriptionOptions().isEnabled()) {
+ lore.add(Display.PREFIX + name);
+ if (enchantments.size() <= options.getDescriptionOptions().getThreshold() && options.getDescriptionOptions().isEnabled()) {
lore.addAll(EnchantmentCache.getEntry(enchantment).getDescription());
}
});
- if (OPTIONS.getShrinkOptions().isEnabled() && (enchantments.size() > OPTIONS.getShrinkOptions().getThreshold())) {
- List> partitionedCombinedLoreList = Lists.partition(lore, OPTIONS.getShrinkOptions().getShrinkPerLine());
+ if (options.getShrinkOptions().isEnabled() && (enchantments.size() > options.getShrinkOptions().getThreshold())) {
+ List> partitionedCombinedLoreList = Lists.partition(lore, options.getShrinkOptions().getShrinkPerLine());
List newLore = new ArrayList<>();
partitionedCombinedLoreList.forEach(list -> {
StringBuilder builder = new StringBuilder();
@@ -232,8 +180,22 @@ public class EnchantDisplay {
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
lore.addAll(itemLore);
meta.setLore(lore);
- item.setItemMeta(meta);
+ itemStack.setItemMeta(meta);
+ }
- return item;
+ @Override
+ protected void revert(@NotNull final ItemStack itemStack) {
+ if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
+ return;
+ }
+
+ ItemMeta meta = itemStack.getItemMeta();
+
+ if (!meta.getPersistentDataContainer().has(keySkip, PersistentDataType.INTEGER)) {
+ meta.removeItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
+ meta.removeItemFlags(ItemFlag.HIDE_ENCHANTS);
+ }
+ meta.getPersistentDataContainer().remove(keySkip);
+ itemStack.setItemMeta(meta);
}
}
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java
index 4b940c2a..4a646843 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java
@@ -2,6 +2,7 @@ package com.willfp.ecoenchants.display;
import com.google.common.collect.ImmutableMap;
import com.willfp.eco.util.config.updating.annotations.ConfigUpdater;
+import com.willfp.eco.util.display.Display;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
@@ -88,7 +89,7 @@ public class EnchantmentCache {
enchantment,
"&4INVALID ENCHANTMENT",
"INVALID",
- Collections.singletonList(EnchantDisplay.PREFIX + "INVALID ENCHANTMENT: " + enchantment.getClass().getName()),
+ Collections.singletonList(Display.PREFIX + "INVALID ENCHANTMENT: " + enchantment.getClass().getName()),
EnchantmentType.NORMAL,
EnchantmentRarity.getByName(PLUGIN.getConfigYml().getString("rarity.vanilla-rarity"))
));
@@ -135,7 +136,7 @@ public class EnchantmentCache {
String rawName = name;
name = color + name;
- description.replaceAll(line -> EnchantDisplay.PREFIX + EnchantDisplay.OPTIONS.getDescriptionOptions().getColor() + line);
+ description.replaceAll(line -> Display.PREFIX + ((EnchantDisplay) PLUGIN.getDisplayModule()).getOptions().getDescriptionOptions().getColor() + line);
CACHE.put(enchantment.getKey(), new CacheEntry(enchantment, name, rawName, description, type, rarity));
}
@@ -205,7 +206,7 @@ public class EnchantmentCache {
String processedStringDescription = descriptionBuilder.toString();
processedStringDescription = processedStringDescription.replace("§w", "");
- this.stringDescription = processedStringDescription.replaceAll(EnchantDisplay.OPTIONS.getDescriptionOptions().getColor(), "");
+ this.stringDescription = processedStringDescription.replaceAll(((EnchantDisplay) PLUGIN.getDisplayModule()).getOptions().getDescriptionOptions().getColor(), "");
}
}
}
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SorterManager.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SorterManager.java
index d06ec3f6..ac08e750 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SorterManager.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/SorterManager.java
@@ -1,5 +1,6 @@
package com.willfp.ecoenchants.display.options.sorting;
+import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.display.options.sorting.implementations.AlphabeticSorter;
import com.willfp.ecoenchants.display.options.sorting.implementations.LengthSorter;
import com.willfp.ecoenchants.display.options.sorting.implementations.RarityAlphabeticSorter;
@@ -34,17 +35,18 @@ public class SorterManager {
return REGISTERED.stream()
.filter(enchantmentSorter -> Arrays.asList(enchantmentSorter.getParameters()).containsAll(Arrays.asList(parameters)) && enchantmentSorter.getParameters().length == parameters.length)
.findFirst()
- .orElse(new AlphabeticSorter());
+ .orElse(new AlphabeticSorter(EcoEnchantsPlugin.getInstance()));
}
static {
- REGISTERED.add(new AlphabeticSorter());
- REGISTERED.add(new LengthSorter());
- REGISTERED.add(new TypeAlphabeticSorter());
- REGISTERED.add(new TypeLengthSorter());
- REGISTERED.add(new RarityAlphabeticSorter());
- REGISTERED.add(new RarityLengthSorter());
- REGISTERED.add(new RarityTypeAlphabeticSorter());
- REGISTERED.add(new RarityTypeLengthSorter());
+ EcoEnchantsPlugin instance = EcoEnchantsPlugin.getInstance(); // Really dirty and janky.
+ REGISTERED.add(new AlphabeticSorter(instance));
+ REGISTERED.add(new LengthSorter(instance));
+ REGISTERED.add(new TypeAlphabeticSorter(instance));
+ REGISTERED.add(new TypeLengthSorter(instance));
+ REGISTERED.add(new RarityAlphabeticSorter(instance));
+ REGISTERED.add(new RarityLengthSorter(instance));
+ REGISTERED.add(new RarityTypeAlphabeticSorter(instance));
+ REGISTERED.add(new RarityTypeLengthSorter(instance));
}
}
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/AlphabeticSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/AlphabeticSorter.java
index 48e7005c..9c1ed69a 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/AlphabeticSorter.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/AlphabeticSorter.java
@@ -1,5 +1,7 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
+import com.willfp.eco.util.internal.PluginDependent;
+import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
import com.willfp.ecoenchants.display.options.sorting.SortParameters;
@@ -8,7 +10,16 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
-public class AlphabeticSorter implements EnchantmentSorter {
+public class AlphabeticSorter extends PluginDependent implements EnchantmentSorter {
+ /**
+ * Instantiate sorter.
+ *
+ * @param plugin Instance of EcoEnchants.
+ */
+ public AlphabeticSorter(@NotNull final AbstractEcoPlugin plugin) {
+ super(plugin);
+ }
+
@Override
public void sortEnchantments(@NotNull final List toSort) {
toSort.sort(((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName())));
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/LengthSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/LengthSorter.java
index 81372897..6fc6f0bb 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/LengthSorter.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/LengthSorter.java
@@ -1,5 +1,7 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
+import com.willfp.eco.util.internal.PluginDependent;
+import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
import com.willfp.ecoenchants.display.options.sorting.SortParameters;
@@ -9,7 +11,16 @@ import org.jetbrains.annotations.NotNull;
import java.util.Comparator;
import java.util.List;
-public class LengthSorter implements EnchantmentSorter {
+public class LengthSorter extends PluginDependent implements EnchantmentSorter {
+ /**
+ * Instantiate sorter.
+ *
+ * @param plugin Instance of EcoEnchants.
+ */
+ public LengthSorter(@NotNull final AbstractEcoPlugin plugin) {
+ super(plugin);
+ }
+
@Override
public void sortEnchantments(@NotNull final List toSort) {
toSort.sort(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length()));
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityAlphabeticSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityAlphabeticSorter.java
index 5f91b225..e61a9355 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityAlphabeticSorter.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityAlphabeticSorter.java
@@ -1,5 +1,7 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
+import com.willfp.eco.util.internal.PluginDependent;
+import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.ecoenchants.display.EnchantDisplay;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
@@ -10,16 +12,26 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
-public class RarityAlphabeticSorter implements EnchantmentSorter {
+public class RarityAlphabeticSorter extends PluginDependent implements EnchantmentSorter {
+ /**
+ * Instantiate sorter.
+ *
+ * @param plugin Instance of EcoEnchants.
+ */
+ public RarityAlphabeticSorter(@NotNull final AbstractEcoPlugin plugin) {
+ super(plugin);
+ }
+
@Override
public void sortEnchantments(@NotNull final List toSort) {
- if (EnchantDisplay.OPTIONS.getSortedRarities().isEmpty() || EnchantDisplay.OPTIONS.getSortedTypes().isEmpty()) {
- EnchantDisplay.update();
+ if (((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().isEmpty()
+ || ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().isEmpty()) {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).update();
}
List sorted = new ArrayList<>();
- EnchantDisplay.OPTIONS.getSortedRarities().forEach(enchantmentRarity -> {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().forEach(enchantmentRarity -> {
List rarityEnchants = new ArrayList<>();
for (Enchantment enchantment : toSort) {
if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) {
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityLengthSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityLengthSorter.java
index 600d4071..e1225222 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityLengthSorter.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityLengthSorter.java
@@ -1,5 +1,7 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
+import com.willfp.eco.util.internal.PluginDependent;
+import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.ecoenchants.display.EnchantDisplay;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
@@ -11,15 +13,25 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
-public class RarityLengthSorter implements EnchantmentSorter {
+public class RarityLengthSorter extends PluginDependent implements EnchantmentSorter {
+ /**
+ * Instantiate sorter.
+ *
+ * @param plugin Instance of EcoEnchants.
+ */
+ public RarityLengthSorter(@NotNull final AbstractEcoPlugin plugin) {
+ super(plugin);
+ }
+
@Override
public void sortEnchantments(@NotNull final List toSort) {
- if (EnchantDisplay.OPTIONS.getSortedRarities().isEmpty() || EnchantDisplay.OPTIONS.getSortedTypes().isEmpty()) {
- EnchantDisplay.update();
+ if (((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().isEmpty()
+ || ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().isEmpty()) {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).update();
}
List sorted = new ArrayList<>();
- EnchantDisplay.OPTIONS.getSortedRarities().forEach(enchantmentRarity -> {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().forEach(enchantmentRarity -> {
List rarityEnchants = new ArrayList<>();
for (Enchantment enchantment : toSort) {
if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) {
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeAlphabeticSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeAlphabeticSorter.java
index b1097f27..7502ef1f 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeAlphabeticSorter.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeAlphabeticSorter.java
@@ -1,5 +1,7 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
+import com.willfp.eco.util.internal.PluginDependent;
+import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.ecoenchants.display.EnchantDisplay;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
@@ -10,15 +12,25 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
-public class RarityTypeAlphabeticSorter implements EnchantmentSorter {
+public class RarityTypeAlphabeticSorter extends PluginDependent implements EnchantmentSorter {
+ /**
+ * Instantiate sorter.
+ *
+ * @param plugin Instance of EcoEnchants.
+ */
+ public RarityTypeAlphabeticSorter(@NotNull final AbstractEcoPlugin plugin) {
+ super(plugin);
+ }
+
@Override
public void sortEnchantments(@NotNull final List toSort) {
- if (EnchantDisplay.OPTIONS.getSortedRarities().isEmpty() || EnchantDisplay.OPTIONS.getSortedTypes().isEmpty()) {
- EnchantDisplay.update();
+ if (((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().isEmpty()
+ || ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().isEmpty()) {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).update();
}
List sorted = new ArrayList<>();
- EnchantDisplay.OPTIONS.getSortedTypes().forEach(enchantmentType -> {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().forEach(enchantmentType -> {
List typeEnchants = new ArrayList<>();
for (Enchantment enchantment : toSort) {
if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) {
@@ -27,7 +39,7 @@ public class RarityTypeAlphabeticSorter implements EnchantmentSorter {
}
typeEnchants.sort((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName()));
- EnchantDisplay.OPTIONS.getSortedRarities().forEach(enchantmentRarity -> {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().forEach(enchantmentRarity -> {
List rarityEnchants = new ArrayList<>();
for (Enchantment enchantment : typeEnchants) {
if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) {
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeLengthSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeLengthSorter.java
index 7a1efb87..1632e889 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeLengthSorter.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/RarityTypeLengthSorter.java
@@ -1,5 +1,7 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
+import com.willfp.eco.util.internal.PluginDependent;
+import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.ecoenchants.display.EnchantDisplay;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
@@ -11,15 +13,25 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
-public class RarityTypeLengthSorter implements EnchantmentSorter {
+public class RarityTypeLengthSorter extends PluginDependent implements EnchantmentSorter {
+ /**
+ * Instantiate sorter.
+ *
+ * @param plugin Instance of EcoEnchants.
+ */
+ public RarityTypeLengthSorter(@NotNull final AbstractEcoPlugin plugin) {
+ super(plugin);
+ }
+
@Override
public void sortEnchantments(@NotNull final List toSort) {
- if (EnchantDisplay.OPTIONS.getSortedRarities().isEmpty() || EnchantDisplay.OPTIONS.getSortedTypes().isEmpty()) {
- EnchantDisplay.update();
+ if (((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().isEmpty()
+ || ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().isEmpty()) {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).update();
}
List sorted = new ArrayList<>();
- EnchantDisplay.OPTIONS.getSortedTypes().forEach(enchantmentType -> {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().forEach(enchantmentType -> {
List typeEnchants = new ArrayList<>();
for (Enchantment enchantment : toSort) {
if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) {
@@ -29,7 +41,7 @@ public class RarityTypeLengthSorter implements EnchantmentSorter {
typeEnchants.sort(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length()));
- EnchantDisplay.OPTIONS.getSortedRarities().forEach(enchantmentRarity -> {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().forEach(enchantmentRarity -> {
List rarityEnchants = new ArrayList<>();
for (Enchantment enchantment : typeEnchants) {
if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) {
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeAlphabeticSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeAlphabeticSorter.java
index f002b8cd..357c4f95 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeAlphabeticSorter.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeAlphabeticSorter.java
@@ -1,5 +1,7 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
+import com.willfp.eco.util.internal.PluginDependent;
+import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.ecoenchants.display.EnchantDisplay;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
@@ -10,15 +12,25 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
-public class TypeAlphabeticSorter implements EnchantmentSorter {
+public class TypeAlphabeticSorter extends PluginDependent implements EnchantmentSorter {
+ /**
+ * Instantiate sorter.
+ *
+ * @param plugin Instance of EcoEnchants.
+ */
+ public TypeAlphabeticSorter(@NotNull final AbstractEcoPlugin plugin) {
+ super(plugin);
+ }
+
@Override
public void sortEnchantments(@NotNull final List toSort) {
- if (EnchantDisplay.OPTIONS.getSortedRarities().isEmpty() || EnchantDisplay.OPTIONS.getSortedTypes().isEmpty()) {
- EnchantDisplay.update();
+ if (((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().isEmpty()
+ || ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().isEmpty()) {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).update();
}
List sorted = new ArrayList<>();
- EnchantDisplay.OPTIONS.getSortedTypes().forEach(enchantmentType -> {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().forEach(enchantmentType -> {
List typeEnchants = new ArrayList<>();
for (Enchantment enchantment : toSort) {
if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) {
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeLengthSorter.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeLengthSorter.java
index 2811a789..2b94bca9 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeLengthSorter.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/options/sorting/implementations/TypeLengthSorter.java
@@ -1,5 +1,7 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
+import com.willfp.eco.util.internal.PluginDependent;
+import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.ecoenchants.display.EnchantDisplay;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
@@ -10,15 +12,25 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
-public class TypeLengthSorter implements EnchantmentSorter {
+public class TypeLengthSorter extends PluginDependent implements EnchantmentSorter {
+ /**
+ * Instantiate sorter.
+ *
+ * @param plugin Instance of EcoEnchants.
+ */
+ public TypeLengthSorter(@NotNull final AbstractEcoPlugin plugin) {
+ super(plugin);
+ }
+
@Override
public void sortEnchantments(@NotNull final List toSort) {
- if (EnchantDisplay.OPTIONS.getSortedRarities().isEmpty() || EnchantDisplay.OPTIONS.getSortedTypes().isEmpty()) {
- EnchantDisplay.update();
+ if (((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().isEmpty()
+ || ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().isEmpty()) {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).update();
}
List sorted = new ArrayList<>();
- EnchantDisplay.OPTIONS.getSortedTypes().forEach(enchantmentType -> {
+ ((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().forEach(enchantmentType -> {
List typeEnchants = new ArrayList<>();
for (Enchantment enchantment : toSort) {
if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) {
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java
index 87297cbd..a6157084 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java
@@ -2,7 +2,6 @@ package com.willfp.ecoenchants.enchantments;
import com.willfp.eco.util.StringUtils;
-import com.willfp.eco.util.interfaces.Registerable;
import com.willfp.eco.util.optional.Prerequisite;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
@@ -41,7 +40,7 @@ import java.util.Set;
import java.util.stream.Collectors;
@SuppressWarnings({"unchecked", "deprecation", "RedundantSuppression"})
-public abstract class EcoEnchant extends Enchantment implements Listener, Registerable, Watcher {
+public abstract class EcoEnchant extends Enchantment implements Listener, Watcher {
/**
* Instance of EcoEnchants for enchantments to be able to access.
*/
@@ -230,7 +229,6 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
* Register the enchantment with spigot.
* Only used internally.
*/
- @Override
public void register() {
try {
Field byIdField = Enchantment.class.getDeclaredField("byKey");
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java
index b237c39f..5716a86c 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java
@@ -1,8 +1,8 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.curse;
import com.willfp.eco.util.VectorUtils;
+import com.willfp.eco.util.bukkit.scheduling.TimedRunnable;
import com.willfp.eco.util.events.armorequip.ArmorEquipEvent;
-import com.willfp.eco.util.interfaces.EcoRunnable;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
@@ -19,7 +19,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
-public class CallingCurse extends EcoEnchant implements EcoRunnable {
+public class CallingCurse extends EcoEnchant implements TimedRunnable {
private final HashMap players = new HashMap<>();
private double distance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance");
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java
index 8a2c737c..b4ea16bb 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java
@@ -1,7 +1,7 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.curse;
import com.willfp.eco.util.DurabilityUtils;
-import com.willfp.eco.util.interfaces.EcoRunnable;
+import com.willfp.eco.util.bukkit.scheduling.TimedRunnable;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
@@ -21,7 +21,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-public class DecayCurse extends EcoEnchant implements EcoRunnable {
+public class DecayCurse extends EcoEnchant implements TimedRunnable {
private final Set players = new HashSet<>();
private int amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier");
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java
index 38a838bd..62a2535e 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java
@@ -2,7 +2,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.eco.util.NumberUtils;
import com.willfp.eco.util.events.armorequip.ArmorEquipEvent;
-import com.willfp.eco.util.interfaces.EcoRunnable;
+import com.willfp.eco.util.bukkit.scheduling.TimedRunnable;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
@@ -17,7 +17,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
-public class Forcefield extends EcoEnchant implements EcoRunnable {
+public class Forcefield extends EcoEnchant implements TimedRunnable {
private final HashMap players = new HashMap<>();
private double initialDistance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "initial-distance");
private double bonus = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level");
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java
index 7245c573..b3595d1e 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java
@@ -1,8 +1,8 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.eco.util.VectorUtils;
+import com.willfp.eco.util.bukkit.scheduling.TimedRunnable;
import com.willfp.eco.util.events.armorequip.ArmorEquipEvent;
-import com.willfp.eco.util.interfaces.EcoRunnable;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
@@ -19,7 +19,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
-public class Magnetic extends EcoEnchant implements EcoRunnable {
+public class Magnetic extends EcoEnchant implements TimedRunnable {
private double initialDistance = 1;
private double bonus = 1;
private final HashMap players = new HashMap<>();
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java
index 46e6ed24..c74944f4 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java
@@ -1,7 +1,7 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.special;
import com.willfp.eco.util.DurabilityUtils;
-import com.willfp.eco.util.interfaces.EcoRunnable;
+import com.willfp.eco.util.bukkit.scheduling.TimedRunnable;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
@@ -21,7 +21,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-public class Repairing extends EcoEnchant implements EcoRunnable {
+public class Repairing extends EcoEnchant implements TimedRunnable {
private final Set players = new HashSet<>();
private int amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier");
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java
index 8ab2cc4c..569624af 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java
@@ -5,7 +5,6 @@ import com.willfp.eco.util.StringUtils;
import com.willfp.eco.util.config.updating.annotations.ConfigUpdater;
import com.willfp.eco.util.integrations.placeholder.PlaceholderEntry;
import com.willfp.eco.util.integrations.placeholder.PlaceholderManager;
-import com.willfp.eco.util.interfaces.Registerable;
import com.willfp.ecoenchants.config.EcoEnchantsConfigs;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
@@ -16,7 +15,7 @@ import java.util.Objects;
import java.util.Optional;
import java.util.Set;
-public class EnchantmentRarity implements Registerable {
+public class EnchantmentRarity {
/**
* All registered rarities.
*/
@@ -82,7 +81,6 @@ public class EnchantmentRarity implements Registerable {
this.customColor = customColor;
}
- @Override
public void register() {
Optional matching = REGISTERED.stream().filter(rarity -> rarity.getName().equalsIgnoreCase(name)).findFirst();
matching.ifPresent(REGISTERED::remove);
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java
index c0ca7017..e0669657 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentTarget.java
@@ -2,7 +2,6 @@ package com.willfp.ecoenchants.enchantments.meta;
import com.google.common.collect.ImmutableSet;
import com.willfp.eco.util.config.updating.annotations.ConfigUpdater;
-import com.willfp.eco.util.interfaces.Registerable;
import com.willfp.ecoenchants.config.EcoEnchantsConfigs;
import lombok.Getter;
import org.bukkit.Material;
@@ -13,7 +12,7 @@ import java.util.Objects;
import java.util.Optional;
import java.util.Set;
-public class EnchantmentTarget implements Registerable {
+public class EnchantmentTarget {
/**
* All registered targets.
*/
@@ -49,7 +48,6 @@ public class EnchantmentTarget implements Registerable {
this.materials = materials;
}
- @Override
public void register() {
Optional matching = REGISTERED.stream().filter(rarity -> rarity.getName().equalsIgnoreCase(name)).findFirst();
matching.ifPresent(REGISTERED::remove);
diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/HoldItemListener.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/HoldItemListener.java
index 9786d218..eb9db330 100644
--- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/HoldItemListener.java
+++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/HoldItemListener.java
@@ -1,6 +1,8 @@
package com.willfp.ecoenchants.enchantments.util;
import com.willfp.eco.util.NumberUtils;
+import com.willfp.eco.util.internal.PluginDependent;
+import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.ecoenchants.display.EnchantDisplay;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
@@ -19,7 +21,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class HoldItemListener implements Listener {
+public class HoldItemListener extends PluginDependent implements Listener {
+ /**
+ * Instantiate HoldItemListener.
+ *
+ * @param plugin Instance of EcoEnchants.
+ */
+ public HoldItemListener(@NotNull final AbstractEcoPlugin plugin) {
+ super(plugin);
+ }
/**
* On player hold item.
@@ -43,7 +53,7 @@ public class HoldItemListener implements Listener {
Map toAdd = new HashMap<>();
- if (!EnchantDisplay.OPTIONS.isUseLoreGetter()) {
+ if (!((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().isUseLoreGetter()) {
return;
}
diff --git a/gradle.properties b/gradle.properties
index 08a58119..03f51f6c 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,2 +1,2 @@
-version = 6.5.6
+version = 6.6.0
plugin-name = EcoEnchants
\ No newline at end of file