mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-25 15:35:11 +01:00
Updated to eco 4.0.0, updated to 6.6.0, reworked for 4.0.0 compatibility
This commit is contained in:
parent
d273a87870
commit
6a1db845b5
@ -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'
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
* <p>
|
||||
* 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<String> 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<String> 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<String> 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<Enchantment, Integer> 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<List<String>> partitionedCombinedLoreList = Lists.partition(lore, OPTIONS.getShrinkOptions().getShrinkPerLine());
|
||||
if (options.getShrinkOptions().isEnabled() && (enchantments.size() > options.getShrinkOptions().getThreshold())) {
|
||||
List<List<String>> partitionedCombinedLoreList = Lists.partition(lore, options.getShrinkOptions().getShrinkPerLine());
|
||||
List<String> 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);
|
||||
}
|
||||
}
|
||||
|
@ -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(), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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<Enchantment> toSort) {
|
||||
toSort.sort(((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName())));
|
||||
|
@ -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<Enchantment> toSort) {
|
||||
toSort.sort(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length()));
|
||||
|
@ -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<Enchantment> 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<Enchantment> sorted = new ArrayList<>();
|
||||
|
||||
EnchantDisplay.OPTIONS.getSortedRarities().forEach(enchantmentRarity -> {
|
||||
((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().forEach(enchantmentRarity -> {
|
||||
List<Enchantment> rarityEnchants = new ArrayList<>();
|
||||
for (Enchantment enchantment : toSort) {
|
||||
if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) {
|
||||
|
@ -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<Enchantment> 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<Enchantment> sorted = new ArrayList<>();
|
||||
EnchantDisplay.OPTIONS.getSortedRarities().forEach(enchantmentRarity -> {
|
||||
((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedRarities().forEach(enchantmentRarity -> {
|
||||
List<Enchantment> rarityEnchants = new ArrayList<>();
|
||||
for (Enchantment enchantment : toSort) {
|
||||
if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) {
|
||||
|
@ -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<Enchantment> 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<Enchantment> sorted = new ArrayList<>();
|
||||
EnchantDisplay.OPTIONS.getSortedTypes().forEach(enchantmentType -> {
|
||||
((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().forEach(enchantmentType -> {
|
||||
List<Enchantment> 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<Enchantment> rarityEnchants = new ArrayList<>();
|
||||
for (Enchantment enchantment : typeEnchants) {
|
||||
if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) {
|
||||
|
@ -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<Enchantment> 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<Enchantment> sorted = new ArrayList<>();
|
||||
EnchantDisplay.OPTIONS.getSortedTypes().forEach(enchantmentType -> {
|
||||
((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().forEach(enchantmentType -> {
|
||||
List<Enchantment> 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<Enchantment> rarityEnchants = new ArrayList<>();
|
||||
for (Enchantment enchantment : typeEnchants) {
|
||||
if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) {
|
||||
|
@ -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<Enchantment> 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<Enchantment> sorted = new ArrayList<>();
|
||||
EnchantDisplay.OPTIONS.getSortedTypes().forEach(enchantmentType -> {
|
||||
((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().forEach(enchantmentType -> {
|
||||
List<Enchantment> typeEnchants = new ArrayList<>();
|
||||
for (Enchantment enchantment : toSort) {
|
||||
if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) {
|
||||
|
@ -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<Enchantment> 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<Enchantment> sorted = new ArrayList<>();
|
||||
EnchantDisplay.OPTIONS.getSortedTypes().forEach(enchantmentType -> {
|
||||
((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().getSortedTypes().forEach(enchantmentType -> {
|
||||
List<Enchantment> typeEnchants = new ArrayList<>();
|
||||
for (Enchantment enchantment : toSort) {
|
||||
if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) {
|
||||
|
@ -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");
|
||||
|
@ -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<Player, Integer> players = new HashMap<>();
|
||||
private double distance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance");
|
||||
|
||||
|
@ -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<Player> players = new HashSet<>();
|
||||
private int amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
|
||||
|
@ -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<Player, Integer> 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");
|
||||
|
@ -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<Player, Integer> players = new HashMap<>();
|
||||
|
@ -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<Player> players = new HashSet<>();
|
||||
private int amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
|
||||
|
@ -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<EnchantmentRarity> matching = REGISTERED.stream().filter(rarity -> rarity.getName().equalsIgnoreCase(name)).findFirst();
|
||||
matching.ifPresent(REGISTERED::remove);
|
||||
|
@ -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<EnchantmentTarget> matching = REGISTERED.stream().filter(rarity -> rarity.getName().equalsIgnoreCase(name)).findFirst();
|
||||
matching.ifPresent(REGISTERED::remove);
|
||||
|
@ -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<Enchantment, Integer> toAdd = new HashMap<>();
|
||||
|
||||
if (!EnchantDisplay.OPTIONS.isUseLoreGetter()) {
|
||||
if (!((EnchantDisplay) this.getPlugin().getDisplayModule()).getOptions().isUseLoreGetter()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
version = 6.5.6
|
||||
version = 6.6.0
|
||||
plugin-name = EcoEnchants
|
Loading…
Reference in New Issue
Block a user