RuneHive-Game
Loading...
Searching...
No Matches
AntiVenomTask.java
Go to the documentation of this file.
1package com.runehive.game.task.impl;
2
3import com.runehive.game.task.Task;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.net.packet.out.SendMessage;
6
7public class AntiVenomTask extends Task {
8 private final Player player;
9
11 super(false, 50);
12 this.player = player;
13 }
14
15 @Override
16 public void execute() {
17 if (player.getVenomImmunity().get() <= 0)
18 this.cancel();
19
20 if (player.getVenomImmunity().decrementAndGet(50) <= 50)
21 player.send(new SendMessage("Your resistance to venom is about to wear off!"));
22
23 if (player.getVenomImmunity().get() <= 0)
24 cancel();
25 }
26
27 @Override
28 protected void onCancel(boolean logout) {
29 player.send(new SendMessage("Your resistance to venom has worn off!"));
30 player.getVenomImmunity().set(0);
31 }
32
33}
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 onCancel(boolean logout)
A function executed on cancellation.
void execute()
A function representing the unit of work that will be carried out.
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.
int decrementAndGet(int amount, int minimum)
Decrements the value within this counter by amount to a minimum of minimum and then returns it.