RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
PvPTimerTask.java
1
package
com.osroyale.game.task.impl;
2
3
import
com.osroyale.game.task.Task;
4
import
com.osroyale.game.world.entity.mob.player.Player;
5
import
com.osroyale.game.world.entity.mob.player.PlayerOption;
6
import
com.osroyale.game.world.position.Area;
7
import
com.osroyale.net.packet.out.SendPlayerOption;
8
import
com.osroyale.net.packet.out.SendString;
9
10
import
java.util.concurrent.TimeUnit;
11
35
36
public
class
PvPTimerTask
extends
Task
{
37
private
static
final
int
[] TIMES = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1 };
38
39
private
final
Player
player;
40
41
public
PvPTimerTask(
Player
player) {
42
super(
false
, 1);
43
this.player = player;
44
}
45
46
@Override
47
protected
void
onSchedule
() {
48
player.pvpTimer.reset();
49
player.hasPvPTimer =
true
;
50
}
51
52
@Override
53
protected
void
execute
() {
54
int
time = TIMES[(int) player.pvpTimer.elapsedTime(TimeUnit.SECONDS)];
55
56
if
(!player.pvpInstance ||
Area
.inPvP(player) || player.pvpTimer.elapsedTime(TimeUnit.SECONDS) > 10 || time == -1) {
57
cancel
();
58
return
;
59
}
60
61
player.send(
new
SendString
(
"<col=FF0011>"
+ time, 23327));
62
}
63
64
@Override
65
protected
void
onCancel
(
boolean
logout) {
66
player.getCombat().reset();
67
player.send(
new
SendString
(
"<col=36CF4D>Safe"
, 23327));
68
player.send(
new
SendPlayerOption
(
PlayerOption
.
ATTACK
,
false
,
true
));
69
player.send(
new
SendPlayerOption
(
PlayerOption
.
DUEL_REQUEST
,
false
,
true
));
70
player.hasPvPTimer =
false
;
71
}
72
}
com.osroyale.game.task.Task.cancel
synchronized final void cancel()
Definition
Task.java:147
com.osroyale.game.task.Task.Task
Task(boolean instant, int delay)
Definition
Task.java:75
com.osroyale.game.task.impl.PvPTimerTask.onSchedule
void onSchedule()
Definition
PvPTimerTask.java:47
com.osroyale.game.task.impl.PvPTimerTask.onCancel
void onCancel(boolean logout)
Definition
PvPTimerTask.java:65
com.osroyale.game.task.impl.PvPTimerTask.execute
void execute()
Definition
PvPTimerTask.java:53
com.osroyale.game.world.entity.mob.player.Player
Definition
Player.java:162
com.osroyale.game.world.position.Area
Definition
Area.java:50
com.osroyale.net.packet.out.SendPlayerOption
Definition
SendPlayerOption.java:38
com.osroyale.net.packet.out.SendString
Definition
SendString.java:39
com.osroyale.game.world.entity.mob.player.PlayerOption
Definition
PlayerOption.java:41
com.osroyale.game.world.entity.mob.player.PlayerOption.ATTACK
ATTACK
Definition
PlayerOption.java:47
com.osroyale.game.world.entity.mob.player.PlayerOption.DUEL_REQUEST
DUEL_REQUEST
Definition
PlayerOption.java:44