Port Herblore plugin to Kotlin

This commit is contained in:
Chivvon
2018-04-06 16:50:27 +02:00
committed by Major
parent 9c4eff712e
commit a52837975e
9 changed files with 410 additions and 0 deletions
@@ -0,0 +1,39 @@
import org.apollo.game.action.ActionBlock
import org.apollo.game.action.AsyncAction
import org.apollo.game.model.Animation
import org.apollo.game.model.entity.Player
import java.util.Objects
class CrushIngredientAction(
player: Player,
private val ingredient: CrushableIngredient
) : AsyncAction<Player>(0, true, player) {
override fun action(): ActionBlock = {
mob.playAnimation(GRINDING_ANIM)
wait(pulses = 1)
val inventory = mob.inventory
if (inventory.remove(ingredient.uncrushed)) {
inventory.add(ingredient.id)
mob.sendMessage("You carefully grind the ${ingredient.uncrushedName} to dust.")
}
stop()
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as CrushIngredientAction
return mob == other.mob && ingredient == other.ingredient
}
override fun hashCode(): Int = Objects.hash(mob, ingredient)
private companion object {
private val GRINDING_ANIM = Animation(364)
}
}