Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd87683b6a | ||
|
|
83da1e7b95 | ||
|
|
9f9515675a | ||
|
|
1aa084cd90 | ||
|
|
525ec0260f | ||
|
|
ac15ffee6c | ||
|
|
83d68c5046 | ||
|
|
7d1186811f | ||
|
|
88bc01e5df | ||
|
|
78d2459c7a | ||
|
|
21f4bd79eb | ||
|
|
64147c6261 | ||
|
|
c67c486f2f | ||
|
|
ae419bacb3 | ||
|
|
17b0214f2f | ||
|
|
963f706018 | ||
|
|
74398cda62 | ||
|
|
8321af5af2 | ||
|
|
2524d86462 | ||
|
|
e050bf83df | ||
|
|
91c936a06f | ||
|
|
93dfd44410 | ||
|
|
304d0cdebf | ||
|
|
108d878939 | ||
|
|
e10e327c56 | ||
|
|
cabea9fba9 | ||
|
|
f9159cf245 | ||
|
|
2db011ae10 | ||
|
|
f96716966d | ||
|
|
7515efbde9 | ||
|
|
4ebd0d79d5 | ||
|
|
0c3b5d3c30 | ||
|
|
e0b06dedff | ||
|
|
187ac8163d | ||
|
|
ac2078957d | ||
|
|
352d495301 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -14,7 +14,7 @@ bin/
|
|||||||
# Gradle
|
# Gradle
|
||||||
.gradle
|
.gradle
|
||||||
**/build/
|
**/build/
|
||||||
!eco-util/src/**/build/
|
!eco-api/src/**/build/
|
||||||
.gradletasknamecache
|
.gradletasknamecache
|
||||||
!gradle-wrapper.jar
|
!gradle-wrapper.jar
|
||||||
gradle-app.setting
|
gradle-app.setting
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(":eco-util")
|
implementation project(":eco-api")
|
||||||
implementation project(":eco-core").getSubprojects()
|
implementation project(":eco-core").getSubprojects()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,6 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT'
|
|
||||||
compileOnly 'org.jetbrains:annotations:19.0.0'
|
compileOnly 'org.jetbrains:annotations:19.0.0'
|
||||||
|
|
||||||
// Lombok
|
// Lombok
|
||||||
@@ -76,8 +75,8 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
relocate('org.bstats.bukkit', 'com.willfp.eco.util.shaded.bstats')
|
relocate('org.bstats.bukkit', 'com.willfp.eco.shaded.bstats')
|
||||||
relocate('org.apache.maven', 'com.willfp.eco.util.shaded.maven')
|
relocate('org.apache.maven', 'com.willfp.eco.shaded.maven')
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
|
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
|
||||||
|
|
||||||
<suppressions>
|
<suppressions>
|
||||||
|
<!-- Internals don't need javadoc. -->
|
||||||
|
<suppress files="[\\/]internal[\\/]" checks="MissingJavadocMethod"/>
|
||||||
|
<suppress files="[\\/]internal[\\/]" checks="JavadocVariable"/>
|
||||||
|
|
||||||
<!-- Modified version of library -->
|
<!-- Modified version of library -->
|
||||||
<suppress files="ArmorEquipEvent.java" checks="JavadocVariable"/>
|
<suppress files="ArmorEquipEvent.java" checks="JavadocVariable"/>
|
||||||
<suppress files="ArmorEquipEvent.java" checks="MissingJavadocMethod"/>
|
<suppress files="ArmorEquipEvent.java" checks="MissingJavadocMethod"/>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ group 'com.willfp'
|
|||||||
version rootProject.version
|
version rootProject.version
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
compileOnly 'org.spigotmc:spigot:1.16.4-R0.1-SNAPSHOT'
|
||||||
compileOnly 'org.apache.maven:maven-artifact:3.0.3'
|
compileOnly 'org.apache.maven:maven-artifact:3.0.3'
|
||||||
compileOnly 'org.bstats:bstats-bukkit:1.7'
|
compileOnly 'org.bstats:bstats-bukkit:1.7'
|
||||||
compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.0-SNAPSHOT'
|
compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.0-SNAPSHOT'
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.protocollib;
|
package com.willfp.eco.core;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
@@ -6,7 +6,6 @@ import com.comphenix.protocol.events.ListenerPriority;
|
|||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -35,7 +34,7 @@ public abstract class AbstractPacketAdapter extends PacketAdapter {
|
|||||||
* @param priority The priority at which the adapter should be ran on packet send/receive.
|
* @param priority The priority at which the adapter should be ran on packet send/receive.
|
||||||
* @param postLoad If the packet adapter should be registered after the server has loaded.
|
* @param postLoad If the packet adapter should be registered after the server has loaded.
|
||||||
*/
|
*/
|
||||||
protected AbstractPacketAdapter(@NotNull final AbstractEcoPlugin plugin,
|
protected AbstractPacketAdapter(@NotNull final EcoPlugin plugin,
|
||||||
@NotNull final PacketType type,
|
@NotNull final PacketType type,
|
||||||
@NotNull final ListenerPriority priority,
|
@NotNull final ListenerPriority priority,
|
||||||
final boolean postLoad) {
|
final boolean postLoad) {
|
||||||
@@ -51,7 +50,7 @@ public abstract class AbstractPacketAdapter extends PacketAdapter {
|
|||||||
* @param type The {@link PacketType} to listen for.
|
* @param type The {@link PacketType} to listen for.
|
||||||
* @param postLoad If the packet adapter should be registered after the server has loaded.
|
* @param postLoad If the packet adapter should be registered after the server has loaded.
|
||||||
*/
|
*/
|
||||||
protected AbstractPacketAdapter(@NotNull final AbstractEcoPlugin plugin,
|
protected AbstractPacketAdapter(@NotNull final EcoPlugin plugin,
|
||||||
@NotNull final PacketType type,
|
@NotNull final PacketType type,
|
||||||
final boolean postLoad) {
|
final boolean postLoad) {
|
||||||
this(plugin, type, ListenerPriority.NORMAL, postLoad);
|
this(plugin, type, ListenerPriority.NORMAL, postLoad);
|
||||||
@@ -1,29 +1,29 @@
|
|||||||
package com.willfp.eco.util.plugin;
|
package com.willfp.eco.core;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.command.AbstractCommand;
|
||||||
|
import com.willfp.eco.core.config.base.ConfigYml;
|
||||||
|
import com.willfp.eco.core.config.base.LangYml;
|
||||||
|
import com.willfp.eco.internal.config.updating.ConfigHandler;
|
||||||
|
import com.willfp.eco.core.display.Display;
|
||||||
|
import com.willfp.eco.core.display.DisplayModule;
|
||||||
|
import com.willfp.eco.core.events.EventManager;
|
||||||
|
import com.willfp.eco.core.extensions.ExtensionLoader;
|
||||||
|
import com.willfp.eco.core.factory.MetadataValueFactory;
|
||||||
|
import com.willfp.eco.core.factory.NamespacedKeyFactory;
|
||||||
|
import com.willfp.eco.core.factory.RunnableFactory;
|
||||||
|
import com.willfp.eco.core.integrations.IntegrationLoader;
|
||||||
|
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager;
|
||||||
|
import com.willfp.eco.core.scheduling.Scheduler;
|
||||||
|
import com.willfp.eco.internal.UpdateChecker;
|
||||||
import com.willfp.eco.internal.arrows.ArrowDataListener;
|
import com.willfp.eco.internal.arrows.ArrowDataListener;
|
||||||
import com.willfp.eco.internal.bukkit.events.EcoEventManager;
|
import com.willfp.eco.internal.events.EcoEventManager;
|
||||||
import com.willfp.eco.internal.bukkit.logging.EcoLogger;
|
|
||||||
import com.willfp.eco.internal.bukkit.scheduling.EcoScheduler;
|
|
||||||
import com.willfp.eco.internal.extensions.EcoExtensionLoader;
|
import com.willfp.eco.internal.extensions.EcoExtensionLoader;
|
||||||
import com.willfp.eco.util.bukkit.events.EventManager;
|
import com.willfp.eco.internal.factory.EcoMetadataValueFactory;
|
||||||
import com.willfp.eco.util.bukkit.keys.NamespacedKeyFactory;
|
import com.willfp.eco.internal.factory.EcoNamespacedKeyFactory;
|
||||||
import com.willfp.eco.util.bukkit.logging.Logger;
|
import com.willfp.eco.internal.factory.EcoRunnableFactory;
|
||||||
import com.willfp.eco.util.bukkit.meta.MetadataValueFactory;
|
import com.willfp.eco.internal.integrations.PlaceholderIntegrationPAPI;
|
||||||
import com.willfp.eco.util.bukkit.scheduling.RunnableFactory;
|
import com.willfp.eco.internal.logging.EcoLogger;
|
||||||
import com.willfp.eco.util.bukkit.scheduling.Scheduler;
|
import com.willfp.eco.internal.scheduling.EcoScheduler;
|
||||||
import com.willfp.eco.util.command.AbstractCommand;
|
|
||||||
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.display.Display;
|
|
||||||
import com.willfp.eco.util.display.DisplayModule;
|
|
||||||
import com.willfp.eco.util.extensions.loader.ExtensionLoader;
|
|
||||||
import com.willfp.eco.util.integrations.IntegrationLoader;
|
|
||||||
import com.willfp.eco.util.integrations.placeholder.PlaceholderManager;
|
|
||||||
import com.willfp.eco.util.integrations.placeholder.plugins.PlaceholderIntegrationPAPI;
|
|
||||||
import com.willfp.eco.util.optional.Prerequisite;
|
|
||||||
import com.willfp.eco.util.protocollib.AbstractPacketAdapter;
|
|
||||||
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;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
@@ -39,9 +39,10 @@ import java.util.Arrays;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class AbstractEcoPlugin extends JavaPlugin {
|
public abstract class EcoPlugin extends JavaPlugin {
|
||||||
/**
|
/**
|
||||||
* Loaded eco plugins.
|
* Loaded eco plugins.
|
||||||
*/
|
*/
|
||||||
@@ -83,22 +84,11 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
@Getter
|
@Getter
|
||||||
private final Set<String> loadedIntegrations = new HashSet<>();
|
private final Set<String> loadedIntegrations = new HashSet<>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Set of external plugin integrations.
|
|
||||||
*/
|
|
||||||
private final List<IntegrationLoader> integrationLoaders = new ArrayList<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set of classes to be processed on config update.
|
* Set of classes to be processed on config update.
|
||||||
*/
|
*/
|
||||||
private final List<Class<?>> updatableClasses = new ArrayList<>();
|
private final List<Class<?>> updatableClasses = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
|
||||||
* The internal plugin logger.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private final Logger log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The internal plugin scheduler.
|
* The internal plugin scheduler.
|
||||||
*/
|
*/
|
||||||
@@ -115,13 +105,13 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
* Config.yml.
|
* Config.yml.
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private final Config configYml;
|
private final ConfigYml configYml;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lang.yml.
|
* Lang.yml.
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private final Lang langYml;
|
private final LangYml langYml;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The internal factory to produce {@link org.bukkit.NamespacedKey}s.
|
* The internal factory to produce {@link org.bukkit.NamespacedKey}s.
|
||||||
@@ -136,7 +126,7 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
private final MetadataValueFactory metadataValueFactory;
|
private final MetadataValueFactory metadataValueFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The internal factory to produce {@link com.willfp.eco.util.bukkit.scheduling.EcoBukkitRunnable}s.
|
* The internal factory to produce {@link com.willfp.eco.core.scheduling.RunnableTask}s.
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private final RunnableFactory runnableFactory;
|
private final RunnableFactory runnableFactory;
|
||||||
@@ -144,7 +134,7 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
/**
|
/**
|
||||||
* The loader for all plugin extensions.
|
* The loader for all plugin extensions.
|
||||||
*
|
*
|
||||||
* @see com.willfp.eco.util.extensions.Extension
|
* @see com.willfp.eco.core.extensions.Extension
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private final ExtensionLoader extensionLoader;
|
private final ExtensionLoader extensionLoader;
|
||||||
@@ -161,6 +151,11 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
@Getter
|
@Getter
|
||||||
private DisplayModule displayModule;
|
private DisplayModule displayModule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The logger for the plugin.
|
||||||
|
*/
|
||||||
|
private final Logger logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the server is running an outdated version of the plugin.
|
* If the server is running an outdated version of the plugin.
|
||||||
*/
|
*/
|
||||||
@@ -176,28 +171,28 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
* @param proxyPackage The package where proxy implementations are stored.
|
* @param proxyPackage The package where proxy implementations are stored.
|
||||||
* @param color The color of the plugin (used in messages, such as &a, &b)
|
* @param color The color of the plugin (used in messages, such as &a, &b)
|
||||||
*/
|
*/
|
||||||
protected AbstractEcoPlugin(@NotNull final String pluginName,
|
protected EcoPlugin(@NotNull final String pluginName,
|
||||||
final int resourceId,
|
final int resourceId,
|
||||||
final int bStatsId,
|
final int bStatsId,
|
||||||
@NotNull final String proxyPackage,
|
@NotNull final String proxyPackage,
|
||||||
@NotNull final String color) {
|
@NotNull final String color) {
|
||||||
this.pluginName = pluginName;
|
this.pluginName = pluginName;
|
||||||
this.resourceId = resourceId;
|
this.resourceId = resourceId;
|
||||||
this.bStatsId = bStatsId;
|
this.bStatsId = bStatsId;
|
||||||
this.proxyPackage = proxyPackage;
|
this.proxyPackage = proxyPackage;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
|
||||||
this.log = new EcoLogger(this);
|
|
||||||
this.scheduler = new EcoScheduler(this);
|
this.scheduler = new EcoScheduler(this);
|
||||||
this.eventManager = new EcoEventManager(this);
|
this.eventManager = new EcoEventManager(this);
|
||||||
this.namespacedKeyFactory = new NamespacedKeyFactory(this);
|
this.namespacedKeyFactory = new EcoNamespacedKeyFactory(this);
|
||||||
this.metadataValueFactory = new MetadataValueFactory(this);
|
this.metadataValueFactory = new EcoMetadataValueFactory(this);
|
||||||
this.runnableFactory = new RunnableFactory(this);
|
this.runnableFactory = new EcoRunnableFactory(this);
|
||||||
this.extensionLoader = new EcoExtensionLoader(this);
|
this.extensionLoader = new EcoExtensionLoader(this);
|
||||||
this.configHandler = new ConfigHandler(this);
|
this.configHandler = new ConfigHandler(this);
|
||||||
|
this.logger = new EcoLogger(this);
|
||||||
|
|
||||||
this.langYml = new Lang(this);
|
this.langYml = new LangYml(this);
|
||||||
this.configYml = new Config(this);
|
this.configYml = new ConfigYml(this);
|
||||||
|
|
||||||
LOADED_ECO_PLUGINS.add(this.getName().toLowerCase());
|
LOADED_ECO_PLUGINS.add(this.getName().toLowerCase());
|
||||||
}
|
}
|
||||||
@@ -207,10 +202,10 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void onEnable() {
|
public final void onEnable() {
|
||||||
super.onLoad();
|
super.onEnable();
|
||||||
|
|
||||||
this.getLog().info("");
|
this.getLogger().info("");
|
||||||
this.getLog().info("Loading " + this.color + this.pluginName);
|
this.getLogger().info("Loading " + this.color + this.pluginName);
|
||||||
|
|
||||||
this.getEventManager().registerListener(new ArrowDataListener(this));
|
this.getEventManager().registerListener(new ArrowDataListener(this));
|
||||||
|
|
||||||
@@ -220,9 +215,9 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
if (!(currentVersion.compareTo(mostRecentVersion) > 0 || currentVersion.equals(mostRecentVersion))) {
|
if (!(currentVersion.compareTo(mostRecentVersion) > 0 || currentVersion.equals(mostRecentVersion))) {
|
||||||
this.outdated = true;
|
this.outdated = true;
|
||||||
this.getScheduler().runTimer(() -> {
|
this.getScheduler().runTimer(() -> {
|
||||||
this.getLog().info("&c " + this.pluginName + " is out of date! (Version " + this.getDescription().getVersion() + ")");
|
this.getLogger().info("&c " + this.pluginName + " is out of date! (Version " + this.getDescription().getVersion() + ")");
|
||||||
this.getLog().info("&cThe newest version is &f" + version);
|
this.getLogger().info("&cThe newest version is &f" + version);
|
||||||
this.getLog().info("&cDownload the new version!");
|
this.getLogger().info("&cDownload the new version!");
|
||||||
}, 0, 864000);
|
}, 0, 864000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -243,7 +238,7 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.getLog().info("Loaded integrations: " + String.join(", ", this.getLoadedIntegrations()));
|
this.getLogger().info("Loaded integrations: " + String.join(", ", this.getLoadedIntegrations()));
|
||||||
|
|
||||||
Prerequisite.update();
|
Prerequisite.update();
|
||||||
|
|
||||||
@@ -265,7 +260,7 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
this.enable();
|
this.enable();
|
||||||
|
|
||||||
this.getLog().info("");
|
this.getLogger().info("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -308,23 +303,23 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!Prerequisite.HAS_PAPER.isMet()) {
|
if (!Prerequisite.HAS_PAPER.isMet()) {
|
||||||
this.getLog().error("");
|
this.getLogger().severe("");
|
||||||
this.getLog().error("----------------------------");
|
this.getLogger().severe("----------------------------");
|
||||||
this.getLog().error("");
|
this.getLogger().severe("");
|
||||||
this.getLog().error("You don't seem to be running paper!");
|
this.getLogger().severe("You don't seem to be running paper!");
|
||||||
this.getLog().error("Paper is strongly recommended for all servers,");
|
this.getLogger().severe("Paper is strongly recommended for all servers,");
|
||||||
this.getLog().error("and some things may not function properly without it");
|
this.getLogger().severe("and some things may not function properly without it");
|
||||||
this.getLog().error("Download Paper from &fhttps://papermc.io");
|
this.getLogger().severe("Download Paper from &fhttps://papermc.io");
|
||||||
this.getLog().error("");
|
this.getLogger().severe("");
|
||||||
this.getLog().error("----------------------------");
|
this.getLogger().severe("----------------------------");
|
||||||
this.getLog().error("");
|
this.getLogger().severe("");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.postLoad();
|
this.postLoad();
|
||||||
|
|
||||||
this.reload();
|
this.reload();
|
||||||
|
|
||||||
this.getLog().info("Loaded " + this.color + this.pluginName);
|
this.getLogger().info("Loaded " + this.color + this.pluginName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -409,5 +404,13 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
|||||||
* @return The display module, or null.
|
* @return The display module, or null.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
protected abstract DisplayModule createDisplayModule();
|
protected DisplayModule createDisplayModule() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Logger getLogger() {
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.willfp.eco.core;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public abstract class PluginDependent {
|
||||||
|
/**
|
||||||
|
* The {@link EcoPlugin} that is stored.
|
||||||
|
*/
|
||||||
|
@Getter(AccessLevel.PROTECTED)
|
||||||
|
private final EcoPlugin plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pass an {@link EcoPlugin} in order to interface with it.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin to manage.
|
||||||
|
*/
|
||||||
|
protected PluginDependent(@NotNull final EcoPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.willfp.eco.util.optional;
|
package com.willfp.eco.core;
|
||||||
|
|
||||||
import com.willfp.eco.util.ClassUtils;
|
import com.willfp.eco.util.ClassUtils;
|
||||||
import com.willfp.eco.util.proxy.ProxyConstants;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -15,15 +14,6 @@ public class Prerequisite {
|
|||||||
* All existing prerequisites are registered on creation.
|
* All existing prerequisites are registered on creation.
|
||||||
*/
|
*/
|
||||||
private static final List<Prerequisite> VALUES = new ArrayList<>();
|
private static final List<Prerequisite> VALUES = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Requires the server to be running minecraft version 1.16 or higher.
|
|
||||||
*/
|
|
||||||
public static final Prerequisite MINIMUM_1_16 = new Prerequisite(
|
|
||||||
() -> !ProxyConstants.NMS_VERSION.contains("15"),
|
|
||||||
"Requires minimum server version of 1.16"
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires the server to be running an implementation of paper.
|
* Requires the server to be running an implementation of paper.
|
||||||
*/
|
*/
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.willfp.eco.util.command;
|
package com.willfp.eco.core.command;
|
||||||
|
|
||||||
import com.willfp.eco.util.internal.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@@ -43,12 +43,12 @@ public abstract class AbstractCommand extends PluginDependent implements Command
|
|||||||
* <p>
|
* <p>
|
||||||
* The name cannot be the same as an existing command as this will conflict.
|
* The name cannot be the same as an existing command as this will conflict.
|
||||||
*
|
*
|
||||||
* @param plugin The owning {@link AbstractEcoPlugin}.
|
* @param plugin The owning {@link EcoPlugin}.
|
||||||
* @param name The name used in execution.
|
* @param name The name used in execution.
|
||||||
* @param permission The permission required to execute the command.
|
* @param permission The permission required to execute the command.
|
||||||
* @param playersOnly If only players should be able to execute this command.
|
* @param playersOnly If only players should be able to execute this command.
|
||||||
*/
|
*/
|
||||||
protected AbstractCommand(@NotNull final AbstractEcoPlugin plugin,
|
protected AbstractCommand(@NotNull final EcoPlugin plugin,
|
||||||
@NotNull final String name,
|
@NotNull final String name,
|
||||||
@NotNull final String permission,
|
@NotNull final String permission,
|
||||||
final boolean playersOnly) {
|
final boolean playersOnly) {
|
||||||
@@ -98,7 +98,7 @@ public abstract class AbstractCommand extends PluginDependent implements Command
|
|||||||
* @param command The bukkit command.
|
* @param command The bukkit command.
|
||||||
* @param label The name of the executed command.
|
* @param label The name of the executed command.
|
||||||
* @param args The arguments of the command (anything after the physical command name)
|
* @param args The arguments of the command (anything after the physical command name)
|
||||||
* @return If the command was processed by the linked {@link AbstractEcoPlugin}
|
* @return If the command was processed by the linked {@link EcoPlugin}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean onCommand(@NotNull final CommandSender sender,
|
public final boolean onCommand(@NotNull final CommandSender sender,
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.command;
|
package com.willfp.eco.core.command;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.willfp.eco.util.config;
|
package com.willfp.eco.core.config;
|
||||||
|
|
||||||
import com.willfp.eco.internal.config.AbstractUpdatableConfig;
|
import com.willfp.eco.internal.config.UpdatableYamlConfig;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class BaseConfig extends AbstractUpdatableConfig {
|
public abstract class BaseConfig extends UpdatableYamlConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config implementation for configs present in the plugin's base directory (eg config.yml, lang.yml).
|
* Config implementation for configs present in the plugin's base directory (eg config.yml, lang.yml).
|
||||||
@@ -18,7 +18,7 @@ public abstract class BaseConfig extends AbstractUpdatableConfig {
|
|||||||
*/
|
*/
|
||||||
protected BaseConfig(@NotNull final String configName,
|
protected BaseConfig(@NotNull final String configName,
|
||||||
final boolean removeUnused,
|
final boolean removeUnused,
|
||||||
@NotNull final AbstractEcoPlugin plugin,
|
@NotNull final EcoPlugin plugin,
|
||||||
@NotNull final String... updateBlacklist) {
|
@NotNull final String... updateBlacklist) {
|
||||||
super(configName, plugin, "", plugin.getClass(), removeUnused, updateBlacklist);
|
super(configName, plugin, "", plugin.getClass(), removeUnused, updateBlacklist);
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ public abstract class BaseConfig extends AbstractUpdatableConfig {
|
|||||||
*/
|
*/
|
||||||
protected BaseConfig(@NotNull final String configName,
|
protected BaseConfig(@NotNull final String configName,
|
||||||
final boolean removeUnused,
|
final boolean removeUnused,
|
||||||
@NotNull final AbstractEcoPlugin plugin) {
|
@NotNull final EcoPlugin plugin) {
|
||||||
super(configName, plugin, "", plugin.getClass(), removeUnused, "");
|
super(configName, plugin, "", plugin.getClass(), removeUnused, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.willfp.eco.util.config;
|
package com.willfp.eco.core.config;
|
||||||
|
|
||||||
import com.willfp.eco.util.serialization.EcoSerializable;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -30,15 +28,6 @@ public interface Config {
|
|||||||
@NotNull
|
@NotNull
|
||||||
List<String> getKeys(boolean deep);
|
List<String> getKeys(boolean deep);
|
||||||
|
|
||||||
/**
|
|
||||||
* Set an object in config.
|
|
||||||
*
|
|
||||||
* @param path The path.
|
|
||||||
* @param object The object.
|
|
||||||
*/
|
|
||||||
void set(@NotNull String path,
|
|
||||||
@NotNull EcoSerializable<?> object);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an object from config.
|
* Get an object from config.
|
||||||
* Default implementations call {@link org.bukkit.configuration.file.YamlConfiguration#get(String)}.
|
* Default implementations call {@link org.bukkit.configuration.file.YamlConfiguration#get(String)}.
|
||||||
@@ -47,49 +36,17 @@ public interface Config {
|
|||||||
* @return The object.
|
* @return The object.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
Object getRaw(@NotNull String path);
|
Object get(@NotNull String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an object from config.
|
* Set an object in config.
|
||||||
|
* Default implementations call {@link org.bukkit.configuration.file.YamlConfiguration#set(String, Object)}
|
||||||
*
|
*
|
||||||
* @param path The path.
|
* @param path The path.
|
||||||
* @param clazz The class of the object.
|
* @param object The object.
|
||||||
* @param <T> The type of the object.
|
|
||||||
* @return The object.
|
|
||||||
*/
|
*/
|
||||||
@NotNull <T extends EcoSerializable<T>> T get(@NotNull String path,
|
void set(@NotNull String path,
|
||||||
@NotNull Class<T> clazz);
|
@Nullable Object object);
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an object from config.
|
|
||||||
*
|
|
||||||
* @param path The path.
|
|
||||||
* @param clazz The class of the object.
|
|
||||||
* @param <T> The type of the object.
|
|
||||||
* @return The object, or null if not found.
|
|
||||||
*/
|
|
||||||
@Nullable <T extends EcoSerializable<T>> T getOrNull(@NotNull String path,
|
|
||||||
@NotNull Class<T> clazz);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get bukkit configuration section from config.
|
|
||||||
*
|
|
||||||
* @param path The key to check.
|
|
||||||
* @return The configuration section. Throws NPE if not found.
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
@Deprecated
|
|
||||||
ConfigurationSection getSection(@NotNull String path);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get bukkit configuration section from config.
|
|
||||||
*
|
|
||||||
* @param path The key to check.
|
|
||||||
* @return The configuration section, or null if not found.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
@Deprecated
|
|
||||||
ConfigurationSection getSectionOrNull(@NotNull String path);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get subsection from config.
|
* Get subsection from config.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.config.updating.annotations;
|
package com.willfp.eco.core.config;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.willfp.eco.util.config;
|
package com.willfp.eco.core.config;
|
||||||
|
|
||||||
import com.willfp.eco.internal.config.AbstractUpdatableConfig;
|
import com.willfp.eco.internal.config.UpdatableYamlConfig;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class ExtendableConfig extends AbstractUpdatableConfig {
|
public abstract class ExtendableConfig extends UpdatableYamlConfig {
|
||||||
/**
|
/**
|
||||||
* Config implementation for configs present in the plugin's base directory (eg config.yml, lang.yml).
|
* Config implementation for configs present in the plugin's base directory (eg config.yml, lang.yml).
|
||||||
* <p>
|
* <p>
|
||||||
@@ -19,7 +19,7 @@ public abstract class ExtendableConfig extends AbstractUpdatableConfig {
|
|||||||
*/
|
*/
|
||||||
protected ExtendableConfig(@NotNull final String configName,
|
protected ExtendableConfig(@NotNull final String configName,
|
||||||
final boolean removeUnused,
|
final boolean removeUnused,
|
||||||
@NotNull final AbstractEcoPlugin plugin,
|
@NotNull final EcoPlugin plugin,
|
||||||
@NotNull final Class<?> source,
|
@NotNull final Class<?> source,
|
||||||
@NotNull final String subDirectoryPath,
|
@NotNull final String subDirectoryPath,
|
||||||
@NotNull final String... updateBlacklist) {
|
@NotNull final String... updateBlacklist) {
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.willfp.eco.util.config;
|
package com.willfp.eco.core.config;
|
||||||
|
|
||||||
import com.willfp.eco.internal.config.AbstractConfig;
|
import com.willfp.eco.internal.config.LoadableYamlConfig;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class StaticBaseConfig extends AbstractConfig {
|
public abstract class StaticBaseConfig extends LoadableYamlConfig {
|
||||||
/**
|
/**
|
||||||
* Config implementation for configs present in the plugin's base directory (eg config.yml, lang.yml).
|
* Config implementation for configs present in the plugin's base directory (eg config.yml, lang.yml).
|
||||||
* <p>
|
* <p>
|
||||||
@@ -14,7 +14,7 @@ public abstract class StaticBaseConfig extends AbstractConfig {
|
|||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
*/
|
*/
|
||||||
protected StaticBaseConfig(@NotNull final String configName,
|
protected StaticBaseConfig(@NotNull final String configName,
|
||||||
@NotNull final AbstractEcoPlugin plugin) {
|
@NotNull final EcoPlugin plugin) {
|
||||||
super(configName, plugin, "", plugin.getClass());
|
super(configName, plugin, "", plugin.getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.willfp.eco.core.config;
|
||||||
|
|
||||||
|
import com.willfp.eco.internal.config.ConfigWrapper;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public abstract class YamlConfig extends ConfigWrapper<YamlConfiguration> {
|
||||||
|
/**
|
||||||
|
* Config implementation for passing YamlConfigurations.
|
||||||
|
* <p>
|
||||||
|
* Does not automatically update.
|
||||||
|
*
|
||||||
|
* @param config The YamlConfiguration handle.
|
||||||
|
*/
|
||||||
|
public YamlConfig(@NotNull final YamlConfiguration config) {
|
||||||
|
init(config);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.willfp.eco.core.config.base;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.config.BaseConfig;
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
||||||
|
public class ConfigYml extends BaseConfig {
|
||||||
|
/**
|
||||||
|
* Config.yml.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin.
|
||||||
|
*/
|
||||||
|
public ConfigYml(@NotNull final EcoPlugin plugin) {
|
||||||
|
super("config", true, plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
package com.willfp.eco.util.config.configs;
|
package com.willfp.eco.core.config.base;
|
||||||
|
|
||||||
import com.willfp.eco.util.config.BaseConfig;
|
import com.willfp.eco.core.config.BaseConfig;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class Lang extends BaseConfig {
|
public class LangYml extends BaseConfig {
|
||||||
/**
|
/**
|
||||||
* Lang.yml.
|
* Lang.yml.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
*/
|
*/
|
||||||
public Lang(@NotNull final AbstractEcoPlugin plugin) {
|
public LangYml(@NotNull final EcoPlugin plugin) {
|
||||||
super("lang", false, plugin);
|
super("lang", false, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.display;
|
package com.willfp.eco.core.display;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
@@ -16,7 +16,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class Display {
|
public class Display {
|
||||||
/**
|
/**
|
||||||
* The prefix for lore lines.
|
* The prefix for lore lines.
|
||||||
@@ -80,7 +79,6 @@ public class Display {
|
|||||||
List<DisplayModule> modules = MODULES.get(priority);
|
List<DisplayModule> modules = MODULES.get(priority);
|
||||||
for (DisplayModule module : modules) {
|
for (DisplayModule module : modules) {
|
||||||
Object[] varargs = pluginVarArgs.get(module.getPluginName());
|
Object[] varargs = pluginVarArgs.get(module.getPluginName());
|
||||||
module.display(itemStack);
|
|
||||||
module.display(itemStack, varargs);
|
module.display(itemStack, varargs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.willfp.eco.util.display;
|
package com.willfp.eco.core.display;
|
||||||
|
|
||||||
import com.willfp.eco.util.internal.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -19,7 +19,7 @@ public abstract class DisplayModule extends PluginDependent {
|
|||||||
* @param plugin The plugin that the display is for.
|
* @param plugin The plugin that the display is for.
|
||||||
* @param priority The priority of the module.
|
* @param priority The priority of the module.
|
||||||
*/
|
*/
|
||||||
protected DisplayModule(@NotNull final AbstractEcoPlugin plugin,
|
protected DisplayModule(@NotNull final EcoPlugin plugin,
|
||||||
@NotNull final DisplayPriority priority) {
|
@NotNull final DisplayPriority priority) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
@@ -36,26 +36,13 @@ public abstract class DisplayModule extends PluginDependent {
|
|||||||
// Technically optional.
|
// Technically optional.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Display an item.
|
|
||||||
* <p>
|
|
||||||
* This method exists for parity with older plugins that don't include the varargs.
|
|
||||||
*
|
|
||||||
* @param itemStack The item.
|
|
||||||
* @deprecated Use {@link this#display(ItemStack, Object...)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
protected void display(@NotNull final ItemStack itemStack) {
|
|
||||||
// Technically optional.
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Revert an item.
|
* Revert an item.
|
||||||
*
|
*
|
||||||
* @param itemStack The item.
|
* @param itemStack The item.
|
||||||
*/
|
*/
|
||||||
protected void revert(@NotNull final ItemStack itemStack) {
|
protected void revert(@NotNull final ItemStack itemStack) {
|
||||||
// Technically optoinal.
|
// Technically optional.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.display;
|
package com.willfp.eco.core.display;
|
||||||
|
|
||||||
public enum DisplayPriority {
|
public enum DisplayPriority {
|
||||||
/**
|
/**
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.drops;
|
package com.willfp.eco.core.drops;
|
||||||
|
|
||||||
import com.willfp.eco.internal.drops.AbstractDropQueue;
|
import com.willfp.eco.internal.drops.AbstractDropQueue;
|
||||||
import com.willfp.eco.internal.drops.DropManager;
|
import com.willfp.eco.internal.drops.DropManager;
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.willfp.eco.core.events;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
||||||
|
public class ArmorEquipEvent extends PlayerEvent {
|
||||||
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
|
||||||
|
public ArmorEquipEvent(@NotNull final Player player) {
|
||||||
|
super(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of handlers handling this event.
|
||||||
|
*
|
||||||
|
* @return A list of handlers handling this event.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.events.entitydeathbyentity;
|
package com.willfp.eco.core.events;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.bukkit.events;
|
package com.willfp.eco.core.events;
|
||||||
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.events.naturalexpgainevent;
|
package com.willfp.eco.core.events;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@@ -1,25 +1,25 @@
|
|||||||
package com.willfp.eco.util.extensions;
|
package com.willfp.eco.core.extensions;
|
||||||
|
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.internal.extensions.ExtensionMetadata;
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class Extension {
|
public abstract class Extension {
|
||||||
/**
|
/**
|
||||||
* The {@link AbstractEcoPlugin} that this extension is for.
|
* The {@link EcoPlugin} that this extension is for.
|
||||||
*/
|
*/
|
||||||
@Getter(AccessLevel.PROTECTED)
|
@Getter(AccessLevel.PROTECTED)
|
||||||
private final AbstractEcoPlugin plugin;
|
private final EcoPlugin plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new extension for a plugin.
|
* Create a new extension for a plugin.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
*/
|
*/
|
||||||
protected Extension(@NotNull final AbstractEcoPlugin plugin) {
|
protected Extension(@NotNull final EcoPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ public abstract class Extension {
|
|||||||
*/
|
*/
|
||||||
public final String getName() {
|
public final String getName() {
|
||||||
Validate.notNull(metadata, "Metadata cannot be null!");
|
Validate.notNull(metadata, "Metadata cannot be null!");
|
||||||
return this.metadata.name;
|
return this.metadata.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,36 +81,6 @@ public abstract class Extension {
|
|||||||
*/
|
*/
|
||||||
public final String getVersion() {
|
public final String getVersion() {
|
||||||
Validate.notNull(metadata, "Metadata cannot be null!");
|
Validate.notNull(metadata, "Metadata cannot be null!");
|
||||||
return this.metadata.version;
|
return this.metadata.getVersion();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper for the string and version of the extension.
|
|
||||||
* Contains versions and name.
|
|
||||||
* Designed for internal use.
|
|
||||||
*/
|
|
||||||
@ApiStatus.Internal
|
|
||||||
public static final class ExtensionMetadata {
|
|
||||||
/**
|
|
||||||
* The version of the extension.
|
|
||||||
*/
|
|
||||||
private final @NotNull String version;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The extension's name.
|
|
||||||
*/
|
|
||||||
private final @NotNull String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new extension metadata.
|
|
||||||
*
|
|
||||||
* @param version The version for the extension to be.
|
|
||||||
* @param name The name of the extension.
|
|
||||||
*/
|
|
||||||
public ExtensionMetadata(@NotNull final String version,
|
|
||||||
@NotNull final String name) {
|
|
||||||
this.version = version;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
package com.willfp.eco.util.extensions.loader;
|
package com.willfp.eco.core.extensions;
|
||||||
|
|
||||||
import com.willfp.eco.util.extensions.Extension;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -20,11 +18,6 @@ public interface ExtensionLoader {
|
|||||||
*/
|
*/
|
||||||
void unloadExtensions();
|
void unloadExtensions();
|
||||||
|
|
||||||
/**
|
|
||||||
* Reload all extensions.
|
|
||||||
*/
|
|
||||||
void reloadExtensions();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a set of all loaded extensions.
|
* Retrieve a set of all loaded extensions.
|
||||||
*
|
*
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.extensions;
|
package com.willfp.eco.core.extensions;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.willfp.eco.core.factory;
|
||||||
|
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public interface MetadataValueFactory {
|
||||||
|
FixedMetadataValue create(@NotNull Object value);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.willfp.eco.core.factory;
|
||||||
|
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public interface NamespacedKeyFactory {
|
||||||
|
/**
|
||||||
|
* Create an {@link NamespacedKey} associated with an {@link com.willfp.eco.core.EcoPlugin}.
|
||||||
|
*
|
||||||
|
* @param key The key in the {@link NamespacedKey}.
|
||||||
|
* @return The created {@link NamespacedKey}.
|
||||||
|
*/
|
||||||
|
NamespacedKey create(@NotNull String key);
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.willfp.eco.core.factory;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.scheduling.RunnableTask;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public interface RunnableFactory {
|
||||||
|
/**
|
||||||
|
* Create a {@link RunnableTask}.
|
||||||
|
*
|
||||||
|
* @param consumer Lambda of the code to run, where the parameter represents the instance of the runnable.
|
||||||
|
* @return The created {@link RunnableTask}.
|
||||||
|
*/
|
||||||
|
RunnableTask create(@NotNull Consumer<RunnableTask> consumer);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.integrations;
|
package com.willfp.eco.core.integrations;
|
||||||
|
|
||||||
public interface Integration {
|
public interface Integration {
|
||||||
/**
|
/**
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.integrations;
|
package com.willfp.eco.core.integrations;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.willfp.eco.util.integrations.anticheat;
|
package com.willfp.eco.core.integrations.anticheat;
|
||||||
|
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -22,7 +22,7 @@ public class AnticheatManager {
|
|||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
* @param anticheat The anticheat to register.
|
* @param anticheat The anticheat to register.
|
||||||
*/
|
*/
|
||||||
public void register(@NotNull final AbstractEcoPlugin plugin,
|
public void register(@NotNull final EcoPlugin plugin,
|
||||||
@NotNull final AnticheatWrapper anticheat) {
|
@NotNull final AnticheatWrapper anticheat) {
|
||||||
if (anticheat instanceof Listener) {
|
if (anticheat instanceof Listener) {
|
||||||
plugin.getEventManager().registerListener((Listener) anticheat);
|
plugin.getEventManager().registerListener((Listener) anticheat);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.willfp.eco.util.integrations.anticheat;
|
package com.willfp.eco.core.integrations.anticheat;
|
||||||
|
|
||||||
import com.willfp.eco.util.integrations.Integration;
|
import com.willfp.eco.core.integrations.Integration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.integrations.antigrief;
|
package com.willfp.eco.core.integrations.antigrief;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.willfp.eco.util.integrations.antigrief;
|
package com.willfp.eco.core.integrations.antigrief;
|
||||||
|
|
||||||
import com.willfp.eco.util.integrations.Integration;
|
import com.willfp.eco.core.integrations.Integration;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.integrations.mcmmo;
|
package com.willfp.eco.core.integrations.mcmmo;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.integrations.mcmmo;
|
package com.willfp.eco.core.integrations.mcmmo;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.integrations.placeholder;
|
package com.willfp.eco.core.integrations.placeholder;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.willfp.eco.util.integrations.placeholder;
|
package com.willfp.eco.core.integrations.placeholder;
|
||||||
|
|
||||||
import com.willfp.eco.util.integrations.Integration;
|
import com.willfp.eco.core.integrations.Integration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.integrations.placeholder;
|
package com.willfp.eco.core.integrations.placeholder;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.willfp.eco.core.items;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
public class CustomItem implements TestableItem {
|
||||||
|
/**
|
||||||
|
* The key.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final NamespacedKey key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The test for ItemStacks to pass.
|
||||||
|
*/
|
||||||
|
private final Predicate<ItemStack> test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example Item: what the user should see.
|
||||||
|
*/
|
||||||
|
private final ItemStack item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new complex recipe part.
|
||||||
|
*
|
||||||
|
* @param key The item key.
|
||||||
|
* @param test The test.
|
||||||
|
* @param item The example ItemStacks.
|
||||||
|
*/
|
||||||
|
public CustomItem(@NotNull final NamespacedKey key,
|
||||||
|
@NotNull final Predicate<ItemStack> test,
|
||||||
|
@NotNull final ItemStack item) {
|
||||||
|
this.key = key;
|
||||||
|
this.test = test;
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(@Nullable final ItemStack itemStack) {
|
||||||
|
return test.test(itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the item.
|
||||||
|
*/
|
||||||
|
public void register() {
|
||||||
|
Items.registerCustomItem(this.getKey(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
69
eco-api/src/main/java/com/willfp/eco/core/items/Items.java
Normal file
69
eco-api/src/main/java/com/willfp/eco/core/items/Items.java
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
package com.willfp.eco.core.items;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.recipe.parts.EmptyTestableItem;
|
||||||
|
import com.willfp.eco.core.recipe.parts.MaterialTestableItem;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public final class Items {
|
||||||
|
/**
|
||||||
|
* All recipe parts.
|
||||||
|
*/
|
||||||
|
private static final Map<NamespacedKey, CustomItem> REGISTRY = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a new recipe part.
|
||||||
|
*
|
||||||
|
* @param key The key of the recipe part.
|
||||||
|
* @param part The recipe part.
|
||||||
|
*/
|
||||||
|
public void registerCustomItem(@NotNull final NamespacedKey key,
|
||||||
|
@NotNull final CustomItem part) {
|
||||||
|
REGISTRY.put(key, part);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup item from string.
|
||||||
|
* <p>
|
||||||
|
* Used for recipes.
|
||||||
|
*
|
||||||
|
* @param key The string to test.
|
||||||
|
* @return The found testable item, or an empty item if not found.
|
||||||
|
*/
|
||||||
|
public TestableItem lookup(@NotNull final String key) {
|
||||||
|
String[] split = key.toLowerCase().split(":");
|
||||||
|
if (split.length == 1) {
|
||||||
|
Material material = Material.getMaterial(key.toUpperCase());
|
||||||
|
if (material == null || material == Material.AIR) {
|
||||||
|
return new EmptyTestableItem();
|
||||||
|
}
|
||||||
|
return new MaterialTestableItem(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomItem part = REGISTRY.get(new NamespacedKey(split[0], split[1]));
|
||||||
|
return part == null ? new EmptyTestableItem() : part;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get if itemStack is a custom item.
|
||||||
|
*
|
||||||
|
* @param itemStack The itemStack to check.
|
||||||
|
* @return If is recipe.
|
||||||
|
*/
|
||||||
|
public boolean isCustomItem(@NotNull final ItemStack itemStack) {
|
||||||
|
for (CustomItem item : REGISTRY.values()) {
|
||||||
|
if (item.matches(itemStack)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.willfp.eco.util.recipe.parts;
|
package com.willfp.eco.core.items;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public interface RecipePart {
|
public interface TestableItem {
|
||||||
/**
|
/**
|
||||||
* If an ItemStack matches the recipe part.
|
* If an ItemStack matches the recipe part.
|
||||||
*
|
*
|
||||||
@@ -13,10 +13,9 @@ public interface RecipePart {
|
|||||||
boolean matches(@Nullable ItemStack itemStack);
|
boolean matches(@Nullable ItemStack itemStack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a displayed itemstack, for autocraft.
|
* Get an example item.
|
||||||
*
|
*
|
||||||
* @return The item, displayed.
|
* @return The item.
|
||||||
*/
|
*/
|
||||||
ItemStack getDisplayed();
|
ItemStack getItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.proxy;
|
package com.willfp.eco.core.proxy;
|
||||||
|
|
||||||
public interface AbstractProxy {
|
public interface AbstractProxy {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.proxy;
|
package com.willfp.eco.core.proxy;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.proxy;
|
package com.willfp.eco.core.proxy;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.willfp.eco.core.recipe;
|
||||||
|
|
||||||
|
import com.google.common.collect.BiMap;
|
||||||
|
import com.google.common.collect.HashBiMap;
|
||||||
|
import com.willfp.eco.core.recipe.recipes.CraftingRecipe;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public class Recipes {
|
||||||
|
/**
|
||||||
|
* Registry of all recipes.
|
||||||
|
*/
|
||||||
|
private static final BiMap<NamespacedKey, CraftingRecipe> RECIPES = HashBiMap.create();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a recipe.
|
||||||
|
*
|
||||||
|
* @param recipe The recipe.
|
||||||
|
*/
|
||||||
|
public void register(@NotNull final CraftingRecipe recipe) {
|
||||||
|
RECIPES.forcePut(recipe.getKey(), recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get recipe matching matrix.
|
||||||
|
*
|
||||||
|
* @param matrix The matrix to test.
|
||||||
|
* @return The match, or null if not found.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public CraftingRecipe getMatch(@NotNull final ItemStack[] matrix) {
|
||||||
|
return RECIPES.values().stream().filter(recipe -> recipe.test(matrix)).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get recipe by key.
|
||||||
|
*
|
||||||
|
* @param key The key.
|
||||||
|
* @return The recipe, or null if not found.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public CraftingRecipe getRecipe(@NotNull final NamespacedKey key) {
|
||||||
|
CraftingRecipe recipe = RECIPES.get(key);
|
||||||
|
if (recipe != null) {
|
||||||
|
return recipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key.getKey().contains("_displayed")) {
|
||||||
|
NamespacedKey otherKey = new NamespacedKey(key.getNamespace(), key.getKey().replace("_displayed", ""));
|
||||||
|
|
||||||
|
return RECIPES.get(otherKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
package com.willfp.eco.util.recipe.parts;
|
package com.willfp.eco.core.recipe.parts;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.items.TestableItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class EmptyRecipePart implements RecipePart {
|
public class EmptyTestableItem implements TestableItem {
|
||||||
/**
|
/**
|
||||||
* Create a new empty recipe part.
|
* Create a new empty recipe part.
|
||||||
*/
|
*/
|
||||||
public EmptyRecipePart() {
|
public EmptyTestableItem() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ public class EmptyRecipePart implements RecipePart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getDisplayed() {
|
public ItemStack getItem() {
|
||||||
return new ItemStack(Material.AIR);
|
return new ItemStack(Material.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
package com.willfp.eco.util.recipe.parts;
|
package com.willfp.eco.core.recipe.parts;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.items.TestableItem;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class SimpleRecipePart implements RecipePart {
|
public class MaterialTestableItem implements TestableItem {
|
||||||
/**
|
/**
|
||||||
* The material.
|
* The material.
|
||||||
*/
|
*/
|
||||||
@@ -18,7 +19,7 @@ public class SimpleRecipePart implements RecipePart {
|
|||||||
*
|
*
|
||||||
* @param material The material.
|
* @param material The material.
|
||||||
*/
|
*/
|
||||||
public SimpleRecipePart(@NotNull final Material material) {
|
public MaterialTestableItem(@NotNull final Material material) {
|
||||||
this.material = material;
|
this.material = material;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ public class SimpleRecipePart implements RecipePart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getDisplayed() {
|
public ItemStack getItem() {
|
||||||
return new ItemStack(material);
|
return new ItemStack(material);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.willfp.eco.core.recipe.recipes;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.items.TestableItem;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface CraftingRecipe {
|
||||||
|
/**
|
||||||
|
* Test matrix against recipe.
|
||||||
|
*
|
||||||
|
* @param matrix The matrix to check.
|
||||||
|
* @return If the recipe matches.
|
||||||
|
*/
|
||||||
|
boolean test(@NotNull ItemStack[] matrix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the recipe.
|
||||||
|
*/
|
||||||
|
void register();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The recipe parts.
|
||||||
|
*
|
||||||
|
* @return The parts.
|
||||||
|
*/
|
||||||
|
List<TestableItem> getParts();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the recipe key.
|
||||||
|
*
|
||||||
|
* @return The key.
|
||||||
|
*/
|
||||||
|
NamespacedKey getKey();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the displayed recipe key.
|
||||||
|
*
|
||||||
|
* @return The key.
|
||||||
|
*/
|
||||||
|
NamespacedKey getDisplayedKey();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the recipe output.
|
||||||
|
*
|
||||||
|
* @return The output.
|
||||||
|
*/
|
||||||
|
ItemStack getOutput();
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.recipe.recipes;
|
package com.willfp.eco.core.recipe.recipes;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -1,24 +1,29 @@
|
|||||||
package com.willfp.eco.util.recipe.recipes;
|
package com.willfp.eco.core.recipe.recipes;
|
||||||
|
|
||||||
import com.willfp.eco.util.internal.PluginDependent;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
import com.willfp.eco.util.recipe.Recipes;
|
import com.willfp.eco.core.items.TestableItem;
|
||||||
import com.willfp.eco.util.recipe.parts.EmptyRecipePart;
|
import com.willfp.eco.core.recipe.Recipes;
|
||||||
import com.willfp.eco.util.recipe.parts.RecipePart;
|
import com.willfp.eco.core.recipe.parts.EmptyTestableItem;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.RecipeChoice;
|
||||||
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class EcoShapedRecipe extends PluginDependent {
|
@SuppressWarnings("deprecation")
|
||||||
|
public final class ShapedCraftingRecipe extends PluginDependent implements CraftingRecipe {
|
||||||
/**
|
/**
|
||||||
* Recipe parts.
|
* Recipe parts.
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private final RecipePart[] parts;
|
private final List<TestableItem> parts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The key of the recipe.
|
* The key of the recipe.
|
||||||
@@ -38,10 +43,10 @@ public final class EcoShapedRecipe extends PluginDependent {
|
|||||||
@Getter
|
@Getter
|
||||||
private final ItemStack output;
|
private final ItemStack output;
|
||||||
|
|
||||||
private EcoShapedRecipe(@NotNull final AbstractEcoPlugin plugin,
|
private ShapedCraftingRecipe(@NotNull final EcoPlugin plugin,
|
||||||
@NotNull final String key,
|
@NotNull final String key,
|
||||||
@NotNull final RecipePart[] parts,
|
@NotNull final List<TestableItem> parts,
|
||||||
@NotNull final ItemStack output) {
|
@NotNull final ItemStack output) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
|
|
||||||
this.parts = parts;
|
this.parts = parts;
|
||||||
@@ -50,36 +55,11 @@ public final class EcoShapedRecipe extends PluginDependent {
|
|||||||
this.output = output;
|
this.output = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Get item material at a specific index.
|
|
||||||
*
|
|
||||||
* @param index The index to check.
|
|
||||||
* @return The material.
|
|
||||||
*/
|
|
||||||
public Material getMaterialAtIndex(final int index) {
|
|
||||||
return parts[index].getDisplayed().getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get "real" item at specific index.
|
|
||||||
*
|
|
||||||
* @param index The index to check.
|
|
||||||
* @return The item.
|
|
||||||
*/
|
|
||||||
public ItemStack getDisplayedAtIndex(final int index) {
|
|
||||||
return parts[index].getDisplayed();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test matrix against recipe.
|
|
||||||
*
|
|
||||||
* @param matrix The matrix to check.
|
|
||||||
* @return If the recipe matches.
|
|
||||||
*/
|
|
||||||
public boolean test(@NotNull final ItemStack[] matrix) {
|
public boolean test(@NotNull final ItemStack[] matrix) {
|
||||||
boolean matches = true;
|
boolean matches = true;
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
if (!parts[i].matches(matrix[i])) {
|
if (!parts.get(i).matches(matrix[i])) {
|
||||||
matches = false;
|
matches = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,20 +67,29 @@ public final class EcoShapedRecipe extends PluginDependent {
|
|||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Register the recipe.
|
|
||||||
*/
|
|
||||||
public void register() {
|
public void register() {
|
||||||
Recipes.register(this);
|
Recipes.register(this);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
Bukkit.getServer().removeRecipe(this.getKey());
|
||||||
public String toString() {
|
Bukkit.getServer().removeRecipe(this.getDisplayedKey());
|
||||||
return "EcoShapedRecipe{"
|
|
||||||
+ "parts=" + Arrays.toString(parts)
|
ShapedRecipe shapedRecipe = new ShapedRecipe(this.getKey(), this.getOutput());
|
||||||
+ ", key='" + key + '\''
|
shapedRecipe.shape("012", "345", "678");
|
||||||
+ ", output=" + output
|
for (int i = 0; i < 9; i++) {
|
||||||
+ '}';
|
char character = String.valueOf(i).toCharArray()[0];
|
||||||
|
shapedRecipe.setIngredient(character, parts.get(i).getItem().getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
ShapedRecipe displayedRecipe = new ShapedRecipe(this.getDisplayedKey(), this.getOutput());
|
||||||
|
displayedRecipe.shape("012", "345", "678");
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
char character = String.valueOf(i).toCharArray()[0];
|
||||||
|
displayedRecipe.setIngredient(character, new RecipeChoice.ExactChoice(parts.get(i).getItem()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getServer().addRecipe(shapedRecipe);
|
||||||
|
Bukkit.getServer().addRecipe(displayedRecipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +99,7 @@ public final class EcoShapedRecipe extends PluginDependent {
|
|||||||
* @param key The recipe key.
|
* @param key The recipe key.
|
||||||
* @return A new builder.
|
* @return A new builder.
|
||||||
*/
|
*/
|
||||||
public static Builder builder(@NotNull final AbstractEcoPlugin plugin,
|
public static Builder builder(@NotNull final EcoPlugin plugin,
|
||||||
@NotNull final String key) {
|
@NotNull final String key) {
|
||||||
return new Builder(plugin, key);
|
return new Builder(plugin, key);
|
||||||
}
|
}
|
||||||
@@ -119,7 +108,7 @@ public final class EcoShapedRecipe extends PluginDependent {
|
|||||||
/**
|
/**
|
||||||
* The recipe parts.
|
* The recipe parts.
|
||||||
*/
|
*/
|
||||||
private final RecipePart[] recipeParts = new RecipePart[9];
|
private final List<TestableItem> recipeParts = new ArrayList<>(Arrays.asList(null, null, null, null, null, null, null, null, null)); // Jank
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The output of the recipe.
|
* The output of the recipe.
|
||||||
@@ -134,7 +123,7 @@ public final class EcoShapedRecipe extends PluginDependent {
|
|||||||
/**
|
/**
|
||||||
* The plugin that created the recipe.
|
* The plugin that created the recipe.
|
||||||
*/
|
*/
|
||||||
private final AbstractEcoPlugin plugin;
|
private final EcoPlugin plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new recipe builder.
|
* Create a new recipe builder.
|
||||||
@@ -142,7 +131,7 @@ public final class EcoShapedRecipe extends PluginDependent {
|
|||||||
* @param plugin The plugin that owns the recipe.
|
* @param plugin The plugin that owns the recipe.
|
||||||
* @param key The recipe key.
|
* @param key The recipe key.
|
||||||
*/
|
*/
|
||||||
private Builder(@NotNull final AbstractEcoPlugin plugin,
|
private Builder(@NotNull final EcoPlugin plugin,
|
||||||
@NotNull final String key) {
|
@NotNull final String key) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@@ -156,8 +145,8 @@ public final class EcoShapedRecipe extends PluginDependent {
|
|||||||
* @return The builder.
|
* @return The builder.
|
||||||
*/
|
*/
|
||||||
public Builder setRecipePart(@NotNull final RecipePosition position,
|
public Builder setRecipePart(@NotNull final RecipePosition position,
|
||||||
@NotNull final RecipePart part) {
|
@NotNull final TestableItem part) {
|
||||||
this.recipeParts[position.getIndex()] = part;
|
recipeParts.set(position.getIndex(), part);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,8 +158,8 @@ public final class EcoShapedRecipe extends PluginDependent {
|
|||||||
* @return The builder.
|
* @return The builder.
|
||||||
*/
|
*/
|
||||||
public Builder setRecipePart(final int position,
|
public Builder setRecipePart(final int position,
|
||||||
@NotNull final RecipePart part) {
|
@NotNull final TestableItem part) {
|
||||||
this.recipeParts[position] = part;
|
recipeParts.set(position, part);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,14 +179,14 @@ public final class EcoShapedRecipe extends PluginDependent {
|
|||||||
*
|
*
|
||||||
* @return The built recipe.
|
* @return The built recipe.
|
||||||
*/
|
*/
|
||||||
public EcoShapedRecipe build() {
|
public ShapedCraftingRecipe build() {
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
if (recipeParts[i] == null) {
|
if (recipeParts.get(i) == null) {
|
||||||
recipeParts[i] = new EmptyRecipePart();
|
recipeParts.set(i, new EmptyTestableItem());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EcoShapedRecipe(plugin, key.toLowerCase(), recipeParts, output);
|
return new ShapedCraftingRecipe(plugin, key.toLowerCase(), recipeParts, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.willfp.eco.core.scheduling;
|
||||||
|
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public interface RunnableTask extends Runnable {
|
||||||
|
/**
|
||||||
|
* Run the task.
|
||||||
|
*
|
||||||
|
* @return The created {@link BukkitTask}.
|
||||||
|
*/
|
||||||
|
@NotNull BukkitTask runTask();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the task asynchronously.
|
||||||
|
*
|
||||||
|
* @return The created {@link BukkitTask}
|
||||||
|
*/
|
||||||
|
@NotNull BukkitTask runTaskAsynchronously();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the task after a specified number of ticks.
|
||||||
|
*
|
||||||
|
* @param delay The number of ticks to wait.
|
||||||
|
* @return The created {@link BukkitTask}
|
||||||
|
*/
|
||||||
|
@NotNull BukkitTask runTaskLater(long delay);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the task asynchronously after a specified number of ticks.
|
||||||
|
*
|
||||||
|
* @param delay The number of ticks to wait.
|
||||||
|
* @return The created {@link BukkitTask}
|
||||||
|
*/
|
||||||
|
@NotNull BukkitTask runTaskLaterAsynchronously(long delay);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the task repeatedly on a timer.
|
||||||
|
*
|
||||||
|
* @param delay The delay before the task is first ran (in ticks).
|
||||||
|
* @param period The ticks elapsed before the task is ran again.
|
||||||
|
* @return The created {@link BukkitTask}
|
||||||
|
*/
|
||||||
|
@NotNull BukkitTask runTaskTimer(long delay, long period);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the task repeatedly on a timer asynchronously.
|
||||||
|
*
|
||||||
|
* @param delay The delay before the task is first ran (in ticks).
|
||||||
|
* @param period The ticks elapsed before the task is ran again.
|
||||||
|
* @return The created {@link BukkitTask}
|
||||||
|
*/
|
||||||
|
@NotNull BukkitTask runTaskTimerAsynchronously(long delay, long period);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel the task.
|
||||||
|
*/
|
||||||
|
void cancel();
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.willfp.eco.util.bukkit.scheduling;
|
package com.willfp.eco.core.scheduling;
|
||||||
|
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ public interface Scheduler {
|
|||||||
long repeat);
|
long repeat);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel all running tasks from the linked {@link AbstractEcoPlugin}.
|
* Cancel all running tasks from the linked {@link EcoPlugin}.
|
||||||
*/
|
*/
|
||||||
void cancelAll();
|
void cancelAll();
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.tuples;
|
package com.willfp.eco.core.tuples;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.tuples;
|
package com.willfp.eco.core.tuples;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.willfp.eco.util.updater;
|
package com.willfp.eco.internal;
|
||||||
|
|
||||||
import com.willfp.eco.util.internal.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import org.bukkit.util.Consumer;
|
import org.bukkit.util.Consumer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ public class UpdateChecker extends PluginDependent {
|
|||||||
*
|
*
|
||||||
* @param plugin The plugin to check.
|
* @param plugin The plugin to check.
|
||||||
*/
|
*/
|
||||||
public UpdateChecker(@NotNull final AbstractEcoPlugin plugin) {
|
public UpdateChecker(@NotNull final EcoPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.willfp.eco.internal.arrows;
|
package com.willfp.eco.internal.arrows;
|
||||||
|
|
||||||
import com.willfp.eco.util.internal.PluginDependent;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -14,16 +13,14 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ArrowDataListener extends PluginDependent implements Listener {
|
public class ArrowDataListener extends PluginDependent implements Listener {
|
||||||
/**
|
/**
|
||||||
* Listener to add metadata to arrows about the enchantments on the bow that shot them.
|
* Listener to add metadata to arrows about the enchantments on the bow that shot them.
|
||||||
*
|
*
|
||||||
* @param plugin The {@link AbstractEcoPlugin} that registered the listener.
|
* @param plugin The {@link EcoPlugin} that registered the listener.
|
||||||
*/
|
*/
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public ArrowDataListener(@NotNull final AbstractEcoPlugin plugin) {
|
public ArrowDataListener(@NotNull final EcoPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +51,6 @@ public class ArrowDataListener extends PluginDependent implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Enchantment, Integer> enchantments = item.getItemMeta().getEnchants();
|
arrow.setMetadata("shot-from", this.getPlugin().getMetadataValueFactory().create(item));
|
||||||
arrow.setMetadata("enchantments", this.getPlugin().getMetadataValueFactory().create(enchantments));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,14 +3,13 @@ package com.willfp.eco.internal.config;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ConfigSection extends AbstractUndefinedConfig<ConfigurationSection> {
|
public class ConfigSection extends ConfigWrapper<ConfigurationSection> {
|
||||||
/**
|
/**
|
||||||
* Config section.
|
* Config section.
|
||||||
*
|
*
|
||||||
* @param section The section.
|
* @param section The section.
|
||||||
*/
|
*/
|
||||||
protected ConfigSection(@NotNull final ConfigurationSection section) {
|
protected ConfigSection(@NotNull final ConfigurationSection section) {
|
||||||
super("subsection");
|
|
||||||
this.init(section);
|
this.init(section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package com.willfp.eco.internal.config;
|
package com.willfp.eco.internal.config;
|
||||||
|
|
||||||
import com.willfp.eco.util.SerializationUtils;
|
|
||||||
import com.willfp.eco.util.StringUtils;
|
import com.willfp.eco.util.StringUtils;
|
||||||
import com.willfp.eco.util.config.Config;
|
import com.willfp.eco.core.config.Config;
|
||||||
import com.willfp.eco.util.serialization.EcoSerializable;
|
import lombok.Getter;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.MemorySection;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -15,12 +14,13 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "unused", "DeprecatedIsStillUsed"})
|
@SuppressWarnings({"unchecked", "unused"})
|
||||||
public abstract class AbstractUndefinedConfig<T extends ConfigurationSection> implements Config {
|
public abstract class ConfigWrapper<T extends ConfigurationSection> implements Config {
|
||||||
/**
|
/**
|
||||||
* The linked {@link MemorySection} where values are physically stored.
|
* The linked {@link ConfigurationSection} where values are physically stored.
|
||||||
*/
|
*/
|
||||||
protected T config = null;
|
@Getter
|
||||||
|
private T handle = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cached values for faster reading.
|
* Cached values for faster reading.
|
||||||
@@ -29,15 +29,13 @@ public abstract class AbstractUndefinedConfig<T extends ConfigurationSection> im
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract config.
|
* Abstract config.
|
||||||
*
|
|
||||||
* @param configName The name of the config
|
|
||||||
*/
|
*/
|
||||||
protected AbstractUndefinedConfig(@NotNull final String configName) {
|
protected ConfigWrapper() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Config init(@NotNull final T config) {
|
protected Config init(@NotNull final T config) {
|
||||||
this.config = config;
|
this.handle = config;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,98 +46,44 @@ public abstract class AbstractUndefinedConfig<T extends ConfigurationSection> im
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean has(@NotNull final String path) {
|
public boolean has(@NotNull final String path) {
|
||||||
return config.contains(path);
|
return handle.contains(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<String> getKeys(final boolean deep) {
|
public List<String> getKeys(final boolean deep) {
|
||||||
return new ArrayList<>(config.getKeys(deep));
|
return new ArrayList<>(handle.getKeys(deep));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public Object get(@NotNull final String path) {
|
||||||
|
return handle.get(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(@NotNull final String path,
|
public void set(@NotNull final String path,
|
||||||
@NotNull final EcoSerializable<?> object) {
|
@Nullable final Object object) {
|
||||||
Config serializedConfig = object.serialize();
|
handle.set(path, object);
|
||||||
for (String key : serializedConfig.getKeys(true)) {
|
|
||||||
Object raw = serializedConfig.getRaw(key);
|
|
||||||
config.set(path + "." + key, raw);
|
|
||||||
cache.put(path + "." + key, raw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public Object getRaw(@NotNull final String path) {
|
|
||||||
return config.get(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@NotNull
|
|
||||||
public <T extends EcoSerializable<T>> T get(@NotNull final String path,
|
|
||||||
@NotNull final Class<T> clazz) {
|
|
||||||
T object = getOrNull(path, clazz);
|
|
||||||
if (object == null) {
|
|
||||||
throw new NullPointerException("Object cannot be null!");
|
|
||||||
} else {
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public <T extends EcoSerializable<T>> T getOrNull(@NotNull final String path,
|
|
||||||
@NotNull final Class<T> clazz) {
|
|
||||||
if (cache.containsKey(path)) {
|
|
||||||
return (T) cache.get(path);
|
|
||||||
} else {
|
|
||||||
Config section = getSubsectionOrNull(path);
|
|
||||||
if (section == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
cache.put(path, SerializationUtils.deserialize(section, clazz));
|
|
||||||
return getOrNull(path, clazz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@NotNull
|
|
||||||
@Deprecated
|
|
||||||
public ConfigurationSection getSection(@NotNull final String path) {
|
|
||||||
ConfigurationSection section = getSectionOrNull(path);
|
|
||||||
if (section == null) {
|
|
||||||
throw new NullPointerException("Section cannot be null!");
|
|
||||||
} else {
|
|
||||||
return section;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
@Deprecated
|
|
||||||
public ConfigurationSection getSectionOrNull(@NotNull final String path) {
|
|
||||||
if (cache.containsKey(path)) {
|
|
||||||
return (ConfigurationSection) cache.get(path);
|
|
||||||
} else {
|
|
||||||
cache.put(path, config.getConfigurationSection(path));
|
|
||||||
return getSectionOrNull(path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public Config getSubsection(@NotNull final String path) {
|
public Config getSubsection(@NotNull final String path) {
|
||||||
return new ConfigSection(this.getSection(path));
|
Config subsection = getSubsectionOrNull(path);
|
||||||
|
Validate.notNull(subsection);
|
||||||
|
return subsection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Config getSubsectionOrNull(@NotNull final String path) {
|
public Config getSubsectionOrNull(@NotNull final String path) {
|
||||||
ConfigurationSection section = this.getSectionOrNull(path);
|
if (cache.containsKey(path)) {
|
||||||
if (section == null) {
|
return (Config) cache.get(path);
|
||||||
return null;
|
} else {
|
||||||
|
cache.put(path, new ConfigSection(Objects.requireNonNull(handle.getConfigurationSection(path))));
|
||||||
|
return getSubsectionOrNull(path);
|
||||||
}
|
}
|
||||||
return new ConfigSection(section);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -147,7 +91,7 @@ public abstract class AbstractUndefinedConfig<T extends ConfigurationSection> im
|
|||||||
if (cache.containsKey(path)) {
|
if (cache.containsKey(path)) {
|
||||||
return (int) cache.get(path);
|
return (int) cache.get(path);
|
||||||
} else {
|
} else {
|
||||||
cache.put(path, config.getInt(path, 0));
|
cache.put(path, handle.getInt(path, 0));
|
||||||
return getInt(path);
|
return getInt(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,7 +112,7 @@ public abstract class AbstractUndefinedConfig<T extends ConfigurationSection> im
|
|||||||
if (cache.containsKey(path)) {
|
if (cache.containsKey(path)) {
|
||||||
return (int) cache.get(path);
|
return (int) cache.get(path);
|
||||||
} else {
|
} else {
|
||||||
cache.put(path, config.getInt(path, def));
|
cache.put(path, handle.getInt(path, def));
|
||||||
return getInt(path);
|
return getInt(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,7 +123,7 @@ public abstract class AbstractUndefinedConfig<T extends ConfigurationSection> im
|
|||||||
if (cache.containsKey(path)) {
|
if (cache.containsKey(path)) {
|
||||||
return (List<Integer>) cache.get(path);
|
return (List<Integer>) cache.get(path);
|
||||||
} else {
|
} else {
|
||||||
cache.put(path, has(path) ? new ArrayList<>(config.getIntegerList(path)) : new ArrayList<>());
|
cache.put(path, has(path) ? new ArrayList<>(handle.getIntegerList(path)) : new ArrayList<>());
|
||||||
return getInts(path);
|
return getInts(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,7 +143,7 @@ public abstract class AbstractUndefinedConfig<T extends ConfigurationSection> im
|
|||||||
if (cache.containsKey(path)) {
|
if (cache.containsKey(path)) {
|
||||||
return (boolean) cache.get(path);
|
return (boolean) cache.get(path);
|
||||||
} else {
|
} else {
|
||||||
cache.put(path, config.getBoolean(path));
|
cache.put(path, handle.getBoolean(path));
|
||||||
return getBool(path);
|
return getBool(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,7 +164,7 @@ public abstract class AbstractUndefinedConfig<T extends ConfigurationSection> im
|
|||||||
if (cache.containsKey(path)) {
|
if (cache.containsKey(path)) {
|
||||||
return (List<Boolean>) cache.get(path);
|
return (List<Boolean>) cache.get(path);
|
||||||
} else {
|
} else {
|
||||||
cache.put(path, has(path) ? new ArrayList<>(config.getBooleanList(path)) : new ArrayList<>());
|
cache.put(path, has(path) ? new ArrayList<>(handle.getBooleanList(path)) : new ArrayList<>());
|
||||||
return getBools(path);
|
return getBools(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,7 +185,7 @@ public abstract class AbstractUndefinedConfig<T extends ConfigurationSection> im
|
|||||||
if (cache.containsKey(path)) {
|
if (cache.containsKey(path)) {
|
||||||
return (String) cache.get(path);
|
return (String) cache.get(path);
|
||||||
} else {
|
} else {
|
||||||
cache.put(path, StringUtils.translate(Objects.requireNonNull(config.getString(path, ""))));
|
cache.put(path, StringUtils.translate(Objects.requireNonNull(handle.getString(path, ""))));
|
||||||
return getString(path);
|
return getString(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,7 +206,7 @@ public abstract class AbstractUndefinedConfig<T extends ConfigurationSection> im
|
|||||||
if (cache.containsKey(path)) {
|
if (cache.containsKey(path)) {
|
||||||
return (List<String>) cache.get(path);
|
return (List<String>) cache.get(path);
|
||||||
} else {
|
} else {
|
||||||
cache.put(path, has(path) ? new ArrayList<>(config.getStringList(path)) : new ArrayList<>());
|
cache.put(path, has(path) ? new ArrayList<>(handle.getStringList(path)) : new ArrayList<>());
|
||||||
return getStrings(path);
|
return getStrings(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -282,7 +226,7 @@ public abstract class AbstractUndefinedConfig<T extends ConfigurationSection> im
|
|||||||
if (cache.containsKey(path)) {
|
if (cache.containsKey(path)) {
|
||||||
return (double) cache.get(path);
|
return (double) cache.get(path);
|
||||||
} else {
|
} else {
|
||||||
cache.put(path, config.getDouble(path));
|
cache.put(path, handle.getDouble(path));
|
||||||
return getDouble(path);
|
return getDouble(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -303,7 +247,7 @@ public abstract class AbstractUndefinedConfig<T extends ConfigurationSection> im
|
|||||||
if (cache.containsKey(path)) {
|
if (cache.containsKey(path)) {
|
||||||
return (List<Double>) cache.get(path);
|
return (List<Double>) cache.get(path);
|
||||||
} else {
|
} else {
|
||||||
cache.put(path, has(path) ? new ArrayList<>(config.getDoubleList(path)) : new ArrayList<>());
|
cache.put(path, has(path) ? new ArrayList<>(handle.getDoubleList(path)) : new ArrayList<>());
|
||||||
return getDoubles(path);
|
return getDoubles(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.willfp.eco.internal.config;
|
package com.willfp.eco.internal.config;
|
||||||
|
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
@@ -16,7 +16,7 @@ import java.io.InputStreamReader;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
public abstract class AbstractConfig extends AbstractUndefinedConfig<YamlConfiguration> {
|
public abstract class LoadableYamlConfig extends ConfigWrapper<YamlConfiguration> {
|
||||||
/**
|
/**
|
||||||
* The physical config file, as stored on disk.
|
* The physical config file, as stored on disk.
|
||||||
*/
|
*/
|
||||||
@@ -27,7 +27,7 @@ public abstract class AbstractConfig extends AbstractUndefinedConfig<YamlConfigu
|
|||||||
* Plugin handle.
|
* Plugin handle.
|
||||||
*/
|
*/
|
||||||
@Getter(AccessLevel.PROTECTED)
|
@Getter(AccessLevel.PROTECTED)
|
||||||
private final AbstractEcoPlugin plugin;
|
private final EcoPlugin plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The full name of the config file (eg config.yml).
|
* The full name of the config file (eg config.yml).
|
||||||
@@ -55,11 +55,10 @@ public abstract class AbstractConfig extends AbstractUndefinedConfig<YamlConfigu
|
|||||||
* @param subDirectoryPath The subdirectory path.
|
* @param subDirectoryPath The subdirectory path.
|
||||||
* @param source The class that owns the resource.
|
* @param source The class that owns the resource.
|
||||||
*/
|
*/
|
||||||
protected AbstractConfig(@NotNull final String configName,
|
protected LoadableYamlConfig(@NotNull final String configName,
|
||||||
@NotNull final AbstractEcoPlugin plugin,
|
@NotNull final EcoPlugin plugin,
|
||||||
@NotNull final String subDirectoryPath,
|
@NotNull final String subDirectoryPath,
|
||||||
@NotNull final Class<?> source) {
|
@NotNull final Class<?> source) {
|
||||||
super(configName);
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.name = configName + ".yml";
|
this.name = configName + ".yml";
|
||||||
this.source = source;
|
this.source = source;
|
||||||
@@ -147,12 +146,11 @@ public abstract class AbstractConfig extends AbstractUndefinedConfig<YamlConfigu
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get config handle.
|
* Save the config.
|
||||||
*
|
*
|
||||||
* @return The config.
|
* @throws IOException If error in saving.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public void save() throws IOException {
|
||||||
public YamlConfiguration getConfig() {
|
this.getHandle().save(this.getConfigFile());
|
||||||
return (YamlConfiguration) super.config;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.willfp.eco.internal.config;
|
package com.willfp.eco.internal.config;
|
||||||
|
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -10,7 +10,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class AbstractUpdatableConfig extends AbstractConfig {
|
public abstract class UpdatableYamlConfig extends LoadableYamlConfig {
|
||||||
/**
|
/**
|
||||||
* Whether keys not in the base config should be removed on update.
|
* Whether keys not in the base config should be removed on update.
|
||||||
*/
|
*/
|
||||||
@@ -31,12 +31,12 @@ public abstract class AbstractUpdatableConfig extends AbstractConfig {
|
|||||||
* @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 updateBlacklist Substring of keys to not add/remove keys for.
|
* @param updateBlacklist Substring of keys to not add/remove keys for.
|
||||||
*/
|
*/
|
||||||
protected AbstractUpdatableConfig(@NotNull final String configName,
|
protected UpdatableYamlConfig(@NotNull final String configName,
|
||||||
@NotNull final AbstractEcoPlugin plugin,
|
@NotNull final EcoPlugin plugin,
|
||||||
@NotNull final String subDirectoryPath,
|
@NotNull final String subDirectoryPath,
|
||||||
@NotNull final Class<?> source,
|
@NotNull final Class<?> source,
|
||||||
final boolean removeUnused,
|
final boolean removeUnused,
|
||||||
@NotNull final String... updateBlacklist) {
|
@NotNull final String... updateBlacklist) {
|
||||||
super(configName, plugin, subDirectoryPath, source);
|
super(configName, plugin, subDirectoryPath, source);
|
||||||
this.removeUnused = removeUnused;
|
this.removeUnused = removeUnused;
|
||||||
this.updateBlacklist = new ArrayList<>(Arrays.asList(updateBlacklist));
|
this.updateBlacklist = new ArrayList<>(Arrays.asList(updateBlacklist));
|
||||||
@@ -53,33 +53,33 @@ public abstract class AbstractUpdatableConfig extends AbstractConfig {
|
|||||||
public void update() {
|
public void update() {
|
||||||
super.clearCache();
|
super.clearCache();
|
||||||
try {
|
try {
|
||||||
config.load(this.getConfigFile());
|
this.getHandle().load(this.getConfigFile());
|
||||||
|
|
||||||
YamlConfiguration newConfig = this.getConfigInJar();
|
YamlConfiguration newConfig = this.getConfigInJar();
|
||||||
|
|
||||||
if (newConfig.getKeys(true).equals(config.getKeys(true))) {
|
if (newConfig.getKeys(true).equals(this.getHandle().getKeys(true))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
newConfig.getKeys(true).forEach((s -> {
|
newConfig.getKeys(true).forEach((s -> {
|
||||||
if (!config.getKeys(true).contains(s)) {
|
if (!this.getHandle().getKeys(true).contains(s)) {
|
||||||
if (updateBlacklist.stream().noneMatch(s::contains)) {
|
if (updateBlacklist.stream().noneMatch(s::contains)) {
|
||||||
config.set(s, newConfig.get(s));
|
this.getHandle().set(s, newConfig.get(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (this.removeUnused) {
|
if (this.removeUnused) {
|
||||||
config.getKeys(true).forEach((s -> {
|
this.getHandle().getKeys(true).forEach((s -> {
|
||||||
if (!newConfig.getKeys(true).contains(s)) {
|
if (!newConfig.getKeys(true).contains(s)) {
|
||||||
if (updateBlacklist.stream().noneMatch(s::contains)) {
|
if (updateBlacklist.stream().noneMatch(s::contains)) {
|
||||||
config.set(s, null);
|
this.getHandle().set(s, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
config.save(this.getConfigFile());
|
this.getHandle().save(this.getConfigFile());
|
||||||
} catch (IOException | InvalidConfigurationException e) {
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.willfp.eco.util.config.updating;
|
package com.willfp.eco.internal.config.updating;
|
||||||
|
|
||||||
import com.willfp.eco.util.config.updating.annotations.ConfigUpdater;
|
import com.willfp.eco.core.config.ConfigUpdater;
|
||||||
import com.willfp.eco.util.config.updating.exceptions.InvalidUpdatableClassException;
|
import com.willfp.eco.internal.config.updating.exceptions.InvalidUpdatableClassException;
|
||||||
import com.willfp.eco.util.config.updating.exceptions.InvalidUpdateMethodException;
|
import com.willfp.eco.internal.config.updating.exceptions.InvalidUpdateMethodException;
|
||||||
import com.willfp.eco.util.internal.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@@ -21,11 +21,11 @@ public class ConfigHandler extends PluginDependent {
|
|||||||
private final Set<Class<?>> updatableClasses = new HashSet<>();
|
private final Set<Class<?>> updatableClasses = new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new config handler and links it to an {@link AbstractEcoPlugin}.
|
* Creates a new config handler and links it to an {@link EcoPlugin}.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin to manage.
|
* @param plugin The plugin to manage.
|
||||||
*/
|
*/
|
||||||
public ConfigHandler(@NotNull final AbstractEcoPlugin plugin) {
|
public ConfigHandler(@NotNull final EcoPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.willfp.eco.util.config.updating.exceptions;
|
package com.willfp.eco.internal.config.updating.exceptions;
|
||||||
|
|
||||||
import com.willfp.eco.util.config.updating.ConfigHandler;
|
import com.willfp.eco.internal.config.updating.ConfigHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class InvalidUpdatableClassException extends RuntimeException {
|
public class InvalidUpdatableClassException extends RuntimeException {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.config.updating.exceptions;
|
package com.willfp.eco.internal.config.updating.exceptions;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.willfp.eco.internal.drops.impl;
|
package com.willfp.eco.internal.drops.impl;
|
||||||
|
|
||||||
import com.willfp.eco.internal.drops.AbstractDropQueue;
|
import com.willfp.eco.internal.drops.AbstractDropQueue;
|
||||||
import com.willfp.eco.util.drops.telekinesis.TelekinesisUtils;
|
import com.willfp.eco.util.TelekinesisUtils;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.willfp.eco.internal.bukkit.events;
|
package com.willfp.eco.internal.events;
|
||||||
|
|
||||||
import com.willfp.eco.util.bukkit.events.EventManager;
|
import com.willfp.eco.core.events.EventManager;
|
||||||
import com.willfp.eco.util.internal.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -13,10 +13,10 @@ public class EcoEventManager extends PluginDependent implements EventManager {
|
|||||||
/**
|
/**
|
||||||
* Manager class for event management.
|
* Manager class for event management.
|
||||||
*
|
*
|
||||||
* @param plugin The {@link AbstractEcoPlugin} that this manages the events of.
|
* @param plugin The {@link EcoPlugin} that this manages the events of.
|
||||||
*/
|
*/
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public EcoEventManager(@NotNull final AbstractEcoPlugin plugin) {
|
public EcoEventManager(@NotNull final EcoPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.willfp.eco.internal.extensions;
|
package com.willfp.eco.internal.extensions;
|
||||||
|
|
||||||
|
|
||||||
import com.willfp.eco.util.extensions.Extension;
|
import com.willfp.eco.core.extensions.Extension;
|
||||||
import com.willfp.eco.util.extensions.MalformedExtensionException;
|
import com.willfp.eco.core.extensions.MalformedExtensionException;
|
||||||
import com.willfp.eco.util.extensions.loader.ExtensionLoader;
|
import com.willfp.eco.core.extensions.ExtensionLoader;
|
||||||
import com.willfp.eco.util.internal.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -31,11 +31,11 @@ public class EcoExtensionLoader extends PluginDependent implements ExtensionLoad
|
|||||||
private final Set<Extension> extensions = new HashSet<>();
|
private final Set<Extension> extensions = new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new extension loader and link it to a specific {@link AbstractEcoPlugin}.
|
* Create a new extension loader and link it to a specific {@link EcoPlugin}.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin to manage
|
* @param plugin The plugin to manage
|
||||||
*/
|
*/
|
||||||
public EcoExtensionLoader(@NotNull final AbstractEcoPlugin plugin) {
|
public EcoExtensionLoader(@NotNull final EcoPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public class EcoExtensionLoader extends PluginDependent implements ExtensionLoad
|
|||||||
try {
|
try {
|
||||||
loadExtension(extensionJar);
|
loadExtension(extensionJar);
|
||||||
} catch (MalformedExtensionException e) {
|
} catch (MalformedExtensionException e) {
|
||||||
this.getPlugin().getLog().error(extensionJar.getName() + " caused MalformedExtensionException: " + e.getMessage());
|
this.getPlugin().getLogger().severe(extensionJar.getName() + " caused MalformedExtensionException: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,13 +99,13 @@ public class EcoExtensionLoader extends PluginDependent implements ExtensionLoad
|
|||||||
Validate.notNull(name, "Name is missing!");
|
Validate.notNull(name, "Name is missing!");
|
||||||
Validate.notNull(version, "Version is missing!");
|
Validate.notNull(version, "Version is missing!");
|
||||||
|
|
||||||
Extension.ExtensionMetadata metadata = new Extension.ExtensionMetadata(version, name);
|
ExtensionMetadata metadata = new ExtensionMetadata(version, name);
|
||||||
|
|
||||||
Class<?> cls;
|
Class<?> cls;
|
||||||
Object object = null;
|
Object object = null;
|
||||||
try {
|
try {
|
||||||
cls = cl.loadClass(mainClass);
|
cls = cl.loadClass(mainClass);
|
||||||
object = cls.getConstructor(AbstractEcoPlugin.class).newInstance(this.getPlugin());
|
object = cls.getConstructor(EcoPlugin.class).newInstance(this.getPlugin());
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -129,15 +129,6 @@ public class EcoExtensionLoader extends PluginDependent implements ExtensionLoad
|
|||||||
extensions.clear();
|
extensions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Unloads, then loads all extensions.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void reloadExtensions() {
|
|
||||||
unloadExtensions();
|
|
||||||
loadExtensions();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all loaded extensions.
|
* Returns all loaded extensions.
|
||||||
*
|
*
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.willfp.eco.internal.extensions;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class ExtensionMetadata {
|
||||||
|
/**
|
||||||
|
* The version of the extension.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
@Getter
|
||||||
|
private final String version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The extension's name.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
@Getter
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new extension metadata.
|
||||||
|
*
|
||||||
|
* @param version The version for the extension to be.
|
||||||
|
* @param name The name of the extension.
|
||||||
|
*/
|
||||||
|
public ExtensionMetadata(@NotNull final String version,
|
||||||
|
@NotNull final String name) {
|
||||||
|
this.version = version;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +1,28 @@
|
|||||||
package com.willfp.eco.util.bukkit.meta;
|
package com.willfp.eco.internal.factory;
|
||||||
|
|
||||||
import com.willfp.eco.util.internal.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import com.willfp.eco.core.factory.MetadataValueFactory;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class MetadataValueFactory extends PluginDependent {
|
public class EcoMetadataValueFactory extends PluginDependent implements MetadataValueFactory {
|
||||||
/**
|
/**
|
||||||
* Factory class to produce {@link FixedMetadataValue}s associated with an {@link AbstractEcoPlugin}.
|
* Factory class to produce {@link FixedMetadataValue}s associated with an {@link EcoPlugin}.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin that this factory creates values for.
|
* @param plugin The plugin that this factory creates values for.
|
||||||
*/
|
*/
|
||||||
public MetadataValueFactory(@NotNull final AbstractEcoPlugin plugin) {
|
public EcoMetadataValueFactory(@NotNull final EcoPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an {@link FixedMetadataValue} associated with an {@link AbstractEcoPlugin} with a specified value.
|
* Create an {@link FixedMetadataValue} associated with an {@link EcoPlugin} with a specified value.
|
||||||
*
|
*
|
||||||
* @param value The value of meta key.
|
* @param value The value of meta key.
|
||||||
* @return The created {@link FixedMetadataValue}.
|
* @return The created {@link FixedMetadataValue}.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public FixedMetadataValue create(@NotNull final Object value) {
|
public FixedMetadataValue create(@NotNull final Object value) {
|
||||||
return new FixedMetadataValue(this.getPlugin(), value);
|
return new FixedMetadataValue(this.getPlugin(), value);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.willfp.eco.internal.factory;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.PluginDependent;
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import com.willfp.eco.core.factory.NamespacedKeyFactory;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class EcoNamespacedKeyFactory extends PluginDependent implements NamespacedKeyFactory {
|
||||||
|
/**
|
||||||
|
* Factory class to produce {@link NamespacedKey}s associated with an {@link EcoPlugin}.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin that this factory creates keys for.
|
||||||
|
*/
|
||||||
|
public EcoNamespacedKeyFactory(@NotNull final EcoPlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public NamespacedKey create(@NotNull final String key) {
|
||||||
|
return new NamespacedKey(this.getPlugin(), key);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.willfp.eco.internal.factory;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.factory.RunnableFactory;
|
||||||
|
import com.willfp.eco.core.scheduling.RunnableTask;
|
||||||
|
import com.willfp.eco.internal.scheduling.EcoRunnableTask;
|
||||||
|
import com.willfp.eco.core.PluginDependent;
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class EcoRunnableFactory extends PluginDependent implements RunnableFactory {
|
||||||
|
/**
|
||||||
|
* Factory class to produce {@link RunnableTask}s associated with an {@link EcoPlugin}.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin that this factory creates runnables for.
|
||||||
|
*/
|
||||||
|
public EcoRunnableFactory(@NotNull final EcoPlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RunnableTask create(@NotNull final Consumer<RunnableTask> consumer) {
|
||||||
|
return new EcoRunnableTask(this.getPlugin()) {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
consumer.accept(this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.willfp.eco.util.integrations.placeholder.plugins;
|
package com.willfp.eco.internal.integrations;
|
||||||
|
|
||||||
import com.willfp.eco.util.integrations.placeholder.PlaceholderIntegration;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.util.integrations.placeholder.PlaceholderManager;
|
import com.willfp.eco.core.integrations.placeholder.PlaceholderIntegration;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -13,14 +13,14 @@ public class PlaceholderIntegrationPAPI extends PlaceholderExpansion implements
|
|||||||
/**
|
/**
|
||||||
* The linked plugin.
|
* The linked plugin.
|
||||||
*/
|
*/
|
||||||
private final AbstractEcoPlugin plugin;
|
private final EcoPlugin plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PlaceholderAPI integration.
|
* Create a new PlaceholderAPI integration.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin to manage placeholders for.
|
* @param plugin The plugin to manage placeholders for.
|
||||||
*/
|
*/
|
||||||
public PlaceholderIntegrationPAPI(@NotNull final AbstractEcoPlugin plugin) {
|
public PlaceholderIntegrationPAPI(@NotNull final EcoPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ public class PlaceholderIntegrationPAPI extends PlaceholderExpansion implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getAuthor() {
|
public @NotNull String getAuthor() {
|
||||||
return "Auxilor";
|
return String.join(", ", plugin.getDescription().getAuthors());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.willfp.eco.internal.logging;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import com.willfp.eco.util.StringUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class EcoLogger extends Logger {
|
||||||
|
public EcoLogger(@NotNull final EcoPlugin plugin) {
|
||||||
|
super(plugin.getName(), (String) null);
|
||||||
|
String prefix = plugin.getDescription().getPrefix();
|
||||||
|
this.setParent(plugin.getServer().getLogger());
|
||||||
|
this.setLevel(Level.ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(@NotNull final String msg) {
|
||||||
|
super.info(StringUtils.translate(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warning(@NotNull final String msg) {
|
||||||
|
super.warning(StringUtils.translate(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void severe(@NotNull final String msg) {
|
||||||
|
super.severe(StringUtils.translate(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.willfp.eco.internal.scheduling;
|
||||||
|
|
||||||
|
import com.willfp.eco.internal.factory.EcoRunnableFactory;
|
||||||
|
import com.willfp.eco.core.scheduling.RunnableTask;
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public abstract class EcoRunnableTask extends BukkitRunnable implements RunnableTask {
|
||||||
|
/**
|
||||||
|
* The linked {@link EcoPlugin} to associate runnables with.
|
||||||
|
*/
|
||||||
|
private final EcoPlugin plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link EcoRunnableTask}.
|
||||||
|
* <p>
|
||||||
|
* Cannot be instantiated normally, use {@link EcoRunnableFactory}.
|
||||||
|
*
|
||||||
|
* @param plugin The {@link EcoPlugin} to associate runnables with.
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public EcoRunnableTask(@NotNull final EcoPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link EcoPlugin} that created this runnable.
|
||||||
|
*
|
||||||
|
* @return The linked plugin.
|
||||||
|
*/
|
||||||
|
protected final EcoPlugin getPlugin() {
|
||||||
|
return this.plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public final synchronized BukkitTask runTask() {
|
||||||
|
return super.runTask(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public final synchronized BukkitTask runTaskAsynchronously() {
|
||||||
|
return super.runTaskAsynchronously(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public final synchronized BukkitTask runTaskLater(final long delay) {
|
||||||
|
return super.runTaskLater(plugin, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public final synchronized BukkitTask runTaskLaterAsynchronously(final long delay) {
|
||||||
|
return super.runTaskLaterAsynchronously(plugin, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public final synchronized BukkitTask runTaskTimer(final long delay, final long period) {
|
||||||
|
return super.runTaskTimer(plugin, delay, period);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public final synchronized BukkitTask runTaskTimerAsynchronously(final long delay, final long period) {
|
||||||
|
return super.runTaskTimerAsynchronously(plugin, delay, period);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.willfp.eco.internal.bukkit.scheduling;
|
package com.willfp.eco.internal.scheduling;
|
||||||
|
|
||||||
import com.willfp.eco.util.bukkit.scheduling.Scheduler;
|
import com.willfp.eco.core.scheduling.Scheduler;
|
||||||
import com.willfp.eco.util.internal.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
@@ -10,12 +10,12 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class EcoScheduler extends PluginDependent implements Scheduler {
|
public class EcoScheduler extends PluginDependent implements Scheduler {
|
||||||
/**
|
/**
|
||||||
* Create a scheduler to manage the tasks of an {@link AbstractEcoPlugin}.
|
* Create a scheduler to manage the tasks of an {@link EcoPlugin}.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin to manage.
|
* @param plugin The plugin to manage.
|
||||||
*/
|
*/
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public EcoScheduler(@NotNull final AbstractEcoPlugin plugin) {
|
public EcoScheduler(@NotNull final EcoPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ public class EcoScheduler extends PluginDependent implements Scheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel all running tasks from the linked {@link AbstractEcoPlugin}.
|
* Cancel all running tasks from the linked {@link EcoPlugin}.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void cancelAll() {
|
public void cancelAll() {
|
||||||
@@ -15,7 +15,7 @@ import java.util.Set;
|
|||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class BlockUtils {
|
public class BlockUtils {
|
||||||
/**
|
/**
|
||||||
* If the meta set function has been set.
|
* If the meta set function has been set.
|
||||||
*/
|
*/
|
||||||
@@ -37,6 +37,15 @@ public class BlockUtils {
|
|||||||
if (blocks.size() > limit || blocks.size() > 2500) {
|
if (blocks.size() > limit || blocks.size() > 2500) {
|
||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Running twice to get more spherical shape.
|
||||||
|
for (BlockFace face : BlockFace.values()) {
|
||||||
|
Block block = start.getRelative(face);
|
||||||
|
if (!blocks.contains(block) && allowedMaterials.contains(block.getType())) {
|
||||||
|
if (blocks.size() > limit || blocks.size() > 2500) {
|
||||||
|
return blocks;
|
||||||
|
}
|
||||||
blocks.addAll(getNearbyBlocks(block, allowedMaterials, blocks, limit));
|
blocks.addAll(getNearbyBlocks(block, allowedMaterials, blocks, limit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,7 +58,6 @@ public class BlockUtils {
|
|||||||
* @param start The initial block.
|
* @param start The initial block.
|
||||||
* @param allowedMaterials A list of all valid {@link Material}s.
|
* @param allowedMaterials A list of all valid {@link Material}s.
|
||||||
* @param limit The maximum size of vein to return.
|
* @param limit The maximum size of vein to return.
|
||||||
*
|
|
||||||
* @return A set of all {@link Block}s.
|
* @return A set of all {@link Block}s.
|
||||||
*/
|
*/
|
||||||
public Set<Block> getVein(@NotNull final Block start,
|
public Set<Block> getVein(@NotNull final Block start,
|
||||||
@@ -10,6 +10,21 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class NumberUtils {
|
public class NumberUtils {
|
||||||
|
/**
|
||||||
|
* Precision.
|
||||||
|
*/
|
||||||
|
private static final int FAST_TRIG_PRECISION = 100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modulus.
|
||||||
|
*/
|
||||||
|
private static final int FAST_TRIG_MODULUS = 360 * FAST_TRIG_PRECISION;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sin lookup table.
|
||||||
|
*/
|
||||||
|
private static final double[] SIN_LOOKUP = new double[FAST_TRIG_MODULUS];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set of roman numerals to look up.
|
* Set of roman numerals to look up.
|
||||||
*/
|
*/
|
||||||
@@ -29,6 +44,34 @@ public class NumberUtils {
|
|||||||
NUMERALS.put(5, "V");
|
NUMERALS.put(5, "V");
|
||||||
NUMERALS.put(4, "IV");
|
NUMERALS.put(4, "IV");
|
||||||
NUMERALS.put(1, "I");
|
NUMERALS.put(1, "I");
|
||||||
|
|
||||||
|
for (int i = 0; i < SIN_LOOKUP.length; i++) {
|
||||||
|
SIN_LOOKUP[i] = Math.sin((i * Math.PI) / (FAST_TRIG_PRECISION * 180));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double sinLookup(final int a) {
|
||||||
|
return a >= 0 ? SIN_LOOKUP[a % FAST_TRIG_MODULUS] : -SIN_LOOKUP[-a % FAST_TRIG_MODULUS];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the sin of a number.
|
||||||
|
*
|
||||||
|
* @param a The number.
|
||||||
|
* @return The sin.
|
||||||
|
*/
|
||||||
|
public static double fastSin(final double a) {
|
||||||
|
return sinLookup((int) (a * FAST_TRIG_PRECISION + 0.5f));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the cosine of a number.
|
||||||
|
*
|
||||||
|
* @param a The number.
|
||||||
|
* @return The cosine.
|
||||||
|
*/
|
||||||
|
public static double fastCos(final double a) {
|
||||||
|
return sinLookup((int) ((a + 90f) * FAST_TRIG_PRECISION + 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.willfp.eco.util;
|
package com.willfp.eco.util;
|
||||||
|
|
||||||
import com.willfp.eco.util.integrations.placeholder.PlaceholderManager;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.willfp.eco.util.optional.Prerequisite;
|
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -21,19 +21,23 @@ import static net.md_5.bungee.api.ChatColor.COLOR_CHAR;
|
|||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class StringUtils {
|
public class StringUtils {
|
||||||
/**
|
/**
|
||||||
* Regex for gradients.
|
* Regexes for gradients.
|
||||||
*/
|
*/
|
||||||
private static final Pattern GRADIENT_REGEX = Pattern.compile("<GRADIENT:([0-9A-Fa-f]{6})>(.*?)</GRADIENT:([0-9A-Fa-f]{6})>");
|
private static final List<Pattern> GRADIENT_PATTERNS = new ImmutableList.Builder<Pattern>()
|
||||||
|
.add(Pattern.compile("<GRADIENT:([0-9A-Fa-f]{6})>(.*?)</GRADIENT:([0-9A-Fa-f]{6})>"))
|
||||||
|
.add(Pattern.compile("<G:([0-9A-Fa-f]{6})>(.*?)</G:([0-9A-Fa-f]{6})>"))
|
||||||
|
.add(Pattern.compile("<#:([0-9A-Fa-f]{6})>(.*?)</#:([0-9A-Fa-f]{6})>"))
|
||||||
|
.add(Pattern.compile("\\{#:([0-9A-Fa-f]{6})}(.*?)\\{/#:([0-9A-Fa-f]{6})}"))
|
||||||
|
.build();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regex for hex codes.
|
* Regexes for hex codes.
|
||||||
*/
|
*/
|
||||||
private static final Pattern HEX_PATTERN = Pattern.compile("&#" + "([A-Fa-f0-9]{6})" + "");
|
private static final List<Pattern> HEX_PATTERNS = new ImmutableList.Builder<Pattern>()
|
||||||
|
.add(Pattern.compile("&#" + "([A-Fa-f0-9]{6})" + ""))
|
||||||
/**
|
.add(Pattern.compile("\\{#" + "([A-Fa-f0-9]{6})" + "}"))
|
||||||
* Regex for hex codes.
|
.add(Pattern.compile("<#" + "([A-Fa-f0-9]{6})" + ">"))
|
||||||
*/
|
.build();
|
||||||
private static final Pattern ALT_HEX_PATTERN = Pattern.compile("\\{#" + "([A-Fa-f0-9]{6})" + "}");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate a string - converts Placeholders and Color codes.
|
* Translate a string - converts Placeholders and Color codes.
|
||||||
@@ -45,9 +49,7 @@ public class StringUtils {
|
|||||||
public String translate(@NotNull final String message,
|
public String translate(@NotNull final String message,
|
||||||
@Nullable final Player player) {
|
@Nullable final Player player) {
|
||||||
String processedMessage = message;
|
String processedMessage = message;
|
||||||
if (Prerequisite.MINIMUM_1_16.isMet()) {
|
processedMessage = translateGradients(processedMessage);
|
||||||
processedMessage = translateGradients(processedMessage);
|
|
||||||
}
|
|
||||||
processedMessage = PlaceholderManager.translatePlaceholders(processedMessage, player);
|
processedMessage = PlaceholderManager.translatePlaceholders(processedMessage, player);
|
||||||
processedMessage = translateHexColorCodes(processedMessage);
|
processedMessage = translateHexColorCodes(processedMessage);
|
||||||
processedMessage = ChatColor.translateAlternateColorCodes('&', processedMessage);
|
processedMessage = ChatColor.translateAlternateColorCodes('&', processedMessage);
|
||||||
@@ -67,20 +69,15 @@ public class StringUtils {
|
|||||||
|
|
||||||
private static String translateHexColorCodes(@NotNull final String message) {
|
private static String translateHexColorCodes(@NotNull final String message) {
|
||||||
String processedMessage = message;
|
String processedMessage = message;
|
||||||
for (HexParseMode parseMode : HexParseMode.values()) {
|
for (Pattern pattern : HEX_PATTERNS) {
|
||||||
processedMessage = translateHexColorCodes(processedMessage, parseMode);
|
processedMessage = translateHexColorCodes(processedMessage, pattern);
|
||||||
}
|
}
|
||||||
return processedMessage;
|
return processedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String translateHexColorCodes(@NotNull final String message,
|
private static String translateHexColorCodes(@NotNull final String message,
|
||||||
@NotNull final HexParseMode mode) {
|
@NotNull final Pattern pattern) {
|
||||||
Matcher matcher;
|
Matcher matcher = pattern.matcher(message);
|
||||||
if (mode == HexParseMode.CMI) {
|
|
||||||
matcher = ALT_HEX_PATTERN.matcher(message);
|
|
||||||
} else {
|
|
||||||
matcher = HEX_PATTERN.matcher(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
|
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
@@ -171,12 +168,14 @@ public class StringUtils {
|
|||||||
*/
|
*/
|
||||||
private static String translateGradients(@NotNull final String string) {
|
private static String translateGradients(@NotNull final String string) {
|
||||||
String processedString = string;
|
String processedString = string;
|
||||||
Matcher matcher = GRADIENT_REGEX.matcher(string);
|
for (Pattern pattern : GRADIENT_PATTERNS) {
|
||||||
while (matcher.find()) {
|
Matcher matcher = pattern.matcher(string);
|
||||||
String start = matcher.group(1);
|
while (matcher.find()) {
|
||||||
String end = matcher.group(3);
|
String start = matcher.group(1);
|
||||||
String content = matcher.group(2);
|
String end = matcher.group(3);
|
||||||
processedString = processedString.replace(matcher.group(), processGradients(content, new Color(Integer.parseInt(start, 16)), new Color(Integer.parseInt(end, 16))));
|
String content = matcher.group(2);
|
||||||
|
processedString = processedString.replace(matcher.group(), processGradients(content, new Color(Integer.parseInt(start, 16)), new Color(Integer.parseInt(end, 16))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return processedString;
|
return processedString;
|
||||||
}
|
}
|
||||||
@@ -221,9 +220,4 @@ public class StringUtils {
|
|||||||
}
|
}
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum HexParseMode {
|
|
||||||
CMI,
|
|
||||||
NORMAL
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@ package com.willfp.eco.util;
|
|||||||
|
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.willfp.eco.util.optional.Prerequisite;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@@ -45,10 +44,10 @@ public class TeamUtils {
|
|||||||
|
|
||||||
Team team;
|
Team team;
|
||||||
|
|
||||||
if (!SCOREBOARD.getTeams().stream().map(Team::getName).collect(Collectors.toList()).contains("EE-" + color.name())) {
|
if (!SCOREBOARD.getTeams().stream().map(Team::getName).collect(Collectors.toList()).contains("EC-" + color.name())) {
|
||||||
team = SCOREBOARD.registerNewTeam("EE-" + color.name());
|
team = SCOREBOARD.registerNewTeam("EC-" + color.name());
|
||||||
} else {
|
} else {
|
||||||
team = SCOREBOARD.getTeam("EE-" + color.name());
|
team = SCOREBOARD.getTeam("EC-" + color.name());
|
||||||
}
|
}
|
||||||
assert team != null;
|
assert team != null;
|
||||||
team.setColor(color);
|
team.setColor(color);
|
||||||
@@ -80,9 +79,6 @@ public class TeamUtils {
|
|||||||
MATERIAL_COLORS.forcePut(Material.LAPIS_ORE, ChatColor.BLUE);
|
MATERIAL_COLORS.forcePut(Material.LAPIS_ORE, ChatColor.BLUE);
|
||||||
MATERIAL_COLORS.forcePut(Material.REDSTONE_ORE, ChatColor.RED);
|
MATERIAL_COLORS.forcePut(Material.REDSTONE_ORE, ChatColor.RED);
|
||||||
MATERIAL_COLORS.forcePut(Material.DIAMOND_ORE, ChatColor.AQUA);
|
MATERIAL_COLORS.forcePut(Material.DIAMOND_ORE, ChatColor.AQUA);
|
||||||
|
MATERIAL_COLORS.forcePut(Material.ANCIENT_DEBRIS, ChatColor.DARK_RED);
|
||||||
if (Prerequisite.MINIMUM_1_16.isMet()) {
|
|
||||||
MATERIAL_COLORS.forcePut(Material.ANCIENT_DEBRIS, ChatColor.DARK_RED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.willfp.eco.util.drops.telekinesis;
|
package com.willfp.eco.util;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -7,6 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
@@ -78,7 +79,7 @@ public class VectorUtils {
|
|||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Vector> circleVecs = new ArrayList<>();
|
List<Vector> vectors = new ArrayList<>();
|
||||||
|
|
||||||
double xoffset = -radius;
|
double xoffset = -radius;
|
||||||
double zoffset = -radius;
|
double zoffset = -radius;
|
||||||
@@ -86,7 +87,7 @@ public class VectorUtils {
|
|||||||
while (zoffset <= radius) {
|
while (zoffset <= radius) {
|
||||||
while (xoffset <= radius) {
|
while (xoffset <= radius) {
|
||||||
if (Math.round(Math.sqrt((xoffset * xoffset) + (zoffset * zoffset))) <= radius) {
|
if (Math.round(Math.sqrt((xoffset * xoffset) + (zoffset * zoffset))) <= radius) {
|
||||||
circleVecs.add(new Vector(xoffset, 0, zoffset));
|
vectors.add(new Vector(xoffset, 0, zoffset));
|
||||||
} else {
|
} else {
|
||||||
xoffset++;
|
xoffset++;
|
||||||
continue;
|
continue;
|
||||||
@@ -97,7 +98,7 @@ public class VectorUtils {
|
|||||||
zoffset++;
|
zoffset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector[] result = circleVecs.toArray(new Vector[0]);
|
Vector[] result = vectors.toArray(new Vector[0]);
|
||||||
CIRCLE_CACHE.put(radius, result);
|
CIRCLE_CACHE.put(radius, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -109,21 +110,21 @@ public class VectorUtils {
|
|||||||
* @return An array of {@link Vector}s.
|
* @return An array of {@link Vector}s.
|
||||||
*/
|
*/
|
||||||
public Vector[] getSquare(final int radius) {
|
public Vector[] getSquare(final int radius) {
|
||||||
ArrayList<Vector> circleVecs = new ArrayList<>();
|
List<Vector> vectors = new ArrayList<>();
|
||||||
|
|
||||||
int xoffset = -radius;
|
int xoffset = -radius;
|
||||||
int zoffset = -radius;
|
int zoffset = -radius;
|
||||||
|
|
||||||
while (zoffset <= radius) {
|
while (zoffset <= radius) {
|
||||||
while (xoffset <= radius) {
|
while (xoffset <= radius) {
|
||||||
circleVecs.add(new Vector(xoffset, 0, zoffset));
|
vectors.add(new Vector(xoffset, 0, zoffset));
|
||||||
xoffset++;
|
xoffset++;
|
||||||
}
|
}
|
||||||
xoffset = -radius;
|
xoffset = -radius;
|
||||||
zoffset++;
|
zoffset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return circleVecs.toArray(new Vector[0]);
|
return vectors.toArray(new Vector[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,16 +134,16 @@ public class VectorUtils {
|
|||||||
* @return An array of {@link Vector}s.
|
* @return An array of {@link Vector}s.
|
||||||
*/
|
*/
|
||||||
public Vector[] getCube(final int radius) {
|
public Vector[] getCube(final int radius) {
|
||||||
ArrayList<Vector> cubeVecs = new ArrayList<>();
|
List<Vector> vectors = new ArrayList<>();
|
||||||
|
|
||||||
for (int y = -radius; y <= radius; y++) {
|
for (int y = -radius; y <= radius; y++) {
|
||||||
for (int z = -radius; z <= radius; z++) {
|
for (int z = -radius; z <= radius; z++) {
|
||||||
for (int x = -radius; x <= radius; x++) {
|
for (int x = -radius; x <= radius; x++) {
|
||||||
cubeVecs.add(new Vector(x, y, z));
|
vectors.add(new Vector(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cubeVecs.toArray(new Vector[0]);
|
return vectors.toArray(new Vector[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,6 @@ version rootProject.version
|
|||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly project(":eco-util")
|
compileOnly project(":eco-api")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
group 'com.willfp'
|
|
||||||
version rootProject.version
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compileOnly 'org.spigotmc:spigot:1.15.2-R0.1-SNAPSHOT'
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package com.willfp.eco.proxy.v1_15_R1;
|
|
||||||
|
|
||||||
import com.willfp.eco.proxy.proxies.AutoCraftProxy;
|
|
||||||
import net.minecraft.server.v1_15_R1.MinecraftKey;
|
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutAutoRecipe;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public final class AutoCraft implements AutoCraftProxy {
|
|
||||||
@Override
|
|
||||||
public void modifyPacket(@NotNull final Object packet) throws NoSuchFieldException, IllegalAccessException {
|
|
||||||
PacketPlayOutAutoRecipe recipePacket = (PacketPlayOutAutoRecipe) packet;
|
|
||||||
Field fKey = recipePacket.getClass().getDeclaredField("b");
|
|
||||||
fKey.setAccessible(true);
|
|
||||||
MinecraftKey key = (MinecraftKey) fKey.get(recipePacket);
|
|
||||||
fKey.set(recipePacket, new MinecraftKey(key.getNamespace(), key.getKey() + "_displayed"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.willfp.eco.proxy.v1_15_R1;
|
|
||||||
|
|
||||||
import com.willfp.eco.proxy.proxies.BlockBreakProxy;
|
|
||||||
import net.minecraft.server.v1_15_R1.BlockPosition;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public final class BlockBreak implements BlockBreakProxy {
|
|
||||||
@Override
|
|
||||||
public void breakBlock(@NotNull final Player player,
|
|
||||||
@NotNull final Block block) {
|
|
||||||
((CraftPlayer) player).getHandle().playerInteractManager.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package com.willfp.eco.proxy.v1_15_R1;
|
|
||||||
|
|
||||||
import com.willfp.eco.proxy.proxies.ChatComponentProxy;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public final class ChatComponent implements ChatComponentProxy {
|
|
||||||
@Override
|
|
||||||
public Object modifyComponent(@NotNull final Object object) {
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.willfp.eco.proxy.v1_15_R1;
|
|
||||||
|
|
||||||
import com.willfp.eco.proxy.proxies.CooldownProxy;
|
|
||||||
import net.minecraft.server.v1_15_R1.EntityHuman;
|
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public final class Cooldown implements CooldownProxy {
|
|
||||||
@Override
|
|
||||||
public double getAttackCooldown(@NotNull final Player player) {
|
|
||||||
EntityHuman entityHuman = ((CraftPlayer) player).getHandle();
|
|
||||||
return entityHuman.s(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user