Add shutdown of bau after five minutes no player #219
@ -46,6 +46,7 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -171,19 +172,27 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
if (autoShutdown != null) {
|
||||
autoShutdown.cancel();
|
||||
}
|
||||
/*autoShutdown = Bukkit.getScheduler().runTaskTimer(this, () -> {
|
||||
try {
|
||||
ProcessBuilder processBuilder = new ProcessBuilder("/bin/bash", "-c", "free");
|
||||
Process process = processBuilder.start();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
bufferedReader.readLine();
|
||||
String s = bufferedReader.readLine();
|
||||
} catch (IOException exception) {
|
||||
Bukkit.shutdown();
|
||||
autoShutdown = Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
|
||||
int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (count >= 5) {
|
||||
Bukkit.shutdown();
|
||||
return;
|
||||
}
|
||||
count++;
|
||||
try {
|
||||
long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize();
|
||||
long freeMemory = ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getFreePhysicalMemorySize();
|
||||
if ((memorySize - freeMemory) / (double) memorySize > 0.8) {
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
}
|
||||
}, 1200, 1200);*/
|
||||
// (Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory()) / Runtime.getRuntime().maxMemory() > 0.8
|
||||
autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 6000);
|
||||
}, 1200, 1200);
|
||||
}
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren