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:
@@ -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"
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ object Currencies {
|
||||
*
|
||||
* @param plugin Instance of EcoBits.
|
||||
*/
|
||||
@ConfigUpdater
|
||||
@JvmStatic
|
||||
fun update(plugin: EcoBitsPlugin) {
|
||||
for (currency in values()) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -18,7 +18,7 @@ class IntegrationVault(
|
||||
}
|
||||
|
||||
override fun getName(): String {
|
||||
return "EcoBits"
|
||||
return "EcoBits ${currency.id}"
|
||||
}
|
||||
|
||||
override fun hasBankSupport(): Boolean {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,3 +2,4 @@ options:
|
||||
resource-id: 4125
|
||||
bstats-id: 16908
|
||||
color: "	efaff"
|
||||
uses-reflective-reload: false
|
||||
|
||||
Reference in New Issue
Block a user