Improved battlestaff crafting

This commit is contained in:
Syndromeramo
2025-08-18 10:46:07 +00:00
committed by Ryan
parent 1ebbed5453
commit d99e6b2541
@@ -17,6 +17,10 @@ class BattlestaffListener : InteractionListener {
onUseWith(IntType.ITEM, orbs, battlestaff) { player, used, with -> onUseWith(IntType.ITEM, orbs, battlestaff) { player, used, with ->
val product = BattlestaffProduct.productMap[used.id] ?: return@onUseWith true val product = BattlestaffProduct.productMap[used.id] ?: return@onUseWith true
fun getMaxAmount(_unused: Int = 0): Int {
return min(amountInInventory(player, with.id), amountInInventory(player, used.id))
}
if (!hasLevelDyn(player, Skills.CRAFTING, product.minimumLevel)) { if (!hasLevelDyn(player, Skills.CRAFTING, product.minimumLevel)) {
sendMessage(player, "You need a Crafting level of ${product.minimumLevel} to make this.") sendMessage(player, "You need a Crafting level of ${product.minimumLevel} to make this.")
return@onUseWith true return@onUseWith true
@@ -41,7 +45,7 @@ class BattlestaffListener : InteractionListener {
withItems(product.producedItemId) withItems(product.producedItemId)
create { _, amount -> create { _, amount ->
runTask(player, 2, amount) { runTask(player, 2, min(amount, getMaxAmount())) {
if (amount < 1) return@runTask if (amount < 1) return@runTask
if (removeItem(player, product.requiredOrbItemId) && removeItem(player, Items.BATTLESTAFF_1391)) { if (removeItem(player, product.requiredOrbItemId) && removeItem(player, Items.BATTLESTAFF_1391)) {
@@ -55,9 +59,7 @@ class BattlestaffListener : InteractionListener {
} }
} }
calculateMaxAmount { _ -> calculateMaxAmount(::getMaxAmount)
min(amountInInventory(player, with.id), amountInInventory(player, used.id))
}
} }
return@onUseWith true return@onUseWith true