RuneHive-Game
Loading...
Searching...
No Matches
SystemUpdateEvent.java
Go to the documentation of this file.
1package com.runehive.game.task.impl;
2
3import com.runehive.game.task.TickableTask;
4import com.runehive.game.world.World;
5import org.apache.logging.log4j.LogManager;
6import org.apache.logging.log4j.Logger;
7
8public final class SystemUpdateEvent extends TickableTask {
9
10 private static final Logger logger = LogManager.getLogger(SystemUpdateEvent.class);
11 private final int ticks;
12
14 super(true, 10);
15 this.ticks = ticks;
16 }
17
18 @Override
19 protected void tick() {
20 int remaining = ticks - tick * 10;
21 logger.info("Server shutdown in " + remaining + " ticks (" + remaining * 3 / 5 + " seconds)");
22
23 if (remaining == 10)
24 World.save();
25
26 if (remaining == 0)
27 cancel();
28 }
29
30 @Override
31 protected void onCancel(boolean logout) {
33 }
34
35}
synchronized final void cancel()
Cancels all subsequent executions.
Definition Task.java:113
TickableTask(boolean instant, int delay)
void onCancel(boolean logout)
A function executed on cancellation.
Represents the game world.
Definition World.java:46
static void shutdown()
Shuts down the server.
Definition World.java:122
static void save()
Saves all the game data.
Definition World.java:97