mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-25 15:35:11 +01:00
parent
aa3816a21d
commit
39c725cd65
@ -87,7 +87,6 @@ clean.doLast {
|
||||
shadowJar {
|
||||
relocate('org.bstats.bukkit', 'com.willfp.eco.util.shaded.bstats')
|
||||
relocate('org.apache.maven', 'com.willfp.eco.util.shaded.maven')
|
||||
relocate('org.reflections', 'com.willfp.eco.util.shaded.reflections')
|
||||
archiveFileName = findProperty("plugin-name") + " v" + findProperty("version") + ".jar"
|
||||
}
|
||||
|
||||
|
@ -6,17 +6,25 @@ import com.willfp.eco.util.command.AbstractCommand;
|
||||
import com.willfp.eco.util.drops.telekinesis.TelekinesisTests;
|
||||
import com.willfp.eco.util.integrations.IntegrationLoader;
|
||||
import com.willfp.eco.util.interfaces.EcoRunnable;
|
||||
import com.willfp.eco.util.interfaces.Updatable;
|
||||
import com.willfp.eco.util.packets.AbstractPacketAdapter;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import com.willfp.ecoenchants.command.commands.CommandEcodebug;
|
||||
import com.willfp.ecoenchants.command.commands.CommandEcoreload;
|
||||
import com.willfp.ecoenchants.command.commands.CommandEnchantinfo;
|
||||
import com.willfp.ecoenchants.command.tabcompleters.TabCompleterEnchantinfo;
|
||||
import com.willfp.ecoenchants.config.EcoEnchantsConfigs;
|
||||
import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||
import com.willfp.ecoenchants.display.EnchantmentCache;
|
||||
import com.willfp.ecoenchants.display.packets.PacketChat;
|
||||
import com.willfp.ecoenchants.display.packets.PacketOpenWindowMerchant;
|
||||
import com.willfp.ecoenchants.display.packets.PacketSetCreativeSlot;
|
||||
import com.willfp.ecoenchants.display.packets.PacketSetSlot;
|
||||
import com.willfp.ecoenchants.display.packets.PacketWindowItems;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
||||
import com.willfp.ecoenchants.enchantments.support.merging.anvil.AnvilListeners;
|
||||
import com.willfp.ecoenchants.enchantments.support.merging.grindstone.GrindstoneListeners;
|
||||
import com.willfp.ecoenchants.enchantments.support.obtaining.EnchantingListeners;
|
||||
@ -194,4 +202,18 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
|
||||
new VillagerListeners()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends Updatable>> getUpdatableClasses() {
|
||||
return Arrays.asList(
|
||||
EcoEnchantsConfigs.class,
|
||||
EnchantmentCache.class,
|
||||
EnchantmentRarity.class,
|
||||
EnchantmentTarget.class,
|
||||
EcoEnchants.class,
|
||||
EnchantDisplay.class,
|
||||
TabCompleterEnchantinfo.class,
|
||||
EnchantmentType.class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ package com.willfp.ecoenchants.command.tabcompleters;
|
||||
import com.willfp.eco.util.StringUtils;
|
||||
import com.willfp.eco.util.command.AbstractCommand;
|
||||
import com.willfp.eco.util.command.AbstractTabCompleter;
|
||||
import com.willfp.eco.util.config.annotations.Updatable;
|
||||
import com.willfp.eco.util.config.annotations.ConfigUpdater;
|
||||
import com.willfp.eco.util.interfaces.Updatable;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -17,8 +18,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Updatable
|
||||
public class TabCompleterEnchantinfo extends AbstractTabCompleter {
|
||||
public class TabCompleterEnchantinfo extends AbstractTabCompleter implements Updatable {
|
||||
/**
|
||||
* The cached enchantment names.
|
||||
*/
|
||||
@ -34,7 +34,8 @@ public class TabCompleterEnchantinfo extends AbstractTabCompleter {
|
||||
/**
|
||||
* Called on /ecoreload.
|
||||
*/
|
||||
public static void update() {
|
||||
@ConfigUpdater
|
||||
public static void reload() {
|
||||
ENCHANT_NAMES.clear();
|
||||
ENCHANT_NAMES.addAll(EcoEnchants.values().stream().filter(EcoEnchant::isEnabled).map(EcoEnchant::getName).collect(Collectors.toList()));
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.willfp.ecoenchants.config;
|
||||
|
||||
import com.willfp.eco.util.config.annotations.Updatable;
|
||||
import com.willfp.eco.util.config.annotations.ConfigUpdater;
|
||||
import com.willfp.eco.util.interfaces.Updatable;
|
||||
import com.willfp.ecoenchants.config.configs.EnchantmentConfig;
|
||||
import com.willfp.ecoenchants.config.configs.Rarity;
|
||||
import com.willfp.ecoenchants.config.configs.Target;
|
||||
@ -11,9 +12,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Updatable(methodName = "updateConfigs")
|
||||
@UtilityClass
|
||||
public class EcoEnchantsConfigs {
|
||||
public class EcoEnchantsConfigs implements Updatable {
|
||||
/**
|
||||
* target.yml.
|
||||
*/
|
||||
@ -33,6 +33,7 @@ public class EcoEnchantsConfigs {
|
||||
/**
|
||||
* Update all configs.
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public void updateConfigs() {
|
||||
TARGET.update();
|
||||
RARITY.update();
|
||||
|
@ -2,7 +2,8 @@ package com.willfp.ecoenchants.display;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.willfp.eco.util.NumberUtils;
|
||||
import com.willfp.eco.util.config.annotations.Updatable;
|
||||
import com.willfp.eco.util.config.annotations.ConfigUpdater;
|
||||
import com.willfp.eco.util.interfaces.Updatable;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import com.willfp.ecoenchants.display.options.DisplayOptions;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
@ -23,9 +24,12 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Updatable
|
||||
/**
|
||||
* All methods and fields pertaining to showing players the enchantments on their items.
|
||||
*/
|
||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||
@UtilityClass
|
||||
public class EnchantDisplay {
|
||||
public class EnchantDisplay implements Updatable {
|
||||
/**
|
||||
* Instance of EcoEnchants.
|
||||
*/
|
||||
@ -58,6 +62,7 @@ public class EnchantDisplay {
|
||||
/**
|
||||
* Update config values.
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public static void update() {
|
||||
OPTIONS.update();
|
||||
EnchantmentCache.update();
|
||||
|
@ -2,7 +2,8 @@ package com.willfp.ecoenchants.display;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.willfp.eco.util.config.Configs;
|
||||
import com.willfp.eco.util.config.annotations.Updatable;
|
||||
import com.willfp.eco.util.config.annotations.ConfigUpdater;
|
||||
import com.willfp.eco.util.interfaces.Updatable;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity;
|
||||
@ -21,10 +22,9 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Updatable
|
||||
@UtilityClass
|
||||
public class EnchantmentCache {
|
||||
@SuppressWarnings("deprecation")
|
||||
public class EnchantmentCache implements Updatable {
|
||||
/**
|
||||
* The physical cache.
|
||||
*/
|
||||
@ -64,6 +64,7 @@ public class EnchantmentCache {
|
||||
/**
|
||||
* Update the cache.
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public static void update() {
|
||||
CACHE.clear();
|
||||
Arrays.asList(Enchantment.values()).parallelStream().forEach(enchantment -> {
|
||||
|
@ -4,7 +4,8 @@ package com.willfp.ecoenchants.enchantments;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.willfp.eco.util.config.annotations.Updatable;
|
||||
import com.willfp.eco.util.config.annotations.ConfigUpdater;
|
||||
import com.willfp.eco.util.interfaces.Updatable;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.AshArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.CloudsArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.CrimsonArtifact;
|
||||
@ -238,10 +239,9 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@Updatable
|
||||
@UtilityClass
|
||||
@SuppressWarnings({"unused", "checkstyle:JavadocVariable"})
|
||||
public class EcoEnchants {
|
||||
public class EcoEnchants implements Updatable {
|
||||
public static final String CONFIG_LOCATION = "config.";
|
||||
public static final String OBTAINING_LOCATION = "obtaining.";
|
||||
public static final String GENERAL_LOCATION = "general-config.";
|
||||
@ -550,6 +550,7 @@ public class EcoEnchants {
|
||||
/**
|
||||
* Update all {@link EcoEnchant}s.
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public static void update() {
|
||||
for (EcoEnchant ecoEnchant : new HashSet<>(values())) {
|
||||
ecoEnchant.update();
|
||||
|
@ -2,10 +2,11 @@ package com.willfp.ecoenchants.enchantments.meta;
|
||||
|
||||
import com.willfp.eco.util.NumberUtils;
|
||||
import com.willfp.eco.util.StringUtils;
|
||||
import com.willfp.eco.util.config.annotations.Updatable;
|
||||
import com.willfp.eco.util.config.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.eco.util.interfaces.Updatable;
|
||||
import com.willfp.ecoenchants.config.EcoEnchantsConfigs;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -15,8 +16,7 @@ import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@Updatable
|
||||
public class EnchantmentRarity implements Registerable {
|
||||
public class EnchantmentRarity implements Registerable, Updatable {
|
||||
/**
|
||||
* All registered rarities.
|
||||
*/
|
||||
@ -134,6 +134,7 @@ public class EnchantmentRarity implements Registerable {
|
||||
/**
|
||||
* Update all rarities.
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public static void update() {
|
||||
Set<String> raritiesNames = EcoEnchantsConfigs.RARITY.getRarities();
|
||||
raritiesNames.forEach(rarity -> {
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.willfp.ecoenchants.enchantments.meta;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.willfp.eco.util.config.annotations.Updatable;
|
||||
import com.willfp.eco.util.config.annotations.ConfigUpdater;
|
||||
import com.willfp.eco.util.interfaces.Registerable;
|
||||
import com.willfp.eco.util.interfaces.Updatable;
|
||||
import com.willfp.ecoenchants.config.EcoEnchantsConfigs;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Material;
|
||||
@ -13,8 +14,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@Updatable
|
||||
public class EnchantmentTarget implements Registerable {
|
||||
public class EnchantmentTarget implements Registerable, Updatable {
|
||||
/**
|
||||
* All registered targets.
|
||||
*/
|
||||
@ -77,6 +77,7 @@ public class EnchantmentTarget implements Registerable {
|
||||
/**
|
||||
* Update all targets.
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public static void update() {
|
||||
Set<String> targetNames = EcoEnchantsConfigs.TARGET.getTargets();
|
||||
ALL.materials.clear();
|
||||
|
@ -2,7 +2,8 @@ package com.willfp.ecoenchants.enchantments.meta;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.willfp.eco.util.config.Configs;
|
||||
import com.willfp.eco.util.config.annotations.Updatable;
|
||||
import com.willfp.eco.util.config.annotations.ConfigUpdater;
|
||||
import com.willfp.eco.util.interfaces.Updatable;
|
||||
import com.willfp.eco.util.lambda.ObjectCallable;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
|
||||
@ -14,8 +15,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Updatable
|
||||
public class EnchantmentType {
|
||||
public class EnchantmentType implements Updatable {
|
||||
/**
|
||||
* All registered types.
|
||||
*/
|
||||
@ -204,6 +204,7 @@ public class EnchantmentType {
|
||||
/**
|
||||
* Update callables of all types.
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public static void update() {
|
||||
REGISTERED.forEach(EnchantmentType::refresh);
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ repositories {
|
||||
dependencies {
|
||||
implementation 'org.apache.maven:maven-artifact:3.0.3'
|
||||
implementation 'org.bstats:bstats-bukkit:1.7'
|
||||
implementation 'org.reflections:reflections:0.9.12'
|
||||
compileOnly 'org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT'
|
||||
compileOnly 'me.clip:placeholderapi:2.10.9'
|
||||
compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.0-SNAPSHOT'
|
||||
@ -20,5 +19,5 @@ dependencies {
|
||||
compileOnly 'com.github.angeschossen:LandsAPI:4.7.3'
|
||||
compileOnly 'fr.neatmonster:nocheatplus:3.16.1-SNAPSHOT'
|
||||
compileOnly 'com.github.jiangdashao:matrix-api-repo:317d4635fd'
|
||||
compileOnly fileTree(dir: '../lib', include: ['*.jar'])
|
||||
compileOnly fileTree(dir: '/../lib', include: ['*.jar'])
|
||||
}
|
@ -1,18 +1,26 @@
|
||||
package com.willfp.eco.util.config;
|
||||
|
||||
import com.willfp.eco.util.config.annotations.Updatable;
|
||||
import com.willfp.eco.util.config.annotations.ConfigUpdater;
|
||||
import com.willfp.eco.util.config.annotations.InvalidUpdatableClassException;
|
||||
import com.willfp.eco.util.config.annotations.InvalidUpdateMethodException;
|
||||
import com.willfp.eco.util.injection.PluginDependent;
|
||||
import com.willfp.eco.util.interfaces.Updatable;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ConfigHandler extends PluginDependent {
|
||||
/**
|
||||
* A set of all classes that can be updated.
|
||||
*/
|
||||
private final Set<Class<? extends Updatable>> updatableClasses = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Creates a new config handler and links it to an {@link AbstractEcoPlugin}.
|
||||
*
|
||||
@ -26,35 +34,43 @@ public class ConfigHandler extends PluginDependent {
|
||||
* Invoke all update methods.
|
||||
*/
|
||||
public void callUpdate() {
|
||||
for (Class<?> clazz : new Reflections("com.willfp").getTypesAnnotatedWith(Updatable.class)) {
|
||||
boolean valid = false;
|
||||
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
if (!method.isAnnotationPresent(Updatable.class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Modifier.isStatic(method.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
updatableClasses.forEach(clazz -> Arrays.stream(clazz.getDeclaredMethods()).forEach(method -> {
|
||||
if (method.isAnnotationPresent(ConfigUpdater.class)) {
|
||||
if (method.getParameterTypes().length != 0) {
|
||||
continue;
|
||||
throw new InvalidUpdateMethodException("Update method must not have parameters.");
|
||||
}
|
||||
if (!Modifier.isStatic(method.getModifiers())) {
|
||||
throw new InvalidUpdateMethodException("Update method must be static.");
|
||||
}
|
||||
|
||||
try {
|
||||
method.invoke(null);
|
||||
valid = true;
|
||||
break;
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
throw new InvalidUpdateMethodException("Update method generated an exception.");
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
throw new InvalidUpdatableClassException("No valid update method found! (Must be static, have no parameters)");
|
||||
/**
|
||||
* Register an updatable class.
|
||||
*
|
||||
* @param updatableClass The class with an update method.
|
||||
*/
|
||||
public void registerUpdatableClass(@NotNull final Class<? extends Updatable> updatableClass) {
|
||||
boolean isValid = false;
|
||||
for (Method method : updatableClass.getDeclaredMethods()) {
|
||||
if (Modifier.isStatic(method.getModifiers()) && method.getParameterTypes().length == 0 && method.isAnnotationPresent(ConfigUpdater.class)) {
|
||||
isValid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
throw new InvalidUpdatableClassException("Registered updatable class " + updatableClass + " must have an annotated static method with no modifiers.");
|
||||
}
|
||||
|
||||
updatableClasses.add(updatableClass);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package com.willfp.eco.util.config;
|
||||
|
||||
import com.willfp.eco.util.config.annotations.Updatable;
|
||||
import com.willfp.eco.util.config.annotations.ConfigUpdater;
|
||||
import com.willfp.eco.util.config.configs.Config;
|
||||
import com.willfp.eco.util.config.configs.Lang;
|
||||
import com.willfp.eco.util.interfaces.Updatable;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@Updatable
|
||||
@UtilityClass
|
||||
public final class Configs {
|
||||
public final class Configs implements Updatable {
|
||||
/**
|
||||
* The {@link BaseConfig} implementation for lang.yml.
|
||||
*/
|
||||
@ -23,6 +23,7 @@ public final class Configs {
|
||||
*
|
||||
* @see BaseConfig
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public void update() {
|
||||
LANG.update();
|
||||
CONFIG.update();
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.willfp.eco.util.config.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface ConfigUpdater {
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.willfp.eco.util.config.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Updatable {
|
||||
/**
|
||||
* The static, no-parameter method to be called on config update.
|
||||
* <p>
|
||||
* Default is <b>update</b>.
|
||||
*
|
||||
* @return The method name.
|
||||
*/
|
||||
String methodName() default "update";
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
package com.willfp.eco.util.drops.internal;
|
||||
|
||||
import com.willfp.eco.util.config.Configs;
|
||||
import com.willfp.eco.util.config.annotations.Updatable;
|
||||
import com.willfp.eco.util.config.annotations.ConfigUpdater;
|
||||
import com.willfp.eco.util.interfaces.Updatable;
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@Updatable
|
||||
@UtilityClass
|
||||
public final class DropManager {
|
||||
public final class DropManager implements Updatable {
|
||||
/**
|
||||
* The currently used type, or implementation, of {@link AbstractDropQueue}.
|
||||
* <p>
|
||||
@ -21,6 +21,7 @@ public final class DropManager {
|
||||
*
|
||||
* @see DropQueueType
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public void update() {
|
||||
type = Configs.CONFIG.getBool("drops.collate") ? DropQueueType.COLLATED : DropQueueType.STANDARD;
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
package com.willfp.eco.util.interfaces;
|
||||
|
||||
public interface Updatable {
|
||||
}
|
@ -12,6 +12,8 @@ import com.willfp.eco.util.bukkit.scheduling.RunnableFactory;
|
||||
import com.willfp.eco.util.bukkit.scheduling.Scheduler;
|
||||
import com.willfp.eco.util.command.AbstractCommand;
|
||||
import com.willfp.eco.util.config.ConfigHandler;
|
||||
import com.willfp.eco.util.config.Configs;
|
||||
import com.willfp.eco.util.drops.internal.DropManager;
|
||||
import com.willfp.eco.util.drops.internal.FastCollatedDropQueue;
|
||||
import com.willfp.eco.util.drops.telekinesis.EcoTelekinesisTests;
|
||||
import com.willfp.eco.util.drops.telekinesis.TelekinesisTests;
|
||||
@ -37,6 +39,7 @@ import com.willfp.eco.util.integrations.antigrief.plugins.AntigriefTowny;
|
||||
import com.willfp.eco.util.integrations.antigrief.plugins.AntigriefWorldGuard;
|
||||
import com.willfp.eco.util.integrations.placeholder.PlaceholderManager;
|
||||
import com.willfp.eco.util.integrations.placeholder.plugins.PlaceholderIntegrationPAPI;
|
||||
import com.willfp.eco.util.interfaces.Updatable;
|
||||
import com.willfp.eco.util.optional.Prerequisite;
|
||||
import com.willfp.eco.util.packets.AbstractPacketAdapter;
|
||||
import com.willfp.eco.util.updater.UpdateChecker;
|
||||
@ -86,6 +89,11 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
||||
*/
|
||||
private final List<IntegrationLoader> integrations = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Set of external plugin integrations.
|
||||
*/
|
||||
private final List<Class<? extends Updatable>> updatableClasses = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* The internal plugin logger.
|
||||
*/
|
||||
@ -232,12 +240,19 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
updatableClasses.add(Configs.class);
|
||||
updatableClasses.add(DropManager.class);
|
||||
updatableClasses.addAll(this.getUpdatableClasses());
|
||||
|
||||
this.getListeners().forEach(listener -> this.getEventManager().registerListener(listener));
|
||||
|
||||
this.getCommands().forEach(AbstractCommand::register);
|
||||
|
||||
this.getScheduler().runLater(this::afterLoad, 1);
|
||||
|
||||
this.updatableClasses.forEach(clazz -> this.getConfigHandler().registerUpdatableClass(clazz));
|
||||
|
||||
this.enable();
|
||||
}
|
||||
|
||||
@ -386,4 +401,11 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
||||
* @return A list of all listeners.
|
||||
*/
|
||||
public abstract List<Listener> getListeners();
|
||||
|
||||
/**
|
||||
* All updatable classes.
|
||||
*
|
||||
* @return A list of all updatable classes.
|
||||
*/
|
||||
public abstract List<Class<? extends Updatable>> getUpdatableClasses();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user