GatheringSkillOptionPlugin.java -> GatheringSkillOptionPlugin.kt

added Kjallak handling for chopping trees on Etceteria
This commit is contained in:
Ceikry 2021-03-12 23:57:34 -06:00
parent ac2ee13889
commit 6f23a5ed2f
3 changed files with 41 additions and 39 deletions

View file

@ -1,39 +0,0 @@
package core.game.node.entity.skill.gather;
import core.cache.def.impl.ObjectDefinition;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
import core.game.node.entity.player.Player;
import core.game.node.entity.skill.gather.woodcutting.WoodcuttingSkillPulse;
import core.plugin.Initializable;
import core.plugin.Plugin;
import rs09.game.node.entity.skill.gather.mining.MiningSkillPulse;
/**
* Handles the gathering skill option handler plugin.
* @author Emperor
* @version 1.0
*/
@Initializable
public final class GatheringSkillOptionPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ObjectDefinition.setOptionHandler("chop-down", this);
ObjectDefinition.setOptionHandler("chop down", this);
ObjectDefinition.setOptionHandler("cut down", this);
ObjectDefinition.setOptionHandler("mine", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
if(option.equals("mine")){
player.getPulseManager().run(new MiningSkillPulse(player, node.asObject()));
} else {
player.getPulseManager().run(new WoodcuttingSkillPulse(player, node.asObject()));
}
return true;
}
}

View file

@ -0,0 +1,12 @@
package rs09.game.content.dialogue
import rs09.tools.END_DIALOGUE
class KjallakOnChopDialogue : DialogueFile() {
override fun handle(componentID: Int, buttonID: Int) {
when(stage){
0 -> npc("Hey! You're not allowed to chop those!").also { stage++ }
1 -> player("Oh, ok...").also { stage = END_DIALOGUE }
}
}
}

View file

@ -0,0 +1,29 @@
package rs09.game.node.entity.skill.gather
import core.game.node.entity.npc.NPC
import core.game.node.entity.skill.gather.woodcutting.WoodcuttingSkillPulse
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.KjallakOnChopDialogue
import rs09.game.interaction.InteractionListener
import rs09.game.node.entity.skill.gather.mining.MiningSkillPulse
class GatheringSkillOptionPlugin : InteractionListener() {
val ETCETERIA_REGION = 10300
override fun defineListeners() {
on(OBJECT,"chop-down","chop down","cut down"){player,node ->
if(player.location.regionId == ETCETERIA_REGION){
player.dialogueInterpreter.open(KjallakOnChopDialogue(), NPC(NPCs.CARPENTER_KJALLAK_3916))
return@on true
}
player.pulseManager.run(WoodcuttingSkillPulse(player, node.asObject()))
return@on true
}
on(OBJECT,"mine"){player,node ->
player.pulseManager.run(MiningSkillPulse(player, node.asObject()))
return@on true
}
}
}