From 1a139034b570964d3f79d5885a8170aca29e6db5 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Sun, 17 Apr 2022 18:26:01 -0500 Subject: [PATCH] merge --- src/main/java/dev/plex/HTTPDModule.java | 6 ++-- ...adEndpoint.java => SchematicEndpoint.java} | 29 +++++++++++++------ .../request/impl/SchematicIndexEndpoint.java | 15 ---------- src/main/resources/httpd/admins.html | 8 ++--- src/main/resources/httpd/index.html | 10 +++---- src/main/resources/httpd/punishments.html | 8 ++--- .../resources/httpd/punishments_error.html | 8 ++--- .../resources/httpd/punishments_good.html | 8 ++--- src/main/resources/httpd/schematic_index.html | 6 ++-- src/main/resources/httpd/schematic_list.html | 6 ++-- 10 files changed, 49 insertions(+), 55 deletions(-) rename src/main/java/dev/plex/request/impl/{SchematicDownloadEndpoint.java => SchematicEndpoint.java} (85%) delete mode 100644 src/main/java/dev/plex/request/impl/SchematicIndexEndpoint.java diff --git a/src/main/java/dev/plex/HTTPDModule.java b/src/main/java/dev/plex/HTTPDModule.java index c3179bf..eb74f7b 100644 --- a/src/main/java/dev/plex/HTTPDModule.java +++ b/src/main/java/dev/plex/HTTPDModule.java @@ -8,8 +8,7 @@ import dev.plex.request.impl.IndefBansEndpoint; import dev.plex.request.impl.IndexEndpoint; import dev.plex.request.impl.ListEndpoint; import dev.plex.request.impl.PunishmentsEndpoint; -import dev.plex.request.impl.SchematicDownloadEndpoint; -import dev.plex.request.impl.SchematicIndexEndpoint; +import dev.plex.request.impl.SchematicEndpoint; import dev.plex.util.PlexLog; import java.util.concurrent.atomic.AtomicReference; import lombok.Getter; @@ -72,8 +71,7 @@ public class HTTPDModule extends PlexModule new IndexEndpoint(); new ListEndpoint(); new PunishmentsEndpoint(); - new SchematicDownloadEndpoint(); - new SchematicIndexEndpoint(); + new SchematicEndpoint(); server.setConnectors(new Connector[]{connector}); server.setHandler(context); diff --git a/src/main/java/dev/plex/request/impl/SchematicDownloadEndpoint.java b/src/main/java/dev/plex/request/impl/SchematicEndpoint.java similarity index 85% rename from src/main/java/dev/plex/request/impl/SchematicDownloadEndpoint.java rename to src/main/java/dev/plex/request/impl/SchematicEndpoint.java index 88aef7b..d1c2e5e 100644 --- a/src/main/java/dev/plex/request/impl/SchematicDownloadEndpoint.java +++ b/src/main/java/dev/plex/request/impl/SchematicEndpoint.java @@ -4,18 +4,17 @@ import dev.plex.HTTPDModule; import dev.plex.request.AbstractServlet; import dev.plex.request.GetMapping; import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.util.Arrays; - -import jakarta.servlet.http.HttpServletResponse; import org.bukkit.Bukkit; -public class SchematicDownloadEndpoint extends AbstractServlet +public class SchematicEndpoint extends AbstractServlet { @GetMapping(endpoint = "/api/schematics/download/") - public String downloadSchematics(HttpServletRequest request, HttpServletResponse response) + public String schematicIndex(HttpServletRequest request, HttpServletResponse response) { if (request.getPathInfo() == null || request.getPathInfo().equals("/")) { @@ -24,9 +23,12 @@ public class SchematicDownloadEndpoint extends AbstractServlet else { OutputStream outputStream = null; - try { + try + { outputStream = response.getOutputStream(); - } catch (IOException e) { + } + catch (IOException e) + { return null; } schematicServe(request.getPathInfo().replace("/", ""), outputStream); @@ -53,7 +55,10 @@ public class SchematicDownloadEndpoint extends AbstractServlet private void schematicServe(String requestedSchematic, OutputStream outputStream) { File worldeditFolder = getWorldeditFolder(); - if (worldeditFolder == null) return; + if (worldeditFolder == null) + { + return; + } File[] schems = worldeditFolder.listFiles(); if (schems != null) { @@ -63,7 +68,10 @@ public class SchematicDownloadEndpoint extends AbstractServlet try { outputStream.write(HTTPDModule.fileCache.getFile(schemFile)); - } catch (IOException ignored) {} + } + catch (IOException ignored) + { + } } } } @@ -72,7 +80,10 @@ public class SchematicDownloadEndpoint extends AbstractServlet { String file = readFile(this.getClass().getResourceAsStream("/httpd/schematic_list.html")); File worldeditFolder = getWorldeditFolder(); - if (worldeditFolder == null) return null; + if (worldeditFolder == null) + { + return null; + } StringBuilder sb = new StringBuilder(); File[] alphabetical = worldeditFolder.listFiles(); if (alphabetical != null) diff --git a/src/main/java/dev/plex/request/impl/SchematicIndexEndpoint.java b/src/main/java/dev/plex/request/impl/SchematicIndexEndpoint.java deleted file mode 100644 index 42a712b..0000000 --- a/src/main/java/dev/plex/request/impl/SchematicIndexEndpoint.java +++ /dev/null @@ -1,15 +0,0 @@ -package dev.plex.request.impl; - -import dev.plex.request.AbstractServlet; -import dev.plex.request.GetMapping; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -public class SchematicIndexEndpoint extends AbstractServlet -{ - @GetMapping(endpoint = "/api/schematics/") - public String schematicIndex(HttpServletRequest request, HttpServletResponse response) - { - return readFile(this.getClass().getResourceAsStream("/httpd/schematic_list.html")); - } -} diff --git a/src/main/resources/httpd/admins.html b/src/main/resources/httpd/admins.html index 52e1ab6..ff1e5ef 100644 --- a/src/main/resources/httpd/admins.html +++ b/src/main/resources/httpd/admins.html @@ -26,16 +26,16 @@ Admins diff --git a/src/main/resources/httpd/index.html b/src/main/resources/httpd/index.html index 7bde1cf..6437af6 100644 --- a/src/main/resources/httpd/index.html +++ b/src/main/resources/httpd/index.html @@ -23,19 +23,19 @@ Home diff --git a/src/main/resources/httpd/punishments.html b/src/main/resources/httpd/punishments.html index 7689efd..350f7d3 100644 --- a/src/main/resources/httpd/punishments.html +++ b/src/main/resources/httpd/punishments.html @@ -23,19 +23,19 @@ Home diff --git a/src/main/resources/httpd/punishments_error.html b/src/main/resources/httpd/punishments_error.html index 2f315c6..4497774 100644 --- a/src/main/resources/httpd/punishments_error.html +++ b/src/main/resources/httpd/punishments_error.html @@ -23,19 +23,19 @@ Home diff --git a/src/main/resources/httpd/punishments_good.html b/src/main/resources/httpd/punishments_good.html index 4a5aaab..b4f010c 100644 --- a/src/main/resources/httpd/punishments_good.html +++ b/src/main/resources/httpd/punishments_good.html @@ -23,19 +23,19 @@ Home diff --git a/src/main/resources/httpd/schematic_index.html b/src/main/resources/httpd/schematic_index.html index 40f3cc7..927c7ff 100644 --- a/src/main/resources/httpd/schematic_index.html +++ b/src/main/resources/httpd/schematic_index.html @@ -26,13 +26,13 @@ Admins