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
|
|
@ -40,11 +40,14 @@ repositories {
|
||||||
// ItemsAdder
|
// ItemsAdder
|
||||||
maven(url = "https://maven.devs.beer/")
|
maven(url = "https://maven.devs.beer/")
|
||||||
|
|
||||||
// for fast stats
|
// For fast stats
|
||||||
maven {
|
maven {
|
||||||
name = "thenextlvlReleases"
|
name = "thenextlvlReleases"
|
||||||
url = uri("https://repo.thenextlvl.net/releases")
|
url = uri("https://repo.thenextlvl.net/releases")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For vault unlocked
|
||||||
|
maven { url = uri("https://jitpack.io") }
|
||||||
}
|
}
|
||||||
|
|
||||||
val reobfNMS = providers.gradleProperty("subprojects.reobfnms")
|
val reobfNMS = providers.gradleProperty("subprojects.reobfnms")
|
||||||
|
|
@ -103,6 +106,9 @@ dependencies {
|
||||||
// ItemsAdder API
|
// ItemsAdder API
|
||||||
compileOnly("dev.lone:api-itemsadder:4.0.10")
|
compileOnly("dev.lone:api-itemsadder:4.0.10")
|
||||||
|
|
||||||
|
// Vault api
|
||||||
|
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
|
||||||
|
|
||||||
// Include nms
|
// Include nms
|
||||||
implementation(project(":nms:nms-common"))
|
implementation(project(":nms:nms-common"))
|
||||||
implementation(project(":nms:nms-paper"))
|
implementation(project(":nms:nms-paper"))
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import xyz.alexcrea.cuanvil.command.ReloadExecutor
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||||
import xyz.alexcrea.cuanvil.dependency.DependencyManager
|
import xyz.alexcrea.cuanvil.dependency.DependencyManager
|
||||||
import xyz.alexcrea.cuanvil.dependency.MinecraftVersionUtil
|
import xyz.alexcrea.cuanvil.dependency.MinecraftVersionUtil
|
||||||
|
import xyz.alexcrea.cuanvil.dependency.econmy.EconomyManager
|
||||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
||||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry
|
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry
|
||||||
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui
|
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui
|
||||||
|
|
@ -258,9 +259,11 @@ open class CustomAnvil : JavaPlugin() {
|
||||||
MainConfigGui.getInstance().init(DependencyManager.packetManager)
|
MainConfigGui.getInstance().init(DependencyManager.packetManager)
|
||||||
GuiSharedConstant.loadConstants()
|
GuiSharedConstant.loadConstants()
|
||||||
|
|
||||||
|
// Prepare economy if possible
|
||||||
|
EconomyManager.setupEconomy(this)
|
||||||
|
|
||||||
// Finally, re add default we may be missing
|
// Finally, re add default we may be missing
|
||||||
PluginSetDefault.reAddMissingDefault()
|
PluginSetDefault.reAddMissingDefault()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reloadResource(
|
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