RuneHive-Game
Loading...
Searching...
No Matches
ForceChatEvent.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.npc.Npc;
5import com.runehive.game.world.World;
6import com.runehive.util.parser.impl.NpcForceChatParser.ForcedMessage;
7
8/**
9 * An randomevent which starts the forced message randomevent.
10 *
11 * @author Daniel | Obey
12 */
13public class ForceChatEvent extends Task {
14
15 private final Npc npc;
16
18
20 super(forcedMessage.getInterval());
21 this.npc = npc;
22 this.forcedMessage = forcedMessage;
23 }
24
25 @Override
26 public void execute() {
27 if (npc == null || !World.getNpcs().contains(npc)) {
28 cancel();
29 return;
30 }
31
32 npc.speak(forcedMessage.nextMessage());
33 }
34
35}
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.
ForceChatEvent(Npc npc, ForcedMessage forcedMessage)
Represents the game world.
Definition World.java:46
static MobList< Npc > getNpcs()
Definition World.java:548
Represents a non-player character in the in-game world.
Definition Npc.java:29