RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
SessionRemovalNotificationTask.java
1package com.osroyale.game.task.impl;
2
3import com.osroyale.game.task.Task;
4import com.osroyale.game.world.entity.mob.player.Player;
5import com.osroyale.game.world.entity.mob.player.exchange.ExchangeSession;
6import com.osroyale.net.packet.out.SendString;
7
30
31public class SessionRemovalNotificationTask extends Task {
32
33 private final Player player;
34 private int time = 11;
35
36 public SessionRemovalNotificationTask(Player player) {
37 super(true, 0);
38 this.player = player;
39 }
40
41 @Override
42 public void execute() {
43 if (!ExchangeSession.getSession(player).isPresent()) {
44 cancel();
45 return;
46 }
47
48 if (time <= 0) {
49 cancel();
50 return;
51 }
52
53 time--;
54
55 player.send(new SendString(time % 2 == 0 ? "<col=ff0000>Trade has been modified!" : "", 33030));
56 }
57
58 @Override
59 protected void onCancel(boolean logout) {
60 player.send(new SendString("", 33030));
61 }
62
63}
synchronized final void cancel()
Definition Task.java:147
Task(boolean instant, int delay)
Definition Task.java:75
static Optional< ExchangeSession > getSession(Player player)