RuneHive-Game
Loading...
Searching...
No Matches
MessageEvent.java
Go to the documentation of this file.
1package com.runehive.game.task.impl;
2
3import com.runehive.Config;
4import com.runehive.content.triviabot.TriviaBot;
5import com.runehive.game.task.Task;
6import com.runehive.game.world.World;
7import com.runehive.util.Utility;
8
9/**
10 * Sends game messages to all the online players.
11 *
12 * @author Daniel
13 */
14public class MessageEvent extends Task {
15
16 /** The message randomevent ticks. */
17 private int tick;
18
19 /** Constructs a new <code>MessageEvent</code>. */
20 public MessageEvent() {
21 super(180);
22 this.tick = 0;
23 }
24
25 @Override
26 public void execute() {
27 tick++;
28
29 if (tick % 2 == 0) {
30 String message = Utility.randomElement(Config.MESSAGES);
31 World.sendMessage("<img=15> <col=2C7526>Broadcast: </col>" + message);
32 } else {
34 }
35 }
36}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final String[] MESSAGES
Messages that are sent periodically to all players.
Definition Config.java:224
Manages the trivia bot system.
static void assign()
Assigns a new question.
Task(boolean instant, int delay)
Creates a new Task.
Definition Task.java:41
MessageEvent()
Constructs a new MessageEvent.
void execute()
A function representing the unit of work that will be carried out.
int tick
The message randomevent ticks.
Represents the game world.
Definition World.java:46
static void sendMessage(String... messages)
Sends a global message.
Definition World.java:396
Handles miscellaneous methods.
Definition Utility.java:27
static< T > T randomElement(Collection< T > collection)
Picks a random element out of any array type.
Definition Utility.java:248