RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.teleport.TeleportHandler Class Reference

Handles teleporting to various locations around OS Royale. More...

Static Public Member Functions

static void click (Player player, int button)
 Handles clicking teleport buttons on the itemcontainer.
static void display (Player player, Teleport teleport)
 Displays all the teleport text on the itemcontainer.
static void favorite (Player player)
 Handles favorite a teleport.
static void open (Player player)
 Opens the teleport itemcontainer.
static void open (Player player, TeleportType type)
 Opens the teleport itemcontainer.
static void open (Player player, TeleportType type, int teleportIndex)
 Opens the teleport itemcontainer to a certain teleportNoChecks type.
static void special (Player player, Teleport teleport)
 Handles special case TELEPORT.
static void teleport (Player player)
 Handles teleporting to the destination.

Static Private Member Functions

static int getOrdinal (int button)
 Gets the ordinal of a teleport based on the list ordinal.
static List< TeleportgetTeleports (TeleportType type)
 Gets a list of teleports based off the teleport type.

Static Private Attributes

static final String[] TITLES = {"Favorites", "Minigames", "Skilling", "Monster Killing", "Player Killing", "Boss Killing"}
 Holds the teleport titles names.

Detailed Description

Handles teleporting to various locations around OS Royale.

Author
Daniel

Definition at line 25 of file TeleportHandler.java.

Member Function Documentation

◆ click()

void com.runehive.content.teleport.TeleportHandler.click ( Player player,
int button )
static

Handles clicking teleport buttons on the itemcontainer.

Definition at line 110 of file TeleportHandler.java.

110 {
111 TeleportType type = player.attributes.get("TELEPORT_TYPE_KEY", TeleportType.class);
112 List<Teleport> teleports = type == TeleportType.FAVORITES ? player.favoriteTeleport : getTeleports(type);
113 int index = getOrdinal(button);
114 player.attributes.set("TELEPORT_INDEX_KEY", index);
115 open(player, type, index);
116 if (index < teleports.size()) {
117 display(player, teleports.get(index));
118 }
119 }
final GenericAttributes attributes
Definition Mob.java:95
public< K, E > E get(K key)
Gets a generic attribute.
public< K, E > void set(K key, E attribute)
Sets a generic attribute.
val index

References com.runehive.game.world.entity.mob.Mob.attributes, display(), com.runehive.content.skill.impl.magic.teleport.TeleportType.FAVORITES, com.runehive.util.generic.GenericAttributes.get(), getOrdinal(), getTeleports(), open(), and com.runehive.util.generic.GenericAttributes.set().

Here is the call graph for this function:

◆ display()

void com.runehive.content.teleport.TeleportHandler.display ( Player player,
Teleport teleport )
static

Displays all the teleport text on the itemcontainer.

Definition at line 72 of file TeleportHandler.java.

72 {
73 player.attributes.set("TELEPORT", teleport);
74 player.send(new SendConfig(348, player.favoriteTeleport.contains(teleport) ? 0 : 1));
75
76 if (teleport != null) {
77 Item items[] = new Item[3];
78 for (int index = 0, count = 0; index < teleport.getDisplay().length; index++, count++) {
79 if (teleport.getDisplay()[index] == -1) {
80 items[count] = null;
81 continue;
82 }
83 Item item = new Item(teleport.getDisplay()[index]);
84 if (item.isStackable())
85 item.setAmount(50000);
86 items[count] = item;
87 }
88 player.send(new SendItemOnInterface(58041, items));
89 }
90
91 if (teleport != null && teleport.getStrings()[0].length() == 0 && teleport.getStrings()[1].length() == 0) {
92 player.send(new SendString(teleport.getName(), 58031));
93 player.send(new SendString("", 58032));
94 player.send(new SendString("", 58033));
95 return;
96 } else if (teleport == null) {
97 player.send(new SendString("", 58031));
98 player.send(new SendString("You do not have any teleport selected", 58032));
99 player.send(new SendString("", 58033));
100 player.send(new SendItemOnInterface(58041));
101 return;
102 }
103
104 player.send(new SendString(teleport.getName(), 58031));
105 player.send(new SendString("<col=ff7000>" + teleport.getStrings()[0], 58032));
106 player.send(new SendString("<col=ff7000>" + teleport.getStrings()[1], 58033));
107 }
final void setAmount(int amount)
Sets the quantity of this item.
Definition Item.java:351

References com.runehive.game.world.entity.mob.Mob.attributes, com.runehive.game.world.entity.mob.player.Player.favoriteTeleport, com.runehive.game.world.items.Item.isStackable(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.util.generic.GenericAttributes.set(), com.runehive.game.world.items.Item.setAmount(), and teleport().

Referenced by click(), and open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ favorite()

void com.runehive.content.teleport.TeleportHandler.favorite ( Player player)
static

Handles favorite a teleport.

Definition at line 148 of file TeleportHandler.java.

148 {
149 Teleport teleport = player.attributes.get("TELEPORT", Teleport.class);
150 if (teleport == null) {
151 player.send(new SendMessage("You have not selected a teleport to favorite!"));
152 player.send(new SendConfig(348, 1));
153 return;
154 }
155 boolean isFavorite = player.favoriteTeleport.contains(teleport);
156 int index = player.attributes.get("TELEPORT_INDEX_KEY", Integer.class);
157 if (index == -1) {
158 index = 0;
159 }
160
161 if (isFavorite) {
162 player.favoriteTeleport.remove(teleport);
163 index = 0;
164 } else {
165 player.favoriteTeleport.add(teleport);
166 }
167
168 isFavorite = player.favoriteTeleport.contains(teleport);
169 player.send(new SendConfig(348, isFavorite ? 0 : 1));
170 player.send(new SendMessage("You have " + (isFavorite ? "" : "un-") + "favorited the " + teleport.getName() + " teleport."));
171 TeleportType type = player.attributes.get("TELEPORT_TYPE_KEY", TeleportType.class);
172 open(player, type, index);
173 }

References com.runehive.game.world.entity.mob.Mob.attributes, com.runehive.game.world.entity.mob.player.Player.favoriteTeleport, com.runehive.util.generic.GenericAttributes.get(), open(), com.runehive.game.world.entity.mob.player.Player.send(), and teleport().

Referenced by open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOrdinal()

int com.runehive.content.teleport.TeleportHandler.getOrdinal ( int button)
staticprivate

Gets the ordinal of a teleport based on the list ordinal.

Definition at line 318 of file TeleportHandler.java.

318 {
319 int base_button = -7484;
320 int ordinal = Math.abs((base_button - button) / 2);
321 return ordinal;
322 }

Referenced by click().

Here is the caller graph for this function:

◆ getTeleports()

List< Teleport > com.runehive.content.teleport.TeleportHandler.getTeleports ( TeleportType type)
staticprivate

Gets a list of teleports based off the teleport type.

Definition at line 309 of file TeleportHandler.java.

309 {
310 List<Teleport> list = new ArrayList<>();
311 for (Teleport t : Teleport.values()) {
312 if (t.getType() == type) list.add(t);
313 }
314 return list;
315 }

Referenced by click(), and open().

Here is the caller graph for this function:

◆ open() [1/3]

void com.runehive.content.teleport.TeleportHandler.open ( Player player)
static

Opens the teleport itemcontainer.

Definition at line 31 of file TeleportHandler.java.

31 {
32 open(player, TeleportType.FAVORITES, 0);
33 }

References com.runehive.content.skill.impl.magic.teleport.TeleportType.FAVORITES, and open().

Referenced by click(), com.runehive.game.action.impl.TutorialActivity.clickButton(), favorite(), open(), and open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ open() [2/3]

void com.runehive.content.teleport.TeleportHandler.open ( Player player,
TeleportType type )
static

Opens the teleport itemcontainer.

Definition at line 36 of file TeleportHandler.java.

36 {
37 open(player, type, 0);
38 }

References open().

Here is the call graph for this function:

◆ open() [3/3]

void com.runehive.content.teleport.TeleportHandler.open ( Player player,
TeleportType type,
int teleportIndex )
static

Opens the teleport itemcontainer to a certain teleportNoChecks type.

Definition at line 41 of file TeleportHandler.java.

41 {
42 List<Teleport> teleports = type == TeleportType.FAVORITES ? player.favoriteTeleport : getTeleports(type);
43 player.attributes.set("TELEPORT_TYPE_KEY", type);
44 if (player.attributes.get("TELEPORT_INDEX_KEY", Integer.class) == null)
45 player.attributes.set("TELEPORT_INDEX_KEY", 0);
46 int size = teleports.size();
47 for (int index = 0, string = 58009; index < 6; index++) {
48 String color = "<col=" + (type.ordinal() == index ? "ffffff" : "ff9933") + ">";
49 player.send(new SendString(color + TITLES[index], string));
50 string += 4;
51 }
52 for (int index = 0, string = 58052; index < (size < 9 ? 9 : size); index++, string += 2) {
53 if (index >= size) {
54 player.send(new SendString("", string));
55 continue;
56 }
57 Teleport teleport = teleports.get(index);
58 String prefex = teleportIndex == index ? "<col=ffffff>" : "</col>";
59 String favorite = player.favoriteTeleport.contains(teleport) ? "<clan=6> " : "";
60 player.send(new SendString(favorite + prefex + teleport.getName(), string));
61 }
62 if (type == TeleportType.FAVORITES && player.favoriteTeleport.isEmpty()) {
63 display(player, null);
64 } else {
65 display(player, teleports.get(teleportIndex));
66 }
67 player.send(new SendScrollbar(58050, size <= 9 ? 225 : (size * 25)));
68 player.interfaceManager.open(58000);
69 }
void open(int identification)
Opens an interface for the player.

References com.runehive.game.world.entity.mob.Mob.attributes, display(), favorite(), com.runehive.content.skill.impl.magic.teleport.TeleportType.FAVORITES, com.runehive.game.world.entity.mob.player.Player.favoriteTeleport, com.runehive.util.generic.GenericAttributes.get(), getTeleports(), com.runehive.game.world.entity.mob.player.Player.interfaceManager, com.runehive.game.world.entity.mob.player.InterfaceManager.open(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.util.generic.GenericAttributes.set(), teleport(), and TITLES.

Here is the call graph for this function:

◆ special()

void com.runehive.content.teleport.TeleportHandler.special ( Player player,
Teleport teleport )
static

Handles special case TELEPORT.

Definition at line 176 of file TeleportHandler.java.

176 {
177 //TODO : Add birdhouse teleports. (https://oldschool.runescape.wiki/w/Bird_house_trapping#Locations) - Add teleport to fossil island tree, have tree display tele options.
178 if (player.isTeleblocked()) {
179 player.message("You are currently under the affects of a teleblock spell and can not teleport!");
180 return;
181 }
182
183 DialogueFactory factory = player.dialogueFactory;
184
185 switch (teleport) {
186 case FARMING:
187 factory.sendOption("Catherby", () -> {
188 Teleportation.teleport(player, new Position(2805, 3464, 0));
189 player.message(true, "You have teleported to the Catherby farming area.");
190 }, "Ardougne", () -> {
191 Teleportation.teleport(player, new Position(2662, 3375, 0));
192 player.message(true, "You have teleported to the Ardougne farming area.");
193 }, "Falador", () -> {
194 Teleportation.teleport(player, new Position(3056, 3310, 0));
195 player.message(true, "You have teleported to the Falador farming area.");
196 }, "Phasmatys", () -> {
197 Teleportation.teleport(player, new Position(3600, 3524, 0));
198 player.message(true, "You have teleported to the Phasmatys farming area.");
199 }).execute();
200 break;
201 case AGILITY:
202 factory.sendOption("Gnome agility course (Level 1 agility req.)", () -> {
203 Teleportation.teleport(player, new Position(2480, 3437, 0));
204 player.send(new SendMessage("You have teleported to the Gnome agility course.", true));
205 }, "Barbarian agility course (Level 35 agility req.)", () -> {
206 Teleportation.teleport(player, new Position(2546, 3551, 0));
207 player.send(new SendMessage("You have teleported to the Barbarian agility course.", true));
208 }, "Wilderness agility course (Level 49 agility req.)", () -> {
209 Teleportation.teleport(player, new Position(2998, 3915, 0));
210 player.send(new SendMessage("You have teleported to the Wilderness agility course.", true));
211 }, "Rooftop courses", () -> {
212 factory.sendStatement("Loading").sendOption("Seer's Village rooftop course (Level 60 agility req.)", () -> {
213 Teleportation.teleport(player, new Position(2729, 3488, 0));
214 player.send(new SendMessage("You have teleported to the Seer's Village rooftop agility course.", true));
215 }, "Ardougne rooftop course (Level 90 agility req.)", () -> {
216 Teleportation.teleport(player, new Position(2674, 3297, 0));
217 player.send(new SendMessage("You have teleported to the Ardougne rooftop agility course.", true));
218 }).execute();
219 }, "Nevermind", factory::clear).execute();
220 break;
221 case MINING:
222 factory.sendOption("Varrock", () -> {
223 Teleportation.teleport(player, new Position(3285, 3365, 0));
224 player.send(new SendMessage("You have teleported to the varrock mining area.", true));
225 }, "Falador", () -> {
226 Teleportation.teleport(player, new Position(3044, 9785, 0));
227 player.send(new SendMessage("You have teleported to the falador mining area.", true));
228 }, "Rune Essence", () -> {
229 Teleportation.teleport(player, new Position(2910, 4832, 0));
230 player.send(new SendMessage("You have teleported to the rune essence mining area.", true));
231 }, "Shilo Village", () -> {
232 Teleportation.teleport(player, new Position(2826, 2997, 0));
233 player.send(new SendMessage("You have teleported to the shilo village mining area.", true));
234 }, "Nevermind", factory::clear).execute();
235 break;
236 case RUNECRAFTING:
237 factory.sendOption("Abyss", () -> {
238 Teleportation.teleport(player, new Position(3039, 4836, 0));
239 player.send(new SendMessage("You have teleported to the abyss area.", true));
240 }, "Astral Altar", () -> {
241 Teleportation.teleport(player, new Position(2155, 3857, 0));
242 player.send(new SendMessage("You have teleported to the astral altar.", true));
243 }, "Wrath Altar", () -> {
244 Teleportation.teleport(player, new Position(2335, 4826, 0));
245 player.send(new SendMessage("You have teleported to the wrath altar.", true));
246 }, "Ournia Altar", () -> {
247 Teleportation.teleport(player, new Position(2464, 3249, 0));
248 player.send(new SendMessage("You have teleported to the ournia altar.", true));
249 }, "Nevermind", factory::clear).execute();
250 break;
251 case WOODCUTTING:
252 factory.sendOption("Camelot", () -> {
253 Teleportation.teleport(player, new Position(2724, 3475, 0));
254 player.send(new SendMessage("You have teleported to the camelot woodcutting area.", true));
255 }, "Woodcutting Guild", () -> {
256 Teleportation.teleport(player, new Position(1587, 3488, 0));
257 player.send(new SendMessage("You have teleported to the woodcutting guild.", true));
258 }, "Nevermind", factory::clear).execute();
259 break;
260 case HUNTER:
261 factory.sendOption("Puro Puro", () -> {
262 Position[] teleports = {new Position(2619, 4292), new Position(2564, 4292), new Position(2564, 4347), new Position(2619, 4347)};
263 Teleportation.teleport(player, Utility.randomElement(teleports));
264 player.send(new SendMessage("You have teleported to the puro puro hunter area.", true));
265 }, "Nevermind", factory::clear).execute();
266 break;
267 case FISHING:
268 factory.sendOption("Catherby", () -> {
269 Teleportation.teleport(player, new Position(2809, 3435, 0));
270 player.send(new SendMessage("You have teleported to the catherby fishing area.", true));
271 }, "Fishing Guild", () -> {
272 if(player.skills.getLevel(10) >= 68) {
273 Teleportation.teleport(player, new Position(2594, 3415, 0));
274 player.send(new SendMessage("You have teleported to the fishing guild.", true));
275 } else {
276 player.send(new SendMessage("You need 68 fishing to access the fishing guild."));
277
278 }
279 }, "Nevermind", factory::clear).execute();
280 break;
281 case GODWARS:
282 Teleportation.teleport(player, new Position(2882, 5308, 2), 20, () -> GodwarsActivity.create(player));
283
284
285 /* factory.sendOption("General Graardor", () -> {
286 Teleportation.teleport(player, new Position(2864, 5354, 2));
287 player.send(new SendMessage("You have teleported to the General Graardor boss."));
288 }, "Commander Zilyana", () -> {
289 Teleportation.teleport(player, new Position(2907, 5265, 0));
290 player.send(new SendMessage("You have teleported to the Commander Zilyana boss."));
291 }, "K'ril Tsutsaroth", () -> {
292 Teleportation.teleport(player, new Position(2925, 5331, 2));
293 player.send(new SendMessage("You have teleported to the K'ril Tsutsaroth boss."));
294 }, "Kree'arra", () -> {
295 Teleportation.teleport(player, new Position(2839, 5296, 2));
296 player.send(new SendMessage("You have teleported to the Kree'arra boss."));
297 }, "Nevermind", factory::clear).execute();*/
298 break;
299 case WARRIOR_GUILD:
300 Teleportation.teleport(player, new Position(2846, 3541, 0), 20, () -> WarriorGuild.create(player));
301 break;
302 case BARROWS:
303 Teleportation.teleport(player, new Position(3565, 3315, 0), 20, () -> Barrows.create(player));
304 break;
305 }
306 }
int getLevel(int id)
Gets the level of a skill.

References com.runehive.content.activity.impl.barrows.Barrows.create(), com.runehive.content.activity.impl.godwars.GodwarsActivity.create(), com.runehive.content.activity.impl.warriorguild.WarriorGuild.create(), com.runehive.game.world.entity.mob.player.Player.dialogueFactory, com.runehive.game.world.entity.skill.SkillManager.getLevel(), com.runehive.game.world.entity.mob.player.Player.isTeleblocked(), com.runehive.game.world.entity.mob.player.Player.message(), com.runehive.util.Utility.randomElement(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.content.dialogue.DialogueFactory.sendOption(), com.runehive.content.dialogue.DialogueFactory.sendStatement(), com.runehive.game.world.entity.mob.Mob.skills, com.runehive.content.skill.impl.magic.teleport.Teleportation.teleport(), and teleport().

Referenced by teleport().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ teleport()

void com.runehive.content.teleport.TeleportHandler.teleport ( Player player)
static

Handles teleporting to the destination.

Definition at line 122 of file TeleportHandler.java.

122 {
123 if (player.wilderness > 20 && !PlayerRight.isAdministrator(player)) {
124 player.send(new SendMessage("You can't teleport past 20 wilderness!"));
125 return;
126 }
127
128
129 Teleport teleport = player.attributes.get("TELEPORT", Teleport.class);
130 if (teleport == null) {
131 player.send(new SendMessage("You have not selected a destination to teleport to!"));
132 return;
133 }
134 player.lastTeleport = teleport;
135 if (teleport.getName() == "Inferno") {
136 Inferno.create(player);
137 player.message("Welcome To Inferno " + player.getUsername());
138 }
139 if (teleport.isSpecial()) {
140 special(player, teleport);
141 return;
142 }
143 Teleportation.teleport(player, teleport.getPosition());
144 player.send(new SendMessage("You have teleported to " + teleport.getName() + ".", true));
145 }

References com.runehive.game.world.entity.mob.Mob.attributes, com.runehive.content.activity.inferno.Inferno.create(), com.runehive.util.generic.GenericAttributes.get(), com.runehive.game.world.entity.mob.player.Player.getUsername(), com.runehive.game.world.entity.mob.player.PlayerRight.isAdministrator(), com.runehive.game.world.entity.mob.player.Player.message(), com.runehive.game.world.entity.mob.player.Player.send(), special(), com.runehive.content.skill.impl.magic.teleport.Teleportation.teleport(), teleport(), and com.runehive.game.world.entity.mob.player.Player.wilderness.

Referenced by display(), favorite(), open(), special(), and teleport().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ TITLES

final String [] com.runehive.content.teleport.TeleportHandler.TITLES = {"Favorites", "Minigames", "Skilling", "Monster Killing", "Player Killing", "Boss Killing"}
staticprivate

Holds the teleport titles names.

Definition at line 28 of file TeleportHandler.java.

28{"Favorites", "Minigames", "Skilling", "Monster Killing", "Player Killing", "Boss Killing"};

Referenced by open().


The documentation for this class was generated from the following file: