31 private final Runnable onDestination;
36 this.position = position;
38 this.onDestination = onDestination;
42 protected void onSchedule() {
43 if (
getMob().isPlayer() &&
getMob().getPlayer().isTeleblocked()) {
45 getMob().getPlayer().message(
"You are currently under the affects of a teleblock spell and can not teleport!");
59 if (type != TeleportationData.TABLET)
64 private boolean valid(Action<Mob> action) {
65 if (type == TeleportationData.HOME && action.getMob().getCombat().inCombat()) {
66 if (action.getMob().isPlayer()) {
67 action.getMob().getPlayer().send(
new SendMessage(
"You can't teleport home while in combat!"));
76 if (type != TeleportationData.HOME)
77 action.getMob().inTeleport =
true;
79 action.setDelay(type.getDelay());
80 action.getMob().movement.reset();
81 type.getStartAnimation().ifPresent(action.getMob()::animate);
82 type.getStartGraphic().ifPresent(action.getMob()::graphic);
84 if (type.lockMovement()) {
85 action.getMob().locking.lock();
88 if (type == TeleportationData.TABLET) {
89 addFirst(this::startTablet);
94 action.setDelay(type.getDelay());
95 type.getEndAnimation().ifPresent(action.getMob()::animate);
101 action.getMob().move(position);
102 action.getMob().inTeleport =
true;
103 action.getMob().teleporting =
true;
105 if (action.getMob().isPlayer()) {
106 action.getMob().getPlayer().send(
new SendString(
"[CLOSE_MENU]", 0));
115 type.getEndGraphic().ifPresent(action.getMob()::graphic);
116 type.getEndAnimation().ifPresent(action.getMob()::animate);
118 if (type.getEndAnimation().isPresent() || type.getEndGraphic().isPresent()) {
119 action.setDelay(type.getDelay());
123 action.getMob().onStep();
126 action.getMob().updateFlags.add(UpdateFlag.APPEARANCE);
130 action.getMob().inTeleport =
false;
135 protected void onCancel(
boolean logout) {
136 getMob().animate(Animation.RESET,
true);
137 getMob().graphic(Graphic.RESET,
true);
138 getMob().inTeleport =
false;
139 getMob().teleporting =
false;
141 if (type == TeleportationData.TABLET) {
142 getMob().getPlayer().pvpInstance =
false;
143 getMob().instance = Mob.DEFAULT_INSTANCE;
144 if (
getMob().getPlayer().pet !=
null) {
152 return "teleport_action";