From 3e6b86d7dfc748d1c6e8dd790fb1ee2a14186e71 Mon Sep 17 00:00:00 2001 From: TomTom <93038247+AverageGithub@users.noreply.github.com> Date: Mon, 27 May 2024 15:39:05 +0200 Subject: [PATCH] Fixes --- .../listeners/MinionInventoryListener.kt | 17 +++--- .../minions/miniontype/MinerMinionType.kt | 61 +++++++++++++------ common/src/main/resources/config.yml | 2 +- 3 files changed, 51 insertions(+), 29 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 01303f5..29bc8da 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionInventoryListener.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionInventoryListener.kt @@ -196,13 +196,6 @@ class MinionInventoryListener : Listener { } "charge" -> { - if ((AxMinionsPlugin.integrations.getEconomyIntegration()?.getBalance(player) - ?: return) < Config.CHARGE_PRICE() - ) { - player.sendMessage(StringUtils.formatToString(Messages.PREFIX() + Messages.CHARGE_FAIL())) - return - } - val chargeSeconds = (minion.getCharge() - System.currentTimeMillis()) / 1000 if ((Config.MAX_CHARGE() * 60) - chargeSeconds < Config.MINIMUM_CHARGE()) { @@ -224,11 +217,19 @@ class MinionInventoryListener : Listener { } } - if (Config.CHARGE_PRICE() <= 0) { + if (Config.CHARGE_PRICE() <= 0 && !itemCharge) { + player.sendMessage(StringUtils.formatToString(Messages.PREFIX() + Messages.CHARGE_FAIL())) return } if (!itemCharge) { + if ((AxMinionsPlugin.integrations.getEconomyIntegration()?.getBalance(player) + ?: return) < Config.CHARGE_PRICE() + ) { + player.sendMessage(StringUtils.formatToString(Messages.PREFIX() + Messages.CHARGE_FAIL())) + return + } + AxMinionsPlugin.integrations.getEconomyIntegration()?.let { minion.getOwner()?.let { player -> it.takeBalance(player, Config.CHARGE_PRICE()) diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/MinerMinionType.kt b/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/MinerMinionType.kt index cc51709..848fa03 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/MinerMinionType.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/MinerMinionType.kt @@ -19,6 +19,7 @@ import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import kotlin.math.roundToInt import me.kryniowesegryderiusz.kgenerators.Main +import me.kryniowesegryderiusz.kgenerators.generators.locations.handlers.enums.InteractionType import org.bukkit.Bukkit import org.bukkit.Material import org.bukkit.block.BlockFace @@ -98,11 +99,15 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource .isChunkFullyLoaded(location) ) { val gen = Main.getPlacedGenerators().getLoaded(location) - val possible = gen?.isBlockPossibleToMine(location) ?: false + if (gen != null) { + val possible = gen.isBlockPossibleToMine(location) - if (possible) { - gen?.scheduleGeneratorRegeneration() - return@fastFor + if (possible) { + gen.scheduleGeneratorRegeneration() + return@fastFor + } else { + return@fastFor + } } } @@ -142,11 +147,15 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource .isChunkFullyLoaded(location) ) { val gen = Main.getPlacedGenerators().getLoaded(location) - val possible = gen?.isBlockPossibleToMine(location) ?: false + if (gen != null) { + val possible = gen.isBlockPossibleToMine(location) - if (possible) { - gen?.scheduleGeneratorRegeneration() - return@fastFor + if (possible) { + gen.scheduleGeneratorRegeneration() + return@fastFor + } else { + return@fastFor + } } } @@ -181,11 +190,15 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource .isChunkFullyLoaded(location) ) { val gen = Main.getPlacedGenerators().getLoaded(location) - val possible = gen?.isBlockPossibleToMine(location) ?: false + if (gen != null) { + val possible = gen.isBlockPossibleToMine(location) - if (possible) { - gen?.scheduleGeneratorRegeneration() - return@fastFor + if (possible) { + gen.scheduleGeneratorRegeneration() + return@fastFor + } else { + return@fastFor + } } } @@ -220,11 +233,15 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource .isChunkFullyLoaded(location) ) { val gen = Main.getPlacedGenerators().getLoaded(location) - val possible = gen?.isBlockPossibleToMine(location) ?: false + if (gen != null) { + val possible = gen.isBlockPossibleToMine(location) - if (possible) { - gen?.scheduleGeneratorRegeneration() - return@fastFor + if (possible) { + gen.scheduleGeneratorRegeneration() + return@fastFor + } else { + return@fastFor + } } } @@ -259,11 +276,15 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource .isChunkFullyLoaded(location) ) { val gen = Main.getPlacedGenerators().getLoaded(location) - val possible = gen?.isBlockPossibleToMine(location) ?: false + if (gen != null) { + val possible = gen.isBlockPossibleToMine(location) - if (possible) { - gen?.scheduleGeneratorRegeneration() - return@fastFor + if (possible) { + gen.scheduleGeneratorRegeneration() + return@fastFor + } else { + return@fastFor + } } } diff --git a/common/src/main/resources/config.yml b/common/src/main/resources/config.yml index a2bd36b..b2760a8 100644 --- a/common/src/main/resources/config.yml +++ b/common/src/main/resources/config.yml @@ -134,4 +134,4 @@ gui: debug: false # Do not change! -config-version: 9 +config-version: 10