Skip to content

Commit 458daaa

Browse files
committed
Fix cli errors when using ctrl+c to stop
1 parent f42ebdb commit 458daaa

File tree

1 file changed

+9
-1
lines changed
  • implementations/cli/src/main/java/de/bluecolored/bluemap/cli

1 file changed

+9
-1
lines changed

implementations/cli/src/main/java/de/bluecolored/bluemap/cli/BlueMapCLI.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@
6868

6969
public class BlueMapCLI {
7070

71+
private static boolean shutdownInProgress = false;
72+
7173
private String minecraftVersion = null;
7274
private Path configFolder = Path.of("config");
7375

76+
7477
public void renderMaps(BlueMapService blueMap, boolean watch, Predicate<TileState> force, boolean forceGenerateWebapp,
7578
@Nullable String mapsToRender) throws ConfigurationException, IOException, InterruptedException {
7679

@@ -190,7 +193,10 @@ public void run() {
190193
Logger.global.logInfo("Stopped.");
191194
};
192195

193-
Thread shutdownHook = new Thread(shutdown, "BlueMap-CLI-ShutdownHook");
196+
Thread shutdownHook = new Thread(() -> {
197+
shutdownInProgress = true;
198+
shutdown.run();
199+
}, "BlueMap-CLI-ShutdownHook");
194200
Runtime.getRuntime().addShutdownHook(shutdownHook);
195201

196202
//metrics report
@@ -201,6 +207,8 @@ public void run() {
201207

202208
// wait until done, then shutdown if not watching
203209
renderManager.awaitIdle();
210+
if (shutdownInProgress) return;
211+
204212
Logger.global.logInfo("Your maps are now all up-to-date!");
205213

206214
if (watch) {

0 commit comments

Comments
 (0)