RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ChestAction.java
1
package
com.osroyale.game.action.impl;
2
3
import
com.osroyale.content.ActivityLog;
4
import
com.osroyale.game.world.items.Item;
5
import
com.osroyale.net.packet.out.SendMessage;
6
import
com.osroyale.game.Animation;
7
import
com.osroyale.game.action.Action;
8
import
com.osroyale.game.action.policy.WalkablePolicy;
9
import
com.osroyale.game.world.entity.mob.player.Player;
10
import
com.osroyale.content.achievement.AchievementHandler;
11
import
com.osroyale.content.achievement.AchievementKey;
12
18
public
final
class
ChestAction
extends
Action
<Player> {
19
private
final
int
key;
20
private
final
Item[] items;
21
22
public
ChestAction(
Player
player,
int
key, Item... items) {
23
super(player, 1);
24
this.key = key;
25
this.items = items;
26
}
27
28
@Override
29
protected
boolean
canSchedule
() {
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
}
36
37
@Override
38
protected
void
onSchedule
() {
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
}
44
45
@Override
46
public
void
execute
() {
47
cancel
();
48
}
49
50
@Override
51
protected
void
onCancel
(
boolean
logout) {
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
}
62
63
@Override
64
public
String
getName
() {
65
return
"chest action"
;
66
}
67
68
@Override
69
public
boolean
prioritized
() {
70
return
false
;
71
}
72
73
@Override
74
public
WalkablePolicy
getWalkablePolicy
() {
75
return
WalkablePolicy
.
NON_WALKABLE
;
76
}
77
}
com.osroyale.content.achievement.AchievementHandler
Definition
AchievementHandler.java:50
com.osroyale.content.achievement.AchievementHandler.activate
static void activate(Player player, AchievementKey achievement)
Definition
AchievementHandler.java:57
com.osroyale.game.Animation
Definition
Animation.java:45
com.osroyale.game.action.Action.getMob
T getMob()
Definition
Action.java:44
com.osroyale.game.action.Action.Action
Action(T mob, int delay, boolean instant)
Definition
Action.java:24
com.osroyale.game.action.impl.ChestAction.getName
String getName()
Definition
ChestAction.java:64
com.osroyale.game.action.impl.ChestAction.getWalkablePolicy
WalkablePolicy getWalkablePolicy()
Definition
ChestAction.java:74
com.osroyale.game.action.impl.ChestAction.onSchedule
void onSchedule()
Definition
ChestAction.java:38
com.osroyale.game.action.impl.ChestAction.prioritized
boolean prioritized()
Definition
ChestAction.java:69
com.osroyale.game.action.impl.ChestAction.execute
void execute()
Definition
ChestAction.java:46
com.osroyale.game.action.impl.ChestAction.onCancel
void onCancel(boolean logout)
Definition
ChestAction.java:51
com.osroyale.game.action.impl.ChestAction.canSchedule
boolean canSchedule()
Definition
ChestAction.java:29
com.osroyale.game.task.Task.cancel
synchronized final void cancel()
Definition
Task.java:147
com.osroyale.game.world.entity.mob.player.Player
Definition
Player.java:162
com.osroyale.net.packet.out.SendMessage
Definition
SendMessage.java:38
com.osroyale.content.ActivityLog
Definition
ActivityLog.java:41
com.osroyale.content.achievement.AchievementKey
Definition
AchievementKey.java:34
com.osroyale.game.action.policy.WalkablePolicy
Definition
WalkablePolicy.java:34
com.osroyale.game.action.policy.WalkablePolicy.NON_WALKABLE
NON_WALKABLE
Definition
WalkablePolicy.java:40