Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdbbb7e40a | ||
|
|
f2503e989c | ||
|
|
11c54a0055 | ||
|
|
7cc24199fb | ||
|
|
068b2cca0c | ||
|
|
f67f01278e | ||
|
|
8be8e1dab2 | ||
|
|
6d3651aca1 | ||
|
|
3dd2c58595 | ||
|
|
255aa1dd54 | ||
|
|
f2c5b085e8 | ||
|
|
b8a5fe0031 | ||
|
|
5603890663 |
@@ -98,5 +98,5 @@ build.dependsOn publishToMavenLocal
|
|||||||
|
|
||||||
group = 'com.willfp'
|
group = 'com.willfp'
|
||||||
archivesBaseName = project.name
|
archivesBaseName = project.name
|
||||||
version = '1.3.1'
|
version = '3.0.1'
|
||||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
package com.willfp.eco.common.recipes.lookup;
|
|
||||||
|
|
||||||
import com.willfp.eco.common.recipes.parts.RecipePart;
|
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.plugin.ServicePriority;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@UtilityClass
|
|
||||||
public final class RecipePartUtils {
|
|
||||||
/**
|
|
||||||
* Item lookup instance.
|
|
||||||
*/
|
|
||||||
private static final ItemLookup itemLookup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lookup recipe part from string.
|
|
||||||
*
|
|
||||||
* @param key The string to test.
|
|
||||||
* @return The generated recipe part, or null if invalid.
|
|
||||||
*/
|
|
||||||
public RecipePart lookup(@NotNull final String key) {
|
|
||||||
return itemLookup.lookup(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a new lookup.
|
|
||||||
*
|
|
||||||
* @param key The key of the lookup.
|
|
||||||
* @param lookup The lookup to register, where the output is the recipe part generated.
|
|
||||||
*/
|
|
||||||
public void registerLookup(@NotNull final String key,
|
|
||||||
@NotNull final Function<String, RecipePart> lookup) {
|
|
||||||
itemLookup.registerLookup(key, lookup);
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
if (!Bukkit.getServicesManager().isProvidedFor(ItemLookup.class)) {
|
|
||||||
Bukkit.getServicesManager().register(ItemLookup.class, new EcoItemLookup(), AbstractEcoPlugin.getInstance(), ServicePriority.Normal);
|
|
||||||
}
|
|
||||||
|
|
||||||
itemLookup = Bukkit.getServicesManager().load(ItemLookup.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
69
src/main/java/com/willfp/eco/spigot/EcoSpigotMain.java
Normal file
69
src/main/java/com/willfp/eco/spigot/EcoSpigotMain.java
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
package com.willfp.eco.spigot;
|
||||||
|
|
||||||
|
import com.willfp.eco.util.command.AbstractCommand;
|
||||||
|
import com.willfp.eco.util.integrations.IntegrationLoader;
|
||||||
|
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||||
|
import com.willfp.eco.util.protocollib.AbstractPacketAdapter;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EcoSpigotMain extends AbstractEcoPlugin {
|
||||||
|
/**
|
||||||
|
* Create a new instance of eco.
|
||||||
|
*/
|
||||||
|
public EcoSpigotMain() {
|
||||||
|
super("eco", 87955, 10043, "com.willfp.eco.proxy", "&a");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReload() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postLoad() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IntegrationLoader> getIntegrationLoaders() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AbstractCommand> getCommands() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AbstractPacketAdapter> getPacketAdapters() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Listener> getListeners() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Class<?>> getUpdatableClasses() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.willfp.eco.util;
|
|
||||||
|
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
|
||||||
import com.willfp.eco.util.proxy.AbstractProxy;
|
|
||||||
import com.willfp.eco.util.proxy.ProxyFactory;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
public class ProxyUtils {
|
|
||||||
/**
|
|
||||||
* Get the implementation of a specified proxy.
|
|
||||||
*
|
|
||||||
* @param proxyClass The proxy interface.
|
|
||||||
* @param <T> The type of the proxy.
|
|
||||||
* @return The proxy implementation.
|
|
||||||
*/
|
|
||||||
public @NotNull <T extends AbstractProxy> T getProxy(@NotNull final Class<T> proxyClass) {
|
|
||||||
return new ProxyFactory<>(AbstractEcoPlugin.getInstance(), proxyClass).getProxy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.willfp.eco.util.command;
|
package com.willfp.eco.util.command;
|
||||||
|
|
||||||
import com.willfp.eco.util.config.Configs;
|
|
||||||
import com.willfp.eco.util.internal.PluginDependent;
|
import com.willfp.eco.util.internal.PluginDependent;
|
||||||
import com.willfp.eco.util.interfaces.Registerable;
|
import com.willfp.eco.util.interfaces.Registerable;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||||
@@ -112,12 +111,12 @@ public abstract class AbstractCommand extends PluginDependent implements Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (playersOnly && !(sender instanceof Player)) {
|
if (playersOnly && !(sender instanceof Player)) {
|
||||||
sender.sendMessage(Configs.LANG.getMessage("not-player"));
|
sender.sendMessage(this.getPlugin().getLangYml().getMessage("not-player"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sender.hasPermission(permission) && sender instanceof Player) {
|
if (!sender.hasPermission(permission) && sender instanceof Player) {
|
||||||
sender.sendMessage(Configs.LANG.getNoPermission());
|
sender.sendMessage(this.getPlugin().getLangYml().getNoPermission());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,10 +48,12 @@ public abstract class BaseConfig extends PluginDependent implements ValueGetter
|
|||||||
*
|
*
|
||||||
* @param configName The name of the config
|
* @param configName The name of the config
|
||||||
* @param removeUnused Whether keys not present in the default config should be removed on update.
|
* @param removeUnused Whether keys not present in the default config should be removed on update.
|
||||||
|
* @param plugin The plugin.
|
||||||
*/
|
*/
|
||||||
protected BaseConfig(@NotNull final String configName,
|
protected BaseConfig(@NotNull final String configName,
|
||||||
final boolean removeUnused) {
|
final boolean removeUnused,
|
||||||
super(AbstractEcoPlugin.getInstance());
|
@NotNull final AbstractEcoPlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
this.name = configName + ".yml";
|
this.name = configName + ".yml";
|
||||||
this.removeUnused = removeUnused;
|
this.removeUnused = removeUnused;
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.willfp.eco.util.config;
|
|
||||||
|
|
||||||
import com.willfp.eco.util.config.updating.annotations.ConfigUpdater;
|
|
||||||
import com.willfp.eco.util.config.configs.Config;
|
|
||||||
import com.willfp.eco.util.config.configs.Lang;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
public final class Configs {
|
|
||||||
/**
|
|
||||||
* The {@link BaseConfig} implementation for lang.yml.
|
|
||||||
*/
|
|
||||||
public static final Lang LANG = new Lang();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link BaseConfig} implementation for config.yml.
|
|
||||||
*/
|
|
||||||
public static final Config CONFIG = new Config();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update lang.yml and config.yml.
|
|
||||||
*
|
|
||||||
* @see BaseConfig
|
|
||||||
*/
|
|
||||||
@ConfigUpdater
|
|
||||||
public void update() {
|
|
||||||
LANG.update();
|
|
||||||
CONFIG.update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +1,17 @@
|
|||||||
package com.willfp.eco.util.config.configs;
|
package com.willfp.eco.util.config.configs;
|
||||||
|
|
||||||
import com.willfp.eco.util.config.BaseConfig;
|
import com.willfp.eco.util.config.BaseConfig;
|
||||||
|
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
||||||
public class Config extends BaseConfig {
|
public class Config extends BaseConfig {
|
||||||
/**
|
/**
|
||||||
* Config.yml.
|
* Config.yml.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin.
|
||||||
*/
|
*/
|
||||||
public Config() {
|
public Config(@NotNull final AbstractEcoPlugin plugin) {
|
||||||
super("config", true);
|
super("config", true, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,17 @@ package com.willfp.eco.util.config.configs;
|
|||||||
|
|
||||||
import com.willfp.eco.util.StringUtils;
|
import com.willfp.eco.util.StringUtils;
|
||||||
import com.willfp.eco.util.config.BaseConfig;
|
import com.willfp.eco.util.config.BaseConfig;
|
||||||
|
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class Lang extends BaseConfig {
|
public class Lang extends BaseConfig {
|
||||||
/**
|
/**
|
||||||
* lang.yml.
|
* Lang.yml.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin.
|
||||||
*/
|
*/
|
||||||
public Lang() {
|
public Lang(@NotNull final AbstractEcoPlugin plugin) {
|
||||||
super("lang", false);
|
super("lang", false, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.willfp.eco.util.drops.internal;
|
package com.willfp.eco.util.drops.internal;
|
||||||
|
|
||||||
import com.willfp.eco.util.config.Configs;
|
|
||||||
import com.willfp.eco.util.config.updating.annotations.ConfigUpdater;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
@@ -13,15 +11,5 @@ public final class DropManager {
|
|||||||
* Standard by default, used if drops.collate key is not present in config.
|
* Standard by default, used if drops.collate key is not present in config.
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private DropQueueType type = DropQueueType.STANDARD;
|
private DropQueueType type = DropQueueType.COLLATED;
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the type of drop queue that should be used.
|
|
||||||
*
|
|
||||||
* @see DropQueueType
|
|
||||||
*/
|
|
||||||
@ConfigUpdater
|
|
||||||
public void update() {
|
|
||||||
type = Configs.CONFIG.getBool("drops.collate") ? DropQueueType.COLLATED : DropQueueType.STANDARD;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,24 +14,9 @@ import java.util.function.Function;
|
|||||||
@UtilityClass
|
@UtilityClass
|
||||||
public final class TelekinesisUtils {
|
public final class TelekinesisUtils {
|
||||||
/**
|
/**
|
||||||
* Instance of registered telekinesis utils.
|
* Instance of registered telekinesis tests.
|
||||||
*/
|
*/
|
||||||
private final Object instance;
|
private final TelekinesisTests tests;
|
||||||
|
|
||||||
/**
|
|
||||||
* The class of the utils.
|
|
||||||
*/
|
|
||||||
private final Class<?> clazz;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The test service registered to bukkit.
|
|
||||||
*/
|
|
||||||
private final Method testMethod;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The register service registered to bukkit.
|
|
||||||
*/
|
|
||||||
private final Method registerMethod;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the player for telekinesis.
|
* Test the player for telekinesis.
|
||||||
@@ -42,13 +27,7 @@ public final class TelekinesisUtils {
|
|||||||
* @return If the player is telekinetic.
|
* @return If the player is telekinetic.
|
||||||
*/
|
*/
|
||||||
public boolean testPlayer(@NotNull final Player player) {
|
public boolean testPlayer(@NotNull final Player player) {
|
||||||
try {
|
return tests.testPlayer(player);
|
||||||
return (boolean) testMethod.invoke(instance, player);
|
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,35 +36,10 @@ public final class TelekinesisUtils {
|
|||||||
* @param test The test to register, where the boolean output is if the player is telekinetic.
|
* @param test The test to register, where the boolean output is if the player is telekinetic.
|
||||||
*/
|
*/
|
||||||
public void registerTest(@NotNull final Function<Player, Boolean> test) {
|
public void registerTest(@NotNull final Function<Player, Boolean> test) {
|
||||||
try {
|
tests.registerTest(test);
|
||||||
registerMethod.invoke(instance, test);
|
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Method testMethod1;
|
tests = Bukkit.getServicesManager().load(TelekinesisTests.class);
|
||||||
Method registerMethod1;
|
|
||||||
if (Bukkit.getServicesManager().getKnownServices().stream().noneMatch(clazz -> clazz.getName().contains("TelekinesisTests"))) {
|
|
||||||
Bukkit.getServicesManager().register(TelekinesisTests.class, new EcoTelekinesisTests(), AbstractEcoPlugin.getInstance(), ServicePriority.Normal);
|
|
||||||
}
|
|
||||||
|
|
||||||
instance = Bukkit.getServicesManager().load(Bukkit.getServicesManager().getKnownServices().stream().filter(clazz -> clazz.getName().contains("TelekinesisTests")).findFirst().get());
|
|
||||||
clazz = instance.getClass();
|
|
||||||
|
|
||||||
try {
|
|
||||||
testMethod1 = clazz.getDeclaredMethod("testPlayer", Player.class);
|
|
||||||
registerMethod1 = clazz.getDeclaredMethod("registerTest", Function.class);
|
|
||||||
testMethod1.setAccessible(true);
|
|
||||||
registerMethod1.setAccessible(true);
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
testMethod1 = null;
|
|
||||||
registerMethod1 = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
testMethod = testMethod1;
|
|
||||||
registerMethod = registerMethod1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,16 @@ public abstract class Extension {
|
|||||||
* The {@link AbstractEcoPlugin} that this extension is for.
|
* The {@link AbstractEcoPlugin} that this extension is for.
|
||||||
*/
|
*/
|
||||||
@Getter(AccessLevel.PROTECTED)
|
@Getter(AccessLevel.PROTECTED)
|
||||||
private final AbstractEcoPlugin plugin = AbstractEcoPlugin.getInstance();
|
private final AbstractEcoPlugin plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new extension for a plugin.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin.
|
||||||
|
*/
|
||||||
|
protected Extension(@NotNull final AbstractEcoPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata containing version and name.
|
* Metadata containing version and name.
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class EcoExtensionLoader extends PluginDependent implements ExtensionLoad
|
|||||||
Object object = null;
|
Object object = null;
|
||||||
try {
|
try {
|
||||||
cls = cl.loadClass(mainClass);
|
cls = cl.loadClass(mainClass);
|
||||||
object = cls.getConstructor().newInstance();
|
object = cls.getConstructor(AbstractEcoPlugin.class).newInstance(this.getPlugin());
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,6 @@ import java.util.Set;
|
|||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class AnticheatManager {
|
public class AnticheatManager {
|
||||||
/**
|
|
||||||
* The linked {@link AbstractEcoPlugin} to register anticheat listeners to.
|
|
||||||
*/
|
|
||||||
private final AbstractEcoPlugin plugin = AbstractEcoPlugin.getInstance();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of all registered anticheats.
|
* A set of all registered anticheats.
|
||||||
*/
|
*/
|
||||||
@@ -24,9 +19,11 @@ public class AnticheatManager {
|
|||||||
/**
|
/**
|
||||||
* Register a new anticheat.
|
* Register a new anticheat.
|
||||||
*
|
*
|
||||||
|
* @param plugin The plugin.
|
||||||
* @param anticheat The anticheat to register.
|
* @param anticheat The anticheat to register.
|
||||||
*/
|
*/
|
||||||
public void register(@NotNull final AnticheatWrapper anticheat) {
|
public void register(@NotNull final AbstractEcoPlugin plugin,
|
||||||
|
@NotNull final AnticheatWrapper anticheat) {
|
||||||
if (anticheat instanceof Listener) {
|
if (anticheat instanceof Listener) {
|
||||||
plugin.getEventManager().registerListener((Listener) anticheat);
|
plugin.getEventManager().registerListener((Listener) anticheat);
|
||||||
}
|
}
|
||||||
@@ -49,8 +46,6 @@ public class AnticheatManager {
|
|||||||
* @param player The player to remove the exemption.
|
* @param player The player to remove the exemption.
|
||||||
*/
|
*/
|
||||||
public void unexemptPlayer(@NotNull final Player player) {
|
public void unexemptPlayer(@NotNull final Player player) {
|
||||||
plugin.getScheduler().runLater(() -> {
|
anticheats.forEach(anticheat -> anticheat.unexempt(player));
|
||||||
anticheats.forEach(anticheat -> anticheat.unexempt(player));
|
|
||||||
}, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,12 @@ import com.willfp.eco.util.bukkit.scheduling.EcoScheduler;
|
|||||||
import com.willfp.eco.util.bukkit.scheduling.RunnableFactory;
|
import com.willfp.eco.util.bukkit.scheduling.RunnableFactory;
|
||||||
import com.willfp.eco.util.bukkit.scheduling.Scheduler;
|
import com.willfp.eco.util.bukkit.scheduling.Scheduler;
|
||||||
import com.willfp.eco.util.command.AbstractCommand;
|
import com.willfp.eco.util.command.AbstractCommand;
|
||||||
import com.willfp.eco.util.config.Configs;
|
import com.willfp.eco.util.config.configs.Config;
|
||||||
|
import com.willfp.eco.util.config.configs.Lang;
|
||||||
import com.willfp.eco.util.config.updating.ConfigHandler;
|
import com.willfp.eco.util.config.updating.ConfigHandler;
|
||||||
import com.willfp.eco.util.drops.internal.DropManager;
|
|
||||||
import com.willfp.eco.util.drops.internal.FastCollatedDropQueue;
|
import com.willfp.eco.util.drops.internal.FastCollatedDropQueue;
|
||||||
|
import com.willfp.eco.util.drops.telekinesis.EcoTelekinesisTests;
|
||||||
|
import com.willfp.eco.util.drops.telekinesis.TelekinesisTests;
|
||||||
import com.willfp.eco.util.events.armorequip.ArmorListener;
|
import com.willfp.eco.util.events.armorequip.ArmorListener;
|
||||||
import com.willfp.eco.util.events.armorequip.DispenserArmorListener;
|
import com.willfp.eco.util.events.armorequip.DispenserArmorListener;
|
||||||
import com.willfp.eco.util.events.entitydeathbyentity.EntityDeathByEntityListeners;
|
import com.willfp.eco.util.events.entitydeathbyentity.EntityDeathByEntityListeners;
|
||||||
@@ -41,6 +43,8 @@ import com.willfp.eco.util.optional.Prerequisite;
|
|||||||
import com.willfp.eco.util.protocollib.AbstractPacketAdapter;
|
import com.willfp.eco.util.protocollib.AbstractPacketAdapter;
|
||||||
import com.willfp.eco.util.recipe.RecipeListener;
|
import com.willfp.eco.util.recipe.RecipeListener;
|
||||||
import com.willfp.eco.util.recipe.RecipeManager;
|
import com.willfp.eco.util.recipe.RecipeManager;
|
||||||
|
import com.willfp.eco.util.recipe.lookup.EcoItemLookup;
|
||||||
|
import com.willfp.eco.util.recipe.lookup.ItemLookup;
|
||||||
import com.willfp.eco.util.updater.UpdateChecker;
|
import com.willfp.eco.util.updater.UpdateChecker;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
@@ -48,6 +52,7 @@ import org.bstats.bukkit.Metrics;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.ServicePriority;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -58,13 +63,8 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public abstract class AbstractEcoPlugin extends JavaPlugin {
|
public abstract class AbstractEcoPlugin extends JavaPlugin {
|
||||||
/**
|
|
||||||
* The instance of the plugin.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private static AbstractEcoPlugin instance;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the plugin.
|
* The name of the plugin.
|
||||||
*/
|
*/
|
||||||
@@ -129,6 +129,18 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
@Getter
|
@Getter
|
||||||
private final EventManager eventManager;
|
private final EventManager eventManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Config.yml.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final Config configYml;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lang.yml.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final Lang langYml;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The internal factory to produce {@link org.bukkit.NamespacedKey}s.
|
* The internal factory to produce {@link org.bukkit.NamespacedKey}s.
|
||||||
*/
|
*/
|
||||||
@@ -202,6 +214,9 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
this.extensionLoader = new EcoExtensionLoader(this);
|
this.extensionLoader = new EcoExtensionLoader(this);
|
||||||
this.configHandler = new ConfigHandler(this);
|
this.configHandler = new ConfigHandler(this);
|
||||||
this.recipeManager = new RecipeManager(this);
|
this.recipeManager = new RecipeManager(this);
|
||||||
|
|
||||||
|
this.langYml = new Lang(this);
|
||||||
|
this.configYml = new Config(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -260,9 +275,6 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
updatableClasses.add(Configs.class);
|
|
||||||
updatableClasses.add(DropManager.class);
|
|
||||||
updatableClasses.addAll(this.getUpdatableClasses());
|
updatableClasses.addAll(this.getUpdatableClasses());
|
||||||
|
|
||||||
this.getListeners().forEach(listener -> this.getEventManager().registerListener(listener));
|
this.getListeners().forEach(listener -> this.getEventManager().registerListener(listener));
|
||||||
@@ -298,7 +310,13 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
public final void onLoad() {
|
public final void onLoad() {
|
||||||
super.onLoad();
|
super.onLoad();
|
||||||
|
|
||||||
instance = this;
|
if (!Bukkit.getServicesManager().isProvidedFor(TelekinesisTests.class)) {
|
||||||
|
Bukkit.getServicesManager().register(TelekinesisTests.class, new EcoTelekinesisTests(), this, ServicePriority.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Bukkit.getServicesManager().isProvidedFor(ItemLookup.class)) {
|
||||||
|
Bukkit.getServicesManager().register(ItemLookup.class, new EcoItemLookup(), this, ServicePriority.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
this.load();
|
this.load();
|
||||||
}
|
}
|
||||||
@@ -339,6 +357,9 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
* Default code to be executed on plugin reload.
|
* Default code to be executed on plugin reload.
|
||||||
*/
|
*/
|
||||||
public final void reload() {
|
public final void reload() {
|
||||||
|
this.getConfigYml().update();
|
||||||
|
this.getLangYml().update();
|
||||||
|
|
||||||
this.getConfigHandler().callUpdate();
|
this.getConfigHandler().callUpdate();
|
||||||
this.getConfigHandler().callUpdate(); // Call twice to fix issues
|
this.getConfigHandler().callUpdate(); // Call twice to fix issues
|
||||||
this.getScheduler().cancelAll();
|
this.getScheduler().cancelAll();
|
||||||
@@ -364,10 +385,10 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
integrationLoaders.add(new IntegrationLoader("Kingdoms", () -> AntigriefManager.register(new AntigriefKingdoms())));
|
integrationLoaders.add(new IntegrationLoader("Kingdoms", () -> AntigriefManager.register(new AntigriefKingdoms())));
|
||||||
|
|
||||||
// Anticheat
|
// Anticheat
|
||||||
integrationLoaders.add(new IntegrationLoader("AAC5", () -> AnticheatManager.register(new AnticheatAAC())));
|
integrationLoaders.add(new IntegrationLoader("AAC5", () -> AnticheatManager.register(this, new AnticheatAAC())));
|
||||||
integrationLoaders.add(new IntegrationLoader("Matrix", () -> AnticheatManager.register(new AnticheatMatrix())));
|
integrationLoaders.add(new IntegrationLoader("Matrix", () -> AnticheatManager.register(this, new AnticheatMatrix())));
|
||||||
integrationLoaders.add(new IntegrationLoader("NoCheatPlus", () -> AnticheatManager.register(new AnticheatNCP())));
|
integrationLoaders.add(new IntegrationLoader("NoCheatPlus", () -> AnticheatManager.register(this, new AnticheatNCP())));
|
||||||
integrationLoaders.add(new IntegrationLoader("Spartan", () -> AnticheatManager.register(new AnticheatSpartan())));
|
integrationLoaders.add(new IntegrationLoader("Spartan", () -> AnticheatManager.register(this, new AnticheatSpartan())));
|
||||||
integrationLoaders.addAll(this.getIntegrationLoaders());
|
integrationLoaders.addAll(this.getIntegrationLoaders());
|
||||||
return integrationLoaders;
|
return integrationLoaders;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
package com.willfp.eco.util.proxy;
|
|
||||||
|
|
||||||
import com.willfp.eco.util.internal.PluginDependent;
|
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.IdentityHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ProxyFactory<T extends AbstractProxy> extends PluginDependent {
|
|
||||||
/**
|
|
||||||
* Cached proxy implementations in order to not perform expensive reflective class-finding.
|
|
||||||
*/
|
|
||||||
private static final Map<Class<? extends AbstractProxy>, AbstractProxy> CACHE = new IdentityHashMap<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The class of the proxy interface.
|
|
||||||
*/
|
|
||||||
private final Class<T> proxyClass;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new Proxy Factory for a specific type.
|
|
||||||
*
|
|
||||||
* @param plugin The plugin to create proxies for.
|
|
||||||
* @param proxyClass The class of the proxy interface.
|
|
||||||
*/
|
|
||||||
public ProxyFactory(@NotNull final AbstractEcoPlugin plugin,
|
|
||||||
@NotNull final Class<T> proxyClass) {
|
|
||||||
super(plugin);
|
|
||||||
this.proxyClass = proxyClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the implementation of a proxy.
|
|
||||||
*
|
|
||||||
* @return The proxy implementation.
|
|
||||||
*/
|
|
||||||
public @NotNull T getProxy() {
|
|
||||||
try {
|
|
||||||
T cachedProxy = attemptCache();
|
|
||||||
if (cachedProxy != null) {
|
|
||||||
return cachedProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
String className = this.getPlugin().getProxyPackage() + "." + ProxyConstants.NMS_VERSION + "." + proxyClass.getSimpleName().replace("Proxy", "");
|
|
||||||
final Class<?> class2 = Class.forName(className);
|
|
||||||
Object instance = class2.getConstructor().newInstance();
|
|
||||||
if (proxyClass.isAssignableFrom(class2) && proxyClass.isInstance(instance)) {
|
|
||||||
T proxy = proxyClass.cast(instance);
|
|
||||||
CACHE.put(proxyClass, proxy);
|
|
||||||
return proxy;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// If not returned, then throw error
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new UnsupportedVersionException("You're running an unsupported server version: " + ProxyConstants.NMS_VERSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
private T attemptCache() {
|
|
||||||
Object proxy = CACHE.get(proxyClass);
|
|
||||||
if (proxy == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (proxyClass.isInstance(proxy)) {
|
|
||||||
return proxyClass.cast(proxy);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.willfp.eco.util.recipe;
|
package com.willfp.eco.util.recipe;
|
||||||
|
|
||||||
import com.willfp.eco.common.recipes.parts.EmptyRecipePart;
|
|
||||||
import com.willfp.eco.common.recipes.parts.RecipePart;
|
|
||||||
import com.willfp.eco.util.interfaces.Registerable;
|
import com.willfp.eco.util.interfaces.Registerable;
|
||||||
import com.willfp.eco.util.internal.PluginDependent;
|
import com.willfp.eco.util.internal.PluginDependent;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||||
|
import com.willfp.eco.util.recipe.parts.EmptyRecipePart;
|
||||||
|
import com.willfp.eco.util.recipe.parts.RecipePart;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.willfp.eco.common.recipes.lookup;
|
package com.willfp.eco.util.recipe.lookup;
|
||||||
|
|
||||||
import com.willfp.eco.common.recipes.parts.EmptyRecipePart;
|
import com.willfp.eco.util.recipe.parts.EmptyRecipePart;
|
||||||
import com.willfp.eco.common.recipes.parts.RecipePart;
|
import com.willfp.eco.util.recipe.parts.RecipePart;
|
||||||
import com.willfp.eco.common.recipes.parts.SimpleRecipePart;
|
import com.willfp.eco.util.recipe.parts.SimpleRecipePart;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.willfp.eco.common.recipes.lookup;
|
package com.willfp.eco.util.recipe.lookup;
|
||||||
|
|
||||||
import com.willfp.eco.common.recipes.parts.RecipePart;
|
import com.willfp.eco.util.recipe.parts.RecipePart;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.willfp.eco.util.recipe.lookup;
|
||||||
|
|
||||||
|
import com.willfp.eco.util.recipe.parts.RecipePart;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public final class RecipePartUtils {
|
||||||
|
/**
|
||||||
|
* Instance of registered lookups.
|
||||||
|
*/
|
||||||
|
private final ItemLookup lookup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a new lookup.
|
||||||
|
*
|
||||||
|
* @param key The key of the lookup.
|
||||||
|
* @param lookupFunction The lookup to register, where the output is the recipe part generated.
|
||||||
|
*/
|
||||||
|
public void registerLookup(@NotNull final String key,
|
||||||
|
@NotNull final Function<String, RecipePart> lookupFunction) {
|
||||||
|
lookup.registerLookup(key, lookupFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup recipe part from string.
|
||||||
|
*
|
||||||
|
* @param key The string to test.
|
||||||
|
* @return The generated recipe part, or null if invalid.
|
||||||
|
*/
|
||||||
|
public RecipePart lookup(@NotNull final String key) {
|
||||||
|
return lookup.lookup(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
lookup = Bukkit.getServicesManager().load(ItemLookup.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.common.recipes.parts;
|
package com.willfp.eco.util.recipe.parts;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.common.recipes.parts;
|
package com.willfp.eco.util.recipe.parts;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.common.recipes.parts;
|
package com.willfp.eco.util.recipe.parts;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.common.recipes.parts;
|
package com.willfp.eco.util.recipe.parts;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
0
src/main/resources/config.yml
Normal file
0
src/main/resources/config.yml
Normal file
0
src/main/resources/lang.yml
Normal file
0
src/main/resources/lang.yml
Normal file
26
src/main/resources/plugin.yml
Normal file
26
src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: eco
|
||||||
|
version: 3.0.1
|
||||||
|
main: com.willfp.eco.spigot.EcoSpigotMain
|
||||||
|
api-version: 1.15
|
||||||
|
authors: [Auxilor]
|
||||||
|
website: willfp.com
|
||||||
|
loadbefore:
|
||||||
|
- EcoEnchants
|
||||||
|
- Talismans
|
||||||
|
- ItemStats
|
||||||
|
- EcoArmor
|
||||||
|
- Illusioner
|
||||||
|
depend:
|
||||||
|
- ProtocolLib
|
||||||
|
softdepend:
|
||||||
|
- WorldGuard
|
||||||
|
- GriefPrevention
|
||||||
|
- Towny
|
||||||
|
- FactionsUUID
|
||||||
|
- Lands
|
||||||
|
- Kingdoms
|
||||||
|
- NoCheatPlus
|
||||||
|
- AAC
|
||||||
|
- Matrix
|
||||||
|
- Spartan
|
||||||
|
- PlaceholderAPI
|
||||||
Reference in New Issue
Block a user