-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathServerShutdownThread.java
More file actions
37 lines (33 loc) · 1.12 KB
/
ServerShutdownThread.java
File metadata and controls
37 lines (33 loc) · 1.12 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
package org.bukkit.craftbukkit.util;
import io.papermc.paper.log.LoggerShutdown;
import net.minecraft.server.MinecraftServer;
public class ServerShutdownThread extends Thread {
private final MinecraftServer server;
public ServerShutdownThread(MinecraftServer server) {
this.server = server;
}
@Override
public void run() {
try {
// Paper start - try to shutdown on main
server.cancelStartup = true;
server.safeShutdown(false, false);
for (int i = 1000; i > 0 && !server.hasStopped(); i -= 100) {
Thread.sleep(100);
}
if (server.hasStopped()) {
while (!server.hasFullyShutdown) Thread.sleep(1000);
return;
}
// Looks stalled, close async
server.forceTicks = true;
this.server.close();
while (!server.hasFullyShutdown) Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
// Paper end
} finally {
LoggerShutdown.shutdownLogging();
}
}
}