RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.bloodmoney.BloodChestEvent Class Reference

Handles the blood chest event. More...

Inheritance diagram for com.runehive.content.bloodmoney.BloodChestEvent:
Collaboration diagram for com.runehive.content.bloodmoney.BloodChestEvent:

Public Member Functions

 BloodChestEvent ()
void execute ()
 A function representing the unit of work that will be carried out.
Public Member Functions inherited from com.runehive.game.task.Task
Task attach (Object newKey)
 Attaches a new key.
synchronized final void cancel ()
 Cancels all subsequent executions.
synchronized final void cancel (boolean logout)
 Cancels all subsequent executions.
boolean canRun ()
 Determines if the task can be ran.
Optional< Object > getAttachment ()
String getCreationStackTraceStr ()
int getDelay ()
Long getElapsedTimeFromRunStartTime ()
Optional< Long > getRunStartTime ()
long getTaskCreationTime ()
String getTaskId ()
boolean isInstant ()
boolean isRunning ()
void setDelay (int delay)
 Sets the cyclic delay.
void setExecutionTime ()
 Task (boolean instant, int delay)
 Creates a new Task.
 Task (int delay)
 Creates a new Task that doesn't execute instantly.

Private Attributes

NavigableMap< Double, String > timeToMessage
 Constructs a new BloodChestEvent.

Additional Inherited Members

Protected Member Functions inherited from com.runehive.game.task.Task
void baseExecute ()
boolean canSchedule ()
 A function executed on registration.
void onCancel (boolean logout)
 A function executed on cancellation.
void onSchedule ()
 A function executed on registration.
Package Functions inherited from com.runehive.game.task.Task
void onException (Exception e)
 A function executed on thrown exceptions.
void onLoop ()
 A function executed when iterated over.
final synchronized void process ()
synchronized void setRunning (boolean running)

Detailed Description

Handles the blood chest event.

Author
Daniel

Definition at line 16 of file BloodChestEvent.java.

Constructor & Destructor Documentation

◆ BloodChestEvent()

com.runehive.content.bloodmoney.BloodChestEvent.BloodChestEvent ( )

Definition at line 22 of file BloodChestEvent.java.

22 {
23 super(100);
24 timeToMessage = new TreeMap<>();
25 timeToMessage.put(1.0, "<icon=0><col=FF0000> Blood Money Chest will vanish in 1 hour!");
26 timeToMessage.put(0.5, "<icon=0><col=FF0000> Blood Money Chest will vanish in 30 minutes!");
27 timeToMessage.put(0.25, "<icon=0><col=FF0000> Blood Money Chest will vanish in 15 minutes!");
28 timeToMessage.put(0.0833, "<icon=0><col=FF0000> Blood Money Chest will vanish in 5 minutes!");
29 }

References timeToMessage.

Member Function Documentation

◆ execute()

void com.runehive.content.bloodmoney.BloodChestEvent.execute ( )

A function representing the unit of work that will be carried out.

Reimplemented from com.runehive.game.task.Task.

Definition at line 33 of file BloodChestEvent.java.

33 {
34 if (!BloodMoneyChest.active) {
35 if (BloodMoneyChest.stopwatch.elapsedTime(TimeUnit.HOURS) >= 4) {
36 BloodMoneyChest.spawn();
37 BloodMoneyChest.stopwatch.reset();
38 }
39 return;
40 }
41
42 double hoursPassed = BloodMoneyChest.stopwatch.elapsedTime(TimeUnit.HOURS);
43
44 if (hoursPassed >= 4) {
45 BloodMoneyChest.finish(false);
46 BloodMoneyChest.stopwatch.reset();
47 } else {
48 double hoursRemaining = 4 - hoursPassed;
49 Map.Entry<Double, String> messageEntry = timeToMessage.floorEntry(hoursRemaining);
50 if (messageEntry != null && hoursRemaining <= messageEntry.getKey()) {
51 String message = messageEntry.getValue();
52 World.sendMessage(message);
53 System.out.println("Sent message: " + message);
54 timeToMessage.remove(messageEntry.getKey());
55 }
56 }
57 }

References com.runehive.content.bloodmoney.BloodMoneyChest.active, com.runehive.util.Stopwatch.elapsedTime(), com.runehive.content.bloodmoney.BloodMoneyChest.finish(), com.runehive.util.Stopwatch.reset(), com.runehive.game.world.World.sendMessage(), com.runehive.content.bloodmoney.BloodMoneyChest.spawn(), com.runehive.content.bloodmoney.BloodMoneyChest.stopwatch, and timeToMessage.

Here is the call graph for this function:

Member Data Documentation

◆ timeToMessage

NavigableMap<Double, String> com.runehive.content.bloodmoney.BloodChestEvent.timeToMessage
private

Constructs a new BloodChestEvent.

Definition at line 20 of file BloodChestEvent.java.

Referenced by BloodChestEvent(), and execute().


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