Fix some issues with the purge command

This commit is contained in:
Lukas Rieger (Blue) 2022-10-04 20:40:38 +02:00
parent d7eb9e8083
commit 5624c5f216
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
2 changed files with 17 additions and 6 deletions

View File

@ -790,12 +790,20 @@ public int purgeCommand(CommandContext<S> context) {
plugin.getRenderManager().scheduleRenderTaskNext(purgeTask);
source.sendMessage(Text.of(TextColor.GREEN, "Created new Task to purge map '" + map.getId() + "'"));
// reset the map and start updating it after the purge
RenderTask updateTask = new MapUpdateTask(map);
plugin.getRenderManager().scheduleRenderTask(updateTask);
source.sendMessage(Text.of(TextColor.GREEN, "Created new Update-Task for map '" + map.getId() + "'"));
source.sendMessage(Text.of(TextColor.GRAY, "If you don't want this map to render again after the purge, use ",
TextColor.DARK_GRAY, "/bluemap freeze " + map.getId(), TextColor.GRAY, " first!"));
// cancel task if currently rendering the same map
RenderTask currentRenderTask = plugin.getRenderManager().getCurrentRenderTask();
if (currentRenderTask instanceof MapUpdateTask && ((MapUpdateTask) currentRenderTask).getMap().getId().equals(map.getId())) {
currentRenderTask.cancel();
}
// start updating the map after the purge
if (plugin.getPluginState().getMapState(map).isUpdateEnabled()) {
RenderTask updateTask = new MapUpdateTask(map);
plugin.getRenderManager().scheduleRenderTask(updateTask);
source.sendMessage(Text.of(TextColor.GREEN, "Created new Update-Task for map '" + map.getId() + "'"));
source.sendMessage(Text.of(TextColor.GRAY, "If you don't want this map to render again after the purge, use ",
TextColor.DARK_GRAY, "/bluemap freeze " + map.getId(), TextColor.GRAY, " first!"));
}
source.sendMessage(Text.of(TextColor.GREEN, "Use ", TextColor.GRAY, "/bluemap", TextColor.GREEN, " to see the progress."));
} catch (IOException | IllegalArgumentException e) {

View File

@ -91,6 +91,9 @@ public void doWork() throws Exception {
}
try {
// save lowres-tile-manager to clear/flush any buffered data
this.map.getLowresTileManager().save();
// delete subFiles first to be able to track the progress and cancel
while (!subFiles.isEmpty()) {
Path subFile = subFiles.getLast();