From 54b54b989a30c8b6387fd0e6cbca42eb8a4eb6eb Mon Sep 17 00:00:00 2001 From: TomTom <93038247+AverageGithub@users.noreply.github.com> Date: Tue, 26 Mar 2024 15:46:54 +0100 Subject: [PATCH] Add zShop integration --- build.gradle | 1 + .../axminions/integrations/Integrations.kt | 7 ++++++ .../integrations/prices/ZShopIntegration.kt | 22 +++++++++++++++++++ common/src/main/resources/plugin.yml | 3 ++- 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 common/src/main/kotlin/com/artillexstudios/axminions/integrations/prices/ZShopIntegration.kt diff --git a/build.gradle b/build.gradle index 0843946..07c9a5f 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/integrations/Integrations.kt b/common/src/main/kotlin/com/artillexstudios/axminions/integrations/Integrations.kt index 3c8accd..6001bc9 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/integrations/Integrations.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/integrations/Integrations.kt @@ -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)) { diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/integrations/prices/ZShopIntegration.kt b/common/src/main/kotlin/com/artillexstudios/axminions/integrations/prices/ZShopIntegration.kt new file mode 100644 index 0000000..6c88a22 --- /dev/null +++ b/common/src/main/kotlin/com/artillexstudios/axminions/integrations/prices/ZShopIntegration.kt @@ -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 + } +} \ No newline at end of file diff --git a/common/src/main/resources/plugin.yml b/common/src/main/resources/plugin.yml index 45605b5..642d2a3 100644 --- a/common/src/main/resources/plugin.yml +++ b/common/src/main/resources/plugin.yml @@ -21,4 +21,5 @@ softdepend: - PlotSquared - KGenerators - Towny - - ItemsAdder \ No newline at end of file + - ItemsAdder + - zShop \ No newline at end of file