From 3c8d1263e5de4a1c61f9ccc1a1cb5c50347fd769 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sat, 28 Sep 2024 18:47:43 -0400 Subject: [PATCH] fix: Re-add `handbook_auth.html` its still used by handbook authenticator; i won't judge anyone if they're still loading the handbook --- .../java/emu/grasscutter/Grasscutter.java | 1 - .../http/documentation/HandbookHandler.java | 1 + .../java/emu/grasscutter/utils/FileUtils.java | 6 +-- src/main/resources/html/handbook_auth.html | 46 +++++++++++++++++++ 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/html/handbook_auth.html diff --git a/src/main/java/emu/grasscutter/Grasscutter.java b/src/main/java/emu/grasscutter/Grasscutter.java index 544667c22..db56dd132 100644 --- a/src/main/java/emu/grasscutter/Grasscutter.java +++ b/src/main/java/emu/grasscutter/Grasscutter.java @@ -150,7 +150,6 @@ public final class Grasscutter { httpServer.addRouter(AuthenticationHandler.class); httpServer.addRouter(GachaHandler.class); httpServer.addRouter(DocumentationServerHandler.class); - httpServer.addRouter(HandbookHandler.class); } // Check if the HTTP server should start. 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 f896f2151..7c3ddacea 100644 --- a/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java +++ b/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java @@ -14,6 +14,7 @@ import java.util.*; import java.util.concurrent.*; /** Handles requests for the new GM Handbook. */ +@Deprecated(since = "1.7.5-dev") public final class HandbookHandler implements Router { private String handbook; private final boolean serve; diff --git a/src/main/java/emu/grasscutter/utils/FileUtils.java b/src/main/java/emu/grasscutter/utils/FileUtils.java index 0b1ab4fd1..0aaf53c92 100644 --- a/src/main/java/emu/grasscutter/utils/FileUtils.java +++ b/src/main/java/emu/grasscutter/utils/FileUtils.java @@ -199,10 +199,10 @@ public final class FileUtils { } public static byte[] readResource(String resourcePath) { - try (InputStream is = Grasscutter.class.getResourceAsStream(resourcePath)) { - return is.readAllBytes(); + try (var is = Grasscutter.class.getResourceAsStream(resourcePath)) { + return Objects.requireNonNull(is).readAllBytes(); } catch (Exception exception) { - Grasscutter.getLogger().warn("Failed to read resource: " + resourcePath); + Grasscutter.getLogger().warn("Failed to read resource: {}", resourcePath); Grasscutter.getLogger().debug("Failed to load resource: " + resourcePath, exception); } diff --git a/src/main/resources/html/handbook_auth.html b/src/main/resources/html/handbook_auth.html new file mode 100644 index 000000000..72895af5b --- /dev/null +++ b/src/main/resources/html/handbook_auth.html @@ -0,0 +1,46 @@ + + + + + Handbook Authentication + + + + + +

Input your Player UID here.

+
+ + + +
+ +