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 213c5fe..cc28135 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 @@ -8,6 +8,8 @@ import com.willfp.ecobits.integrations.IntegrationVault import org.bukkit.event.Listener class EcoBitsPlugin : EcoPlugin() { + val serverID = configYml.getString("server-id") + init { instance = this } 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 ad15c7f..28a66c4 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 @@ -2,7 +2,6 @@ package com.willfp.ecobits.currencies -import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.data.keys.PersistentDataKey import com.willfp.eco.core.data.keys.PersistentDataKeyType @@ -12,6 +11,7 @@ import com.willfp.eco.core.placeholder.PlayerPlaceholder import com.willfp.eco.core.placeholder.PlayerlessPlaceholder import com.willfp.eco.core.price.Prices import com.willfp.eco.util.toNiceString +import com.willfp.ecobits.EcoBitsPlugin import com.willfp.ecobits.integrations.IntegrationVault import net.milkbowl.vault.economy.Economy import org.bukkit.Bukkit @@ -24,17 +24,11 @@ import kotlin.math.pow class Currency( val id: String, - val plugin: EcoPlugin, + val plugin: EcoBitsPlugin, val config: Config ) { val default = config.getDouble("default") - val key = PersistentDataKey( - plugin.createNamespacedKey(id), - PersistentDataKeyType.DOUBLE, - default - ) - val name = config.getFormattedString("name") val max = config.getDouble("max").let { if (it < 0) Double.MAX_VALUE else it } @@ -44,6 +38,14 @@ class Currency( val isRegisteredWithVault = config.getBool("vault") + val isLocal = config.getBool("local") + + val key = PersistentDataKey( + plugin.createNamespacedKey(if (isLocal) "${plugin.serverID}_${id}" else id), + PersistentDataKeyType.DOUBLE, + default + ) + init { PlaceholderManager.registerPlaceholder( PlayerPlaceholder( diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index 8381e07..af9c96c 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -14,6 +14,8 @@ # %ecobits__default% - The default balance of a certain currency # %ecobits__name% - The display name of a certain currency +server-id: "main" # Server ID for local currencies over MySQL/MongoDB. + currencies: - id: crystals # The ID of the currency. name: "&bCrystals ❖" # The name of the currency. @@ -22,3 +24,4 @@ currencies: 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 + local: false # If this currency should not sync between servers