-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathViaVersionAutoUpdate.java
More file actions
56 lines (46 loc) · 1.56 KB
/
ViaVersionAutoUpdate.java
File metadata and controls
56 lines (46 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package me.adarsh.autoupdate;
/**
* The entrance point of the ViaVersionAutoUpdate program
*/
public class ViaVersionAutoUpdate {
private IPlugin plugin;
public ViaVersionAutoUpdate(IPlugin plugin) {
this.plugin = plugin;
// Check for an update on startup,
new UpdateChecker(this, "VV").run(); // ViaVerison
new UpdateChecker(this, "VB").run(); // ViaBackwards
new UpdateChecker(this, "VR").run(); // ViaRewind
}
/**
* Get the plugin
* @return The IPlugin for this instance
*/
public IPlugin getPlugin() {
return plugin;
}
/**
* Restarts the server after a 5 minute countdown
*/
public void startRestartCountdown() {
// 0 seconds from now
plugin.runTaskLaterAsync(() -> {
plugin.broadcastMessage("[ViaVersionAutoUpdate] Server restart in 5 minutes");
}, 0);
// 3 minutes from now
plugin.runTaskLaterAsync(() -> {
plugin.broadcastMessage("[ViaVersionAutoUpdate] Server restart in 2 minutes");
}, 3*60);
// 4 minutes from now
plugin.runTaskLaterAsync(() -> {
plugin.broadcastMessage("[ViaVersionAutoUpdate] Server restart in 1 minute");
}, 4*60);
// 4 minutes and a half from now
plugin.runTaskLaterAsync(() -> {
plugin.broadcastMessage("[ViaVersionAutoUpdate] Server restart in 30 seconds");
}, 4*60 + 30);
// 5 minutes from now
plugin.runTaskLaterAsync(() -> {
plugin.restart();
}, 5*60);
}
}