This commit is contained in:
TomTom 2024-05-27 15:39:05 +02:00
parent 06970c95d3
commit 3e6b86d7df
3 changed files with 51 additions and 29 deletions

View File

@ -196,13 +196,6 @@ class MinionInventoryListener : Listener {
} }
"charge" -> { "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 val chargeSeconds = (minion.getCharge() - System.currentTimeMillis()) / 1000
if ((Config.MAX_CHARGE() * 60) - chargeSeconds < Config.MINIMUM_CHARGE()) { 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 return
} }
if (!itemCharge) { 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 { AxMinionsPlugin.integrations.getEconomyIntegration()?.let {
minion.getOwner()?.let { player -> minion.getOwner()?.let { player ->
it.takeBalance(player, Config.CHARGE_PRICE()) it.takeBalance(player, Config.CHARGE_PRICE())

View File

@ -19,6 +19,7 @@ import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors import java.util.concurrent.Executors
import kotlin.math.roundToInt import kotlin.math.roundToInt
import me.kryniowesegryderiusz.kgenerators.Main import me.kryniowesegryderiusz.kgenerators.Main
import me.kryniowesegryderiusz.kgenerators.generators.locations.handlers.enums.InteractionType
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.Material import org.bukkit.Material
import org.bukkit.block.BlockFace import org.bukkit.block.BlockFace
@ -98,11 +99,15 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource
.isChunkFullyLoaded(location) .isChunkFullyLoaded(location)
) { ) {
val gen = Main.getPlacedGenerators().getLoaded(location) val gen = Main.getPlacedGenerators().getLoaded(location)
val possible = gen?.isBlockPossibleToMine(location) ?: false if (gen != null) {
val possible = gen.isBlockPossibleToMine(location)
if (possible) { if (possible) {
gen?.scheduleGeneratorRegeneration() gen.scheduleGeneratorRegeneration()
return@fastFor return@fastFor
} else {
return@fastFor
}
} }
} }
@ -142,11 +147,15 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource
.isChunkFullyLoaded(location) .isChunkFullyLoaded(location)
) { ) {
val gen = Main.getPlacedGenerators().getLoaded(location) val gen = Main.getPlacedGenerators().getLoaded(location)
val possible = gen?.isBlockPossibleToMine(location) ?: false if (gen != null) {
val possible = gen.isBlockPossibleToMine(location)
if (possible) { if (possible) {
gen?.scheduleGeneratorRegeneration() gen.scheduleGeneratorRegeneration()
return@fastFor return@fastFor
} else {
return@fastFor
}
} }
} }
@ -181,11 +190,15 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource
.isChunkFullyLoaded(location) .isChunkFullyLoaded(location)
) { ) {
val gen = Main.getPlacedGenerators().getLoaded(location) val gen = Main.getPlacedGenerators().getLoaded(location)
val possible = gen?.isBlockPossibleToMine(location) ?: false if (gen != null) {
val possible = gen.isBlockPossibleToMine(location)
if (possible) { if (possible) {
gen?.scheduleGeneratorRegeneration() gen.scheduleGeneratorRegeneration()
return@fastFor return@fastFor
} else {
return@fastFor
}
} }
} }
@ -220,11 +233,15 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource
.isChunkFullyLoaded(location) .isChunkFullyLoaded(location)
) { ) {
val gen = Main.getPlacedGenerators().getLoaded(location) val gen = Main.getPlacedGenerators().getLoaded(location)
val possible = gen?.isBlockPossibleToMine(location) ?: false if (gen != null) {
val possible = gen.isBlockPossibleToMine(location)
if (possible) { if (possible) {
gen?.scheduleGeneratorRegeneration() gen.scheduleGeneratorRegeneration()
return@fastFor return@fastFor
} else {
return@fastFor
}
} }
} }
@ -259,11 +276,15 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource
.isChunkFullyLoaded(location) .isChunkFullyLoaded(location)
) { ) {
val gen = Main.getPlacedGenerators().getLoaded(location) val gen = Main.getPlacedGenerators().getLoaded(location)
val possible = gen?.isBlockPossibleToMine(location) ?: false if (gen != null) {
val possible = gen.isBlockPossibleToMine(location)
if (possible) { if (possible) {
gen?.scheduleGeneratorRegeneration() gen.scheduleGeneratorRegeneration()
return@fastFor return@fastFor
} else {
return@fastFor
}
} }
} }

View File

@ -134,4 +134,4 @@ gui:
debug: false debug: false
# Do not change! # Do not change!
config-version: 9 config-version: 10