diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/EcoBitsPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/EcoBitsPlugin.kt index 4b46812..1f5d720 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/EcoBitsPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/EcoBitsPlugin.kt @@ -3,7 +3,9 @@ package com.willfp.ecobits import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.command.impl.PluginCommand import com.willfp.eco.core.integrations.IntegrationLoader +import com.willfp.eco.util.ClassUtils import com.willfp.ecobits.commands.CommandEcoBits +import com.willfp.ecobits.currencies.Currencies import com.willfp.ecobits.integrations.IntegrationVault import org.bukkit.event.Listener @@ -14,6 +16,18 @@ class EcoBitsPlugin : EcoPlugin() { instance = this } + override fun handleLoad() { + // Initial preload for Vault + if (ClassUtils.exists("net.milkbowl.vault.economy.Economy")) { + IntegrationVault.isVaultPresent = true + Currencies.update(this) + } + } + + override fun handleReload() { + Currencies.update(this) + } + override fun loadListeners(): List { return emptyList() } @@ -24,12 +38,6 @@ class EcoBitsPlugin : EcoPlugin() { ) } - override fun loadIntegrationLoaders(): List { - return listOf( - IntegrationLoader("Vault") { IntegrationVault.isVaultPresent = true } - ) - } - override fun getMinimumEcoVersion(): String { return "6.60.0" } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/currencies/Currencies.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/currencies/Currencies.kt index 24d3453..1553437 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/currencies/Currencies.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/currencies/Currencies.kt @@ -35,7 +35,6 @@ object Currencies { * * @param plugin Instance of EcoBits. */ - @ConfigUpdater @JvmStatic fun update(plugin: EcoBitsPlugin) { for (currency in values()) { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/currencies/Currency.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/currencies/Currency.kt index 528ea9a..f4aaea9 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/currencies/Currency.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/currencies/Currency.kt @@ -7,6 +7,7 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.data.keys.PersistentDataKey import com.willfp.eco.core.data.keys.PersistentDataKeyType import com.willfp.eco.core.data.profile +import com.willfp.eco.core.integrations.economy.EconomyManager import com.willfp.eco.core.integrations.placeholder.PlaceholderManager import com.willfp.eco.core.placeholder.DynamicPlaceholder import com.willfp.eco.core.placeholder.PlayerPlaceholder @@ -159,11 +160,6 @@ class Currency( Prices.registerPriceFactory(PriceFactoryCurrency(this)) if (isRegisteredWithVault && IntegrationVault.isVaultPresent) { - // Override Vault economy - Bukkit.getServer().servicesManager.getRegistration(Economy::class.java)?.let { - Bukkit.getServer().servicesManager.unregister(it.provider) - } - Bukkit.getServer().servicesManager.register( Economy::class.java, IntegrationVault(this), @@ -175,6 +171,14 @@ class Currency( this.unregisterCommands() this.registerCommands() } + + override fun equals(other: Any?): Boolean { + return other is Currency && other.id == this.id + } + + override fun hashCode(): Int { + return this.id.hashCode() + } } data class LeaderboardPlace( diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/integrations/IntegrationVault.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/integrations/IntegrationVault.kt index 8300930..af2e27f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/integrations/IntegrationVault.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobits/integrations/IntegrationVault.kt @@ -18,7 +18,7 @@ class IntegrationVault( } override fun getName(): String { - return "EcoBits" + return "EcoBits ${currency.id}" } override fun hasBankSupport(): Boolean { diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index ef3d21b..97f5d2a 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -28,7 +28,7 @@ currencies: max: -1 # The maximum balance, set to -1 if no max. payable: false # If players should be able to use /ecobits pay to pay other players decimal: true # If decimal amounts are allowed rather than just integer amounts - vault: false # If this currency should be registered with vault (Only one currency can be registered with vault) + vault: false # If this currency should be registered with vault (Only one currency can be registered with vault, requires server restart) local: false # If this currency should not sync between servers commands: # A list of commands dedicated to this currency (for easier paying, checking balance, etc) - crystals diff --git a/eco-core/core-plugin/src/main/resources/eco.yml b/eco-core/core-plugin/src/main/resources/eco.yml index 9dcc246..bf5b423 100644 --- a/eco-core/core-plugin/src/main/resources/eco.yml +++ b/eco-core/core-plugin/src/main/resources/eco.yml @@ -2,3 +2,4 @@ options: resource-id: 4125 bstats-id: 16908 color: " efaff" + uses-reflective-reload: false