Converted Seamen plugin to listener

This commit is contained in:
Sam 2023-03-03 01:28:04 +00:00 committed by Ryan
parent b6fa73d94c
commit f1e2083506
2 changed files with 15 additions and 31 deletions

View file

@ -0,0 +1,15 @@
package content.region.asgarnia.portsarim.handlers
import core.game.interaction.IntType
import core.game.interaction.InteractionListener
import core.game.node.entity.npc.NPC
class SeamanListener : InteractionListener {
override fun defineListeners() {
on(IntType.NPC, "pay-fare") { player, node ->
val npc = node as NPC
player.dialogueInterpreter.open(npc.id, npc, true)
return@on true
}
}
}

View file

@ -1,31 +0,0 @@
package content.region.asgarnia.portsarim.handlers;
import core.cache.def.impl.NPCDefinition;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.plugin.Initializable;
import core.plugin.Plugin;
/**
* Represents a plugin used to handle the pay fare option.
* @author 'Vexia
*/
@Initializable
public class SeamanPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
NPCDefinition.setOptionHandler("pay-fare", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
final NPC npc = ((NPC) node);
player.getDialogueInterpreter().open(npc.getId(), npc, true);
return true;
}
}