diff --git a/Plan/pom.xml b/Plan/pom.xml index ee70cb4c3..50d990bcc 100644 --- a/Plan/pom.xml +++ b/Plan/pom.xml @@ -105,6 +105,7 @@ . ${basedir}/src/main/resources + *.js *.yml *.html diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/html/DataRequestHandler.java b/Plan/src/main/java/com/djrapitops/plan/ui/html/DataRequestHandler.java index 4d7889e70..b1cadbb9d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/html/DataRequestHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/html/DataRequestHandler.java @@ -52,7 +52,7 @@ public class DataRequestHandler { return "

404 Data was not found in cache

"; } return HtmlUtils.replacePlaceholders( - HtmlUtils.getHtmlStringFromResource("player.html"), + HtmlUtils.getStringFromResource("player.html"), PlaceholderUtils.getInspectReplaceRules(data) ); } catch (FileNotFoundException ex) { @@ -71,7 +71,7 @@ public class DataRequestHandler { return "

404 Data was not found in cache

"; } return HtmlUtils.replacePlaceholders( - HtmlUtils.getHtmlStringFromResource("analysis.html"), + HtmlUtils.getStringFromResource("analysis.html"), PlaceholderUtils.getAnalysisReplaceRules(analysisCache.getData()) ); } catch (FileNotFoundException ex) { diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/response/JavaScriptResponse.java b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/response/JavaScriptResponse.java new file mode 100644 index 000000000..d5145e901 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/response/JavaScriptResponse.java @@ -0,0 +1,25 @@ +package main.java.com.djrapitops.plan.ui.webserver.response; + +import main.java.com.djrapitops.plan.Log; +import main.java.com.djrapitops.plan.utilities.HtmlUtils; + +import java.io.FileNotFoundException; +import java.io.OutputStream; + +/** + * @author Rsl1122 + * @since 3.5.2 + */ +public class JavaScriptResponse extends Response { + + public JavaScriptResponse(OutputStream output, String resource) { + super(output); + super.setHeader("HTTP/1.1 200 OK"); + try { + super.setContent(HtmlUtils.getStringFromResource(resource)); + } catch (FileNotFoundException e) { + Log.toLog(this.getClass().getName(), e); + super.setContent(""); + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java index ca29dd44d..196bc866b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java @@ -21,7 +21,7 @@ public class HtmlUtils { * @return * @throws FileNotFoundException */ - public static String getHtmlStringFromResource(String fileName) throws FileNotFoundException { + public static String getStringFromResource(String fileName) throws FileNotFoundException { InputStream resourceStream = null; Scanner scanner = null; try { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/ExportUtility.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/ExportUtility.java index 2a71b03e8..ff057faa6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/ExportUtility.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/ExportUtility.java @@ -90,7 +90,7 @@ public class ExportUtility { if (!Settings.ANALYSIS_EXPORT.isTrue()) { return; } - String inspectHtml = HtmlUtils.replacePlaceholders(HtmlUtils.getHtmlStringFromResource("player.html"), + String inspectHtml = HtmlUtils.replacePlaceholders(HtmlUtils.getStringFromResource("player.html"), PlaceholderUtils.getInspectReplaceRules(userData)); File playerFolder = new File(playersFolder, userData.getName()); playerFolder.mkdir(); @@ -109,7 +109,7 @@ public class ExportUtility { if (!Settings.ANALYSIS_EXPORT.isTrue()) { return; } - String analysisHtml = HtmlUtils.replacePlaceholders(HtmlUtils.getHtmlStringFromResource("analysis.html"), + String analysisHtml = HtmlUtils.replacePlaceholders(HtmlUtils.getStringFromResource("analysis.html"), PlaceholderUtils.getAnalysisReplaceRules(analysisData)) .replace(HtmlUtils.getInspectUrl(""), "../player/"); File analysisHtmlFile = new File(serverFolder, "index.html"); diff --git a/Plan/src/main/resources/analysis.html b/Plan/src/main/resources/analysis.html index 78927aebe..dd115a49b 100644 --- a/Plan/src/main/resources/analysis.html +++ b/Plan/src/main/resources/analysis.html @@ -129,7 +129,7 @@ color: white; background-color: #348e0f; padding: 8px 14px; - border-radius: 10px; + border-radius: 6px; float: right; } .info-text { @@ -155,7 +155,7 @@ border-style: solid; border-color: #348e0f; padding: 8px 14px; - border-radius: 10px; + border-radius: 3px; width: 95%; } .header-icon { @@ -389,65 +389,8 @@ class="fa fa-crosshairs" aria-hidden="true"> Mob kills: %mobkills% | Deaths: %deaths%

-
-

Gamemode Usage


-
-
-
- -
-
-
- %gm0% -
-
- Survival -
-
-
-
-
- -
-
-
- %gm1% -
-
- Creative -
-
-
-
-
- -
-
-
- %gm2% -
-
- Adventure -
-
-
-
-
- -
-
-
- %gm3% -
-
- Spectator -
-
-
-
- +
+
@@ -536,10 +479,10 @@
-
+
Playerbase Composition
+ class="header-text"> Playerbase
@@ -555,63 +498,7 @@
-
-
-
- -
-
-
- %active% -
-
- __Active -
-
-
-
-
- -
-
-
- %inactive% -
-
- Inactive -
-
-
-
-
- -
-
-
- %joinleaver% -
-
- Single_join -
-
-
-
-
- -
-
-
- %banned% -
-
- Banned -
-
-
-
-

- -
+

+ - - +

\ No newline at end of file diff --git a/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/HtmlUtilsTest.java b/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/HtmlUtilsTest.java index dfa447914..40b0a54c2 100644 --- a/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/HtmlUtilsTest.java +++ b/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/HtmlUtilsTest.java @@ -47,7 +47,7 @@ public class HtmlUtilsTest { public void testGetHtmlStringFromResource() throws Exception { TestInit t = TestInit.init(); String fileName = "player.html"; - String result = HtmlUtils.getHtmlStringFromResource(fileName); + String result = HtmlUtils.getStringFromResource(fileName); assertTrue("Result empty", !result.isEmpty()); }