Files
2009scape/Server/src/main/content/global/skill/summoning/familiar/FamiliarNPCOptionPlugin.java
T
Ceikry a100affda2 Repository reorganisation
Unified kotlin and java into just src/main
Unified the rs09 and core packages
Took all content out of the core package, and placed it into the new content package
Reorganised all source code relating to content to be easier to find and explore
2023-01-26 13:59:28 +00:00

64 lines
1.8 KiB
Java

package content.global.skill.summoning.familiar;
import core.cache.def.impl.NPCDefinition;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
import core.game.node.entity.player.Player;
import core.game.world.update.flag.player.FaceLocationFlag;
import core.plugin.Initializable;
import core.plugin.Plugin;
/**
* Represents the class used for handling the npc options of familiars.
* @author Emperor
* @author 'Vexia
* @version 2.0
*/
@Initializable
public final class FamiliarNPCOptionPlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
NPCDefinition.setOptionHandler("pick-up", this);
NPCDefinition.setOptionHandler("interact-with", this);
NPCDefinition.setOptionHandler("interact", this);
NPCDefinition.setOptionHandler("store", this);
NPCDefinition.setOptionHandler("withdraw", this);
return this;
}
@Override
public boolean handle(final Player player, Node node, String option) {
if (!(node instanceof Familiar)) {
return false;
}
Familiar familiar = (Familiar) node;
if (familiar.getOwner() != player) {
player.getPacketDispatch().sendMessage("This is not your familiar.");
return true;
}
switch (option) {
case "pick-up":
player.faceLocation(FaceLocationFlag.getFaceLocation(player, familiar));
player.getFamiliarManager().pickup();
break;
case "interact-with":
player.getDialogueInterpreter().open(343823);
break;
case "interact":
player.getDialogueInterpreter().open(node.getId(), node);
break;
case "store":
case "withdraw":
if (!familiar.isBurdenBeast()) {
player.getPacketDispatch().sendMessage("This is not a beast of burden.");
break;
}
((BurdenBeast) familiar).openInterface();
break;
}
return true;
}
}