RuneHive-Game
Loading...
Searching...
No Matches
BloodMoneyChest.java
Go to the documentation of this file.
1package com.runehive.content.bloodmoney;
2
3import com.runehive.content.puzzle.PuzzleType;
4import com.runehive.game.world.World;
5import com.runehive.game.world.entity.mob.npc.Npc;
6import com.runehive.game.world.entity.mob.player.Player;
7import com.runehive.game.world.items.Item;
8import com.runehive.game.world.object.CustomGameObject;
9import com.runehive.util.Stopwatch;
10import com.runehive.util.Utility;
11
12/**
13 * The blood money chest manager.
14 *
15 * @author Daniel
16 */
17public class BloodMoneyChest {
18 /** The state of the blood money chest. */
19 public static boolean active;
20
21 /** The current blood money chest viewer. */
22 private static Player viewer;
23
24 /** The blood money chest object. */
25 public static CustomGameObject chest;
26
27 /** The guardian npc. */
28 public static Npc guardian;
29
30 /** Blood chest position. */
31 public static BloodMoneyPosition data;
32
33 /** The stopwatch for this event. */
34 public static final Stopwatch stopwatch = Stopwatch.start();
35
36 /** Handles spawning the blood money chest. */
37 public static void spawn() {
39
40 chest = new CustomGameObject(27290, data.position);
41 chest.rotate(data.direction);
42 chest.register();
43
44 guardian = new Npc(8066, data.position);
45 guardian.boundaries = Utility.getInnerBoundaries(data.position, 5, 5);
46 guardian.walkingRadius = 3;
47 guardian.register();
48
49 active = true;
50
51 World.sendMessage("<icon=0><col=FF0000> Blood money chest has spawned at: " + data.name + ".");
52 // DiscordPlugin.sendSimpleMessage("Blood money chest has spawned at " + data.name + "!");
53 }
54
55 /** Handles finishing the blood money chet. */
56 public static void finish(boolean unlocked) {
57 active = false;
58 chest.unregister();
59 if (guardian != null && guardian.isRegistered()) {
60 guardian.unregister();
61 }
62
63 if (viewer != null) {
64 if (unlocked) {
65 World.sendMessage("<icon=0><col=FF0000> Blood money chest was unlocked by " + viewer.getName() + "!");
66 // DiscordPlugin.sendSimpleMessage("Blood money chest has been unlocked by " + viewer.getName() + "!");
67 viewer.inventory.addOrDrop(new Item(20608));
68 }
69
70 viewer.interfaceManager.close(4543);
71 viewer = null;
72 return;
73 }
74 World.sendMessage("<icon=0><col=FF0000> Blood money chest has vanished!");
75 }
76
77 /** Handles opening the blood money chest. */
78 public static void open(Player player) {
79 if (guardian != null) {
80 player.dialogueFactory.sendStatement("The stone guardian must be killed!").execute();
81 return;
82 }
83
84 if (viewer != null) {
85 if (!viewer.interfaceManager.isInterfaceOpen(4543)) {
86 viewer = null;
87 } else {
88 player.dialogueFactory.sendStatement("There is already someone unlocking the chest!").execute();
89 return;
90 }
91 }
92
93 viewer = player;
95 }
96
97 /** The information displayed on information tab. */
98 public static String getInformation() {
99 return !active ? "Not Active" : data.name;
100 }
101}
static void open(Player player)
Handles opening the blood money chest.
static BloodMoneyPosition data
Blood chest position.
static final Stopwatch stopwatch
The stopwatch for this event.
static void finish(boolean unlocked)
Handles finishing the blood money chet.
static Player viewer
The current blood money chest viewer.
static CustomGameObject chest
The blood money chest object.
static String getInformation()
The information displayed on information tab.
static void spawn()
Handles spawning the blood money chest.
static boolean active
The state of the blood money chest.
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.
void open(PuzzleType puzzleType)
Opens the puzzle interface.
Represents the game world.
Definition World.java:46
static void sendMessage(String... messages)
Sends a global message.
Definition World.java:396
Represents a non-player character in the in-game world.
Definition Npc.java:29
This class represents a character controlled by a player.
Definition Player.java:125
The container class that represents an item that can be interacted with.
Definition Item.java:21
Represents a static game object loaded from the map fs.
static Stopwatch start()
Handles miscellaneous methods.
Definition Utility.java:27
static< T > T randomElement(Collection< T > collection)
Picks a random element out of any array type.
Definition Utility.java:248
static Position[] getInnerBoundaries(Position position, int width, int length)
Definition Utility.java:621
The difference puzzle types.