Bloated toads no longer bankable

Implemented releasing bloated toads
Updated ContentAPI slightly so that removeAll has more similarity to removeItem function and can be called in the same way
This commit is contained in:
Byte 2022-09-17 05:22:46 +00:00 committed by Ryan
parent 338bf3ab70
commit a9fd970e06
3 changed files with 16 additions and 2 deletions

View file

@ -30667,6 +30667,7 @@
"id": "2874"
},
{
"bankable": "false",
"examine": "An inflated toad.",
"durability": null,
"name": "Bloated toad",

View file

@ -1122,14 +1122,15 @@ fun adjustLevel(entity: Entity, skill: Int, amount: Int) {
* @param item the item to remove. Can be an Item object or an ID.
* @param container the Container to remove the item from. An enum exists for this called Container. Ex: Container.BANK
*/
fun <T> removeAll(player: Player, item: T, container: Container) {
fun <T> removeAll(player: Player, item: T, container: Container = Container.INVENTORY): Boolean {
item ?: return false
val it = when (item) {
is Item -> item.id
is Int -> item
else -> throw IllegalStateException("Invalid value passed as item")
}
when (container) {
return when (container) {
Container.EQUIPMENT -> player.equipment.remove(Item(it, amountInEquipment(player, it)))
Container.BANK -> {
val amountInPrimary = amountInBank(player, it, false)

View file

@ -150,5 +150,17 @@ class BloatedToadListeners : InteractionListener, StartupListener, Commands {
}
return@on true
}
on(Items.BLOATED_TOAD_2875, ITEM, "release") { player, used ->
removeItem(player, used.asItem())
sendPlayerDialogue(player, "Free the fat toadsies!")
return@on true
}
on(Items.BLOATED_TOAD_2875, ITEM, "release all") { player, used ->
removeAll(player, used.asItem())
sendPlayerDialogue(player, "Free the fat toadsies!")
return@on true
}
}
}