RuneHive-Game
Loading...
Searching...
No Matches
SessionRemovalNotificationTask.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.game.world.entity.mob.player.exchange.ExchangeSession;
6import com.runehive.net.packet.out.SendString;
7
8public class SessionRemovalNotificationTask extends Task {
9
10 private final Player player;
11 private int time = 11;
12
14 super(true, 0);
15 this.player = player;
16 }
17
18 @Override
19 public void execute() {
20 if (!ExchangeSession.getSession(player).isPresent()) {
21 cancel();
22 return;
23 }
24
25 if (time <= 0) {
26 cancel();
27 return;
28 }
29
30 time--;
31
32 player.send(new SendString(time % 2 == 0 ? "<col=ff0000>Trade has been modified!" : "", 33030));
33 }
34
35 @Override
36 protected void onCancel(boolean logout) {
37 player.send(new SendString("", 33030));
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 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
static Optional< ExchangeSession > getSession(Player player)
Gets the session if applicable the player is in.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.