From 8052ffa706fb68eb74a6e947c3f97f4d11ea6541 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Sun, 20 Aug 2023 17:39:22 +0300 Subject: [PATCH 1/2] Added ability to specify local storage usage individually for each persistent data key via a constructor parameter --- .../eco/core/data/keys/PersistentDataKey.java | 28 +++++++++++++++++++ .../eco/internal/spigot/data/EcoProfile.kt | 1 + 2 files changed, 29 insertions(+) diff --git a/eco-api/src/main/java/com/willfp/eco/core/data/keys/PersistentDataKey.java b/eco-api/src/main/java/com/willfp/eco/core/data/keys/PersistentDataKey.java index 44ce98c98..00f0aa8b2 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/data/keys/PersistentDataKey.java +++ b/eco-api/src/main/java/com/willfp/eco/core/data/keys/PersistentDataKey.java @@ -29,6 +29,31 @@ public final class PersistentDataKey { */ private final PersistentDataKeyType type; + /** + * If the key uses local storage. + */ + private final boolean local; + + /** + * Create a new Persistent Data Key. + * + * @param key The key. + * @param type The data type. + * @param defaultValue The default value. + * @param local If the key uses local storage. + */ + public PersistentDataKey(@NotNull final NamespacedKey key, + @NotNull final PersistentDataKeyType type, + @NotNull final T defaultValue, + final boolean local) { + this.key = key; + this.defaultValue = defaultValue; + this.type = type; + this.local = local; + + Eco.get().registerPersistentKey(this); + } + /** * Create a new Persistent Data Key. * @@ -42,6 +67,7 @@ public PersistentDataKey(@NotNull final NamespacedKey key, this.key = key; this.defaultValue = defaultValue; this.type = type; + this.local = false; Eco.get().registerPersistentKey(this); } @@ -82,6 +108,8 @@ public PersistentDataKeyType getType() { return this.type; } + public boolean isLocalStorage() { return this.local; } + /** * Get all persistent data keys. * diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/EcoProfile.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/EcoProfile.kt index 7de71c377..72ba1062f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/EcoProfile.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/EcoProfile.kt @@ -106,3 +106,4 @@ class EcoServerProfile( private val PersistentDataKey<*>.isLocal: Boolean get() = this == localServerIDKey || EcoPlugin.getPlugin(this.key.namespace)?.isUsingLocalStorage == true + || this.isLocalStorage From 510034af0d3d602cc3a2c705fe7edea2e0acbb73 Mon Sep 17 00:00:00 2001 From: Sen2000 <18487475+SenPr@users.noreply.github.com> Date: Sun, 3 Sep 2023 18:03:19 +0700 Subject: [PATCH 2/2] Fix RoyaleEconomy integration --- .../com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt index 519b6ae34..af1ee650d 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt @@ -367,8 +367,10 @@ abstract class EcoSpigotPlugin : EcoPlugin() { }, IntegrationLoader("PlayerPoints") { Prices.registerPriceFactory(PriceFactoryPlayerPoints()) }, IntegrationLoader("RoyaleEconomy") { - for (currency in MultiCurrencyHandler.getCurrencies()) { - Prices.registerPriceFactory(PriceFactoryRoyaleEconomy(currency)) + if (!MultiCurrencyHandler.getCurrencies().isNullOrEmpty()) { + for (currency in MultiCurrencyHandler.getCurrencies()) { + Prices.registerPriceFactory(PriceFactoryRoyaleEconomy(currency)) + } } },