Try to reinforce non-nullability in xp interface callback

This commit is contained in:
ceikry
2021-08-04 17:20:17 -05:00
parent 396dd56dbe
commit 41596156a6
2 changed files with 5 additions and 6 deletions
@@ -68,19 +68,19 @@ class LarryHandler(player: Player? = null) : DialoguePlugin(player){
return true
}
override fun handleSelectionCallback(skill: Int, player: Player?) {
val points = player?.getAttribute("phns:points",0)
override fun handleSelectionCallback(skill: Int, player: Player) {
val points = player.getAttribute("phns:points",0)
if(points == 0){
player.sendMessage("Sorry, but you have no points to redeem.")
return
}
val level = player?.skills?.getLevel(skill) ?: 0
val level = player.skills.getLevel(skill) ?: 0
System.out.println("Level: $level")
val expGained = points?.toDouble()?.times((level * 25))
System.out.print("exp: $expGained")
player?.skills?.addExperience(skill,expGained!!)
player?.setAttribute("/save:phns:points",0)
player.skills.addExperience(skill,expGained!!)
player.setAttribute("/save:phns:points",0)
}
override fun getIds(): IntArray {
@@ -70,7 +70,6 @@ class ExperienceInterface() : ComponentPlugin() {
46 -> Skills.WOODCUTTING
40 -> Skills.FLETCHING
51 -> Skills.CONSTRUCTION
52 -> Skills.SUMMONING
else -> Skills.SLAYER.also { SystemLogger.logWarn("EXP_INTERFACE: Invalid SKILL CHOICE BUTTON: $button") }
}
player.setAttribute("exp_interface:skill",skill)