RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.game.action.impl.ChestAction Class Reference

Handles opening a chest. More...

Inheritance diagram for com.runehive.game.action.impl.ChestAction:
Collaboration diagram for com.runehive.game.action.impl.ChestAction:

Public Member Functions

 ChestAction (Player player, int key, Item... items)
void execute ()
 A function representing the unit of work that will be carried out.
String getName ()
 Gets the name of this action.
WalkablePolicy getWalkablePolicy ()
 Gets the WalkablePolicy of this action.
boolean prioritized ()
 Determines if this action is prioritized.
Public Member Functions inherited from com.runehive.game.action.Action< T extends Mob >
 Action (T mob, int delay)
 Creates a new Action randomevent.
 Action (T mob, int delay, boolean instant)
 Creates a new Action randomevent.
boolean cancellableInProgress ()
getMob ()
 Gets the player.
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.

Protected Member Functions

boolean canSchedule ()
 A function executed on registration.
void onCancel (boolean logout)
 A function executed on cancellation.
void onSchedule ()
 A function executed on registration.
Protected Member Functions inherited from com.runehive.game.task.Task
void baseExecute ()

Private Attributes

final Item[] items
final int key

Additional Inherited Members

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 opening a chest.

Author
Daniel

Definition at line 18 of file ChestAction.java.

Constructor & Destructor Documentation

◆ ChestAction()

com.runehive.game.action.impl.ChestAction.ChestAction ( Player player,
int key,
Item... items )

Definition at line 22 of file ChestAction.java.

22 {
23 super(player, 1);
24 this.key = key;
25 this.items = items;
26 }

References items, and key.

Member Function Documentation

◆ canSchedule()

boolean com.runehive.game.action.impl.ChestAction.canSchedule ( )
protected

A function executed on registration.

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

Definition at line 29 of file ChestAction.java.

29 {
30 if (!getMob().inventory.hasCapacityFor(items)) {
31 getMob().message("You do not have enough free inventory spaces to do this!");
32 return false;
33 }
34 return true;
35 }

References com.runehive.game.action.Action< T extends Mob >.getMob(), and items.

Here is the call graph for this function:

◆ execute()

void com.runehive.game.action.impl.ChestAction.execute ( )

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

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

Definition at line 46 of file ChestAction.java.

46 {
47 cancel();
48 }

References com.runehive.game.task.Task.cancel().

Here is the call graph for this function:

◆ getName()

String com.runehive.game.action.impl.ChestAction.getName ( )

Gets the name of this action.

Returns
The name of this action.

Reimplemented from com.runehive.game.action.Action< T extends Mob >.

Definition at line 64 of file ChestAction.java.

64 {
65 return "chest action";
66 }

◆ getWalkablePolicy()

WalkablePolicy com.runehive.game.action.impl.ChestAction.getWalkablePolicy ( )

Gets the WalkablePolicy of this action.

Returns
The walkable policy of this action.

Reimplemented from com.runehive.game.action.Action< T extends Mob >.

Definition at line 74 of file ChestAction.java.

74 {
75 return WalkablePolicy.NON_WALKABLE;
76 }

References com.runehive.game.action.policy.WalkablePolicy.NON_WALKABLE.

◆ onCancel()

void com.runehive.game.action.impl.ChestAction.onCancel ( boolean logout)
protected

A function executed on cancellation.

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

Definition at line 51 of file ChestAction.java.

51 {
52 getMob().inventory.addOrDrop(items);
53 getMob().send(new SendMessage("...you find a few items inside of the chest.", true));
54
55 if (key == 989) {
56 getMob().activityLogger.add(ActivityLog.CRYSTAL_CHEST);
57 AchievementHandler.activate(getMob(), AchievementKey.CRYSTAL_CHEST, 1);
58 } else if (key == 20608) {
59 getMob().activityLogger.add(ActivityLog.BLOOD_MONEY_CHEST);
60 }
61 }

References com.runehive.content.achievement.AchievementHandler.activate(), com.runehive.content.ActivityLog.BLOOD_MONEY_CHEST, com.runehive.content.achievement.AchievementKey.CRYSTAL_CHEST, com.runehive.content.ActivityLog.CRYSTAL_CHEST, com.runehive.game.action.Action< T extends Mob >.getMob(), items, and key.

Here is the call graph for this function:

◆ onSchedule()

void com.runehive.game.action.impl.ChestAction.onSchedule ( )
protected

A function executed on registration.

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

Definition at line 38 of file ChestAction.java.

38 {
39 getMob().locking.lock(2);
40 getMob().inventory.remove(key, 1);
41 getMob().animate(new Animation(881));
42 getMob().send(new SendMessage("You attempt to unlock the chest..."));
43 }

References com.runehive.game.action.Action< T extends Mob >.getMob(), and key.

Here is the call graph for this function:

◆ prioritized()

boolean com.runehive.game.action.impl.ChestAction.prioritized ( )

Determines if this action is prioritized.

When making an action prioritized, the next action will be ignored if not queued.

Returns
true if this action is prioritized, false otherwise.

Reimplemented from com.runehive.game.action.Action< T extends Mob >.

Definition at line 69 of file ChestAction.java.

69 {
70 return false;
71 }

Member Data Documentation

◆ items

final Item [] com.runehive.game.action.impl.ChestAction.items
private

Definition at line 20 of file ChestAction.java.

Referenced by canSchedule(), ChestAction(), and onCancel().

◆ key

final int com.runehive.game.action.impl.ChestAction.key
private

Definition at line 19 of file ChestAction.java.

Referenced by ChestAction(), onCancel(), and onSchedule().


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