Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
726f4a44c4 | ||
|
|
eafae209a6 | ||
|
|
04c450b46a | ||
|
|
d4e1f58f2a | ||
|
|
b0806b934b | ||
|
|
a21ecfbdde | ||
|
|
f3a6861bc6 | ||
|
|
eaa295e6a3 | ||
|
|
399387eca1 | ||
|
|
272f551aae | ||
|
|
d8c5fc0959 | ||
|
|
d1ca106d01 | ||
|
|
99f5174e28 | ||
|
|
d9f4aee384 | ||
|
|
c2aae8c2eb | ||
|
|
52061b7b51 | ||
|
|
762969c172 | ||
|
|
62d5cf885f | ||
|
|
1e70a9fdea | ||
|
|
ec8a65b4f8 | ||
|
|
a163219372 | ||
|
|
4d6e097f8f | ||
|
|
497adbe7b1 | ||
|
|
78907412b2 | ||
|
|
d6bec5d88b | ||
|
|
aab1f31ca0 | ||
|
|
5ea586eaae | ||
|
|
2ffc293211 | ||
|
|
88bedef420 | ||
|
|
dac5ffce9a | ||
|
|
d641adadea | ||
|
|
46269354c6 | ||
|
|
2d93465d1d | ||
|
|
484d4dde75 | ||
|
|
5e9a408704 | ||
|
|
f1b113f435 |
@@ -142,6 +142,11 @@ public abstract class AbstractPacketAdapter extends PacketAdapter {
|
|||||||
onSend(event.getPacket(), event.getPlayer(), event);
|
onSend(event.getPacket(), event.getPlayer(), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final EcoPlugin getPlugin() {
|
||||||
|
return (EcoPlugin) super.getPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the packet adapter with ProtocolLib.
|
* Register the packet adapter with ProtocolLib.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package com.willfp.eco.core;
|
package com.willfp.eco.core;
|
||||||
|
|
||||||
import com.willfp.eco.core.command.AbstractCommand;
|
import com.willfp.eco.core.command.AbstractCommand;
|
||||||
|
import com.willfp.eco.core.command.impl.PluginCommand;
|
||||||
|
import com.willfp.eco.core.config.ConfigHandler;
|
||||||
import com.willfp.eco.core.config.base.ConfigYml;
|
import com.willfp.eco.core.config.base.ConfigYml;
|
||||||
import com.willfp.eco.core.config.base.LangYml;
|
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.Display;
|
||||||
import com.willfp.eco.core.display.DisplayModule;
|
import com.willfp.eco.core.display.DisplayModule;
|
||||||
import com.willfp.eco.core.events.EventManager;
|
import com.willfp.eco.core.events.EventManager;
|
||||||
@@ -14,8 +15,10 @@ import com.willfp.eco.core.factory.RunnableFactory;
|
|||||||
import com.willfp.eco.core.integrations.IntegrationLoader;
|
import com.willfp.eco.core.integrations.IntegrationLoader;
|
||||||
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager;
|
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager;
|
||||||
import com.willfp.eco.core.scheduling.Scheduler;
|
import com.willfp.eco.core.scheduling.Scheduler;
|
||||||
|
import com.willfp.eco.internal.Internals;
|
||||||
import com.willfp.eco.internal.UpdateChecker;
|
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.config.updating.EcoConfigHandler;
|
||||||
import com.willfp.eco.internal.events.EcoEventManager;
|
import com.willfp.eco.internal.events.EcoEventManager;
|
||||||
import com.willfp.eco.internal.extensions.EcoExtensionLoader;
|
import com.willfp.eco.internal.extensions.EcoExtensionLoader;
|
||||||
import com.willfp.eco.internal.factory.EcoMetadataValueFactory;
|
import com.willfp.eco.internal.factory.EcoMetadataValueFactory;
|
||||||
@@ -25,9 +28,11 @@ import com.willfp.eco.internal.integrations.PlaceholderIntegrationPAPI;
|
|||||||
import com.willfp.eco.internal.logging.EcoLogger;
|
import com.willfp.eco.internal.logging.EcoLogger;
|
||||||
import com.willfp.eco.internal.scheduling.EcoScheduler;
|
import com.willfp.eco.internal.scheduling.EcoScheduler;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@@ -42,6 +47,7 @@ import java.util.Set;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@SuppressWarnings({"deprecation", "DeprecatedIsStillUsed"})
|
||||||
public abstract class EcoPlugin extends JavaPlugin {
|
public abstract class EcoPlugin extends JavaPlugin {
|
||||||
/**
|
/**
|
||||||
* Loaded eco plugins.
|
* Loaded eco plugins.
|
||||||
@@ -50,8 +56,11 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the plugin.
|
* The name of the plugin.
|
||||||
|
*
|
||||||
|
* @deprecated Pointless, use getName instead.
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
|
@Deprecated
|
||||||
private final String pluginName;
|
private final String pluginName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,6 +171,100 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
@Getter
|
@Getter
|
||||||
private boolean outdated = false;
|
private boolean outdated = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the plugin supports extensions.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final boolean supportingExtensions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new plugin without a specified color, proxy support, spigot, or bStats.
|
||||||
|
*/
|
||||||
|
protected EcoPlugin() {
|
||||||
|
this("&f");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new plugin without proxy support, spigot, or bStats.
|
||||||
|
*
|
||||||
|
* @param color The color.
|
||||||
|
*/
|
||||||
|
protected EcoPlugin(@NotNull final String color) {
|
||||||
|
this("", color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new plugin unlinked to spigot and bStats.
|
||||||
|
*
|
||||||
|
* @param proxyPackage The package where proxy implementations are stored.
|
||||||
|
* @param color The color of the plugin (used in messages, such as &a, &b)
|
||||||
|
*/
|
||||||
|
protected EcoPlugin(@NotNull final String proxyPackage,
|
||||||
|
@NotNull final String color) {
|
||||||
|
this(0, 0, proxyPackage, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new plugin without proxy or extension support.
|
||||||
|
*
|
||||||
|
* @param resourceId The spigot resource ID for the plugin.
|
||||||
|
* @param bStatsId The bStats resource ID for the plugin.
|
||||||
|
* @param color The color of the plugin (used in messages, such as &a, &b)
|
||||||
|
*/
|
||||||
|
protected EcoPlugin(final int resourceId,
|
||||||
|
final int bStatsId,
|
||||||
|
@NotNull final String color) {
|
||||||
|
this(resourceId, bStatsId, "", color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new plugin without proxy support.
|
||||||
|
*
|
||||||
|
* @param resourceId The spigot resource ID for the plugin.
|
||||||
|
* @param bStatsId The bStats resource ID for the plugin.
|
||||||
|
* @param color The color of the plugin (used in messages, such as &a, &b)
|
||||||
|
* @param supportingExtensions If the plugin supports extensions.
|
||||||
|
*/
|
||||||
|
protected EcoPlugin(final int resourceId,
|
||||||
|
final int bStatsId,
|
||||||
|
@NotNull final String color,
|
||||||
|
final boolean supportingExtensions) {
|
||||||
|
this(resourceId, bStatsId, "", color, supportingExtensions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new plugin without extension support.
|
||||||
|
*
|
||||||
|
* @param resourceId The spigot resource ID for the plugin.
|
||||||
|
* @param bStatsId The bStats resource ID for the plugin.
|
||||||
|
* @param proxyPackage The package where proxy implementations are stored.
|
||||||
|
* @param color The color of the plugin (used in messages, such as &a, &b)
|
||||||
|
*/
|
||||||
|
protected EcoPlugin(final int resourceId,
|
||||||
|
final int bStatsId,
|
||||||
|
@NotNull final String proxyPackage,
|
||||||
|
@NotNull final String color) {
|
||||||
|
this(resourceId, bStatsId, proxyPackage, color, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new plugin.
|
||||||
|
*
|
||||||
|
* @param resourceId The spigot resource ID for the plugin.
|
||||||
|
* @param bStatsId The bStats resource ID for the plugin.
|
||||||
|
* @param proxyPackage The package where proxy implementations are stored.
|
||||||
|
* @param color The color of the plugin (used in messages, such as &a, &b)
|
||||||
|
* @param supportingExtensions If the plugin supports extensions.
|
||||||
|
*/
|
||||||
|
protected EcoPlugin(final int resourceId,
|
||||||
|
final int bStatsId,
|
||||||
|
@NotNull final String proxyPackage,
|
||||||
|
@NotNull final String color,
|
||||||
|
final boolean supportingExtensions) {
|
||||||
|
this("", resourceId, bStatsId, proxyPackage, color, supportingExtensions);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new plugin.
|
* Create a new plugin.
|
||||||
*
|
*
|
||||||
@@ -170,17 +273,43 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
* @param bStatsId The bStats resource ID for the plugin.
|
* @param bStatsId The bStats resource ID for the plugin.
|
||||||
* @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)
|
||||||
|
* @deprecated pluginName is redundant.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@SuppressWarnings("unused")
|
||||||
protected EcoPlugin(@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, resourceId, bStatsId, proxyPackage, color, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new plugin.
|
||||||
|
*
|
||||||
|
* @param pluginName The name of the plugin.
|
||||||
|
* @param resourceId The spigot resource ID for the plugin.
|
||||||
|
* @param bStatsId The bStats resource ID for the plugin.
|
||||||
|
* @param proxyPackage The package where proxy implementations are stored.
|
||||||
|
* @param color The color of the plugin (used in messages, such as &a, &b)
|
||||||
|
* @param supportingExtensions If the plugin supports extensions.
|
||||||
|
* @deprecated pluginName is redundant.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
protected EcoPlugin(@NotNull final String pluginName,
|
||||||
|
final int resourceId,
|
||||||
|
final int bStatsId,
|
||||||
|
@NotNull final String proxyPackage,
|
||||||
|
@NotNull final String color,
|
||||||
|
final boolean supportingExtensions) {
|
||||||
|
this.pluginName = this.getName();
|
||||||
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.supportingExtensions = supportingExtensions;
|
||||||
|
|
||||||
this.scheduler = new EcoScheduler(this);
|
this.scheduler = new EcoScheduler(this);
|
||||||
this.eventManager = new EcoEventManager(this);
|
this.eventManager = new EcoEventManager(this);
|
||||||
@@ -188,7 +317,7 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
this.metadataValueFactory = new EcoMetadataValueFactory(this);
|
this.metadataValueFactory = new EcoMetadataValueFactory(this);
|
||||||
this.runnableFactory = new EcoRunnableFactory(this);
|
this.runnableFactory = new EcoRunnableFactory(this);
|
||||||
this.extensionLoader = new EcoExtensionLoader(this);
|
this.extensionLoader = new EcoExtensionLoader(this);
|
||||||
this.configHandler = new ConfigHandler(this);
|
this.configHandler = new EcoConfigHandler(this);
|
||||||
this.logger = new EcoLogger(this);
|
this.logger = new EcoLogger(this);
|
||||||
|
|
||||||
this.langYml = new LangYml(this);
|
this.langYml = new LangYml(this);
|
||||||
@@ -205,24 +334,38 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
super.onEnable();
|
super.onEnable();
|
||||||
|
|
||||||
this.getLogger().info("");
|
this.getLogger().info("");
|
||||||
this.getLogger().info("Loading " + this.color + this.pluginName);
|
this.getLogger().info("Loading " + this.getColor() + this.getName());
|
||||||
|
|
||||||
this.getEventManager().registerListener(new ArrowDataListener(this));
|
this.getEventManager().registerListener(new ArrowDataListener(this));
|
||||||
|
|
||||||
|
if (this.getResourceId() != 0) {
|
||||||
new UpdateChecker(this).getVersion(version -> {
|
new UpdateChecker(this).getVersion(version -> {
|
||||||
DefaultArtifactVersion currentVersion = new DefaultArtifactVersion(this.getDescription().getVersion());
|
DefaultArtifactVersion currentVersion = new DefaultArtifactVersion(this.getDescription().getVersion());
|
||||||
DefaultArtifactVersion mostRecentVersion = new DefaultArtifactVersion(version);
|
DefaultArtifactVersion mostRecentVersion = new DefaultArtifactVersion(version);
|
||||||
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.getLogger().info("&c " + this.pluginName + " is out of date! (Version " + this.getDescription().getVersion() + ")");
|
this.getLogger().info("&c " + this.getName() + " is out of date! (Version " + this.getDescription().getVersion() + ")");
|
||||||
this.getLogger().info("&cThe newest version is &f" + version);
|
this.getLogger().info("&cThe newest version is &f" + version);
|
||||||
this.getLogger().info("&cDownload the new version!");
|
this.getLogger().info("&cDownload the new version!");
|
||||||
}, 0, 864000);
|
}, 0, 864000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
new Metrics(this, this.bStatsId);
|
DefaultArtifactVersion runningVersion = new DefaultArtifactVersion(Internals.getInstance().getPlugin().getDescription().getVersion());
|
||||||
|
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(this.getMinimumEcoVersion());
|
||||||
|
if (!(runningVersion.compareTo(requiredVersion) > 0 || runningVersion.equals(requiredVersion))) {
|
||||||
|
this.getLogger().severe("You are running an outdated version of eco!");
|
||||||
|
this.getLogger().severe("You must be on at least" + this.getMinimumEcoVersion());
|
||||||
|
this.getLogger().severe("Download the newest version here:");
|
||||||
|
this.getLogger().severe("https://polymart.org/download/773/recent/JSpprMspkuyecf5y1wQ2Jn8OoLQSQ_IW");
|
||||||
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getBStatsId() != 0) {
|
||||||
|
new Metrics(this, this.getBStatsId());
|
||||||
|
}
|
||||||
|
|
||||||
Set<String> enabledPlugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toSet());
|
Set<String> enabledPlugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toSet());
|
||||||
|
|
||||||
@@ -253,11 +396,23 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
this.getListeners().forEach(listener -> this.getEventManager().registerListener(listener));
|
this.getListeners().forEach(listener -> this.getEventManager().registerListener(listener));
|
||||||
|
|
||||||
this.getCommands().forEach(AbstractCommand::register);
|
this.getCommands().forEach(AbstractCommand::register);
|
||||||
|
this.getPluginCommands().forEach(PluginCommand::register);
|
||||||
|
|
||||||
this.getScheduler().runLater(this::afterLoad, 1);
|
this.getScheduler().runLater(this::afterLoad, 1);
|
||||||
|
|
||||||
this.updatableClasses.forEach(clazz -> this.getConfigHandler().registerUpdatableClass(clazz));
|
this.updatableClasses.forEach(clazz -> this.getConfigHandler().registerUpdatableClass(clazz));
|
||||||
|
|
||||||
|
if (this.isSupportingExtensions()) {
|
||||||
|
this.getExtensionLoader().loadExtensions();
|
||||||
|
|
||||||
|
if (this.getExtensionLoader().getLoadedExtensions().isEmpty()) {
|
||||||
|
this.getLogger().info("&cNo extensions found");
|
||||||
|
} else {
|
||||||
|
this.getLogger().info("Extensions Loaded:");
|
||||||
|
this.getExtensionLoader().getLoadedExtensions().forEach(extension -> this.getLogger().info("- " + extension.getName() + " v" + extension.getVersion()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.enable();
|
this.enable();
|
||||||
|
|
||||||
this.getLogger().info("");
|
this.getLogger().info("");
|
||||||
@@ -275,6 +430,10 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
this.getConfigHandler().saveAllConfigs();
|
this.getConfigHandler().saveAllConfigs();
|
||||||
|
|
||||||
this.disable();
|
this.disable();
|
||||||
|
|
||||||
|
if (this.isSupportingExtensions()) {
|
||||||
|
this.getExtensionLoader().unloadExtensions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -327,8 +486,7 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
* Default code to be executed on plugin reload.
|
* Default code to be executed on plugin reload.
|
||||||
*/
|
*/
|
||||||
public final void reload() {
|
public final void reload() {
|
||||||
this.getConfigYml().update();
|
this.getConfigHandler().updateConfigs();
|
||||||
this.getLangYml().update();
|
|
||||||
|
|
||||||
this.getConfigHandler().callUpdate();
|
this.getConfigHandler().callUpdate();
|
||||||
this.getConfigHandler().callUpdate(); // Call twice to fix issues
|
this.getConfigHandler().callUpdate(); // Call twice to fix issues
|
||||||
@@ -339,42 +497,79 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The plugin-specific code to be executed on enable.
|
* The plugin-specific code to be executed on enable.
|
||||||
|
* <p>
|
||||||
|
* Override when needed.
|
||||||
*/
|
*/
|
||||||
public abstract void enable();
|
public void enable() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plugin-specific code to be executed on disable.
|
* The plugin-specific code to be executed on disable.
|
||||||
|
* <p>
|
||||||
|
* Override when needed.
|
||||||
*/
|
*/
|
||||||
public abstract void disable();
|
public void disable() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plugin-specific code to be executed on load.
|
* The plugin-specific code to be executed on load.
|
||||||
|
* <p>
|
||||||
|
* This is executed before enabling.
|
||||||
|
* <p>
|
||||||
|
* Override when needed.
|
||||||
*/
|
*/
|
||||||
public abstract void load();
|
public void load() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plugin-specific code to be executed on reload.
|
* The plugin-specific code to be executed on reload.
|
||||||
|
* <p>
|
||||||
|
* Override when needed.
|
||||||
*/
|
*/
|
||||||
public abstract void onReload();
|
public void onReload() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plugin-specific code to be executed after the server is up.
|
* The plugin-specific code to be executed after the server is up.
|
||||||
|
* <p>
|
||||||
|
* Override when needed.
|
||||||
*/
|
*/
|
||||||
public abstract void postLoad();
|
public void postLoad() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plugin-specific integrations to be tested and loaded.
|
* The plugin-specific integrations to be tested and loaded.
|
||||||
*
|
*
|
||||||
* @return A list of integrations.
|
* @return A list of integrations.
|
||||||
*/
|
*/
|
||||||
public abstract List<IntegrationLoader> getIntegrationLoaders();
|
public List<IntegrationLoader> getIntegrationLoaders() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The command to be registered.
|
* The commands to be registered.
|
||||||
|
*
|
||||||
|
* @return A list of commands.
|
||||||
|
* @deprecated Use {@link this#getPluginCommands()} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public List<AbstractCommand> getCommands() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The commands to be registered.
|
||||||
*
|
*
|
||||||
* @return A list of commands.
|
* @return A list of commands.
|
||||||
*/
|
*/
|
||||||
public abstract List<AbstractCommand> getCommands();
|
public List<PluginCommand> getPluginCommands() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ProtocolLib packet adapters to be registered.
|
* ProtocolLib packet adapters to be registered.
|
||||||
@@ -383,7 +578,9 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return A list of packet adapters.
|
* @return A list of packet adapters.
|
||||||
*/
|
*/
|
||||||
public abstract List<AbstractPacketAdapter> getPacketAdapters();
|
public List<AbstractPacketAdapter> getPacketAdapters() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All listeners to be registered.
|
* All listeners to be registered.
|
||||||
@@ -397,7 +594,9 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return A list of all updatable classes.
|
* @return A list of all updatable classes.
|
||||||
*/
|
*/
|
||||||
public abstract List<Class<?>> getUpdatableClasses();
|
public List<Class<?>> getUpdatableClasses() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the display module for the plugin.
|
* Create the display module for the plugin.
|
||||||
@@ -406,12 +605,86 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
protected DisplayModule createDisplayModule() {
|
protected DisplayModule createDisplayModule() {
|
||||||
|
Validate.isTrue(
|
||||||
|
this.getDisplayModule() == null,
|
||||||
|
"Display module exists!"
|
||||||
|
);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the minimum version of eco to use the plugin.
|
||||||
|
*
|
||||||
|
* @return The version.
|
||||||
|
*/
|
||||||
|
protected String getMinimumEcoVersion() {
|
||||||
|
return "5.0.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the plugin's logger.
|
||||||
|
*
|
||||||
|
* @return The logger.
|
||||||
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Logger getLogger() {
|
public Logger getLogger() {
|
||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get unwrapped config.
|
||||||
|
* Does not use eco config system, don't use.
|
||||||
|
*
|
||||||
|
* @return The bukkit config.
|
||||||
|
* @deprecated Use {@link EcoPlugin#getConfigYml()} instead.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public final FileConfiguration getConfig() {
|
||||||
|
this.getLogger().warning("Call to default config method in eco plugin!");
|
||||||
|
|
||||||
|
return this.getConfigYml().getHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does not use eco config system, don't use.
|
||||||
|
*
|
||||||
|
* @deprecated Use eco config system.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public final void saveConfig() {
|
||||||
|
this.getLogger().warning("Call to default config method in eco plugin!");
|
||||||
|
|
||||||
|
super.saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does not use eco config system, don't use.
|
||||||
|
*
|
||||||
|
* @deprecated Use eco config system.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public final void saveDefaultConfig() {
|
||||||
|
this.getLogger().warning("Call to default config method in eco plugin!");
|
||||||
|
|
||||||
|
super.saveDefaultConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does not use eco config system, don't use.
|
||||||
|
*
|
||||||
|
* @deprecated Use eco config system.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public final void reloadConfig() {
|
||||||
|
this.getLogger().warning("Call to default config method in eco plugin!");
|
||||||
|
|
||||||
|
super.reloadConfig();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,19 +4,19 @@ import lombok.AccessLevel;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class PluginDependent {
|
public abstract class PluginDependent<T extends EcoPlugin> {
|
||||||
/**
|
/**
|
||||||
* The {@link EcoPlugin} that is stored.
|
* The {@link EcoPlugin} that is stored.
|
||||||
*/
|
*/
|
||||||
@Getter(AccessLevel.PROTECTED)
|
@Getter(AccessLevel.PROTECTED)
|
||||||
private final EcoPlugin plugin;
|
private final T plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass an {@link EcoPlugin} in order to interface with it.
|
* Pass an {@link EcoPlugin} in order to interface with it.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin to manage.
|
* @param plugin The plugin to manage.
|
||||||
*/
|
*/
|
||||||
protected PluginDependent(@NotNull final EcoPlugin plugin) {
|
protected PluginDependent(@NotNull final T plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class AbstractCommand extends PluginDependent implements CommandExecutor {
|
@Deprecated
|
||||||
|
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||||
|
public abstract class AbstractCommand extends PluginDependent<EcoPlugin> implements CommandExecutor {
|
||||||
/**
|
/**
|
||||||
* The name of the command
|
* The name of the command
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public abstract class AbstractTabCompleter implements TabCompleter {
|
public abstract class AbstractTabCompleter implements TabCompleter {
|
||||||
/**
|
/**
|
||||||
* The {@link AbstractCommand} that is tab-completed.
|
* The {@link AbstractCommand} that is tab-completed.
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.willfp.eco.core.command;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public interface CommandBase {
|
||||||
|
/**
|
||||||
|
* Get command name.
|
||||||
|
*
|
||||||
|
* @return The name.
|
||||||
|
*/
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get command permission.
|
||||||
|
*
|
||||||
|
* @return The permission.
|
||||||
|
*/
|
||||||
|
String getPermission();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If only players can execute the command.
|
||||||
|
*
|
||||||
|
* @return If true.
|
||||||
|
*/
|
||||||
|
boolean isPlayersOnly();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a subcommand to the command.
|
||||||
|
*
|
||||||
|
* @param command The subcommand.
|
||||||
|
* @return The parent command.
|
||||||
|
*/
|
||||||
|
CommandBase addSubcommand(@NotNull CommandBase command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the handler.
|
||||||
|
*
|
||||||
|
* @return The handler.
|
||||||
|
*/
|
||||||
|
CommandHandler getHandler();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the tab completer.
|
||||||
|
*
|
||||||
|
* @return The tab completer.
|
||||||
|
*/
|
||||||
|
TabCompleteHandler getTabCompleter();
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.willfp.eco.core.command;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface CommandHandler {
|
||||||
|
/**
|
||||||
|
* The code to be called on execution.
|
||||||
|
*
|
||||||
|
* @param sender The sender.
|
||||||
|
* @param args The arguments.
|
||||||
|
*/
|
||||||
|
void onExecute(@NotNull CommandSender sender,
|
||||||
|
@NotNull List<String> args);
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.willfp.eco.core.command;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface TabCompleteHandler {
|
||||||
|
/**
|
||||||
|
* Handle Tab Completion.
|
||||||
|
*
|
||||||
|
* @param sender The sender.
|
||||||
|
* @param args The arguments.
|
||||||
|
* @return The tab completion results.
|
||||||
|
*/
|
||||||
|
List<String> tabComplete(@NotNull CommandSender sender,
|
||||||
|
@NotNull List<String> args);
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package com.willfp.eco.core.command.impl;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import com.willfp.eco.internal.commands.HandledCommand;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class PluginCommand extends HandledCommand implements CommandExecutor, TabCompleter {
|
||||||
|
/**
|
||||||
|
* Create a new command.
|
||||||
|
* <p>
|
||||||
|
* The command will not be registered until {@link this#register()} is called.
|
||||||
|
* <p>
|
||||||
|
* The name cannot be the same as an existing command as this will conflict.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin.
|
||||||
|
* @param name The name used in execution.
|
||||||
|
* @param permission The permission required to execute the command.
|
||||||
|
* @param playersOnly If only players should be able to execute this command.
|
||||||
|
*/
|
||||||
|
protected PluginCommand(@NotNull final EcoPlugin plugin,
|
||||||
|
@NotNull final String name,
|
||||||
|
@NotNull final String permission,
|
||||||
|
final boolean playersOnly) {
|
||||||
|
super(plugin, name, permission, playersOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the command with the server,
|
||||||
|
* <p>
|
||||||
|
* Requires the command name to exist, defined in plugin.yml.
|
||||||
|
*/
|
||||||
|
public final void register() {
|
||||||
|
org.bukkit.command.PluginCommand command = Bukkit.getPluginCommand(this.getName());
|
||||||
|
assert command != null;
|
||||||
|
command.setExecutor(this);
|
||||||
|
command.setTabCompleter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal implementation used to clean up boilerplate.
|
||||||
|
* Used for parity with {@link CommandExecutor#onCommand(CommandSender, Command, String, String[])}.
|
||||||
|
*
|
||||||
|
* @param sender The executor of the command.
|
||||||
|
* @param command The bukkit command.
|
||||||
|
* @param label The name of the executed command.
|
||||||
|
* @param args The arguments of the command (anything after the physical command name)
|
||||||
|
* @return If the command was processed by the linked {@link EcoPlugin}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final boolean onCommand(@NotNull final CommandSender sender,
|
||||||
|
@NotNull final Command command,
|
||||||
|
@NotNull final String label,
|
||||||
|
@NotNull final String[] args) {
|
||||||
|
if (!command.getName().equalsIgnoreCase(this.getName())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.handle(sender, args);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal implementation used to clean up boilerplate.
|
||||||
|
* Used for parity with {@link TabCompleter#onTabComplete(CommandSender, Command, String, String[])}.
|
||||||
|
*
|
||||||
|
* @param sender The executor of the command.
|
||||||
|
* @param command The bukkit command.
|
||||||
|
* @param label The name of the executed command.
|
||||||
|
* @param args The arguments of the command (anything after the physical command name).
|
||||||
|
* @return The list of tab-completions.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull final CommandSender sender,
|
||||||
|
@NotNull final Command command,
|
||||||
|
@NotNull final String label,
|
||||||
|
@NotNull final String[] args) {
|
||||||
|
if (!command.getName().equalsIgnoreCase(this.getName())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.handleTabCompletion(sender, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.willfp.eco.core.command.impl;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import com.willfp.eco.core.command.CommandBase;
|
||||||
|
import com.willfp.eco.internal.commands.HandledCommand;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public abstract class Subcommand extends HandledCommand {
|
||||||
|
/**
|
||||||
|
* Create subcommand.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin.
|
||||||
|
* @param name The subcommand name.
|
||||||
|
* @param permission The subcommand permission.
|
||||||
|
* @param playersOnly If the subcommand only works on players.
|
||||||
|
*/
|
||||||
|
protected Subcommand(@NotNull final EcoPlugin plugin,
|
||||||
|
@NotNull final String name,
|
||||||
|
@NotNull final String permission,
|
||||||
|
final boolean playersOnly) {
|
||||||
|
super(plugin, name, permission, playersOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create subcommand.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin.
|
||||||
|
* @param name The name of the subcommand.
|
||||||
|
* @param parent The parent command.
|
||||||
|
*/
|
||||||
|
protected Subcommand(@NotNull final EcoPlugin plugin,
|
||||||
|
@NotNull final String name,
|
||||||
|
@NotNull final CommandBase parent) {
|
||||||
|
super(plugin, name, parent.getPermission(), parent.isPlayersOnly());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.willfp.eco.core.config;
|
||||||
|
|
||||||
|
import com.willfp.eco.internal.config.LoadableConfig;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public interface ConfigHandler {
|
||||||
|
/**
|
||||||
|
* Invoke all update methods.
|
||||||
|
*/
|
||||||
|
void callUpdate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register an updatable class.
|
||||||
|
*
|
||||||
|
* @param updatableClass The class with an update method.
|
||||||
|
*/
|
||||||
|
void registerUpdatableClass(@NotNull Class<?> updatableClass);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save all configs.
|
||||||
|
*/
|
||||||
|
void saveAllConfigs();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update all updatable configs.
|
||||||
|
*/
|
||||||
|
void updateConfigs();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new config to be saved.
|
||||||
|
*
|
||||||
|
* @param config The config.
|
||||||
|
*/
|
||||||
|
void addConfig(@NotNull LoadableConfig config);
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import com.willfp.eco.core.config.Config;
|
|||||||
import com.willfp.eco.core.config.JSONConfig;
|
import com.willfp.eco.core.config.JSONConfig;
|
||||||
import com.willfp.eco.core.config.JsonStaticBaseConfig;
|
import com.willfp.eco.core.config.JsonStaticBaseConfig;
|
||||||
import com.willfp.eco.internal.config.LoadableConfig;
|
import com.willfp.eco.internal.config.LoadableConfig;
|
||||||
import com.willfp.eco.internal.config.json.JSONConfigSection;
|
import com.willfp.eco.internal.config.json.JsonConfigSection;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
@@ -74,7 +74,7 @@ public class Data {
|
|||||||
if (config == null) {
|
if (config == null) {
|
||||||
config = (JSONConfig) datafile.getSubsectionOrNull("player-data." + plugin.getName().toLowerCase() + "." + player.getUniqueId());
|
config = (JSONConfig) datafile.getSubsectionOrNull("player-data." + plugin.getName().toLowerCase() + "." + player.getUniqueId());
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
config = new JSONConfigSection(new HashMap<>());
|
config = new JsonConfigSection(new HashMap<>());
|
||||||
}
|
}
|
||||||
PLAYER_DATA.get(player.getUniqueId()).put(plugin, config);
|
PLAYER_DATA.get(player.getUniqueId()).put(plugin, config);
|
||||||
return getData(player, plugin);
|
return getData(player, plugin);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import lombok.Getter;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class DisplayModule extends PluginDependent {
|
public abstract class DisplayModule extends PluginDependent<EcoPlugin> {
|
||||||
/**
|
/**
|
||||||
* The priority of the module.
|
* The priority of the module.
|
||||||
*/
|
*/
|
||||||
@@ -61,6 +61,6 @@ public abstract class DisplayModule extends PluginDependent {
|
|||||||
* @return The plugin name.
|
* @return The plugin name.
|
||||||
*/
|
*/
|
||||||
final String getPluginName() {
|
final String getPluginName() {
|
||||||
return super.getPlugin().getPluginName();
|
return super.getPlugin().getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.getName();
|
return this.metadata.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,6 +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.getVersion();
|
return this.metadata.version();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public interface Menu {
|
|||||||
/**
|
/**
|
||||||
* Get the amount of rows.
|
* Get the amount of rows.
|
||||||
*
|
*
|
||||||
* @return
|
* @return The amount of rows.
|
||||||
*/
|
*/
|
||||||
int getRows();
|
int getRows();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.willfp.eco.core.recipe.parts;
|
package com.willfp.eco.core.recipe.parts;
|
||||||
|
|
||||||
import com.willfp.eco.core.items.TestableItem;
|
import com.willfp.eco.core.items.TestableItem;
|
||||||
import com.willfp.eco.internal.InternalInterfacing;
|
import com.willfp.eco.internal.Internals;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -58,7 +58,7 @@ public class TestableStack implements TestableItem {
|
|||||||
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
|
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
|
||||||
assert lore != null;
|
assert lore != null;
|
||||||
lore.add("");
|
lore.add("");
|
||||||
String add = InternalInterfacing.getInstance().getLang().getString("multiple-in-craft");
|
String add = Internals.getInstance().getPlugin().getLangYml().getString("multiple-in-craft");
|
||||||
add = add.replace("%amount%", String.valueOf(amount));
|
add = add.replace("%amount%", String.valueOf(amount));
|
||||||
lore.add(add);
|
lore.add(add);
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
public final class ShapedCraftingRecipe extends PluginDependent<EcoPlugin> implements CraftingRecipe {
|
||||||
public final class ShapedCraftingRecipe extends PluginDependent implements CraftingRecipe {
|
|
||||||
/**
|
/**
|
||||||
* Recipe parts.
|
* Recipe parts.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.willfp.eco.core.web;
|
package com.willfp.eco.core.web;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -8,11 +9,15 @@ import java.io.IOException;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
public class Paste {
|
public class Paste {
|
||||||
/**
|
/**
|
||||||
* The contents.
|
* The contents.
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
private final String contents;
|
private final String contents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,8 +36,8 @@ public class Paste {
|
|||||||
*/
|
*/
|
||||||
public String getHastebinToken() {
|
public String getHastebinToken() {
|
||||||
try {
|
try {
|
||||||
String urly = "https://hastebin.com/documents";
|
String url = "https://hastebin.com/documents";
|
||||||
URL obj = new URL(urly);
|
URL obj = new URL(url);
|
||||||
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
|
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
|
||||||
|
|
||||||
con.setRequestMethod("POST");
|
con.setRequestMethod("POST");
|
||||||
@@ -40,7 +45,7 @@ public class Paste {
|
|||||||
|
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
|
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
|
||||||
wr.writeBytes(contents);
|
wr.writeBytes(URLEncoder.encode(contents, StandardCharsets.UTF_8));
|
||||||
wr.flush();
|
wr.flush();
|
||||||
wr.close();
|
wr.close();
|
||||||
|
|
||||||
@@ -66,4 +71,30 @@ public class Paste {
|
|||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get paste from hastebin.
|
||||||
|
*
|
||||||
|
* @param token The token.
|
||||||
|
* @return The paste.
|
||||||
|
*/
|
||||||
|
public static Paste getFromHastebin(@NotNull final String token) {
|
||||||
|
try {
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
URL url = new URL("https://hastebin.com/raw/" + token);
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
try (var reader = new BufferedReader(
|
||||||
|
new InputStreamReader(conn.getInputStream()))) {
|
||||||
|
for (String line; (line = reader.readLine()) != null;) {
|
||||||
|
result.append(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Paste(URLDecoder.decode(result.toString(), StandardCharsets.UTF_8));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.willfp.eco.internal;
|
|
||||||
|
|
||||||
import com.willfp.eco.core.config.base.LangYml;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public abstract class InternalInterfacing {
|
|
||||||
private static InternalInterfacing interfacing;
|
|
||||||
|
|
||||||
public static void setInterfacing(@NotNull final InternalInterfacing interfacing) {
|
|
||||||
InternalInterfacing.interfacing = interfacing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract LangYml getLang();
|
|
||||||
|
|
||||||
public static InternalInterfacing getInstance() {
|
|
||||||
return interfacing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
18
eco-api/src/main/java/com/willfp/eco/internal/Internals.java
Normal file
18
eco-api/src/main/java/com/willfp/eco/internal/Internals.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package com.willfp.eco.internal;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public abstract class Internals {
|
||||||
|
private static Internals internals;
|
||||||
|
|
||||||
|
public static void setInterfacing(@NotNull final Internals internals) {
|
||||||
|
Internals.internals = internals;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract EcoPlugin getPlugin();
|
||||||
|
|
||||||
|
public static Internals getInstance() {
|
||||||
|
return internals;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ import java.io.InputStream;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class UpdateChecker extends PluginDependent {
|
public class UpdateChecker extends PluginDependent<EcoPlugin> {
|
||||||
/**
|
/**
|
||||||
* Create an update checker for the specified spigot resource id.
|
* Create an update checker for the specified spigot resource id.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ 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;
|
||||||
|
|
||||||
public class ArrowDataListener extends PluginDependent implements Listener {
|
public class ArrowDataListener extends PluginDependent<EcoPlugin> 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.
|
||||||
*
|
*
|
||||||
@@ -34,12 +34,11 @@ public class ArrowDataListener extends PluginDependent implements Listener {
|
|||||||
if (!(event.getEntity() instanceof Arrow arrow)) {
|
if (!(event.getEntity() instanceof Arrow arrow)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(event.getEntity().getShooter() instanceof LivingEntity)) {
|
|
||||||
|
if (!(arrow.getShooter() instanceof LivingEntity entity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LivingEntity entity = (LivingEntity) arrow.getShooter();
|
|
||||||
|
|
||||||
if (entity.getEquipment() == null) {
|
if (entity.getEquipment() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,166 @@
|
|||||||
|
package com.willfp.eco.internal.commands;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import com.willfp.eco.core.PluginDependent;
|
||||||
|
import com.willfp.eco.core.command.CommandBase;
|
||||||
|
import com.willfp.eco.core.command.CommandHandler;
|
||||||
|
import com.willfp.eco.core.command.TabCompleteHandler;
|
||||||
|
import com.willfp.eco.internal.commands.util.CommandUtils;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public abstract class HandledCommand extends PluginDependent<EcoPlugin> implements CommandBase {
|
||||||
|
/**
|
||||||
|
* The name of the command.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The permission required to execute the command.
|
||||||
|
* <p>
|
||||||
|
* Written out as a string for flexibility with subclasses.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final String permission;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should the command only be allowed to be executed by players?
|
||||||
|
* <p>
|
||||||
|
* In other worlds, only allowed to be executed by console.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final boolean playersOnly;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All subcommands for the command.
|
||||||
|
*/
|
||||||
|
@Getter(AccessLevel.PROTECTED)
|
||||||
|
private final List<CommandBase> subcommands;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command.
|
||||||
|
* <p>
|
||||||
|
* The name cannot be the same as an existing command as this will conflict.
|
||||||
|
*
|
||||||
|
* @param plugin Instance of a plugin.
|
||||||
|
* @param name The name used in execution.
|
||||||
|
* @param permission The permission required to execute the command.
|
||||||
|
* @param playersOnly If only players should be able to execute this command.
|
||||||
|
*/
|
||||||
|
protected HandledCommand(@NotNull final EcoPlugin plugin,
|
||||||
|
@NotNull final String name,
|
||||||
|
@NotNull final String permission,
|
||||||
|
final boolean playersOnly) {
|
||||||
|
super(plugin);
|
||||||
|
this.name = name;
|
||||||
|
this.permission = permission;
|
||||||
|
this.playersOnly = playersOnly;
|
||||||
|
this.subcommands = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a subcommand to the command.
|
||||||
|
*
|
||||||
|
* @param subcommand The subcommand.
|
||||||
|
* @return The parent command.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final CommandBase addSubcommand(@NotNull final CommandBase subcommand) {
|
||||||
|
subcommands.add(subcommand);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the command.
|
||||||
|
*
|
||||||
|
* @param sender The sender.
|
||||||
|
* @param args The arguments.
|
||||||
|
*/
|
||||||
|
protected final void handle(@NotNull final CommandSender sender,
|
||||||
|
@NotNull final String[] args) {
|
||||||
|
if (!CommandUtils.canExecute(sender, this, this.getPlugin())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length > 0) {
|
||||||
|
for (CommandBase subcommand : this.getSubcommands()) {
|
||||||
|
if (subcommand.getName().equalsIgnoreCase(args[0])) {
|
||||||
|
if (!CommandUtils.canExecute(sender, subcommand, this.getPlugin())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
((HandledCommand) subcommand).handle(sender, Arrays.copyOfRange(args, 1, args.length));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getHandler().onExecute(sender, Arrays.asList(args));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the tab completion.
|
||||||
|
*
|
||||||
|
* @param sender The sender.
|
||||||
|
* @param args The arguments.
|
||||||
|
*/
|
||||||
|
protected final List<String> handleTabCompletion(@NotNull final CommandSender sender,
|
||||||
|
@NotNull final String[] args) {
|
||||||
|
|
||||||
|
if (!sender.hasPermission(this.getPermission())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
List<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
|
StringUtil.copyPartialMatches(
|
||||||
|
args[0],
|
||||||
|
this.getSubcommands().stream().map(CommandBase::getName).collect(Collectors.toList()),
|
||||||
|
completions
|
||||||
|
);
|
||||||
|
|
||||||
|
Collections.sort(completions);
|
||||||
|
|
||||||
|
if (!completions.isEmpty()) {
|
||||||
|
return completions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length >= 2) {
|
||||||
|
HandledCommand command = null;
|
||||||
|
|
||||||
|
for (CommandBase subcommand : this.getSubcommands()) {
|
||||||
|
if (args[0].equalsIgnoreCase(subcommand.getName())) {
|
||||||
|
command = (HandledCommand) subcommand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command != null) {
|
||||||
|
return command.handleTabCompletion(sender, Arrays.copyOfRange(args, 1, args.length));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getTabCompleter().tabComplete(sender, Arrays.asList(args));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract CommandHandler getHandler();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TabCompleteHandler getTabCompleter() {
|
||||||
|
return (sender, args) -> new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.willfp.eco.internal.commands.util;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import com.willfp.eco.core.command.CommandBase;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public class CommandUtils {
|
||||||
|
public boolean canExecute(@NotNull final CommandSender sender,
|
||||||
|
@NotNull final CommandBase command,
|
||||||
|
@NotNull final EcoPlugin plugin) {
|
||||||
|
if (command.isPlayersOnly() && !(sender instanceof Player)) {
|
||||||
|
sender.sendMessage(plugin.getLangYml().getMessage("not-player"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sender.hasPermission(command.getPermission()) && sender instanceof Player) {
|
||||||
|
sender.sendMessage(plugin.getLangYml().getNoPermission());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,13 +4,13 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class JSONConfigSection extends JSONConfigWrapper {
|
public class JsonConfigSection extends JsonConfigWrapper {
|
||||||
/**
|
/**
|
||||||
* Config section.
|
* Config section.
|
||||||
*
|
*
|
||||||
* @param values The values.
|
* @param values The values.
|
||||||
*/
|
*/
|
||||||
public JSONConfigSection(@NotNull final Map<String, Object> values) {
|
public JsonConfigSection(@NotNull final Map<String, Object> values) {
|
||||||
this.init(values);
|
this.init(values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ import java.util.Objects;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "unused"})
|
@SuppressWarnings({"unchecked", "unused"})
|
||||||
public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
|
public abstract class JsonConfigWrapper implements JSONConfig, Cloneable {
|
||||||
/**
|
/**
|
||||||
* The linked {@link ConfigurationSection} where values are physically stored.
|
* The linked {@link ConfigurationSection} where values are physically stored.
|
||||||
*/
|
*/
|
||||||
@@ -42,7 +42,7 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
|
|||||||
/**
|
/**
|
||||||
* Abstract config.
|
* Abstract config.
|
||||||
*/
|
*/
|
||||||
protected JSONConfigWrapper() {
|
protected JsonConfigWrapper() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (values.get(closestPath) instanceof Map && !path.equals(closestPath)) {
|
if (values.get(closestPath) instanceof Map && !path.equals(closestPath)) {
|
||||||
JSONConfigSection section = new JSONConfigSection((Map<String, Object>) values.get(closestPath));
|
JsonConfigSection section = new JsonConfigSection((Map<String, Object>) values.get(closestPath));
|
||||||
return section.getOfKnownType(path.substring(closestPath.length() + 1), clazz, false);
|
return section.getOfKnownType(path.substring(closestPath.length() + 1), clazz, false);
|
||||||
} else {
|
} else {
|
||||||
if (values.containsKey(closestPath)) {
|
if (values.containsKey(closestPath)) {
|
||||||
@@ -115,7 +115,7 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
|
|||||||
list.add(root + key);
|
list.add(root + key);
|
||||||
|
|
||||||
if (values.get(key) instanceof Map) {
|
if (values.get(key) instanceof Map) {
|
||||||
JSONConfigSection section = new JSONConfigSection((Map<String, Object>) values.get(key));
|
JsonConfigSection section = new JsonConfigSection((Map<String, Object>) values.get(key));
|
||||||
list.addAll(section.getDeepKeys(list, root + key + "."));
|
list.addAll(section.getDeepKeys(list, root + key + "."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,14 +147,14 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (values.get(closestPath) instanceof Map && !path.equals(closestPath)) {
|
if (values.get(closestPath) instanceof Map && !path.equals(closestPath)) {
|
||||||
JSONConfigSection section = new JSONConfigSection((Map<String, Object>) values.get(closestPath));
|
JsonConfigSection section = new JsonConfigSection((Map<String, Object>) values.get(closestPath));
|
||||||
section.setRecursively(path.substring(closestPath.length() + 1), object, false);
|
section.setRecursively(path.substring(closestPath.length() + 1), object, false);
|
||||||
values.put(closestPath, section.getValues());
|
values.put(closestPath, section.getValues());
|
||||||
} else {
|
} else {
|
||||||
Object obj = object;
|
Object obj = object;
|
||||||
|
|
||||||
if (object instanceof JSONConfig) {
|
if (object instanceof JSONConfig) {
|
||||||
obj = ((JSONConfigWrapper) object).getValues();
|
obj = ((JsonConfigWrapper) object).getValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
values.put(path, obj);
|
values.put(path, obj);
|
||||||
@@ -174,7 +174,7 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
|
|||||||
public Config getSubsectionOrNull(@NotNull final String path) {
|
public Config getSubsectionOrNull(@NotNull final String path) {
|
||||||
if (values.containsKey(path)) {
|
if (values.containsKey(path)) {
|
||||||
Map<String, Object> subsection = (Map<String, Object>) values.get(path);
|
Map<String, Object> subsection = (Map<String, Object>) values.get(path);
|
||||||
return new JSONConfigSection(subsection);
|
return new JsonConfigSection(subsection);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
|
|||||||
List<JSONConfig> configs = new ArrayList<>();
|
List<JSONConfig> configs = new ArrayList<>();
|
||||||
|
|
||||||
for (Map<String, Object> map : maps) {
|
for (Map<String, Object> map : maps) {
|
||||||
configs.add(new JSONConfigSection(map));
|
configs.add(new JsonConfigSection(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
return configs;
|
return configs;
|
||||||
@@ -339,7 +339,7 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONConfigWrapper clone() {
|
public JSONConfig clone() {
|
||||||
return new JSONConfigSection(new HashMap<>(this.getValues()));
|
return new JsonConfigSection(new HashMap<>(this.getValues()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ import java.nio.file.StandardOpenOption;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "unused"})
|
@SuppressWarnings({"unchecked", "unused"})
|
||||||
public abstract class LoadableJsonConfig extends JSONConfigWrapper implements LoadableConfig {
|
public abstract class LoadableJsonConfig extends JsonConfigWrapper implements LoadableConfig {
|
||||||
/**
|
/**
|
||||||
* The physical config file, as stored on disk.
|
* The physical config file, as stored on disk.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package com.willfp.eco.internal.config.updating;
|
|||||||
|
|
||||||
import com.willfp.eco.core.EcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.core.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
|
import com.willfp.eco.core.config.ConfigHandler;
|
||||||
import com.willfp.eco.core.config.ConfigUpdater;
|
import com.willfp.eco.core.config.ConfigUpdater;
|
||||||
import com.willfp.eco.internal.config.LoadableConfig;
|
import com.willfp.eco.internal.config.LoadableConfig;
|
||||||
import com.willfp.eco.internal.config.updating.exceptions.InvalidUpdatableClassException;
|
import com.willfp.eco.internal.config.updating.exceptions.InvalidUpdatableClassException;
|
||||||
import com.willfp.eco.internal.config.updating.exceptions.InvalidUpdateMethodException;
|
import com.willfp.eco.internal.config.updating.exceptions.InvalidUpdateMethodException;
|
||||||
|
import com.willfp.eco.internal.config.yaml.UpdatableYamlConfig;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -18,7 +20,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ConfigHandler extends PluginDependent {
|
public class EcoConfigHandler extends PluginDependent<EcoPlugin> implements ConfigHandler {
|
||||||
/**
|
/**
|
||||||
* A set of all configs that can be saved.
|
* A set of all configs that can be saved.
|
||||||
*/
|
*/
|
||||||
@@ -34,13 +36,11 @@ public class ConfigHandler extends PluginDependent {
|
|||||||
*
|
*
|
||||||
* @param plugin The plugin to manage.
|
* @param plugin The plugin to manage.
|
||||||
*/
|
*/
|
||||||
public ConfigHandler(@NotNull final EcoPlugin plugin) {
|
public EcoConfigHandler(@NotNull final EcoPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Invoke all update methods.
|
|
||||||
*/
|
|
||||||
public void callUpdate() {
|
public void callUpdate() {
|
||||||
updatableClasses.forEach(clazz -> Arrays.stream(clazz.getDeclaredMethods()).forEach(method -> {
|
updatableClasses.forEach(clazz -> Arrays.stream(clazz.getDeclaredMethods()).forEach(method -> {
|
||||||
if (method.isAnnotationPresent(ConfigUpdater.class)) {
|
if (method.isAnnotationPresent(ConfigUpdater.class)) {
|
||||||
@@ -64,11 +64,7 @@ public class ConfigHandler extends PluginDependent {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Register an updatable class.
|
|
||||||
*
|
|
||||||
* @param updatableClass The class with an update method.
|
|
||||||
*/
|
|
||||||
public void registerUpdatableClass(@NotNull final Class<?> updatableClass) {
|
public void registerUpdatableClass(@NotNull final Class<?> updatableClass) {
|
||||||
boolean isValid = false;
|
boolean isValid = false;
|
||||||
for (Method method : updatableClass.getDeclaredMethods()) {
|
for (Method method : updatableClass.getDeclaredMethods()) {
|
||||||
@@ -85,9 +81,7 @@ public class ConfigHandler extends PluginDependent {
|
|||||||
updatableClasses.add(updatableClass);
|
updatableClasses.add(updatableClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Save all configs.
|
|
||||||
*/
|
|
||||||
public void saveAllConfigs() {
|
public void saveAllConfigs() {
|
||||||
try {
|
try {
|
||||||
for (LoadableConfig config : configs) {
|
for (LoadableConfig config : configs) {
|
||||||
@@ -98,11 +92,17 @@ public class ConfigHandler extends PluginDependent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Add new config to be saved.
|
|
||||||
* @param config The config.
|
|
||||||
*/
|
|
||||||
public void addConfig(@NotNull final LoadableConfig config) {
|
public void addConfig(@NotNull final LoadableConfig config) {
|
||||||
configs.add(config);
|
configs.add(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateConfigs() {
|
||||||
|
for (LoadableConfig config : configs) {
|
||||||
|
if (config instanceof UpdatableYamlConfig updatableYamlConfig) {
|
||||||
|
updatableYamlConfig.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.willfp.eco.internal.config.updating.exceptions;
|
package com.willfp.eco.internal.config.updating.exceptions;
|
||||||
|
|
||||||
import com.willfp.eco.internal.config.updating.ConfigHandler;
|
import com.willfp.eco.internal.config.updating.EcoConfigHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class InvalidUpdatableClassException extends RuntimeException {
|
public class InvalidUpdatableClassException extends RuntimeException {
|
||||||
/**
|
/**
|
||||||
* Called when an updatable class is registered into an {@link ConfigHandler}.
|
* Called when an updatable class is registered into an {@link EcoConfigHandler}.
|
||||||
*
|
*
|
||||||
* @param message The error message.
|
* @param message The error message.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ package com.willfp.eco.internal.config.yaml;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ConfigSection extends YamlConfigWrapper<ConfigurationSection> {
|
public class YamlConfigSection extends YamlConfigWrapper<ConfigurationSection> {
|
||||||
/**
|
/**
|
||||||
* Config section.
|
* Config section.
|
||||||
*
|
*
|
||||||
* @param section The section.
|
* @param section The section.
|
||||||
*/
|
*/
|
||||||
public ConfigSection(@NotNull final ConfigurationSection section) {
|
public YamlConfigSection(@NotNull final ConfigurationSection section) {
|
||||||
this.init(section);
|
this.init(section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ public abstract class YamlConfigWrapper<T extends ConfigurationSection> implemen
|
|||||||
if (raw == null) {
|
if (raw == null) {
|
||||||
cache.put(path, null);
|
cache.put(path, null);
|
||||||
} else {
|
} else {
|
||||||
cache.put(path, new ConfigSection(raw));
|
cache.put(path, new YamlConfigSection(raw));
|
||||||
}
|
}
|
||||||
return getSubsectionOrNull(path);
|
return getSubsectionOrNull(path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class EcoEventManager extends PluginDependent implements EventManager {
|
public class EcoEventManager extends PluginDependent<EcoPlugin> implements EventManager {
|
||||||
/**
|
/**
|
||||||
* Manager class for event management.
|
* Manager class for event management.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* Concrete implementation of {@link ExtensionLoader}.
|
* Concrete implementation of {@link ExtensionLoader}.
|
||||||
*/
|
*/
|
||||||
public class EcoExtensionLoader extends PluginDependent implements ExtensionLoader {
|
public class EcoExtensionLoader extends PluginDependent<EcoPlugin> implements ExtensionLoader {
|
||||||
/**
|
/**
|
||||||
* All currently loaded extensions.
|
* All currently loaded extensions.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,32 +1,8 @@
|
|||||||
package com.willfp.eco.internal.extensions;
|
package com.willfp.eco.internal.extensions;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ExtensionMetadata {
|
public record ExtensionMetadata(@NotNull String version,
|
||||||
/**
|
@NotNull String name) {
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ 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 EcoMetadataValueFactory extends PluginDependent implements MetadataValueFactory {
|
public class EcoMetadataValueFactory extends PluginDependent<EcoPlugin> implements MetadataValueFactory {
|
||||||
/**
|
/**
|
||||||
* Factory class to produce {@link FixedMetadataValue}s associated with an {@link EcoPlugin}.
|
* Factory class to produce {@link FixedMetadataValue}s associated with an {@link EcoPlugin}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import com.willfp.eco.core.factory.NamespacedKeyFactory;
|
|||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class EcoNamespacedKeyFactory extends PluginDependent implements NamespacedKeyFactory {
|
public class EcoNamespacedKeyFactory extends PluginDependent<EcoPlugin> implements NamespacedKeyFactory {
|
||||||
/**
|
/**
|
||||||
* Factory class to produce {@link NamespacedKey}s associated with an {@link EcoPlugin}.
|
* Factory class to produce {@link NamespacedKey}s associated with an {@link EcoPlugin}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class EcoRunnableFactory extends PluginDependent implements RunnableFactory {
|
public class EcoRunnableFactory extends PluginDependent<EcoPlugin> implements RunnableFactory {
|
||||||
/**
|
/**
|
||||||
* Factory class to produce {@link RunnableTask}s associated with an {@link EcoPlugin}.
|
* Factory class to produce {@link RunnableTask}s associated with an {@link EcoPlugin}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class EcoScheduler extends PluginDependent implements Scheduler {
|
public class EcoScheduler extends PluginDependent<EcoPlugin> implements Scheduler {
|
||||||
/**
|
/**
|
||||||
* Create a scheduler to manage the tasks of an {@link EcoPlugin}.
|
* Create a scheduler to manage the tasks of an {@link EcoPlugin}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ public final class BlockBreak implements BlockBreakProxy {
|
|||||||
@Override
|
@Override
|
||||||
public void breakBlock(@NotNull final Player player,
|
public void breakBlock(@NotNull final Player player,
|
||||||
@NotNull final Block block) {
|
@NotNull final Block block) {
|
||||||
|
if (!(player instanceof CraftPlayer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
((CraftPlayer) player).getHandle().playerInteractManager.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
((CraftPlayer) player).getHandle().playerInteractManager.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ public final class BlockBreak implements BlockBreakProxy {
|
|||||||
@Override
|
@Override
|
||||||
public void breakBlock(@NotNull final Player player,
|
public void breakBlock(@NotNull final Player player,
|
||||||
@NotNull final Block block) {
|
@NotNull final Block block) {
|
||||||
|
if (!(player instanceof CraftPlayer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
((CraftPlayer) player).getHandle().playerInteractManager.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
((CraftPlayer) player).getHandle().playerInteractManager.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ public final class BlockBreak implements BlockBreakProxy {
|
|||||||
@Override
|
@Override
|
||||||
public void breakBlock(@NotNull final Player player,
|
public void breakBlock(@NotNull final Player player,
|
||||||
@NotNull final Block block) {
|
@NotNull final Block block) {
|
||||||
|
if (!(player instanceof CraftPlayer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
((CraftPlayer) player).getHandle().playerInteractManager.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
((CraftPlayer) player).getHandle().playerInteractManager.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ public final class BlockBreak implements BlockBreakProxy {
|
|||||||
@Override
|
@Override
|
||||||
public void breakBlock(@NotNull final Player player,
|
public void breakBlock(@NotNull final Player player,
|
||||||
@NotNull final Block block) {
|
@NotNull final Block block) {
|
||||||
|
if (!(player instanceof CraftPlayer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
((CraftPlayer) player).getHandle().d.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
((CraftPlayer) player).getHandle().d.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,15 @@ dependencies {
|
|||||||
compileOnly 'fr.neatmonster:nocheatplus:3.16.1-SNAPSHOT'
|
compileOnly 'fr.neatmonster:nocheatplus:3.16.1-SNAPSHOT'
|
||||||
compileOnly 'com.github.jiangdashao:matrix-api-repo:317d4635fd'
|
compileOnly 'com.github.jiangdashao:matrix-api-repo:317d4635fd'
|
||||||
compileOnly 'com.gmail.nossr50.mcMMO:mcMMO:2.1.157'
|
compileOnly 'com.gmail.nossr50.mcMMO:mcMMO:2.1.157'
|
||||||
|
|
||||||
|
// CombatLogX V10 + NewbieHelper Expansion
|
||||||
|
compileOnly 'com.SirBlobman.combatlogx:CombatLogX-API:10.0.0.0-SNAPSHOT'
|
||||||
|
compileOnly 'com.SirBlobman.combatlogx.expansions:NewbieHelper:10.0.0.0-SNAPSHOT'
|
||||||
|
|
||||||
|
// CombatLogX V11 + NewbieHelper Expansion
|
||||||
|
compileOnly 'com.github.sirblobman.combatlogx:api:11.0.0.0-SNAPSHOT'
|
||||||
|
compileOnly 'com.github.sirblobman.combatlogx.expansion:newbie-helper:11.0.0.0-SNAPSHOT'
|
||||||
|
|
||||||
compileOnly fileTree(dir: '../../lib', include: ['*.jar'])
|
compileOnly fileTree(dir: '../../lib', include: ['*.jar'])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.willfp.eco.spigot;
|
||||||
|
|
||||||
|
import com.willfp.eco.internal.Internals;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class EcoInternals extends Internals {
|
||||||
|
private final EcoSpigotPlugin plugin;
|
||||||
|
|
||||||
|
EcoInternals(@NotNull final EcoSpigotPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EcoSpigotPlugin getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,16 +2,13 @@ package com.willfp.eco.spigot;
|
|||||||
|
|
||||||
import com.willfp.eco.core.AbstractPacketAdapter;
|
import com.willfp.eco.core.AbstractPacketAdapter;
|
||||||
import com.willfp.eco.core.EcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.core.command.AbstractCommand;
|
|
||||||
import com.willfp.eco.core.config.base.LangYml;
|
|
||||||
import com.willfp.eco.core.data.Data;
|
import com.willfp.eco.core.data.Data;
|
||||||
import com.willfp.eco.core.display.Display;
|
import com.willfp.eco.core.display.Display;
|
||||||
import com.willfp.eco.core.display.DisplayModule;
|
|
||||||
import com.willfp.eco.core.integrations.IntegrationLoader;
|
import com.willfp.eco.core.integrations.IntegrationLoader;
|
||||||
import com.willfp.eco.core.integrations.anticheat.AnticheatManager;
|
import com.willfp.eco.core.integrations.anticheat.AnticheatManager;
|
||||||
import com.willfp.eco.core.integrations.antigrief.AntigriefManager;
|
import com.willfp.eco.core.integrations.antigrief.AntigriefManager;
|
||||||
import com.willfp.eco.core.integrations.mcmmo.McmmoManager;
|
import com.willfp.eco.core.integrations.mcmmo.McmmoManager;
|
||||||
import com.willfp.eco.internal.InternalInterfacing;
|
import com.willfp.eco.internal.Internals;
|
||||||
import com.willfp.eco.proxy.proxies.BlockBreakProxy;
|
import com.willfp.eco.proxy.proxies.BlockBreakProxy;
|
||||||
import com.willfp.eco.proxy.proxies.SkullProxy;
|
import com.willfp.eco.proxy.proxies.SkullProxy;
|
||||||
import com.willfp.eco.proxy.proxies.TridentStackProxy;
|
import com.willfp.eco.proxy.proxies.TridentStackProxy;
|
||||||
@@ -34,7 +31,8 @@ import com.willfp.eco.spigot.integrations.anticheat.AnticheatMatrix;
|
|||||||
import com.willfp.eco.spigot.integrations.anticheat.AnticheatNCP;
|
import com.willfp.eco.spigot.integrations.anticheat.AnticheatNCP;
|
||||||
import com.willfp.eco.spigot.integrations.anticheat.AnticheatSpartan;
|
import com.willfp.eco.spigot.integrations.anticheat.AnticheatSpartan;
|
||||||
import com.willfp.eco.spigot.integrations.anticheat.AnticheatVulcan;
|
import com.willfp.eco.spigot.integrations.anticheat.AnticheatVulcan;
|
||||||
import com.willfp.eco.spigot.integrations.antigrief.AntigriefCombatLogX;
|
import com.willfp.eco.spigot.integrations.antigrief.AntigriefCombatLogXV10;
|
||||||
|
import com.willfp.eco.spigot.integrations.antigrief.AntigriefCombatLogXV11;
|
||||||
import com.willfp.eco.spigot.integrations.antigrief.AntigriefFactionsUUID;
|
import com.willfp.eco.spigot.integrations.antigrief.AntigriefFactionsUUID;
|
||||||
import com.willfp.eco.spigot.integrations.antigrief.AntigriefGriefPrevention;
|
import com.willfp.eco.spigot.integrations.antigrief.AntigriefGriefPrevention;
|
||||||
import com.willfp.eco.spigot.integrations.antigrief.AntigriefKingdoms;
|
import com.willfp.eco.spigot.integrations.antigrief.AntigriefKingdoms;
|
||||||
@@ -47,8 +45,11 @@ import com.willfp.eco.util.BlockUtils;
|
|||||||
import com.willfp.eco.util.SkullUtils;
|
import com.willfp.eco.util.SkullUtils;
|
||||||
import com.willfp.eco.util.TridentUtils;
|
import com.willfp.eco.util.TridentUtils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -71,28 +72,22 @@ public class EcoSpigotPlugin extends EcoPlugin {
|
|||||||
* Create a new instance of eco.
|
* Create a new instance of eco.
|
||||||
*/
|
*/
|
||||||
public EcoSpigotPlugin() {
|
public EcoSpigotPlugin() {
|
||||||
super("eco", 87955, 10043, "com.willfp.eco.proxy", "&a");
|
super(87955, 10043, "com.willfp.eco.proxy", "&a");
|
||||||
instance = this;
|
instance = this;
|
||||||
|
Internals.setInterfacing(new EcoInternals(this));
|
||||||
Display.setFinalizeKey(this.getNamespacedKeyFactory().create("finalized"));
|
Display.setFinalizeKey(this.getNamespacedKeyFactory().create("finalized"));
|
||||||
|
|
||||||
SkullProxy skullProxy = InternalProxyUtils.getProxy(SkullProxy.class);
|
SkullProxy skullProxy = ProxyUtils.getProxy(SkullProxy.class);
|
||||||
SkullUtils.initialize(skullProxy::setSkullTexture);
|
SkullUtils.initialize(skullProxy::setSkullTexture);
|
||||||
|
|
||||||
BlockBreakProxy blockBreakProxy = InternalProxyUtils.getProxy(BlockBreakProxy.class);
|
BlockBreakProxy blockBreakProxy = ProxyUtils.getProxy(BlockBreakProxy.class);
|
||||||
BlockUtils.initialize(blockBreakProxy::breakBlock);
|
BlockUtils.initialize(blockBreakProxy::breakBlock);
|
||||||
|
|
||||||
TridentStackProxy tridentStackProxy = InternalProxyUtils.getProxy(TridentStackProxy.class);
|
TridentStackProxy tridentStackProxy = ProxyUtils.getProxy(TridentStackProxy.class);
|
||||||
TridentUtils.initialize(tridentStackProxy::getTridentStack);
|
TridentUtils.initialize(tridentStackProxy::getTridentStack);
|
||||||
|
|
||||||
this.dataJson = new DataJson(this);
|
this.dataJson = new DataJson(this);
|
||||||
Data.init(this.dataJson);
|
Data.init(this.dataJson);
|
||||||
|
|
||||||
InternalInterfacing.setInterfacing(new InternalInterfacing() {
|
|
||||||
@Override
|
|
||||||
public LangYml getLang() {
|
|
||||||
return EcoSpigotPlugin.getInstance().getLangYml();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -109,21 +104,11 @@ public class EcoSpigotPlugin extends EcoPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReload() {
|
public void onReload() {
|
||||||
new CollatedRunnable(this);
|
new CollatedRunnable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postLoad() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IntegrationLoader> getIntegrationLoaders() {
|
public List<IntegrationLoader> getIntegrationLoaders() {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
@@ -134,7 +119,20 @@ public class EcoSpigotPlugin extends EcoPlugin {
|
|||||||
new IntegrationLoader("Towny", () -> AntigriefManager.register(new AntigriefTowny())),
|
new IntegrationLoader("Towny", () -> AntigriefManager.register(new AntigriefTowny())),
|
||||||
new IntegrationLoader("Lands", () -> AntigriefManager.register(new AntigriefLands(this))),
|
new IntegrationLoader("Lands", () -> AntigriefManager.register(new AntigriefLands(this))),
|
||||||
new IntegrationLoader("Kingdoms", () -> AntigriefManager.register(new AntigriefKingdoms())),
|
new IntegrationLoader("Kingdoms", () -> AntigriefManager.register(new AntigriefKingdoms())),
|
||||||
new IntegrationLoader("CombatLogX", () -> AntigriefManager.register(new AntigriefCombatLogX())),
|
new IntegrationLoader("CombatLogX", () -> {
|
||||||
|
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||||
|
Plugin plugin_CombatLogX = pluginManager.getPlugin("CombatLogX");
|
||||||
|
if (plugin_CombatLogX == null) return;
|
||||||
|
|
||||||
|
String pluginVersion = plugin_CombatLogX.getDescription().getVersion();
|
||||||
|
if (pluginVersion.startsWith("10")) {
|
||||||
|
AntigriefManager.register(new AntigriefCombatLogXV10());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pluginVersion.startsWith("11")) {
|
||||||
|
AntigriefManager.register(new AntigriefCombatLogXV11());
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
// Anticheat
|
// Anticheat
|
||||||
new IntegrationLoader("AAC5", () -> AnticheatManager.register(this, new AnticheatAAC())),
|
new IntegrationLoader("AAC5", () -> AnticheatManager.register(this, new AnticheatAAC())),
|
||||||
@@ -148,11 +146,6 @@ public class EcoSpigotPlugin extends EcoPlugin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AbstractCommand> getCommands() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AbstractPacketAdapter> getPacketAdapters() {
|
public List<AbstractPacketAdapter> getPacketAdapters() {
|
||||||
List<AbstractPacketAdapter> adapters = new ArrayList<>(Arrays.asList(
|
List<AbstractPacketAdapter> adapters = new ArrayList<>(Arrays.asList(
|
||||||
@@ -182,15 +175,4 @@ public class EcoSpigotPlugin extends EcoPlugin {
|
|||||||
new GUIListener(this)
|
new GUIListener(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<?>> getUpdatableClasses() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
protected DisplayModule createDisplayModule() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.willfp.eco.spigot;
|
|
||||||
|
|
||||||
import com.willfp.eco.core.proxy.AbstractProxy;
|
|
||||||
import com.willfp.eco.proxy.util.ProxyFactory;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
public class InternalProxyUtils {
|
|
||||||
/**
|
|
||||||
* Get the implementation of a specified proxy.
|
|
||||||
*
|
|
||||||
* @param proxyClass The proxy interface.
|
|
||||||
* @param <T> The type of the proxy.
|
|
||||||
* @return The proxy implementation.
|
|
||||||
*/
|
|
||||||
public @NotNull <T extends AbstractProxy> T getProxy(@NotNull final Class<T> proxyClass) {
|
|
||||||
return new ProxyFactory<>(EcoSpigotPlugin.getInstance(), proxyClass).getProxy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.willfp.eco.spigot;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.proxy.AbstractProxy;
|
||||||
|
import com.willfp.eco.proxy.util.ProxyFactory;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public class ProxyUtils {
|
||||||
|
public <T extends AbstractProxy> T getProxy(@NotNull final Class<T> proxy) {
|
||||||
|
return new ProxyFactory<>(EcoSpigotPlugin.getInstance(), proxy).getProxy();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,10 +3,10 @@ package com.willfp.eco.spigot.display;
|
|||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.willfp.eco.proxy.proxies.AutoCraftProxy;
|
|
||||||
import com.willfp.eco.spigot.InternalProxyUtils;
|
|
||||||
import com.willfp.eco.core.EcoPlugin;
|
|
||||||
import com.willfp.eco.core.AbstractPacketAdapter;
|
import com.willfp.eco.core.AbstractPacketAdapter;
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import com.willfp.eco.proxy.proxies.AutoCraftProxy;
|
||||||
|
import com.willfp.eco.spigot.ProxyUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ public class PacketAutoRecipe extends AbstractPacketAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InternalProxyUtils.getProxy(AutoCraftProxy.class).modifyPacket(packet.getHandle());
|
ProxyUtils.getProxy(AutoCraftProxy.class).modifyPacket(packet.getHandle());
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import com.comphenix.protocol.PacketType;
|
|||||||
import com.comphenix.protocol.events.ListenerPriority;
|
import com.comphenix.protocol.events.ListenerPriority;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
import com.willfp.eco.proxy.proxies.ChatComponentProxy;
|
|
||||||
import com.willfp.eco.spigot.InternalProxyUtils;
|
|
||||||
import com.willfp.eco.core.EcoPlugin;
|
|
||||||
import com.willfp.eco.core.AbstractPacketAdapter;
|
import com.willfp.eco.core.AbstractPacketAdapter;
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import com.willfp.eco.proxy.proxies.ChatComponentProxy;
|
||||||
|
import com.willfp.eco.spigot.ProxyUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ public class PacketChat extends AbstractPacketAdapter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedChatComponent newComponent = WrappedChatComponent.fromHandle(InternalProxyUtils.getProxy(ChatComponentProxy.class).modifyComponent(component.getHandle()));
|
WrappedChatComponent newComponent = WrappedChatComponent.fromHandle(ProxyUtils.getProxy(ChatComponentProxy.class).modifyComponent(component.getHandle()));
|
||||||
packet.getChatComponents().write(i, newComponent);
|
packet.getChatComponents().write(i, newComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import com.comphenix.protocol.events.PacketEvent;
|
|||||||
import com.willfp.eco.core.AbstractPacketAdapter;
|
import com.willfp.eco.core.AbstractPacketAdapter;
|
||||||
import com.willfp.eco.core.EcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.proxy.proxies.VillagerTradeProxy;
|
import com.willfp.eco.proxy.proxies.VillagerTradeProxy;
|
||||||
import com.willfp.eco.spigot.InternalProxyUtils;
|
import com.willfp.eco.spigot.ProxyUtils;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
@@ -35,7 +35,7 @@ public class PacketOpenWindowMerchant extends AbstractPacketAdapter {
|
|||||||
@NotNull final PacketEvent event) {
|
@NotNull final PacketEvent event) {
|
||||||
List<MerchantRecipe> recipes = new ArrayList<>();
|
List<MerchantRecipe> recipes = new ArrayList<>();
|
||||||
|
|
||||||
if (((EcoPlugin) this.getPlugin()).getConfigYml().getBool("villager-display-fix")) {
|
if (this.getPlugin().getConfigYml().getBool("villager-display-fix")) {
|
||||||
for (MerchantRecipe recipe : packet.getMerchantRecipeLists().read(0)) {
|
for (MerchantRecipe recipe : packet.getMerchantRecipeLists().read(0)) {
|
||||||
ItemStack result = recipe.getResult();
|
ItemStack result = recipe.getResult();
|
||||||
ItemMeta meta = result.getItemMeta();
|
ItemMeta meta = result.getItemMeta();
|
||||||
@@ -48,7 +48,7 @@ public class PacketOpenWindowMerchant extends AbstractPacketAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (MerchantRecipe recipe : packet.getMerchantRecipeLists().read(0)) {
|
for (MerchantRecipe recipe : packet.getMerchantRecipeLists().read(0)) {
|
||||||
MerchantRecipe newRecipe = InternalProxyUtils.getProxy(VillagerTradeProxy.class).displayTrade(recipe);
|
MerchantRecipe newRecipe = ProxyUtils.getProxy(VillagerTradeProxy.class).displayTrade(recipe);
|
||||||
recipes.add(newRecipe);
|
recipes.add(newRecipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class EntityDeathByEntityListeners extends PluginDependent implements Listener {
|
public class EntityDeathByEntityListeners extends PluginDependent<EcoPlugin> implements Listener {
|
||||||
/**
|
/**
|
||||||
* The events currently being built.
|
* The events currently being built.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class GUIListener extends PluginDependent implements Listener {
|
public class GUIListener extends PluginDependent<EcoPlugin> implements Listener {
|
||||||
/**
|
/**
|
||||||
* Pass an {@link EcoPlugin} in order to interface with it.
|
* Pass an {@link EcoPlugin} in order to interface with it.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package com.willfp.eco.spigot.integrations.antigrief;
|
|||||||
|
|
||||||
import com.SirBlobman.combatlogx.api.ICombatLogX;
|
import com.SirBlobman.combatlogx.api.ICombatLogX;
|
||||||
import com.SirBlobman.combatlogx.api.expansion.Expansion;
|
import com.SirBlobman.combatlogx.api.expansion.Expansion;
|
||||||
|
import com.SirBlobman.combatlogx.api.expansion.ExpansionManager;
|
||||||
import com.SirBlobman.combatlogx.expansion.newbie.helper.NewbieHelper;
|
import com.SirBlobman.combatlogx.expansion.newbie.helper.NewbieHelper;
|
||||||
import com.SirBlobman.combatlogx.expansion.newbie.helper.listener.ListenerPVP;
|
import com.SirBlobman.combatlogx.expansion.newbie.helper.listener.ListenerPVP;
|
||||||
import com.willfp.eco.spigot.EcoSpigotPlugin;
|
|
||||||
import com.willfp.eco.core.integrations.antigrief.AntigriefWrapper;
|
import com.willfp.eco.core.integrations.antigrief.AntigriefWrapper;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -13,28 +13,19 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class AntigriefCombatLogX implements AntigriefWrapper {
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class AntigriefCombatLogXV10 implements AntigriefWrapper {
|
||||||
/**
|
/**
|
||||||
* Instance of CombatLogX.
|
* Instance of CombatLogX.
|
||||||
*/
|
*/
|
||||||
private final ICombatLogX instance = (ICombatLogX) Bukkit.getPluginManager().getPlugin("CombatLogX");
|
private final ICombatLogX instance;
|
||||||
|
|
||||||
/**
|
|
||||||
* PVPManager for CombatLogX NewbieHelper.
|
|
||||||
*/
|
|
||||||
private ListenerPVP pvp = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new CombatLogX antigrief.
|
* Create new CombatLogX antigrief.
|
||||||
*/
|
*/
|
||||||
public AntigriefCombatLogX() {
|
public AntigriefCombatLogXV10() {
|
||||||
assert instance != null;
|
this.instance = (ICombatLogX) Bukkit.getPluginManager().getPlugin("CombatLogX");
|
||||||
EcoSpigotPlugin.getInstance().getScheduler().runLater(() -> {
|
|
||||||
Expansion expansionUncast = instance.getExpansionManager().getExpansionByName("NewbieHelper").orElse(null);
|
|
||||||
if (expansionUncast instanceof NewbieHelper) {
|
|
||||||
pvp = ((NewbieHelper) expansionUncast).getPVPListener();
|
|
||||||
}
|
|
||||||
}, 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -62,11 +53,17 @@ public class AntigriefCombatLogX implements AntigriefWrapper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pvp == null) {
|
// Only run checks if the NewbieHelper expansion is installed on the server.
|
||||||
return true;
|
ExpansionManager expansionManager = this.instance.getExpansionManager();
|
||||||
|
Optional<Expansion> optionalExpansion = expansionManager.getExpansionByName("NewbieHelper");
|
||||||
|
if(optionalExpansion.isPresent()) {
|
||||||
|
Expansion expansion = optionalExpansion.get();
|
||||||
|
NewbieHelper newbieHelper = (NewbieHelper) expansion;
|
||||||
|
ListenerPVP pvpListener = newbieHelper.getPVPListener();
|
||||||
|
return (pvpListener.isPVPEnabled(player) && pvpListener.isPVPEnabled((Player) victim));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (pvp.isPVPEnabled(player) && pvp.isPVPEnabled((Player) victim));
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package com.willfp.eco.spigot.integrations.antigrief;
|
||||||
|
|
||||||
|
import com.github.sirblobman.combatlogx.api.ICombatLogX;
|
||||||
|
import com.github.sirblobman.combatlogx.api.expansion.Expansion;
|
||||||
|
import com.github.sirblobman.combatlogx.api.expansion.ExpansionManager;
|
||||||
|
import com.willfp.eco.core.integrations.antigrief.AntigriefWrapper;
|
||||||
|
import combatlogx.expansion.newbie.helper.NewbieHelperExpansion;
|
||||||
|
import combatlogx.expansion.newbie.helper.manager.PVPManager;
|
||||||
|
import combatlogx.expansion.newbie.helper.manager.ProtectionManager;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class AntigriefCombatLogXV11 implements AntigriefWrapper {
|
||||||
|
/**
|
||||||
|
* Instance of CombatLogX.
|
||||||
|
*/
|
||||||
|
private final ICombatLogX instance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new CombatLogX antigrief.
|
||||||
|
*/
|
||||||
|
public AntigriefCombatLogXV11() {
|
||||||
|
this.instance = (ICombatLogX) Bukkit.getPluginManager().getPlugin("CombatLogX");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBreakBlock(@NotNull final Player player,
|
||||||
|
@NotNull final Block block) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCreateExplosion(@NotNull final Player player,
|
||||||
|
@NotNull final Location location) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlaceBlock(@NotNull final Player player,
|
||||||
|
@NotNull final Block block) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInjure(@NotNull final Player player,
|
||||||
|
@NotNull final LivingEntity victim) {
|
||||||
|
if (!(victim instanceof Player)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only run checks if the NewbieHelper expansion is installed on the server.
|
||||||
|
ExpansionManager expansionManager = this.instance.getExpansionManager();
|
||||||
|
Optional<Expansion> optionalExpansion = expansionManager.getExpansion("NewbieHelper");
|
||||||
|
if(optionalExpansion.isPresent()) {
|
||||||
|
Expansion expansion = optionalExpansion.get();
|
||||||
|
NewbieHelperExpansion newbieHelperExpansion = (NewbieHelperExpansion) expansion;
|
||||||
|
|
||||||
|
ProtectionManager protectionManager = newbieHelperExpansion.getProtectionManager();
|
||||||
|
PVPManager pvpManager = newbieHelperExpansion.getPVPManager();
|
||||||
|
|
||||||
|
Player victimPlayer = (Player) victim;
|
||||||
|
boolean victimProtected = protectionManager.isProtected(victimPlayer);
|
||||||
|
boolean victimDisabledPvP = pvpManager.isDisabled(victimPlayer);
|
||||||
|
boolean playerDisabledPvp = pvpManager.isDisabled(player);
|
||||||
|
return (!victimProtected && !victimDisabledPvP && !playerDisabledPvp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginName() {
|
||||||
|
return "CombatLogX";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class AntigriefLands extends PluginDependent implements AntigriefWrapper {
|
public class AntigriefLands extends PluginDependent<EcoPlugin> implements AntigriefWrapper {
|
||||||
/**
|
/**
|
||||||
* Lands integration.
|
* Lands integration.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class McmmoIntegrationImpl implements McmmoWrapper {
|
|||||||
/**
|
/**
|
||||||
* Disabled if mcmmo is outdated or missing classes.
|
* Disabled if mcmmo is outdated or missing classes.
|
||||||
*/
|
*/
|
||||||
boolean disabled = false;
|
private boolean disabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize mcMMO integration.
|
* Initialize mcMMO integration.
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.ShapedRecipe;
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ShapedRecipeListener extends PluginDependent implements Listener {
|
public class ShapedRecipeListener extends PluginDependent<EcoPlugin> implements Listener {
|
||||||
/**
|
/**
|
||||||
* Pass an {@link EcoPlugin} in order to interface with it.
|
* Pass an {@link EcoPlugin} in order to interface with it.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -5,12 +5,13 @@ import com.willfp.eco.core.EcoPlugin;
|
|||||||
import com.willfp.eco.core.proxy.AbstractProxy;
|
import com.willfp.eco.core.proxy.AbstractProxy;
|
||||||
import com.willfp.eco.core.proxy.ProxyConstants;
|
import com.willfp.eco.core.proxy.ProxyConstants;
|
||||||
import com.willfp.eco.core.proxy.UnsupportedVersionException;
|
import com.willfp.eco.core.proxy.UnsupportedVersionException;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ProxyFactory<T extends AbstractProxy> extends PluginDependent {
|
public class ProxyFactory<T extends AbstractProxy> extends PluginDependent<EcoPlugin> {
|
||||||
/**
|
/**
|
||||||
* Cached proxy implementations in order to not perform expensive reflective class-finding.
|
* Cached proxy implementations in order to not perform expensive reflective class-finding.
|
||||||
*/
|
*/
|
||||||
@@ -30,6 +31,12 @@ public class ProxyFactory<T extends AbstractProxy> extends PluginDependent {
|
|||||||
public ProxyFactory(@NotNull final EcoPlugin plugin,
|
public ProxyFactory(@NotNull final EcoPlugin plugin,
|
||||||
@NotNull final Class<T> proxyClass) {
|
@NotNull final Class<T> proxyClass) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
|
|
||||||
|
Validate.isTrue(
|
||||||
|
!plugin.getProxyPackage().equalsIgnoreCase(""),
|
||||||
|
"Specified plugin has no proxy support!"
|
||||||
|
);
|
||||||
|
|
||||||
this.proxyClass = proxyClass;
|
this.proxyClass = proxyClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
version = 5.5.1
|
version = 5.7.0
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user