9
0
mirror of https://github.com/Auxilor/EcoBits.git synced 2025-12-19 15:09:19 +00:00

Fixed vault support

This commit is contained in:
Auxilor
2023-08-05 12:37:20 +01:00
parent d8f44a0a9b
commit 54948e3f1f
6 changed files with 26 additions and 14 deletions

View File

@@ -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<Listener> {
return emptyList()
}
@@ -24,12 +38,6 @@ class EcoBitsPlugin : EcoPlugin() {
)
}
override fun loadIntegrationLoaders(): List<IntegrationLoader> {
return listOf(
IntegrationLoader("Vault") { IntegrationVault.isVaultPresent = true }
)
}
override fun getMinimumEcoVersion(): String {
return "6.60.0"
}

View File

@@ -35,7 +35,6 @@ object Currencies {
*
* @param plugin Instance of EcoBits.
*/
@ConfigUpdater
@JvmStatic
fun update(plugin: EcoBitsPlugin) {
for (currency in values()) {

View File

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

View File

@@ -18,7 +18,7 @@ class IntegrationVault(
}
override fun getName(): String {
return "EcoBits"
return "EcoBits ${currency.id}"
}
override fun hasBankSupport(): Boolean {

View File

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

View File

@@ -2,3 +2,4 @@ options:
resource-id: 4125
bstats-id: 16908
color: "&#9efaff"
uses-reflective-reload: false