cn.nukkit.utils.ServerKiller Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powernukkit Show documentation
Show all versions of powernukkit Show documentation
A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.
package cn.nukkit.utils;
import java.util.concurrent.TimeUnit;
/**
* @author MagicDroidX (Nukkit Project)
*/
public class ServerKiller extends Thread {
public final long sleepTime;
public ServerKiller(long time) {
this(time, TimeUnit.SECONDS);
}
public ServerKiller(long time, TimeUnit unit) {
this.sleepTime = unit.toMillis(time);
this.setName("Server Killer");
}
@Override
public void run() {
try {
sleep(sleepTime);
} catch (InterruptedException e) {
// ignore
}
System.out.println("\nTook too long to stop, server was killed forcefully!\n");
System.exit(1);
}
}