World saving has to go on the main thread
This commit is contained in:
parent
01c02b1aa2
commit
948c0da731
1 changed files with 20 additions and 20 deletions
|
@ -64,6 +64,25 @@ public enum BackupHandler {
|
||||||
|
|
||||||
doingBackup = 1;
|
doingBackup = 1;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (server.getPlayerList() != null) {
|
||||||
|
server.getPlayerList().saveAllPlayerData();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (WorldServer world : server.worlds) {
|
||||||
|
if (world != null) {
|
||||||
|
world.saveAllChunks(true, null);
|
||||||
|
world.flushToDisk();
|
||||||
|
world.disableLevelSaving = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ExtBackup.logger.error("Saving the world failed!");
|
||||||
|
enableSaving(server);
|
||||||
|
ex.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ThreadedFileIOBase.getThreadedIOInstance().queueIO(() -> {
|
ThreadedFileIOBase.getThreadedIOInstance().queueIO(() -> {
|
||||||
try {
|
try {
|
||||||
doBackup(server, script);
|
doBackup(server, script);
|
||||||
|
@ -81,26 +100,7 @@ public enum BackupHandler {
|
||||||
|
|
||||||
private void doBackup(MinecraftServer server, File script) {
|
private void doBackup(MinecraftServer server, File script) {
|
||||||
ExtBackup.logger.info("Starting backup.");
|
ExtBackup.logger.info("Starting backup.");
|
||||||
PlayerList pl = server.getPlayerList();
|
|
||||||
ExtBackupUtil.broadcast(server, "Starting Backup!");
|
ExtBackupUtil.broadcast(server, "Starting Backup!");
|
||||||
try {
|
|
||||||
if (server.getPlayerList() != null) {
|
|
||||||
server.getPlayerList().saveAllPlayerData();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (WorldServer world : server.worlds) {
|
|
||||||
if (world != null) {
|
|
||||||
world.saveAllChunks(true, null);
|
|
||||||
world.flushToDisk();
|
|
||||||
world.disableLevelSaving = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ExtBackup.logger.error("Saving the world failed!");
|
|
||||||
enableSaving(server);
|
|
||||||
ex.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(script.getAbsolutePath());
|
ProcessBuilder pb = new ProcessBuilder(script.getAbsolutePath());
|
||||||
int returnValue = -1;
|
int returnValue = -1;
|
||||||
|
@ -147,4 +147,4 @@ public enum BackupHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue