Add zShop integration

This commit is contained in:
TomTom 2024-03-26 15:46:54 +01:00
parent e327644f4d
commit 54b54b989a
4 changed files with 32 additions and 1 deletions

View File

@ -132,6 +132,7 @@ allprojects {
implementation("com.zaxxer:HikariCP:5.1.0")
implementation("org.bstats:bstats-bukkit:3.0.2")
compileOnly 'org.black_ixx:playerpoints:3.2.6'
compileOnly 'com.github.Maxlego08:zShop-API:3.0.5'
}
compileKotlin {

View File

@ -16,6 +16,7 @@ import com.artillexstudios.axminions.integrations.prices.CMIIntegration
import com.artillexstudios.axminions.integrations.prices.EconomyShopGUIIntegration
import com.artillexstudios.axminions.integrations.prices.EssentialsIntegration
import com.artillexstudios.axminions.integrations.prices.ShopGUIPlusIntegration
import com.artillexstudios.axminions.integrations.prices.ZShopIntegration
import com.artillexstudios.axminions.integrations.protection.BentoBoxIntegration
import com.artillexstudios.axminions.integrations.protection.GriefPreventionIntegration
import com.artillexstudios.axminions.integrations.protection.IridiumSkyBlockIntegration
@ -102,6 +103,12 @@ class Integrations : Integrations {
Bukkit.getConsoleSender()
.sendMessage(StringUtils.formatToString("<#33FF33>[AxMinions] Hooked into EconomyShopGUI!"))}
}
"zshop" -> {
if (isPluginLoaded("zShop")) {
register(ZShopIntegration())
}
}
}
when (Config.ECONOMY_HOOK().lowercase(Locale.ENGLISH)) {

View File

@ -0,0 +1,22 @@
package com.artillexstudios.axminions.integrations.prices
import com.artillexstudios.axminions.api.integrations.types.PricesIntegration
import fr.maxlego08.zshop.api.ShopManager
import org.bukkit.Bukkit
import org.bukkit.inventory.ItemStack
class ZShopIntegration : PricesIntegration {
private var shopManager: ShopManager? = null
override fun getPrice(itemStack: ItemStack): Double {
val button = shopManager?.getItemButton(itemStack.type)
return button?.map { itemButton -> itemButton.getSellPrice(itemStack.amount) }?.orElse(0.0) ?: 0.0
}
override fun register() {
val rsp = Bukkit.getServer().servicesManager.getRegistration(
ShopManager::class.java
)
shopManager = rsp!!.provider
}
}

View File

@ -21,4 +21,5 @@ softdepend:
- PlotSquared
- KGenerators
- Towny
- ItemsAdder
- ItemsAdder
- zShop