This commit is contained in:
TomTom 2024-03-20 14:26:07 +01:00
parent 810bf22bb2
commit 7dcbb3ae64
4 changed files with 15 additions and 7 deletions

View File

@ -181,14 +181,19 @@ class MinionInventoryListener : Listener {
return 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 { AxMinionsPlugin.integrations.getEconomyIntegration()?.let {
minion.getOwner()?.let { player -> minion.getOwner()?.let { player ->
it.takeBalance(player, Config.CHARGE_PRICE()) it.takeBalance(player, Config.CHARGE_PRICE())
} }
} }
val chargeSeconds = (minion.getCharge() - System.currentTimeMillis()) / 1000
if (chargeSeconds + Config.CHARGE_AMOUNT() > Config.MAX_CHARGE() * 60L) { if (chargeSeconds + Config.CHARGE_AMOUNT() > Config.MAX_CHARGE() * 60L) {
minion.setCharge(System.currentTimeMillis() + Config.MAX_CHARGE() * 60L * 1000L) minion.setCharge(System.currentTimeMillis() + Config.MAX_CHARGE() * 60L * 1000L)
return return

View File

@ -13,6 +13,7 @@ import com.artillexstudios.axminions.minions.Minion
import com.artillexstudios.axminions.minions.Minions import com.artillexstudios.axminions.minions.Minions
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder
import org.bukkit.Material import org.bukkit.Material
import org.bukkit.NamespacedKey
import org.bukkit.event.EventHandler import org.bukkit.event.EventHandler
import org.bukkit.event.Listener import org.bukkit.event.Listener
import org.bukkit.event.block.Action import org.bukkit.event.block.Action
@ -34,7 +35,9 @@ class MinionPlaceListener : Listener {
val minionType = MinionTypes.valueOf(type) ?: return val minionType = MinionTypes.valueOf(type) ?: return
event.isCancelled = true 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()) { if (Config.DEBUG()) {
event.player.sendMessage( event.player.sendMessage(
"Could not place due to protection hook!" "Could not place due to protection hook!"
@ -93,7 +96,7 @@ class MinionPlaceListener : Listener {
} }
return@submit return@submit
} }
val locationId = AxMinionsPlugin.dataHandler.getLocationID(location) val locationId = AxMinionsPlugin.dataHandler.getLocationID(location)
val minion = Minion( val minion = Minion(
location, location,

View File

@ -636,7 +636,7 @@ class Minion(
override fun damageTool(amount: Int) { override fun damageTool(amount: Int) {
if (!Config.USE_DURABILITY()) return if (!Config.USE_DURABILITY()) return
if (notDurable.contains(tool?.type)) { if (notDurable.contains(tool?.type) && !(tool?.type?.isAir ?: return)) {
return return
} }
@ -686,7 +686,7 @@ class Minion(
} }
override fun canUseTool(): Boolean { override fun canUseTool(): Boolean {
if (notDurable.contains(tool?.type)) { if (notDurable.contains(tool?.type) && !(tool?.type?.isAir ?: return false)) {
return true return true
} }

View File

@ -66,7 +66,7 @@ class SellerMinionType : MinionType("seller", AxMinionsPlugin.INSTANCE.getResour
var price = AxMinionsPlugin.integrations.getPricesIntegration()!!.getPrice(it) var price = AxMinionsPlugin.integrations.getPricesIntegration()!!.getPrice(it)
if (price == -1.0) { if (price <= 0) {
if (getConfig().get("delete-unsellable")) { if (getConfig().get("delete-unsellable")) {
it.amount = 0 it.amount = 0
} }