RuneHive-Game
Loading...
Searching...
No Matches
Waypoints.java
Go to the documentation of this file.
1package com.runehive.content;
2
3import com.runehive.game.world.entity.mob.player.Player;
4import com.runehive.game.world.position.Area;
5import com.runehive.net.packet.out.SendMessage;
6
7public class Waypoints {
8
9 public static void setWaypoint(Player player, String waypointName) {
10 if(Area.inRestrictedArea(player)) {
11 player.message("You cannot set a waypoint here");
12 return;
13 }
14 if (player.waypoints.size() >= getAllowedPoints(player)) {
15 player.message("You have reached the maximum amount of waypoints allowed for your rank.");
16 return;
17 }
18 if (player.waypoints.containsKey(waypointName)) {
19 player.message("You already have a waypoint with this name.");
20 return;
21 }
22 player.waypoints.put(waypointName, player.getPosition().copy());
23 player.dialogueFactory.sendStatement("You have set a waypoint named " + waypointName + " at your current location.").execute();
24 }
25
26 public static void removeWaypoint (Player player, String waypointName) {
27 player.waypoints.remove(waypointName);
28 player.dialogueFactory.sendStatement("You have removed " + waypointName + " from your waypoints.").execute();
29 }
30 public static void getWaypoints(Player player) {
31 if (player.waypoints.isEmpty()) {
32 player.message("You have no waypoints set.");
33 return;
34 }
35 player.message("Current waypoints:");
36 player.waypoints.forEach((k, v) -> player.message("@red@" +k));
37 }
38 private static int getAllowedPoints(Player player) {
39 return switch (player.right.getName()) {
40 case "King Donator" -> 10;
41 case "Elite Donator" -> 8;
42 case "Extreme Donator" -> 6;
43 case "Super Donator" -> 4;
44 case "Donator" -> 2;
45 default -> 5;
46 };
47 }
48
49}
static void setWaypoint(Player player, String waypointName)
Definition Waypoints.java:9
static int getAllowedPoints(Player player)
static void removeWaypoint(Player player, String waypointName)
static void getWaypoints(Player player)
final DialogueFactory execute()
Retrieves the next dialogue in the chain and executes it.
final DialogueFactory sendStatement(String... lines)
Appends a StatementDialogue to the current dialogue chain.
This class represents a character controlled by a player.
Definition Player.java:125
Handles checking if mobs are in a certain area.
Definition Area.java:13
static boolean inRestrictedArea(Mob mob)
Definition Area.java:385
Position copy()
Creates a deep copy of this location.