mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
hook to vault economy api
This commit is contained in:
parent
bf926fb159
commit
b18cf1fd59
3 changed files with 42 additions and 2 deletions
|
|
@ -12,6 +12,7 @@ import xyz.alexcrea.cuanvil.command.ReloadExecutor
|
|||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||
import xyz.alexcrea.cuanvil.dependency.DependencyManager
|
||||
import xyz.alexcrea.cuanvil.dependency.MinecraftVersionUtil
|
||||
import xyz.alexcrea.cuanvil.dependency.econmy.EconomyManager
|
||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry
|
||||
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui
|
||||
|
|
@ -258,9 +259,11 @@ open class CustomAnvil : JavaPlugin() {
|
|||
MainConfigGui.getInstance().init(DependencyManager.packetManager)
|
||||
GuiSharedConstant.loadConstants()
|
||||
|
||||
// Prepare economy if possible
|
||||
EconomyManager.setupEconomy(this)
|
||||
|
||||
// Finally, re add default we may be missing
|
||||
PluginSetDefault.reAddMissingDefault()
|
||||
|
||||
}
|
||||
|
||||
fun reloadResource(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.econmy
|
||||
|
||||
import net.milkbowl.vault.economy.Economy
|
||||
import org.bukkit.OfflinePlayer
|
||||
import org.bukkit.plugin.Plugin
|
||||
import org.bukkit.plugin.RegisteredServiceProvider
|
||||
|
||||
object EconomyManager {
|
||||
|
||||
private var economy: Economy? = null
|
||||
|
||||
fun setupEconomy(plugin: Plugin) {
|
||||
if (economy != null) return
|
||||
|
||||
if (plugin.server.pluginManager.getPlugin("Vault") == null)
|
||||
return
|
||||
|
||||
val rsp: RegisteredServiceProvider<Economy?>? =
|
||||
plugin.server.servicesManager.getRegistration(Economy::class.java)
|
||||
if (rsp == null) return
|
||||
|
||||
economy = rsp.getProvider()
|
||||
}
|
||||
|
||||
fun has(player: OfflinePlayer, amount: Double): Boolean {
|
||||
return economy?.has(player, amount) == true
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue