Compare commits

..

23 Commits

Author SHA1 Message Date
Auxilor
364550d228 Pain 2022-04-06 13:47:01 +01:00
Auxilor
d5e8cbaf33 Updated to 6.32.1 2022-04-06 13:35:34 +01:00
Auxilor
c4d532fda9 Removed MySQL relocation 2022-04-06 13:34:33 +01:00
Auxilor
aa097cf7e2 Fixed wrong MySQL driver class 2022-04-06 13:08:29 +01:00
Auxilor
6f4ca40a94 Changed load order for custom items 2022-04-05 16:29:13 +01:00
Auxilor
2ef9b4033c Updated to 6.32.0 2022-04-05 15:38:44 +01:00
Auxilor
9aa22ffc86 Added Items#mergeFrom 2022-04-05 15:38:34 +01:00
Auxilor
d81c1e6fcb Added comment 2022-04-05 13:22:13 +01:00
Auxilor
ac72e0770a Undid last commit 2022-04-05 13:17:29 +01:00
Auxilor
5e3e09c4bc Moved adventure api to api configuration 2022-04-05 13:17:07 +01:00
Auxilor
ee945d5901 Updated to 6.31.4 2022-04-05 13:14:48 +01:00
Auxilor
7f747f3afc Fixed & color code 2022-04-05 13:12:49 +01:00
Auxilor
2d47593f51 More build changes 2022-04-05 13:12:29 +01:00
Auxilor
df529ba239 Minimized use of the lib-loader 2022-04-05 13:01:05 +01:00
Auxilor
2fea736631 Updated to 6.31.3 2022-04-02 14:36:23 +01:00
Auxilor
9df4fae2dc Fixed colors in console on new versions of paper 2022-04-02 14:36:14 +01:00
Auxilor
ca964a1a40 Updated to 6.31.2 and fixed default key values 2022-03-29 16:17:59 +01:00
Auxilor
ada2832839 Fixed data.yml 2022-03-28 21:24:34 +01:00
Auxilor
4d92cbb7ff Fixed PersistentDataKeyType equality 2022-03-28 14:33:28 +01:00
Auxilor
d6ab36929b Changed data reading 2022-03-28 14:29:56 +01:00
Auxilor
e06623d3fe Fixed some config constructors 2022-03-28 14:23:27 +01:00
Auxilor
8b70a37459 Updated to 6.31.1 2022-03-28 14:21:19 +01:00
Auxilor
daab3829bc Config changes 2022-03-28 14:21:09 +01:00
36 changed files with 273 additions and 112 deletions

View File

@@ -85,21 +85,25 @@ allprojects {
}
dependencies {
compileOnly(kotlin("stdlib", version = "1.6.10"))
// Included in spigot jar, no need to move to implementation
compileOnly("org.jetbrains:annotations:23.0.0")
compileOnly("com.google.guava:guava:31.1-jre")
// Test
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
// Adventure
compileOnly("net.kyori:adventure-api:4.10.0")
compileOnly("net.kyori:adventure-text-serializer-gson:4.10.0")
compileOnly("net.kyori:adventure-text-serializer-legacy:4.10.0")
implementation("net.kyori:adventure-api:4.10.1")
implementation("net.kyori:adventure-text-serializer-gson:4.10.1") {
exclude("com.google.code.gson", "gson") // Prevent shading into the jar
}
implementation("net.kyori:adventure-text-serializer-legacy:4.10.1")
// Other
compileOnly("com.google.guava:guava:31.1-jre")
compileOnly("com.github.ben-manes.caffeine:caffeine:3.0.5")
implementation("com.github.ben-manes.caffeine:caffeine:3.0.6")
implementation("org.apache.maven:maven-artifact:3.8.4")
implementation(kotlin("stdlib", version = "1.6.10"))
}
tasks.withType<JavaCompile> {
@@ -115,10 +119,11 @@ allprojects {
exclude(group = "com.darkblade12", module = "particleeffect")
exclude(group = "com.github.cryptomorin", module = "XSeries")
exclude(group = "net.wesjd", module = "anvilgui")
exclude(group = "org.slf4j", module = "slf4j-api")
}
configurations.testImplementation {
setExtendsFrom(listOf(configurations.compileOnly.get()))
setExtendsFrom(listOf(configurations.compileOnly.get(), configurations.implementation.get()))
}
tasks {
@@ -133,6 +138,28 @@ allprojects {
shadowJar {
relocate("org.bstats", "com.willfp.eco.libs.bstats")
relocate("redempt.crunch", "com.willfp.eco.libs.crunch")
relocate("org.apache.commons.lang3", "com.willfp.eco.libs.lang3")
relocate("org.apache.maven", "com.willfp.eco.libs.maven")
relocate("org.checkerframework", "com.willfp.eco.libs.checkerframework")
relocate("org.intellij", "com.willfp.eco.libs.intellij")
relocate("org.jetbrains.annotations", "com.willfp.eco.libs.jetbrains.annotations")
//relocate("org.jetbrains.exposed", "com.willfp.eco.libs.exposed")
relocate("org.objenesis", "com.willfp.eco.libs.objenesis")
relocate("org.reflections", "com.willfp.eco.libs.reflections")
relocate("javassist", "com.willfp.eco.libs.javassist")
relocate("javax.annotation", "com.willfp.eco.libs.annotation")
relocate("com.google.errorprone", "com.willfp.eco.libs.errorprone")
relocate("com.google.j2objc", "com.willfp.eco.libs.j2objc")
relocate("com.google.thirdparty", "com.willfp.eco.libs.google.thirdparty")
relocate("com.google.protobuf", "com.willfp.eco.libs.google.protobuf") // No I don't know either
relocate("google.protobuf", "com.willfp.eco.libs.protobuf") // Still don't know
relocate("com.zaxxer.hikari", "com.willfp.eco.libs.hikari")
//relocate("com.mysql", "com.willfp.eco.libs.mysql")
/*
Kotlin and caffeine are not shaded so that they can be accessed directly by eco plugins.
Also, not relocating adventure, because it's a pain in the ass, and it doesn't *seem* to be causing loader constraint violations.
*/
}
compileJava {

View File

@@ -4,7 +4,6 @@ dependencies {
// Other
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'org.apache.maven:maven-artifact:3.8.1'
compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.1-SNAPSHOT'
compileOnly 'com.google.code.gson:gson:2.8.8'
}

View File

@@ -353,9 +353,9 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike {
DefaultArtifactVersion mostRecentVersion = new DefaultArtifactVersion(version);
if (!(currentVersion.compareTo(mostRecentVersion) > 0 || currentVersion.equals(mostRecentVersion))) {
this.outdated = true;
this.getLogger().warning("&c" + this.getName() + " is out of date! (Version " + this.getDescription().getVersion() + ")");
this.getLogger().warning("&cThe newest version is &f" + version);
this.getLogger().warning("&cDownload the new version!");
this.getLogger().warning(this.getName() + " is out of date! (Version " + this.getDescription().getVersion() + ")");
this.getLogger().warning("The newest version is " + version);
this.getLogger().warning("Download the new version!");
}
});
}

View File

@@ -23,13 +23,31 @@ public abstract class BaseConfig extends LoadableConfigWrapper {
@NotNull final PluginLike plugin,
final boolean removeUnused,
@NotNull final ConfigType type) {
this(configName, plugin, removeUnused, type, true);
}
/**
* Create new Base Config.
*
* @param plugin The plugin or extension.
* @param configName The config name (excluding extension).
* @param removeUnused If unused sections should be removed.
* @param type The config type.
* @param requiresChangeToSave If changes must be applied to save the config.
*/
protected BaseConfig(@NotNull final String configName,
@NotNull final PluginLike plugin,
final boolean removeUnused,
@NotNull final ConfigType type,
final boolean requiresChangeToSave) {
super(Eco.getHandler().getConfigFactory().createUpdatableConfig(
configName,
plugin,
"",
plugin.getClass(),
removeUnused,
type
type,
requiresChangeToSave
));
}
}

View File

@@ -38,6 +38,7 @@ public abstract class ExtendableConfig extends LoadableConfigWrapper {
source,
removeUnused,
type,
true,
updateBlacklist
));
}

View File

@@ -26,7 +26,8 @@ public abstract class StaticBaseConfig extends LoadableConfigWrapper {
plugin,
"",
plugin.getClass(),
type
type,
true
));
}
}

View File

@@ -30,8 +30,13 @@ import java.util.Set;
public interface Config extends Cloneable, PlaceholderInjectable {
/**
* Clears cache.
* <p>
* Configs no longer have caches as they have in previous versions.
*/
void clearCache();
@Deprecated(since = "6.31.1", forRemoval = true)
default void clearCache() {
// Do nothing.
}
/**
* Convert the config into readable text.

View File

@@ -20,13 +20,14 @@ public interface ConfigFactory {
/**
* Updatable config.
*
* @param configName The name of the config
* @param plugin The plugin.
* @param subDirectoryPath The subdirectory path.
* @param source The class that owns the resource.
* @param removeUnused Whether keys not present in the default config should be removed on update.
* @param type The config type.
* @param updateBlacklist Substring of keys to not add/remove keys for.
* @param configName The name of the config
* @param plugin The plugin.
* @param subDirectoryPath The subdirectory path.
* @param source The class that owns the resource.
* @param removeUnused Whether keys not present in the default config should be removed on update.
* @param type The config type.
* @param updateBlacklist Substring of keys to not add/remove keys for.
* @param requiresChangesToSave If the config must be changed in order to save the config.
* @return The config implementation.
*/
LoadableConfig createUpdatableConfig(@NotNull String configName,
@@ -35,23 +36,26 @@ public interface ConfigFactory {
@NotNull Class<?> source,
boolean removeUnused,
@NotNull ConfigType type,
boolean requiresChangesToSave,
@NotNull String... updateBlacklist);
/**
* Loadable config.
*
* @param configName The name of the config
* @param plugin The plugin.
* @param subDirectoryPath The subdirectory path.
* @param source The class that owns the resource.
* @param type The config type.
* @param configName The name of the config
* @param plugin The plugin.
* @param subDirectoryPath The subdirectory path.
* @param source The class that owns the resource.
* @param type The config type.
* @param requiresChangesToSave If the config must be changed in order to save the config.
* @return The config implementation.
*/
LoadableConfig createLoadableConfig(@NotNull String configName,
@NotNull PluginLike plugin,
@NotNull String subDirectoryPath,
@NotNull Class<?> source,
@NotNull ConfigType type);
@NotNull ConfigType type,
boolean requiresChangesToSave);
/**
* Create config.

View File

@@ -19,7 +19,7 @@ import java.util.Set;
*
* @param <T> The type of the handle.
*/
@SuppressWarnings("MethodDoesntCallSuperMethod")
@SuppressWarnings({"MethodDoesntCallSuperMethod", "removal"})
public abstract class ConfigWrapper<T extends Config> implements Config {
/**
* Configs from eco have an internal implementation,
@@ -43,6 +43,7 @@ public abstract class ConfigWrapper<T extends Config> implements Config {
}
@Override
@Deprecated(since = "6.31.1", forRemoval = true)
public void clearCache() {
handle.clearCache();
}

View File

@@ -5,6 +5,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* All storable data key types.
@@ -79,6 +80,22 @@ public final class PersistentDataKeyType<T> {
this.name = name;
}
@Override
public boolean equals(@Nullable final Object that) {
if (this == that) {
return true;
}
if (!(that instanceof PersistentDataKeyType type)) {
return false;
}
return Objects.equals(this.name, type.name);
}
@Override
public int hashCode() {
return Objects.hash(this.name);
}
/**
* Get all registered {@link PersistentDataKeyType}s.
*

View File

@@ -34,6 +34,17 @@ public final class CustomItemsManager {
}
}
/**
* Register all the custom items for a specific plugin into eco.
*
* @see com.willfp.eco.core.items.Items
*/
public static void registerProviders() {
for (CustomItemsWrapper customItemsWrapper : REGISTERED) {
customItemsWrapper.registerProvider();
}
}
private CustomItemsManager() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}

View File

@@ -11,5 +11,14 @@ public interface CustomItemsWrapper extends Integration {
*
* @see com.willfp.eco.core.items.Items
*/
void registerAllItems();
default void registerAllItems() {
// Override when needed.
}
/**
* Register {@link com.willfp.eco.core.items.provider.ItemProvider}s.
*/
default void registerProvider() {
// Override when needed.
}
}

View File

@@ -13,6 +13,7 @@ import com.willfp.eco.util.NamespacedKeyUtils;
import com.willfp.eco.util.NumberUtils;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
@@ -430,6 +431,64 @@ public final class Items {
return items;
}
/**
* Merge ItemStack onto another ItemStack.
*
* @param from The ItemStack to merge from.
* @param to The ItemStack to merge onto.
* @return The ItemStack, merged (same instance as to).
*/
@NotNull
public static ItemStack mergeFrom(@NotNull final ItemStack from,
@NotNull final ItemStack to) {
ItemMeta fromMeta = from.getItemMeta();
ItemMeta toMeta = to.getItemMeta();
if (fromMeta == null || toMeta == null) {
return to;
}
ItemMeta newMeta = mergeFrom(fromMeta, toMeta);
to.setItemMeta(newMeta);
to.setType(from.getType());
to.setAmount(from.getAmount());
return to;
}
/**
* Merge ItemMeta onto other ItemMeta.
*
* @param from The ItemMeta to merge from.
* @param to The ItemMeta to merge onto.
* @return The ItemMeta, merged (same instance as to).
*/
@NotNull
public static ItemMeta mergeFrom(@NotNull final ItemMeta from,
@NotNull final ItemMeta to) {
if (from.hasDisplayName()) {
to.setDisplayName(from.getDisplayName());
}
to.setLore(from.getLore());
for (Enchantment enchant : to.getEnchants().keySet()) {
to.removeEnchant(enchant);
}
for (Map.Entry<Enchantment, Integer> entry : from.getEnchants().entrySet()) {
to.addEnchant(entry.getKey(), entry.getValue(), true);
}
if (from.hasCustomModelData()) {
to.setCustomModelData(from.getCustomModelData());
} else {
to.setCustomModelData(null);
}
return to;
}
private Items() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}

View File

@@ -59,6 +59,10 @@ public abstract class AbstractItemStackBuilder<T extends ItemMeta, U extends Abs
* @param base The ItemStack to start with.
*/
protected AbstractItemStackBuilder(@NotNull final ItemStack base) {
if (base.getType() == Material.AIR) {
base.setType(Material.STONE); // Prevents NPEs.
}
this.base = base;
this.meta = (T) base.getItemMeta();
assert meta != null;

View File

@@ -3,9 +3,22 @@
package com.willfp.eco.core.items
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.ItemMeta
/**
* @see Items.toLookupString
*/
fun ItemStack?.toLookupString(): String =
Items.toLookupString(this)
/**
* @see Items.mergeFrom
*/
fun ItemStack.mergeFrom(other: ItemStack): ItemStack =
Items.mergeFrom(other, this)
/**
* @see Items.mergeFrom
*/
fun ItemMeta.mergeFrom(other: ItemMeta): ItemMeta =
Items.mergeFrom(other, this)

View File

@@ -2,10 +2,12 @@ group 'com.willfp'
version rootProject.version
dependencies {
// Libraries
implementation 'org.reflections:reflections:0.9.12'
implementation 'org.objenesis:objenesis:3.2'
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'me.clip:placeholderapi:2.10.10'
compileOnly 'org.reflections:reflections:0.9.12'
compileOnly 'net.kyori:adventure-text-minimessage:4.10.0'
compileOnly 'net.kyori:adventure-platform-bukkit:4.1.0'
compileOnly 'org.objenesis:objenesis:3.2'
}

View File

@@ -21,10 +21,6 @@ open class EcoConfig(
this.values.putAll(values.normalizeToConfig(this.type))
}
override fun clearCache() {
// No cache
}
override fun toPlaintext(): String {
return configType.toString(this.values)
}
@@ -80,7 +76,6 @@ open class EcoConfig(
path: String,
obj: Any?
) {
this.clearCache()
val nearestPath = path.split(".")[0]
if (path.contains(".")) {
@@ -90,14 +85,10 @@ open class EcoConfig(
return
}
val section = get(nearestPath)
if (section == null) {
values[nearestPath] = EcoConfigSection(this.type)
return set(path, obj)
} else if (section is Config) {
section.set(remainingPath, obj)
return
}
val section = getSubsection(nearestPath) // Creates a section if null, therefore it can be set.
section.set(remainingPath, obj)
values[nearestPath] = section // Set the value
return
}
if (obj == null) {
@@ -108,7 +99,7 @@ open class EcoConfig(
}
override fun getSubsection(path: String): Config {
return getSubsectionOrNull(path) ?: EcoConfigSection(type, mutableMapOf(), injections)
return getSubsectionOrNull(path) ?: EcoConfigSection(type, injections = injections)
}
override fun getSubsectionOrNull(path: String): Config? {
@@ -168,7 +159,6 @@ open class EcoConfig(
override fun injectPlaceholders(placeholders: Iterable<StaticPlaceholder>) {
injections.removeIf { placeholders.any { placeholder -> it.identifier == placeholder.identifier } }
injections.addAll(placeholders)
this.clearCache()
}
override fun getInjectedPlaceholders(): List<StaticPlaceholder> {
@@ -177,7 +167,6 @@ open class EcoConfig(
override fun clearInjectedPlaceholders() {
injections.clear()
this.clearCache()
}
override fun toMap(): MutableMap<String, Any?> {

View File

@@ -28,13 +28,15 @@ object EcoConfigFactory : ConfigFactory {
plugin: PluginLike,
subDirectoryPath: String,
source: Class<*>,
type: ConfigType
type: ConfigType,
requiresChangesToSave: Boolean
): LoadableConfig = EcoLoadableConfig(
type,
configName,
plugin,
subDirectoryPath,
source
source,
requiresChangesToSave
)
override fun createUpdatableConfig(
@@ -44,6 +46,7 @@ object EcoConfigFactory : ConfigFactory {
source: Class<*>,
removeUnused: Boolean,
type: ConfigType,
requiresChangesToSave: Boolean,
vararg updateBlacklist: String
): LoadableConfig = EcoUpdatableConfig(
type,
@@ -52,6 +55,7 @@ object EcoConfigFactory : ConfigFactory {
subDirectoryPath,
source,
removeUnused,
requiresChangesToSave,
*updateBlacklist
)
}

View File

@@ -19,7 +19,8 @@ open class EcoLoadableConfig(
configName: String,
private val plugin: PluginLike,
private val subDirectoryPath: String,
val source: Class<*>
val source: Class<*>,
private val requiresChangesToSave: Boolean
) : EcoConfig(type), LoadableConfig {
private val configFile: File
private val name: String = "$configName.${type.extension}"
@@ -57,8 +58,10 @@ open class EcoLoadableConfig(
@Throws(IOException::class)
override fun save() {
if (!hasChanged) { // In order to preserve comments
return
if (requiresChangesToSave) {
if (!hasChanged) { // In order to preserve comments
return
}
}
if (configFile.delete()) {

View File

@@ -14,12 +14,12 @@ open class EcoUpdatableConfig(
subDirectoryPath: String,
source: Class<*>,
private val removeUnused: Boolean,
requiresChangesToSave: Boolean,
vararg updateBlacklist: String
) : EcoLoadableConfig(type, configName, plugin, subDirectoryPath, source) {
) : EcoLoadableConfig(type, configName, plugin, subDirectoryPath, source, requiresChangesToSave) {
private val updateBlacklist = mutableListOf(*updateBlacklist)
fun update() {
super.clearCache()
this.init(configFile)
val newConfig = configInJar ?: return
if (newConfig.getKeys(true) == this.getKeys(true)) {

View File

@@ -2,24 +2,17 @@ package com.willfp.eco.internal.logging
import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.util.StringUtils
import org.bukkit.Bukkit
import java.util.logging.Level
import java.util.logging.Logger
class EcoLogger(plugin: EcoPlugin) : Logger(plugin.name, null as String?) {
class EcoLogger(private val plugin: EcoPlugin) : Logger(plugin.name, null as String?) {
override fun info(msg: String) {
super.info(StringUtils.format(msg))
}
override fun warning(msg: String) {
super.warning(StringUtils.format(msg))
}
override fun severe(msg: String) {
super.severe(StringUtils.format(msg))
Bukkit.getConsoleSender().sendMessage("[${plugin.name}] ${StringUtils.format(msg)}")
}
init {
parent = plugin.server.logger
this.level = Level.ALL
}
}
}

View File

@@ -2,13 +2,23 @@ group 'com.willfp'
version rootProject.version
dependencies {
implementation 'com.github.Redempt:Crunch:1.1.2'
compileOnly 'net.kyori:adventure-platform-bukkit:4.1.0'
compileOnly 'org.apache.maven:maven-artifact:3.8.1'
compileOnly 'com.google.code.gson:gson:2.8.8'
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
compileOnly project(":eco-core:core-proxy")
compileOnly project(":eco-core:core-backend")
// Libraries
implementation 'com.github.Redempt:Crunch:1.1.2'
implementation 'mysql:mysql-connector-java:8.0.25'
implementation 'org.jetbrains.exposed:exposed-core:0.37.3'
implementation 'org.jetbrains.exposed:exposed-dao:0.37.3'
implementation 'org.jetbrains.exposed:exposed-jdbc:0.37.3'
implementation 'com.zaxxer:HikariCP:5.0.0'
implementation 'net.kyori:adventure-platform-bukkit:4.1.0'
// Included in spigot jar
compileOnly 'com.google.code.gson:gson:2.8.8'
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
// Plugin dependencies
compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.1-SNAPSHOT'
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.7-SNAPSHOT'
compileOnly 'com.github.TechFortress:GriefPrevention:16.17.1'
@@ -26,11 +36,6 @@ dependencies {
compileOnly 'com.github.brcdev-minecraft:shopgui-api:2.2.0'
compileOnly 'com.github.LoneDev6:API-ItemsAdder:2.4.7'
compileOnly 'com.arcaniax:HeadDatabase-API:1.3.0'
compileOnly 'org.jetbrains.exposed:exposed-core:0.37.3'
compileOnly 'org.jetbrains.exposed:exposed-dao:0.37.3'
compileOnly 'org.jetbrains.exposed:exposed-jdbc:0.37.3'
compileOnly 'mysql:mysql-connector-java:8.0.25'
compileOnly 'com.zaxxer:HikariCP:5.0.0'
compileOnly 'com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0'
compileOnly 'com.github.EssentialsX:Essentials:2.18.2'
compileOnly 'com.bgsoftware:SuperiorSkyblockAPI:1.8.3'
@@ -40,6 +45,8 @@ dependencies {
compileOnly 'com.github.WhipDevelopment:CrashClaim:f9cd7d92eb'
compileOnly 'com.wolfyscript.wolfyutilities:wolfyutilities:3.16.0.0'
compileOnly 'com.github.decentsoftware-eu:decentholograms:2.1.2'
// MythicMobs
compileOnly 'io.lumine:Mythic:5.0.1'
compileOnly 'io.lumine:LumineUtils:1.16.1-SNAPSHOT'
@@ -54,6 +61,7 @@ dependencies {
// LibsDisguises
compileOnly 'LibsDisguises:LibsDisguises:10.0.26'
// All other libs
compileOnly fileTree(dir: '../../lib', include: ['*.jar'])
}

View File

@@ -178,6 +178,8 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
NumberUtils.initCrunch { expression, player, statics -> evaluateExpression(expression, player, statics) }
CustomItemsManager.registerProviders()
postInit()
}

View File

@@ -10,5 +10,6 @@ class DataYml(
"data",
plugin,
false,
ConfigType.YAML
ConfigType.YAML,
false
)

View File

@@ -27,7 +27,7 @@ abstract class EcoProfile(
return this.data[key] as T
}
this.data[key] = handler.read(uuid, key.key) ?: key.defaultValue
this.data[key] = handler.read(uuid, key) ?: key.defaultValue
return read(key)
}
@@ -36,11 +36,11 @@ abstract class EcoProfile(
return false
}
return this.data == other.data && this.uuid == other.uuid
return this.uuid == other.uuid
}
override fun hashCode(): Int {
return this.data.hashCode()
return this.uuid.hashCode()
}
companion object {

View File

@@ -23,5 +23,5 @@ interface DataHandler {
fun <T> write(uuid: UUID, key: NamespacedKey, value: T)
fun saveKeysFor(uuid: UUID, keys: Set<PersistentDataKey<*>>)
fun <T> read(uuid: UUID, key: NamespacedKey): T?
fun <T> read(uuid: UUID, key: PersistentDataKey<T>): T?
}

View File

@@ -45,6 +45,7 @@ class MySQLDataHandler(
private val serverHandler: ImplementedMySQLHandler
init {
val config = HikariConfig()
config.driverClassName = "com.mysql.cj.jdbc.Driver"
config.username = plugin.configYml.getString("mysql.user")
@@ -102,9 +103,9 @@ class MySQLDataHandler(
}
}
override fun <T> read(uuid: UUID, key: NamespacedKey): T? {
override fun <T> read(uuid: UUID, key: PersistentDataKey<T>): T? {
return applyFor(uuid) {
it.read(uuid, key)
it.read(uuid, key.key)
}
}

View File

@@ -1,6 +1,7 @@
package com.willfp.eco.internal.spigot.data.storage
import com.willfp.eco.core.data.keys.PersistentDataKey
import com.willfp.eco.core.data.keys.PersistentDataKeyType
import com.willfp.eco.internal.spigot.EcoSpigotPlugin
import com.willfp.eco.internal.spigot.data.EcoProfileHandler
import org.bukkit.NamespacedKey
@@ -37,7 +38,15 @@ class YamlDataHandler(
dataYml.set("player.$uuid.$key", value)
}
override fun <T> read(uuid: UUID, key: NamespacedKey): T? {
return dataYml.get("player.$uuid.$key") as T?
override fun <T> read(uuid: UUID, key: PersistentDataKey<T>): T? {
val value = when (key.type) {
PersistentDataKeyType.INT -> dataYml.getIntOrNull("player.$uuid.${key.key}")
PersistentDataKeyType.DOUBLE -> dataYml.getDoubleOrNull("player.$uuid.${key.key}")
PersistentDataKeyType.STRING -> dataYml.getStringOrNull("player.$uuid.${key.key}")
PersistentDataKeyType.BOOLEAN -> dataYml.getBoolOrNull("player.$uuid.${key.key}")
else -> null
} as? T?
return value
}
}

View File

@@ -14,7 +14,7 @@ import org.bukkit.inventory.ItemStack
import java.util.function.Predicate
class CustomItemsCustomCrafting : CustomItemsWrapper {
override fun registerAllItems() {
override fun registerProvider() {
Items.registerItemProvider(CustomCraftingProvider())
}

View File

@@ -11,7 +11,7 @@ import org.bukkit.inventory.ItemStack
import java.util.function.Predicate
class CustomItemsExecutableItems : CustomItemsWrapper {
override fun registerAllItems() {
override fun registerProvider() {
Items.registerItemProvider(ExecutableItemsProvider())
}

View File

@@ -23,7 +23,7 @@ class CustomItemsHeadDatabase(
plugin.eventManager.registerListener(provider)
}
override fun registerAllItems() {
override fun registerProvider() {
Items.registerItemProvider(HeadDBProvider())
}

View File

@@ -11,7 +11,7 @@ import org.bukkit.inventory.ItemStack
import java.util.function.Predicate
class CustomItemsItemsAdder : CustomItemsWrapper {
override fun registerAllItems() {
override fun registerProvider() {
Items.registerItemProvider(ItemsAdderProvider())
}

View File

@@ -26,10 +26,6 @@ class CustomItemsMythicMobs(
return "MythicMobs"
}
override fun registerAllItems() {
// Do nothing.
}
@EventHandler
fun onLoad(event: MythicDropLoadEvent) {
val name = event.dropName

View File

@@ -9,7 +9,7 @@ import com.willfp.eco.util.NamespacedKeyUtils
import io.th0rgal.oraxen.items.OraxenItems
class CustomItemsOraxen : CustomItemsWrapper {
override fun registerAllItems() {
override fun registerProvider() {
Items.registerItemProvider(OraxenProvider())
}

View File

@@ -42,20 +42,4 @@ softdepend:
- MythicMobs
- CustomCrafting
- ExecutableItems
- RPGHorses
libraries:
- 'org.reflections:reflections:0.9.12'
- 'org.apache.maven:maven-artifact:3.0.3'
- 'org.jetbrains.kotlin:kotlin-stdlib:1.6.10'
- 'net.kyori:adventure-platform-bukkit:4.1.0'
- 'net.kyori:adventure-api:4.10.0'
- 'net.kyori:adventure-text-serializer-gson:4.10.0'
- 'net.kyori:adventure-text-serializer-legacy:4.10.0'
- 'org.jetbrains.exposed:exposed-core:0.37.3'
- 'org.jetbrains.exposed:exposed-dao:0.37.3'
- 'org.jetbrains.exposed:exposed-jdbc:0.37.3'
- 'mysql:mysql-connector-java:8.0.25'
- 'com.google.guava:guava:31.1-jre'
- 'com.zaxxer:HikariCP:5.0.0'
- 'org.objenesis:objenesis:3.2'
- 'com.github.ben-manes.caffeine:caffeine:3.0.5'
- RPGHorses

View File

@@ -1,3 +1,3 @@
version = 6.31.0
version = 6.32.1
plugin-name = eco
kotlin.code.style = official