mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-29 14:06:32 +01:00
Fix bluemap not stopping correctly when stopping the server
This commit is contained in:
parent
27d7f37e38
commit
4ed0731956
@ -140,11 +140,7 @@ public synchronized void load() throws ExecutionException, IOException, NoSuchRe
|
|||||||
handleMissingResources(defaultResourceFile, configFile);
|
handleMissingResources(defaultResourceFile, configFile);
|
||||||
unload();
|
unload();
|
||||||
|
|
||||||
//only register reload command
|
Sponge.getCommandManager().register(this, new Commands(this).createStandaloneReloadCommand(), "bluemap");
|
||||||
syncExecutor.submit(() -> //just to be save we do this on the server thread
|
|
||||||
Sponge.getCommandManager().register(this, new Commands(this).createStandaloneReloadCommand(), "bluemap")
|
|
||||||
).get();
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,9 +228,7 @@ public synchronized void load() throws ExecutionException, IOException, NoSuchRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
//start map updater
|
//start map updater
|
||||||
syncExecutor.submit(() ->
|
this.updateHandler = new MapUpdateHandler();
|
||||||
this.updateHandler = new MapUpdateHandler()
|
|
||||||
).get();
|
|
||||||
|
|
||||||
//create/update webfiles
|
//create/update webfiles
|
||||||
WebFilesManager webFilesManager = new WebFilesManager(config.getWebRoot());
|
WebFilesManager webFilesManager = new WebFilesManager(config.getWebRoot());
|
||||||
@ -261,9 +255,7 @@ public synchronized void load() throws ExecutionException, IOException, NoSuchRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
//init commands
|
//init commands
|
||||||
syncExecutor.submit(() -> //just to be save we do this on the server thread
|
Sponge.getCommandManager().register(this, new Commands(this).createRootCommand(), "bluemap");
|
||||||
Sponge.getCommandManager().register(this, new Commands(this).createRootCommand(), "bluemap")
|
|
||||||
).get();
|
|
||||||
|
|
||||||
//metrics
|
//metrics
|
||||||
Sponge.getScheduler().createTaskBuilder()
|
Sponge.getScheduler().createTaskBuilder()
|
||||||
@ -279,8 +271,6 @@ public synchronized void load() throws ExecutionException, IOException, NoSuchRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void unload() {
|
public synchronized void unload() {
|
||||||
try {
|
|
||||||
syncExecutor.submit(() -> { //just to be save we do this on the server thread
|
|
||||||
//unregister commands
|
//unregister commands
|
||||||
Sponge.getCommandManager().getOwnedBy(this).forEach(Sponge.getCommandManager()::removeMapping);
|
Sponge.getCommandManager().getOwnedBy(this).forEach(Sponge.getCommandManager()::removeMapping);
|
||||||
|
|
||||||
@ -289,10 +279,6 @@ public synchronized void unload() {
|
|||||||
|
|
||||||
//stop scheduled tasks
|
//stop scheduled tasks
|
||||||
Sponge.getScheduler().getScheduledTasks(this).forEach(t -> t.cancel());
|
Sponge.getScheduler().getScheduledTasks(this).forEach(t -> t.cancel());
|
||||||
}).get();
|
|
||||||
} catch (InterruptedException | ExecutionException unexpected) {
|
|
||||||
throw new RuntimeException("Unexpected exception!", unexpected); //should never happen
|
|
||||||
}
|
|
||||||
|
|
||||||
//stop services
|
//stop services
|
||||||
if (renderManager != null) renderManager.stop();
|
if (renderManager != null) renderManager.stop();
|
||||||
@ -354,10 +340,8 @@ public void onServerStart(GameStartingServerEvent evt) {
|
|||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onServerStop(GameStoppingEvent evt) {
|
public void onServerStop(GameStoppingEvent evt) {
|
||||||
asyncExecutor.execute(() -> {
|
|
||||||
unload();
|
unload();
|
||||||
Logger.global.logInfo("Saved and stopped!");
|
Logger.global.logInfo("Saved and stopped!");
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
|
Loading…
Reference in New Issue
Block a user