Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb28726bc3 | ||
|
|
c0c20d63bb | ||
|
|
3b11610c45 | ||
|
|
232048022e | ||
|
|
9abfe0ab01 | ||
|
|
e7ac05278c | ||
|
|
85ba40c279 | ||
|
|
1acf86492e |
@@ -52,7 +52,7 @@ import java.util.stream.Collectors;
|
||||
* be cancelled.</b>
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class EcoPlugin extends JavaPlugin {
|
||||
public abstract class EcoPlugin extends JavaPlugin implements PluginLike {
|
||||
/**
|
||||
* The polymart resource ID of the plugin.
|
||||
*/
|
||||
|
||||
29
eco-api/src/main/java/com/willfp/eco/core/PluginLike.java
Normal file
29
eco-api/src/main/java/com/willfp/eco/core/PluginLike.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.willfp.eco.core;
|
||||
|
||||
import com.willfp.eco.core.config.updating.ConfigHandler;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Represents any class that acts like a plugin, for example {@link EcoPlugin}
|
||||
* or {@link com.willfp.eco.core.extensions.Extension}. This exists to create
|
||||
* things such as extension base configs rather than needing to pass an instance
|
||||
* of the owning plugin.
|
||||
*/
|
||||
public interface PluginLike {
|
||||
/**
|
||||
* Get the data folder of the object.
|
||||
* <p>
|
||||
* Returns the plugin data folder for a plugin, or the extension's parent plugin's folder
|
||||
*
|
||||
* @return The data folder.
|
||||
*/
|
||||
File getDataFolder();
|
||||
|
||||
/**
|
||||
* Get the handler class for updatable classes.
|
||||
*
|
||||
* @return The config handler.
|
||||
*/
|
||||
ConfigHandler getConfigHandler();
|
||||
}
|
||||
@@ -2,8 +2,8 @@ package com.willfp.eco.core.config.json;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginLike;
|
||||
import com.willfp.eco.core.config.json.wrapper.LoadableJSONConfigWrapper;
|
||||
import com.willfp.eco.core.config.yaml.wrapper.LoadableYamlConfigWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -20,7 +20,7 @@ public abstract class JSONBaseConfig extends LoadableJSONConfigWrapper {
|
||||
*/
|
||||
protected JSONBaseConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final PluginLike plugin,
|
||||
@NotNull final String... updateBlacklist) {
|
||||
super(
|
||||
Eco.getHandler().getConfigFactory().createUpdatableJSONConfig(
|
||||
@@ -40,7 +40,7 @@ public abstract class JSONBaseConfig extends LoadableJSONConfigWrapper {
|
||||
*/
|
||||
protected JSONBaseConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final EcoPlugin plugin) {
|
||||
@NotNull final PluginLike plugin) {
|
||||
super(
|
||||
Eco.getHandler().getConfigFactory().createUpdatableJSONConfig(
|
||||
configName,
|
||||
@@ -51,4 +51,28 @@ public abstract class JSONBaseConfig extends LoadableJSONConfigWrapper {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param configName The name of the config
|
||||
* @param removeUnused Whether keys not present in the default config should be removed on update.
|
||||
* @param plugin The plugin.
|
||||
* @param updateBlacklist Substring of keys to not add/remove keys for.
|
||||
*/
|
||||
protected JSONBaseConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final String... updateBlacklist) {
|
||||
this(configName, removeUnused, (PluginLike) plugin, updateBlacklist);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param configName The name of the config
|
||||
* @param removeUnused Whether keys not present in the default config should be removed on update.
|
||||
* @param plugin The plugin.
|
||||
*/
|
||||
protected JSONBaseConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final EcoPlugin plugin) {
|
||||
this(configName, removeUnused, (PluginLike) plugin);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@ package com.willfp.eco.core.config.json;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginLike;
|
||||
import com.willfp.eco.core.config.json.wrapper.LoadableJSONConfigWrapper;
|
||||
import com.willfp.eco.core.config.yaml.wrapper.LoadableYamlConfigWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -26,7 +26,7 @@ public abstract class JSONExtendableConfig extends LoadableJSONConfigWrapper {
|
||||
*/
|
||||
protected JSONExtendableConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final PluginLike plugin,
|
||||
@NotNull final Class<?> source,
|
||||
@NotNull final String subDirectoryPath,
|
||||
@NotNull final String... updateBlacklist) {
|
||||
@@ -41,4 +41,20 @@ public abstract class JSONExtendableConfig extends LoadableJSONConfigWrapper {
|
||||
)
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @param configName The name of the config
|
||||
* @param removeUnused Whether keys not present in the default config should be removed on update.
|
||||
* @param plugin The plugin.
|
||||
* @param updateBlacklist Substring of keys to not add/remove keys for.
|
||||
* @param subDirectoryPath The subdirectory path.
|
||||
* @param source The class that owns the resource.
|
||||
*/
|
||||
protected JSONExtendableConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final Class<?> source,
|
||||
@NotNull final String subDirectoryPath,
|
||||
@NotNull final String... updateBlacklist) {
|
||||
this(configName, removeUnused, (PluginLike) plugin, source, subDirectoryPath, updateBlacklist);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.core.config.json;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginLike;
|
||||
import com.willfp.eco.core.config.json.wrapper.LoadableJSONConfigWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -18,7 +19,20 @@ public abstract class JSONStaticBaseConfig extends LoadableJSONConfigWrapper {
|
||||
* @param plugin The plugin.
|
||||
*/
|
||||
protected JSONStaticBaseConfig(@NotNull final String configName,
|
||||
@NotNull final EcoPlugin plugin) {
|
||||
@NotNull final PluginLike plugin) {
|
||||
super(Eco.getHandler().getConfigFactory().createLoadableJSONConfig(configName, plugin, "", plugin.getClass()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Config implementation for configs present in the plugin's base directory (eg config.json, lang.json).
|
||||
* <p>
|
||||
* Does not automatically update.
|
||||
*
|
||||
* @param configName The name of the config
|
||||
* @param plugin The plugin.
|
||||
*/
|
||||
protected JSONStaticBaseConfig(@NotNull final String configName,
|
||||
@NotNull final EcoPlugin plugin) {
|
||||
this(configName, (PluginLike) plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.willfp.eco.core.config.interfaces.LoadableConfig;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Every {@link com.willfp.eco.core.EcoPlugin} has a config handler.
|
||||
* Every {@link com.willfp.eco.core.PluginLike} has a config handler.
|
||||
* <p>
|
||||
* Handles updating and saving configs.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.willfp.eco.core.config.wrapper;
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginLike;
|
||||
import com.willfp.eco.core.config.interfaces.Config;
|
||||
import com.willfp.eco.core.config.interfaces.JSONConfig;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -24,7 +24,7 @@ public interface ConfigFactory {
|
||||
* @return The config implementation.
|
||||
*/
|
||||
Config createUpdatableYamlConfig(@NotNull String configName,
|
||||
@NotNull EcoPlugin plugin,
|
||||
@NotNull PluginLike plugin,
|
||||
@NotNull String subDirectoryPath,
|
||||
@NotNull Class<?> source,
|
||||
boolean removeUnused,
|
||||
@@ -42,7 +42,7 @@ public interface ConfigFactory {
|
||||
* @return The config implementation.
|
||||
*/
|
||||
JSONConfig createUpdatableJSONConfig(@NotNull String configName,
|
||||
@NotNull EcoPlugin plugin,
|
||||
@NotNull PluginLike plugin,
|
||||
@NotNull String subDirectoryPath,
|
||||
@NotNull Class<?> source,
|
||||
boolean removeUnused,
|
||||
@@ -58,7 +58,7 @@ public interface ConfigFactory {
|
||||
* @return The config implementation.
|
||||
*/
|
||||
JSONConfig createLoadableJSONConfig(@NotNull String configName,
|
||||
@NotNull EcoPlugin plugin,
|
||||
@NotNull PluginLike plugin,
|
||||
@NotNull String subDirectoryPath,
|
||||
@NotNull Class<?> source);
|
||||
|
||||
@@ -72,7 +72,7 @@ public interface ConfigFactory {
|
||||
* @return The config implementation.
|
||||
*/
|
||||
Config createLoadableYamlConfig(@NotNull String configName,
|
||||
@NotNull EcoPlugin plugin,
|
||||
@NotNull PluginLike plugin,
|
||||
@NotNull String subDirectoryPath,
|
||||
@NotNull Class<?> source);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.core.config.yaml;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginLike;
|
||||
import com.willfp.eco.core.config.yaml.wrapper.LoadableYamlConfigWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -19,7 +20,7 @@ public abstract class YamlBaseConfig extends LoadableYamlConfigWrapper {
|
||||
*/
|
||||
protected YamlBaseConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final PluginLike plugin,
|
||||
@NotNull final String... updateBlacklist) {
|
||||
super(
|
||||
Eco.getHandler().getConfigFactory().createUpdatableYamlConfig(
|
||||
@@ -39,7 +40,7 @@ public abstract class YamlBaseConfig extends LoadableYamlConfigWrapper {
|
||||
*/
|
||||
protected YamlBaseConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final EcoPlugin plugin) {
|
||||
@NotNull final PluginLike plugin) {
|
||||
super(
|
||||
Eco.getHandler().getConfigFactory().createUpdatableYamlConfig(
|
||||
configName,
|
||||
@@ -50,4 +51,28 @@ public abstract class YamlBaseConfig extends LoadableYamlConfigWrapper {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param configName The name of the config
|
||||
* @param removeUnused Whether keys not present in the default config should be removed on update.
|
||||
* @param plugin The plugin.
|
||||
* @param updateBlacklist Substring of keys to not add/remove keys for.
|
||||
*/
|
||||
protected YamlBaseConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final String... updateBlacklist) {
|
||||
this(configName, removeUnused, (PluginLike) plugin, updateBlacklist);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param configName The name of the config
|
||||
* @param removeUnused Whether keys not present in the default config should be removed on update.
|
||||
* @param plugin The plugin.
|
||||
*/
|
||||
protected YamlBaseConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final EcoPlugin plugin) {
|
||||
this(configName, removeUnused, (PluginLike) plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.core.config.yaml;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginLike;
|
||||
import com.willfp.eco.core.config.yaml.wrapper.LoadableYamlConfigWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -25,7 +26,7 @@ public abstract class YamlExtendableConfig extends LoadableYamlConfigWrapper {
|
||||
*/
|
||||
protected YamlExtendableConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final PluginLike plugin,
|
||||
@NotNull final Class<?> source,
|
||||
@NotNull final String subDirectoryPath,
|
||||
@NotNull final String... updateBlacklist) {
|
||||
@@ -40,4 +41,20 @@ public abstract class YamlExtendableConfig extends LoadableYamlConfigWrapper {
|
||||
)
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @param configName The name of the config
|
||||
* @param removeUnused Whether keys not present in the default config should be removed on update.
|
||||
* @param plugin The plugin.
|
||||
* @param updateBlacklist Substring of keys to not add/remove keys for.
|
||||
* @param subDirectoryPath The subdirectory path.
|
||||
* @param source The class that owns the resource.
|
||||
*/
|
||||
protected YamlExtendableConfig(@NotNull final String configName,
|
||||
final boolean removeUnused,
|
||||
@NotNull final EcoPlugin plugin,
|
||||
@NotNull final Class<?> source,
|
||||
@NotNull final String subDirectoryPath,
|
||||
@NotNull final String... updateBlacklist) {
|
||||
this(configName, removeUnused, (PluginLike) plugin, source, subDirectoryPath, updateBlacklist);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.core.config.yaml;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginLike;
|
||||
import com.willfp.eco.core.config.yaml.wrapper.LoadableYamlConfigWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -18,7 +19,20 @@ public abstract class YamlStaticBaseConfig extends LoadableYamlConfigWrapper {
|
||||
* @param plugin The plugin.
|
||||
*/
|
||||
protected YamlStaticBaseConfig(@NotNull final String configName,
|
||||
@NotNull final EcoPlugin plugin) {
|
||||
@NotNull final PluginLike plugin) {
|
||||
super(Eco.getHandler().getConfigFactory().createLoadableYamlConfig(configName, plugin, "", plugin.getClass()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Config implementation for configs present in the plugin's base directory (eg config.yml, lang.yml).
|
||||
* <p>
|
||||
* Does not automatically update.
|
||||
*
|
||||
* @param configName The name of the config
|
||||
* @param plugin The plugin.
|
||||
*/
|
||||
protected YamlStaticBaseConfig(@NotNull final String configName,
|
||||
@NotNull final EcoPlugin plugin) {
|
||||
this(configName, (PluginLike) plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.willfp.eco.core.extensions;
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginLike;
|
||||
import com.willfp.eco.core.config.updating.ConfigHandler;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* An extension is a separate jar file that hooks into the base plugin jar.
|
||||
* <p>
|
||||
@@ -15,9 +19,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Syntactically, extensions are very similar to plugins in their own right, except that
|
||||
* they are loaded by another plugin.
|
||||
*
|
||||
* @see <a href="https://ecoenchants.polymart.org">EcoEnchants extension examples.</a>
|
||||
* @see <a href="https://auxilor.polymart.org">Extension examples.</a>
|
||||
*/
|
||||
public abstract class Extension {
|
||||
public abstract class Extension implements PluginLike {
|
||||
/**
|
||||
* The {@link EcoPlugin} that this extension is for.
|
||||
*/
|
||||
@@ -103,4 +107,14 @@ public abstract class Extension {
|
||||
Validate.notNull(metadata, "Metadata cannot be null!");
|
||||
return this.metadata.version();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return this.plugin.getDataFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigHandler getConfigHandler() {
|
||||
return this.plugin.getConfigHandler();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.internal.config
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.PluginLike
|
||||
import com.willfp.eco.core.config.interfaces.Config
|
||||
import com.willfp.eco.core.config.interfaces.JSONConfig
|
||||
import com.willfp.eco.core.config.wrapper.ConfigFactory
|
||||
@@ -15,7 +16,7 @@ import org.bukkit.configuration.file.YamlConfiguration
|
||||
class EcoConfigFactory : ConfigFactory {
|
||||
override fun createUpdatableYamlConfig(
|
||||
configName: String,
|
||||
plugin: EcoPlugin,
|
||||
plugin: PluginLike,
|
||||
subDirectoryPath: String,
|
||||
source: Class<*>,
|
||||
removeUnused: Boolean,
|
||||
@@ -33,7 +34,7 @@ class EcoConfigFactory : ConfigFactory {
|
||||
|
||||
override fun createUpdatableJSONConfig(
|
||||
configName: String,
|
||||
plugin: EcoPlugin,
|
||||
plugin: PluginLike,
|
||||
subDirectoryPath: String,
|
||||
source: Class<*>,
|
||||
removeUnused: Boolean,
|
||||
@@ -51,7 +52,7 @@ class EcoConfigFactory : ConfigFactory {
|
||||
|
||||
override fun createLoadableJSONConfig(
|
||||
configName: String,
|
||||
plugin: EcoPlugin,
|
||||
plugin: PluginLike,
|
||||
subDirectoryPath: String,
|
||||
source: Class<*>
|
||||
): JSONConfig {
|
||||
@@ -65,7 +66,7 @@ class EcoConfigFactory : ConfigFactory {
|
||||
|
||||
override fun createLoadableYamlConfig(
|
||||
configName: String,
|
||||
plugin: EcoPlugin,
|
||||
plugin: PluginLike,
|
||||
subDirectoryPath: String,
|
||||
source: Class<*>
|
||||
): Config {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.willfp.eco.internal.config.json
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.PluginLike
|
||||
import com.willfp.eco.core.config.interfaces.LoadableConfig
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import java.io.*
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.StandardOpenOption
|
||||
@@ -10,7 +9,7 @@ import java.nio.file.StandardOpenOption
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
open class EcoLoadableJSONConfig(
|
||||
configName: String,
|
||||
private val plugin: EcoPlugin,
|
||||
private val plugin: PluginLike,
|
||||
private val subDirectoryPath: String,
|
||||
val source: Class<*>
|
||||
) : EcoJSONConfigWrapper(), LoadableConfig {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.willfp.eco.internal.config.json
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.PluginLike
|
||||
import org.bukkit.configuration.InvalidConfigurationException
|
||||
import org.bukkit.configuration.file.YamlConfiguration
|
||||
import java.io.BufferedReader
|
||||
@@ -10,7 +10,7 @@ import java.nio.charset.StandardCharsets
|
||||
|
||||
open class EcoUpdatableJSONConfig(
|
||||
configName: String,
|
||||
plugin: EcoPlugin,
|
||||
plugin: PluginLike,
|
||||
subDirectoryPath: String,
|
||||
source: Class<*>,
|
||||
private val removeUnused: Boolean,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.willfp.eco.internal.config.yaml
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.PluginLike
|
||||
import com.willfp.eco.core.config.interfaces.LoadableConfig
|
||||
import com.willfp.eco.core.config.interfaces.WrappedYamlConfiguration
|
||||
import org.bukkit.configuration.InvalidConfigurationException
|
||||
@@ -12,7 +12,7 @@ import java.io.OutputStream
|
||||
|
||||
open class EcoLoadableYamlConfig(
|
||||
configName: String,
|
||||
private val plugin: EcoPlugin,
|
||||
private val plugin: PluginLike,
|
||||
private val subDirectoryPath: String,
|
||||
val source: Class<*>
|
||||
) : EcoYamlConfigWrapper<YamlConfiguration>(), WrappedYamlConfiguration, LoadableConfig {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.willfp.eco.internal.config.yaml
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.PluginLike
|
||||
import org.bukkit.configuration.InvalidConfigurationException
|
||||
import org.bukkit.configuration.file.YamlConfiguration
|
||||
import java.io.BufferedReader
|
||||
@@ -10,7 +10,7 @@ import java.nio.charset.StandardCharsets
|
||||
|
||||
class EcoUpdatableYamlConfig(
|
||||
configName: String,
|
||||
plugin: EcoPlugin,
|
||||
plugin: PluginLike,
|
||||
subDirectoryPath: String,
|
||||
source: Class<*>,
|
||||
private val removeUnused: Boolean,
|
||||
@@ -27,9 +27,9 @@ class EcoUpdatableYamlConfig(
|
||||
if (newConfig.getKeys(true) == this.handle.getKeys(true)) {
|
||||
return
|
||||
}
|
||||
newConfig.getKeys(true).forEach { key: String ->
|
||||
newConfig.getKeys(true).forEach { key ->
|
||||
if (!this.handle.getKeys(true).contains(key)) {
|
||||
if (updateBlacklist.stream().noneMatch { s: String -> key.contains(s) }) {
|
||||
if (updateBlacklist.stream().noneMatch { key.contains(it) }) {
|
||||
this.handle.set(key, newConfig[key])
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class EcoUpdatableYamlConfig(
|
||||
}
|
||||
|
||||
init {
|
||||
this.updateBlacklist.removeIf { obj: String -> obj.isEmpty() }
|
||||
this.updateBlacklist.removeIf { it.isEmpty() }
|
||||
plugin.configHandler.addConfig(this)
|
||||
update()
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.willfp.eco.proxy.FastItemStackFactoryProxy
|
||||
import com.willfp.eco.proxy.SkullProxy
|
||||
import com.willfp.eco.spigot.arrows.ArrowDataListener
|
||||
import com.willfp.eco.spigot.display.*
|
||||
import com.willfp.eco.spigot.display.frame.clearFrames
|
||||
import com.willfp.eco.spigot.drops.CollatedRunnable
|
||||
import com.willfp.eco.spigot.eventlisteners.EntityDeathByEntityListeners
|
||||
import com.willfp.eco.spigot.eventlisteners.NaturalExpGainListeners
|
||||
@@ -34,6 +35,7 @@ import com.willfp.eco.spigot.integrations.customitems.CustomItemsHeadDatabase
|
||||
import com.willfp.eco.spigot.integrations.customitems.CustomItemsItemsAdder
|
||||
import com.willfp.eco.spigot.integrations.customitems.CustomItemsOraxen
|
||||
import com.willfp.eco.spigot.integrations.mcmmo.McmmoIntegrationImpl
|
||||
import com.willfp.eco.spigot.integrations.multiverseinventories.MultiverseInventoriesIntegration
|
||||
import com.willfp.eco.spigot.integrations.shop.ShopShopGuiPlus
|
||||
import com.willfp.eco.spigot.recipes.ShapedRecipeListener
|
||||
import com.willfp.eco.util.BlockUtils
|
||||
@@ -106,6 +108,11 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
override fun handleReload() {
|
||||
CollatedRunnable(this)
|
||||
DropManager.update(this)
|
||||
this.scheduler.runTimer(
|
||||
{ clearFrames() },
|
||||
this.configYml.getInt("display-frame-ttl").toLong(),
|
||||
this.configYml.getInt("display-frame-ttl").toLong()
|
||||
)
|
||||
}
|
||||
|
||||
override fun handleAfterLoad() {
|
||||
@@ -150,7 +157,8 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
IntegrationLoader("ShopGUIPlus") { ShopManager.register(ShopShopGuiPlus()) },
|
||||
|
||||
// Misc
|
||||
IntegrationLoader("mcMMO") { McmmoManager.register(McmmoIntegrationImpl()) }
|
||||
IntegrationLoader("mcMMO") { McmmoManager.register(McmmoIntegrationImpl()) },
|
||||
IntegrationLoader("Multiverse-Inventories") { this.eventManager.registerListener(MultiverseInventoriesIntegration(this)) }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,16 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
|
||||
) {
|
||||
val windowId = packet.integers.read(0)
|
||||
|
||||
if (windowId != 0) {
|
||||
player.lastDisplayFrame = DisplayFrame.EMPTY
|
||||
}
|
||||
|
||||
packet.itemListModifier.modify(0) { itemStacks: List<ItemStack>? ->
|
||||
if (itemStacks == null) {
|
||||
return@modify null
|
||||
}
|
||||
|
||||
if (windowId == 0) {
|
||||
if (this.getPlugin().configYml.getBool("use-display-frame") && windowId == 0) {
|
||||
val frameMap = mutableMapOf<Byte, Int>()
|
||||
|
||||
for (index in itemStacks.indices) {
|
||||
@@ -42,9 +46,7 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
|
||||
Display.display(itemStacks[index.toInt()], player)
|
||||
}
|
||||
} else {
|
||||
itemStacks.forEach {
|
||||
Display.display(it, player)
|
||||
}
|
||||
itemStacks.forEach { Display.display(it, player) }
|
||||
}
|
||||
itemStacks
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.spigot.display.frame
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
data class DisplayFrame(val items: Map<Byte, Int>) {
|
||||
fun getChangedSlots(newFrame: DisplayFrame): List<Byte> {
|
||||
@@ -15,14 +16,22 @@ data class DisplayFrame(val items: Map<Byte, Int>) {
|
||||
|
||||
return changes
|
||||
}
|
||||
|
||||
companion object {
|
||||
val EMPTY = DisplayFrame(emptyMap())
|
||||
}
|
||||
}
|
||||
|
||||
private val frames = mutableMapOf<UUID, DisplayFrame>()
|
||||
private val frames = ConcurrentHashMap<UUID, DisplayFrame>()
|
||||
|
||||
var Player.lastDisplayFrame: DisplayFrame
|
||||
get() {
|
||||
return frames[this.uniqueId] ?: DisplayFrame(emptyMap())
|
||||
return frames[this.uniqueId] ?: DisplayFrame.EMPTY
|
||||
}
|
||||
set(value) {
|
||||
frames[this.uniqueId] = value
|
||||
}
|
||||
|
||||
fun clearFrames() {
|
||||
frames.clear()
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.willfp.eco.spigot.integrations.multiverseinventories
|
||||
|
||||
import com.onarandombox.multiverseinventories.event.WorldChangeShareHandlingEvent
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.events.ArmorChangeEvent
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
|
||||
class MultiverseInventoriesIntegration(
|
||||
private val plugin: EcoPlugin
|
||||
): Listener {
|
||||
@EventHandler
|
||||
fun onWorldChange(event: WorldChangeShareHandlingEvent) {
|
||||
val before = event.player.inventory.armorContents.toMutableList()
|
||||
this.plugin.scheduler.run {
|
||||
val after = event.player.inventory.armorContents.toMutableList()
|
||||
Bukkit.getPluginManager().callEvent(ArmorChangeEvent(event.player, before, after))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,4 +19,13 @@ enable-bstats: true
|
||||
# Some plugins use their own item display systems (eg Triton)
|
||||
# And must be ran after eco. Don't enable this unless you run a conflicting plugin
|
||||
# and have been told to enable it.
|
||||
use-lower-protocollib-priority: false
|
||||
use-lower-protocollib-priority: false
|
||||
|
||||
# Display frames massively optimize PacketWindowItems, however some users have
|
||||
# reported display bugs by using it. If you have any problems with it, then you
|
||||
# should disable this option.
|
||||
use-display-frame: true
|
||||
|
||||
# Time to live for a display frame. In other words, this is how frequent (in ticks)
|
||||
# that display frames will be cleared / deleted.
|
||||
display-frame-ttl: 17
|
||||
@@ -25,6 +25,7 @@ softdepend:
|
||||
- ItemsAdder
|
||||
- Oraxen
|
||||
- HeadDatabase
|
||||
- Multiverse-Inventories
|
||||
libraries:
|
||||
- 'org.reflections:reflections:0.9.12'
|
||||
- 'org.apache.maven:maven-artifact:3.0.3'
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version = 6.10.1
|
||||
version = 6.11.0
|
||||
plugin-name = eco
|
||||
BIN
lib/Multiverse-Inventories-4.2.2.jar
Normal file
BIN
lib/Multiverse-Inventories-4.2.2.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user