From 8162c4232d24d85cb1c9a5d4c33ecbe1c4c5daf3 Mon Sep 17 00:00:00 2001 From: Lilly <46890129+RainbowDashLabs@users.noreply.github.com> Date: Mon, 19 Aug 2024 19:32:19 +0200 Subject: [PATCH] Shutdown server before deleting --- bot/src/main/java/de/chojo/gamejam/api/v1/Server.java | 9 +++++++-- .../de/chojo/gamejam/commands/server/system/Delete.java | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bot/src/main/java/de/chojo/gamejam/api/v1/Server.java b/bot/src/main/java/de/chojo/gamejam/api/v1/Server.java index 1f95f5d..1592053 100644 --- a/bot/src/main/java/de/chojo/gamejam/api/v1/Server.java +++ b/bot/src/main/java/de/chojo/gamejam/api/v1/Server.java @@ -36,7 +36,7 @@ public void routes() { return; } - if(!ctx.contentType().equals("application/octet-stream")) { + if (!ctx.contentType().equals("application/octet-stream")) { ctx.status(HttpCode.BAD_REQUEST); ctx.result("Use Content-Type: application/octet-stream"); return; @@ -56,7 +56,12 @@ public void routes() { } ctx.status(HttpCode.ACCEPTED); - teamServer.restart(); + String restart = ctx.queryParam("restart"); + if ("true".equals(restart) && teamServer.running()) { + teamServer.restart(); + } else if (teamServer.running()) { + teamServer.send("say Plugin Updated"); + } }); }); } diff --git a/bot/src/main/java/de/chojo/gamejam/commands/server/system/Delete.java b/bot/src/main/java/de/chojo/gamejam/commands/server/system/Delete.java index 698d83f..75ed3e0 100644 --- a/bot/src/main/java/de/chojo/gamejam/commands/server/system/Delete.java +++ b/bot/src/main/java/de/chojo/gamejam/commands/server/system/Delete.java @@ -27,8 +27,11 @@ public Delete(Server server) { @Override public void onSlashCommand(SlashCommandInteractionEvent event, EventContext context) { var optServer = server.getServer(event, context); - if(optServer.isEmpty())return; + if (optServer.isEmpty()) return; var teamServer = optServer.get(); + if(teamServer.running()){ + teamServer.stop().join(); + } boolean deleted; try { deleted = teamServer.purge();