Separate the dispatch and game servers (pt. 1)

gacha is still broken, handbook still needs to be done
This commit is contained in:
KingRainbow44
2023-05-15 00:43:16 -04:00
parent 97fbbdca84
commit bcc9ae10cd
28 changed files with 1225 additions and 379 deletions

View File

@@ -27,6 +27,12 @@ public final class HttpServer {
* Configures the Javalin application.
*/
public HttpServer() {
// Check if we are in game only mode.
if (Grasscutter.getRunMode() == Grasscutter.ServerRunMode.GAME_ONLY) {
this.javalin = null;
return;
}
this.javalin = Javalin.create(config -> {
// Set the Javalin HTTP server.
config.jetty.server(HttpServer::createServer);
@@ -51,6 +57,13 @@ public final class HttpServer {
// Static files should be added like this https://javalin.io/documentation#static-files
});
this.javalin.exception(Exception.class, (exception, ctx) -> {
ctx.status(500).result("Internal server error. %s"
.formatted(exception.getMessage()));
Grasscutter.getLogger().debug("Exception thrown: " +
exception.getMessage(), exception);
});
}
/**