From 7dcbb3ae64419fe766b2da597d14c3f7d0a16446 Mon Sep 17 00:00:00 2001 From: TomTom <93038247+AverageGithub@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:26:07 +0100 Subject: [PATCH] Fixes --- .../axminions/listeners/MinionInventoryListener.kt | 9 +++++++-- .../axminions/listeners/MinionPlaceListener.kt | 7 +++++-- .../com/artillexstudios/axminions/minions/Minion.kt | 4 ++-- .../axminions/minions/miniontype/SellerMinionType.kt | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionInventoryListener.kt b/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionInventoryListener.kt index 608651a..86342ed 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionInventoryListener.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionInventoryListener.kt @@ -181,14 +181,19 @@ class MinionInventoryListener : Listener { return } + val chargeSeconds = (minion.getCharge() - System.currentTimeMillis()) / 1000 + + if ((Config.MAX_CHARGE() * 60) - chargeSeconds < 10) { + println("Not enough time has passed!") + return + } + AxMinionsPlugin.integrations.getEconomyIntegration()?.let { minion.getOwner()?.let { player -> it.takeBalance(player, Config.CHARGE_PRICE()) } } - val chargeSeconds = (minion.getCharge() - System.currentTimeMillis()) / 1000 - if (chargeSeconds + Config.CHARGE_AMOUNT() > Config.MAX_CHARGE() * 60L) { minion.setCharge(System.currentTimeMillis() + Config.MAX_CHARGE() * 60L * 1000L) return diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionPlaceListener.kt b/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionPlaceListener.kt index 9b1c501..12c01e4 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionPlaceListener.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionPlaceListener.kt @@ -13,6 +13,7 @@ import com.artillexstudios.axminions.minions.Minion import com.artillexstudios.axminions.minions.Minions import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder import org.bukkit.Material +import org.bukkit.NamespacedKey import org.bukkit.event.EventHandler import org.bukkit.event.Listener import org.bukkit.event.block.Action @@ -34,7 +35,9 @@ class MinionPlaceListener : Listener { val minionType = MinionTypes.valueOf(type) ?: return event.isCancelled = true - if (!AxMinionsPlugin.integrations.getProtectionIntegration().canBuildAt(event.player, event.clickedBlock!!.location)) { + if (!AxMinionsPlugin.integrations.getProtectionIntegration() + .canBuildAt(event.player, event.clickedBlock!!.location) + ) { if (Config.DEBUG()) { event.player.sendMessage( "Could not place due to protection hook!" @@ -93,7 +96,7 @@ class MinionPlaceListener : Listener { } return@submit } - + val locationId = AxMinionsPlugin.dataHandler.getLocationID(location) val minion = Minion( location, diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/minions/Minion.kt b/common/src/main/kotlin/com/artillexstudios/axminions/minions/Minion.kt index 8433818..4b5e4c2 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/minions/Minion.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/minions/Minion.kt @@ -636,7 +636,7 @@ class Minion( override fun damageTool(amount: Int) { if (!Config.USE_DURABILITY()) return - if (notDurable.contains(tool?.type)) { + if (notDurable.contains(tool?.type) && !(tool?.type?.isAir ?: return)) { return } @@ -686,7 +686,7 @@ class Minion( } override fun canUseTool(): Boolean { - if (notDurable.contains(tool?.type)) { + if (notDurable.contains(tool?.type) && !(tool?.type?.isAir ?: return false)) { return true } diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/SellerMinionType.kt b/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/SellerMinionType.kt index 4b17e9c..1c2d2c6 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/SellerMinionType.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/SellerMinionType.kt @@ -66,7 +66,7 @@ class SellerMinionType : MinionType("seller", AxMinionsPlugin.INSTANCE.getResour var price = AxMinionsPlugin.integrations.getPricesIntegration()!!.getPrice(it) - if (price == -1.0) { + if (price <= 0) { if (getConfig().get("delete-unsellable")) { it.amount = 0 }