Skip to content

Commit

Permalink
Shutdown server before deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
rainbowdashlabs committed Aug 19, 2024
1 parent 5c7c4da commit 8162c42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions bot/src/main/java/de/chojo/gamejam/api/v1/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 8162c42

Please sign in to comment.