From 2009a90e6600f09a08f340fc5a8624b8b0ea4cc6 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Tue, 30 May 2023 14:29:55 -0400 Subject: [PATCH] Change the way HTML is served after authentication --- .../java/emu/grasscutter/auth/HandbookAuthenticator.java | 1 + .../server/http/documentation/HandbookHandler.java | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/emu/grasscutter/auth/HandbookAuthenticator.java b/src/main/java/emu/grasscutter/auth/HandbookAuthenticator.java index 732887770..46d2f473f 100644 --- a/src/main/java/emu/grasscutter/auth/HandbookAuthenticator.java +++ b/src/main/java/emu/grasscutter/auth/HandbookAuthenticator.java @@ -11,6 +11,7 @@ public interface HandbookAuthenticator { class Response { private final int status; private final String body; + @Builder.Default private boolean html = false; } /** diff --git a/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java b/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java index 2f722bd22..61a27cd47 100644 --- a/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java +++ b/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java @@ -1,7 +1,5 @@ package emu.grasscutter.server.http.documentation; -import static emu.grasscutter.config.Configuration.HANDBOOK; - import emu.grasscutter.Grasscutter; import emu.grasscutter.auth.AuthenticationSystem.AuthenticationRequest; import emu.grasscutter.server.http.Router; @@ -13,6 +11,8 @@ import io.javalin.Javalin; import io.javalin.http.ContentType; import io.javalin.http.Context; +import static emu.grasscutter.config.Configuration.HANDBOOK; + /** Handles requests for the new GM Handbook. */ public final class HandbookHandler implements Router { private final byte[] handbook; @@ -103,7 +103,7 @@ public final class HandbookHandler implements Router { ctx.status(result.getStatus()) .result(result.getBody()) .contentType( - result.getBody().contains("html") ? ContentType.TEXT_HTML : ContentType.TEXT_PLAIN); + result.isHtml() ? ContentType.TEXT_HTML : ContentType.TEXT_PLAIN); } } }