There's probably a way better and fancier way to do this, but was quick and hopefully some people find it useful.
Currently has 3 locations, add others if you wish.
in io.ruin.model.map.object.actions.impl create a package named fossilisland, inside the package, Rowboat.Java:
Code:
package io.ruin.model.map.object.actions.impl.fossilisland;
import io.ruin.model.map.object.actions.ObjectAction;
import io.ruin.model.entity.player.Player;
import io.ruin.model.inter.dialogue.OptionsDialogue;
import io.ruin.model.inter.utils.Option;
import io.ruin.model.map.object.GameObject;
/**
* @author Rowley - https://www.rune-server.ee/members/322493-rowley/
*/
public class Rowboat {
enum Boat {
BOAT1 ("Island",3768, 3898, 0),
BOAT2 ("Northern Shore", 3734, 3893, 0),
BOAT3 ("Camp",3724, 3807, 0);
private final String name;
private final int x, y, z;
Boat(String name, int x, int y, int z) {
this.name = name;
this.x = x;
this.y = y;
this.z = z;
}
}
static {
ObjectAction.register(30915, "travel", Rowboat::fromNorthernShore);
ObjectAction.register(30914, "travel", Rowboat::fromCamp);
ObjectAction.register(30919, "travel", Rowboat::fromIsland);
}
private static void fromCamp(Player player, GameObject boat) {
handleDialogue(player, Boat.BOAT1, Boat.BOAT2);
}
private static void fromIsland(Player player, GameObject boat) {
handleDialogue(player, Boat.BOAT3, Boat.BOAT2);
}
private static void fromNorthernShore(Player player, GameObject boat) {
handleDialogue(player, Boat.BOAT3, Boat.BOAT1);
}
private static void handleDialogue(Player player, Boat... options) {
Option[] dialogueOptions = new Option[options.length + 1];
for (int i = 0; i < options.length; i++) {
Boat option = options[i];
dialogueOptions[i] = new Option(option.name, () -> teleport(player, option));
}
dialogueOptions[options.length] = new Option("Nowhere");
player.dialogue(new OptionsDialogue("Where would you like to travel?", dialogueOptions));
}
private static void teleport(Player player, Boat destination) {
player.startEvent(e -> {
player.lock();
player.getPacketSender().fadeOut();
e.delay(2);
player.getMovement().teleport(destination.x, destination.y, destination.z);
e.delay(2);
player.getPacketSender().fadeIn();
player.unlock();
});
}
}
Specifically written on Kronos, cheers!