9
0
mirror of https://github.com/Auxilor/EcoBits.git synced 2025-12-31 04:46:30 +00:00

Added local currencies

This commit is contained in:
Auxilor
2022-11-22 09:24:32 +00:00
parent 44e60f3912
commit 7a0768d6c9
3 changed files with 15 additions and 8 deletions

View File

@@ -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
}

View File

@@ -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(

View File

@@ -14,6 +14,8 @@
# %ecobits_<id>_default% - The default balance of a certain currency
# %ecobits_<id>_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