RuneHive-Game
Loading...
Searching...
No Matches
Teleportation.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.magic.teleport;
2
3import com.runehive.content.activity.Activity;
4import com.runehive.content.lms.LMSGame;
5import com.runehive.content.lms.lobby.LMSLobby;
6import com.runehive.game.action.impl.TeleportAction;
7import com.runehive.game.world.entity.mob.Mob;
8import com.runehive.game.world.entity.mob.data.PacketType;
9import com.runehive.game.world.entity.mob.player.Player;
10import com.runehive.game.world.entity.mob.player.PlayerRight;
11import com.runehive.game.world.position.Position;
12import com.runehive.net.packet.out.SendMessage;
13
14/**
15 * Handles a player teleporting.
16 *
17 * @author Daniel
18 */
19public class Teleportation {
20
21
22 public static void activateOverride(Mob mob, Position position, TeleportationData teleport) {
23 mob.action.execute(new TeleportAction(mob, position, teleport, () -> {}), true);
24 }
25
26 public static void activateOverride(Mob mob, Position position, TeleportationData teleport, Runnable runnable) {
27 mob.action.execute(new TeleportAction(mob, position, teleport, runnable), true);
28 }
29
30 public static boolean teleport(Player player, Position position) {
31 return teleport(player, position, 20, TeleportationData.MODERN, () -> {});
32 }
33
34 public static boolean teleport(Player player, Position position, TeleportationData teleport, Runnable runnable) {
35 return teleport(player, position, 20, teleport, runnable);
36 }
37
38 public static boolean teleport(Player player, Position position, TeleportationData teleport) {
39 return teleport(player, position, 20, teleport, () -> {});
40 }
41
42 public static boolean teleport(Player player, Position position, int wilderness) {
43 return teleport(player, position, wilderness, TeleportationData.MODERN, () -> {});
44 }
45
46 public static boolean teleport(Player player, Position position, int wilderness, Runnable runnable) {
47 return teleport(player, position, wilderness, TeleportationData.MODERN, runnable);
48 }
49
50 public static boolean teleport(Player player, Position position, int wilderness, TeleportationData teleport) {
51 return teleport(player, position, wilderness, teleport, () -> {});
52 }
53
54 public static boolean teleport(Player player, Position position, int wilderness, TeleportationData teleport, Runnable runnable) {
55 if(player.isGambleLocked()) return false;
56
57 player.interfaceManager.close(false);
58
59 if (Activity.evaluate(player, it -> !it.canTeleport(player))) {
60 return false;
61 }
62
63 if(LMSLobby.lobbyMembers.contains(player) || LMSGame.isActivePlayer(player)) {
64 return false;
65 }
66
67 if (player.locking.locked(PacketType.TELEPORT)) {
68 return false;
69 }
70
71 if (player.isTeleblocked()) {
72 player.message("You are currently under the affects of a teleblock spell and can not teleport!");
73 return false;
74 }
75
76 if (player.wilderness > wilderness && !PlayerRight.isDeveloper(player)) {
77 player.send(new SendMessage("You can't teleport past " + wilderness + " wilderness!"));
78 return false;
79 }
80
82 player.getCombat().reset();
83 player.damageImmunity.reset(3_000);
84 }
85
87 player.pvpInstance = false;
88 player.instance = Mob.DEFAULT_INSTANCE;
89 if (player.pet != null) {
90 player.pet.instance = player.instance;
91 }
92 }
93
94 player.action.execute(new TeleportAction(player, position, teleport, runnable), true);
95 return true;
96 }
97}
A Activity object constructs an in-game activity and sequences it through the start() and finish() me...
Definition Activity.java:31
static boolean evaluate(Mob mob, Predicate< Activity > predicate)
Definition Activity.java:74
static boolean isActivePlayer(Player player)
Checks if a player is a active player within the LMS game.
Definition LMSGame.java:151
static List< Player > lobbyMembers
A list with all the players in the lobby.
Definition LMSLobby.java:28
static boolean teleport(Player player, Position position, int wilderness, TeleportationData teleport)
static void activateOverride(Mob mob, Position position, TeleportationData teleport, Runnable runnable)
static boolean teleport(Player player, Position position)
static void activateOverride(Mob mob, Position position, TeleportationData teleport)
static boolean teleport(Player player, Position position, int wilderness)
static boolean teleport(Player player, Position position, int wilderness, Runnable runnable)
static boolean teleport(Player player, Position position, int wilderness, TeleportationData teleport, Runnable runnable)
static boolean teleport(Player player, Position position, TeleportationData teleport, Runnable runnable)
static boolean teleport(Player player, Position position, TeleportationData teleport)
public< A extends Action<?> > void execute(A action)
Teleports an entity to another part of the world.
boolean locked()
Checks if the mob is locked.
Definition Locking.java:52
Handles the mob class.
Definition Mob.java:66
This class represents a character controlled by a player.
Definition Player.java:125
Combat< Player > getCombat()
The combat of the mob.
Definition Player.java:759
Represents a single tile on the game world.
Definition Position.java:14
The OutgoingPacket that sends a message to a Players chatbox in the client.
static boolean isDeveloper(Player player)
Checks if the player has developer status.