mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-19 21:10:17 -07:00
Fixed a bug with leprechaun interface
This commit is contained in:
parent
95eb5747e1
commit
f68b626739
2 changed files with 42 additions and 0 deletions
|
|
@ -0,0 +1,34 @@
|
|||
package core.game.node.entity.skill.farming
|
||||
|
||||
import core.cache.def.impl.NPCDefinition
|
||||
import core.game.component.Component
|
||||
import core.game.content.dialogue.FacialExpression
|
||||
import core.game.interaction.OptionHandler
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.player.Player
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import core.tools.Components
|
||||
|
||||
val TL_IDS = arrayOf(3021,8000,4965)
|
||||
@Initializable
|
||||
class ToolLeprechaunHandler : OptionHandler() {
|
||||
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||
for(id in TL_IDS){
|
||||
val def = NPCDefinition.forId(id)
|
||||
def.handlers["option:exchange"] = this
|
||||
def.handlers["option:teleport"] = this
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
override fun handle(player: Player?, node: Node?, option: String?): Boolean {
|
||||
node ?: return false
|
||||
when(option){
|
||||
"exchange" -> player?.interfaceManager?.open(Component(Components.farming_tools_125))
|
||||
"teleport" -> player?.dialogueInterpreter?.sendDialogues(node.id,if(node.id == 4965) FacialExpression.FRIENDLY else FacialExpression.OLD_NORMAL, "I forgot how to do that it seems.")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -136,6 +136,10 @@ class ToolLeprechaunInterface : ComponentPlugin() {
|
|||
if(!checkMethod.invoke(player)){
|
||||
player.dialogueInterpreter.sendDialogue("You don't have any of those stored.")
|
||||
} else {
|
||||
if(!player.inventory.hasSpaceFor(Item(item))){
|
||||
player.dialogueInterpreter.sendDialogue("You don't have enough space for that.")
|
||||
return
|
||||
}
|
||||
withdrawMethod.invoke(player,false)
|
||||
player.inventory.add(Item(item))
|
||||
}
|
||||
|
|
@ -239,6 +243,10 @@ class ToolLeprechaunInterface : ComponentPlugin() {
|
|||
if(finalAmount > hasAmount){
|
||||
finalAmount = hasAmount
|
||||
}
|
||||
if(!player.inventory.hasSpaceFor(Item(item,finalAmount)) || finalAmount == 0){
|
||||
player.dialogueInterpreter.sendDialogue("You don't have enough inventory space for that.")
|
||||
return
|
||||
}
|
||||
player.inventory.add(Item(item,finalAmount))
|
||||
updateQuantityMethod.invoke(player,-finalAmount)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue