Skip to content

Commit 75e93cb

Browse files
committed
feat: add server process cleanup before exit in CosmicJarsFrame
Ensure the Minecraft server process is properly destroyed before exiting the application. This prevents potential orphaned processes when the application is closed.
1 parent 2e9c7c6 commit 75e93cb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/com/georgev22/cosmicjars/CosmicJarsFrame.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ public CosmicJarsFrame() {
4848
JMenu helpMenu = new JMenu("Help");
4949

5050
JMenuItem exitItem = new JMenuItem("Exit");
51-
exitItem.addActionListener(e -> System.exit(0));
51+
exitItem.addActionListener(e -> {
52+
MinecraftServer server = main.getMinecraftServer();
53+
if (server != null && (server.getMinecraftServerProcess() != null && server.getMinecraftServerProcess().isAlive())) {
54+
server.getMinecraftServerProcess().destroy();
55+
}
56+
System.exit(0);
57+
});
5258
fileMenu.add(exitItem);
5359
JMenuItem configItem = new JMenuItem("Config");
5460
configItem.addActionListener(e -> ConfigPopup.showConfigPopup());

0 commit comments

Comments
 (0)