RuneHive-Game
Loading...
Searching...
No Matches
TeleblockTask.java
Go to the documentation of this file.
1package com.runehive.game.task.impl;
2
3import com.runehive.game.task.Task;
4import com.runehive.net.packet.out.SendMessage;
5import com.runehive.net.packet.out.SendWidget;
6import com.runehive.game.world.entity.mob.player.Player;
7
8/**
9 * This randomevent handles the teleblock counter.
10 *
11 * @author Daniel | Obey
12 */
13public class TeleblockTask extends Task {
14
15 private final Player player;
16
18 super(false, 0);
19 this.player = player;
20 }
21
22 @Override
23 protected void execute() {
24 if (player == null || !player.isValid()) {
25 cancel();
26 return;
27 }
28
29 if (player.teleblockTimer.decrementAndGet() <= 0) {
30 cancel();
31 }
32 }
33
34 @Override
35 protected void onCancel(boolean logout) {
37 player.send(new SendMessage("You feel the effects of the tele-block spell go away."));
38 }
39
40}
synchronized final void cancel()
Cancels all subsequent executions.
Definition Task.java:113
Task(boolean instant, int delay)
Creates a new Task.
Definition Task.java:41
void execute()
A function representing the unit of work that will be carried out.
void onCancel(boolean logout)
A function executed on cancellation.
This class represents a character controlled by a player.
Definition Player.java:125
The OutgoingPacket that sends a message to a Players chatbox in the client.