diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 0e1048fc8..84c5011c4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -180,16 +180,16 @@ public class Plan extends BukkitPlugin implements IPlan { this.api = new API(this); - // Data view settings // TODO Rewrite. (TextUI removed & webServer might be running on bungee -// boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue(); -// boolean hasDataViewCapability = usingAlternativeIP; -// -// if (!hasDataViewCapability) { -// Log.infoColor(Locale.get(Msg.ENABLE_NOTIFY_NO_DATA_VIEW).toString()); -// } -// if (!usingAlternativeIP && serverVariableHolder.getIp().isEmpty()) { -// Log.infoColor(Locale.get(Msg.ENABLE_NOTIFY_EMPTY_IP).toString()); -// } + boolean usingBungeeWebServer = infoManager.isUsingBungeeWebServer(); + boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue(); + + if (!usingAlternativeIP && serverVariableHolder.getIp().isEmpty()) { + Log.infoColor(Locale.get(Msg.ENABLE_NOTIFY_EMPTY_IP).toString()); + } + if (usingBungeeWebServer && usingAlternativeIP) { + // TODO Move to Locale + Log.info("Make sure that the alternative IP points to Bungee Server: " + Settings.ALTERNATIVE_IP.toString()); + } registerCommand(new PlanCommand(this)); diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index 796c2db26..077c62cdc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -67,7 +67,9 @@ public class PlanBungee extends BungeePlugin implements IPlan { String ip = variableHolder.getIp(); if ("0.0.0.0".equals(ip)) { - Log.error("IP setting still 0.0.0.0 - Set up AlternativeIP/IP that connects to the Proxy server."); + Log.error("IP setting still 0.0.0.0 - Config AlternativeIP/IP that connects to the Proxy server."); + disablePlugin(); + return; } Benchmark.start("WebServer Initialization"); diff --git a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java index 52168eb03..6f8e6088b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java +++ b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java @@ -18,7 +18,9 @@ import java.util.Map; import java.util.UUID; /** - * //TODO Class Javadoc Comment + * Thread that is run when JVM shuts down. + *

+ * Saves active sessions to the Database (PlayerQuitEvent is not called) * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPINotFoundException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPINotFoundException.java index c46a51aa3..1cc8ad299 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPINotFoundException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPINotFoundException.java @@ -5,7 +5,7 @@ package main.java.com.djrapitops.plan.api.exceptions; /** - * //TODO Class Javadoc Comment + * Thrown when WebAPI returns 404, usually when response is supposed to be false. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java index 3d1891763..91ad675ec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java @@ -19,7 +19,7 @@ import java.util.Optional; import java.util.UUID; /** - * //TODO Class Javadoc Comment + * Command used for testing functions that are too difficult to unit test. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java index 9a0db537c..58b4c2719 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -37,7 +37,9 @@ import java.io.Serializable; import java.util.*; /** - * //TODO Class Javadoc Comment + * Manages the Information going to the PageCache. + *

+ * This means Inspect and Analysis pages as well as managing what is sent to Bungee WebServer when one is in use. * * @author Rsl1122 */ @@ -231,4 +233,9 @@ public class BukkitInformationManager extends InformationManager { } return false; } + + @Override + public String getWebServerAddress() { + return webServerAddress != null ? webServerAddress : plugin.getWebServer().getAccessAddress(); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java index 4fd649d14..828907479 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -25,7 +25,7 @@ import java.util.function.Function; import java.util.stream.Collectors; /** - * //TODO Class Javadoc Comment + * Manages information going to the PageCache from Bukkit servers. * * @author Rsl1122 */ @@ -175,4 +175,8 @@ public class BungeeInformationManager extends InformationManager { return plugin.getWebServer().getWebAPI(); } + @Override + public String getWebServerAddress() { + return plugin.getWebServer().getAccessAddress(); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java index f8a2bdfd0..124f747f0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java @@ -15,7 +15,9 @@ import java.util.Set; import java.util.UUID; /** - * //TODO Class Javadoc Comment + * Abstract layer for Bukkit and Bungee Information managers. + *

+ * Manages analysis notification sending. * * @author Rsl1122 */ @@ -77,4 +79,6 @@ public abstract class InformationManager { public boolean isUsingBungeeWebServer() { return usingBungeeWebServer; } + + public abstract String getWebServerAddress(); } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java index f6a62c312..0771ec803 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java @@ -17,7 +17,7 @@ import main.java.com.djrapitops.plan.utilities.html.HtmlUtils; import java.io.FileNotFoundException; /** - * //TODO Class Javadoc Comment + * Used for parsing a Html String out of AnalysisData and the html file. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java index 1c64e4f95..91869c73f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java @@ -35,7 +35,7 @@ import java.util.UUID; import java.util.stream.Collectors; /** - * //TODO Class Javadoc Comment + * Used for parsing Inspect page out of database data and the html. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/PageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/PageParser.java index 6701cceab..f0e77140e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/PageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/PageParser.java @@ -11,7 +11,7 @@ import java.util.HashMap; import java.util.Map; /** - * //TODO Class Javadoc Comment + * Abstract class that is responsible for parsing data and html together into a String. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/CommandProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/CommandProcessor.java index 5bcafc8f0..e07d41451 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/CommandProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/CommandProcessor.java @@ -10,7 +10,7 @@ import main.java.com.djrapitops.plan.Plan; import java.sql.SQLException; /** - * //TODO Class Javadoc Comment + * Updates Command usage amount in the database. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/DBCommitProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/DBCommitProcessor.java deleted file mode 100644 index 555971930..000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/DBCommitProcessor.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licence is provided in the jar as license.yml also here: - * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml - */ -package main.java.com.djrapitops.plan.systems.processing; - -import main.java.com.djrapitops.plan.database.Database; - -/** - * Processor for queueing a Database Commit after changes. - * - * @author Rsl1122 - */ -public class DBCommitProcessor extends Processor { - public DBCommitProcessor(Database object) { - super(object); - } - - @Override - public void process() { - // TODO Prevent Commit during batch operations. -// try { -// object.commit(); -// } catch (SQLException e) { -// Log.toLog(this.getClass().getName(), e); -// } - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java index 54bb6384e..a4e8ac9e8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java @@ -13,7 +13,7 @@ import java.sql.SQLException; import java.util.List; /** - * //TODO Class Javadoc Comment + * Processes 60s average of a TPS list. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java index 8f88575fd..f580099ba 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java @@ -15,7 +15,7 @@ import main.java.com.djrapitops.plan.utilities.html.HtmlUtils; import java.util.UUID; /** - * //TODO Class Javadoc Comment + * Sends a request to cache players inspect page to the PageCache on the appropriate WebServer. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BanAndOpProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BanAndOpProcessor.java index 0e930eddd..c0d06b0f2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BanAndOpProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BanAndOpProcessor.java @@ -11,7 +11,7 @@ import java.sql.SQLException; import java.util.UUID; /** - * //TODO Class Javadoc Comment + * Updates ban and OP status of the player to the database. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/DeathProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/DeathProcessor.java index 45f641515..e192999d1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/DeathProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/DeathProcessor.java @@ -7,7 +7,7 @@ import java.util.Optional; import java.util.UUID; /** - * // TODO Write Javadoc Class Description + * Updates death count of the current session. * * @author Rsl1122 * @since 4.0.0 diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/EndSessionProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/EndSessionProcessor.java index f185d59a4..bcc923e98 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/EndSessionProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/EndSessionProcessor.java @@ -9,7 +9,7 @@ import main.java.com.djrapitops.plan.Plan; import java.util.UUID; /** - * //TODO Class Javadoc Comment + * Ends a session and saves it to the database. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/IPUpdateProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/IPUpdateProcessor.java index 8cf272852..4d044ace6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/IPUpdateProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/IPUpdateProcessor.java @@ -12,7 +12,7 @@ import java.sql.SQLException; import java.util.UUID; /** - * //TODO Class Javadoc Comment + * Updates the IP and Geolocation of a user. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KickProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KickProcessor.java index c3fe16200..ea8dfa541 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KickProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KickProcessor.java @@ -11,7 +11,7 @@ import java.sql.SQLException; import java.util.UUID; /** - * //TODO Class Javadoc Comment + * Updates the Kick count of a user. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIResponseHandler.java index 7635ae5a0..fc81f0be8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIResponseHandler.java @@ -7,11 +7,13 @@ package main.java.com.djrapitops.plan.systems.webserver; import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.systems.webserver.response.ForbiddenResponse; +import main.java.com.djrapitops.plan.systems.webserver.response.NotFoundResponse; import main.java.com.djrapitops.plan.systems.webserver.response.Response; import main.java.com.djrapitops.plan.systems.webserver.response.api.BadRequestResponse; import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPI; import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPIManager; import main.java.com.djrapitops.plan.utilities.MiscUtils; +import main.java.com.djrapitops.plan.utilities.html.Html; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -25,7 +27,7 @@ import java.util.UUID; import java.util.stream.Collectors; /** - * //TODO Class Javadoc Comment + * Handles choosing of the correct API response to an API request. * * @author Rsl1122 */ @@ -41,6 +43,13 @@ public class APIResponseHandler { String target = request.getTarget(); String[] args = target.split("/"); + if (args.length < 2 || !"api".equals(args[1])) { + String address = MiscUtils.getIPlan().getInfoManager().getWebServerAddress() + target; + String link = Html.LINK.parse(address, address); + return PageCache.loadPage("Non-API Request", () -> new NotFoundResponse("WebServer is in WebAPI-only mode, " + + "connect to the Bungee server instead: " + link)); + } + if (args.length < 3) { String error = "API Method not specified"; return PageCache.loadPage(error, () -> new BadRequestResponse(error)); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/Request.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/Request.java index 1c1e56993..d63e41e12 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/Request.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/Request.java @@ -12,7 +12,9 @@ import java.io.InputStream; import java.util.List; /** - * //TODO Class Javadoc Comment + * Represents a HttpExchange Request. + *

+ * Automatically gets the Basic Auth from headers. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java index f6ca62c27..230cf5ad7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java @@ -20,7 +20,7 @@ import java.util.Optional; import java.util.UUID; /** - * //TODO Class Javadoc Comment + * Handles choosing of the correct response to a request. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java index 4ab3fe925..3e423be14 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java @@ -15,7 +15,13 @@ import java.util.Map; import java.util.UUID; /** - * //TODO Class Javadoc Comment + * WebAPI for requesting Inspect plugins tab contents from a Bukkit Server. + *

+ * Call: Bungee -> Bukkit + *

+ * Bad Requests: + * - Called a Bungee Server + * - Did not include uuid variable * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java index 69a3f1ef1..3de307e9d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java @@ -4,7 +4,6 @@ */ package main.java.com.djrapitops.plan.systems.webserver.webapi.bungee; -import com.djrapitops.plugin.utilities.Verify; import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.exceptions.WebAPIException; import main.java.com.djrapitops.plan.systems.info.BungeeInformationManager; @@ -15,7 +14,12 @@ import java.util.Map; import java.util.UUID; /** - * //TODO Class Javadoc Comment + * WebAPI for posting Inspect page Plugins tab contents to the Bungee server. + *

+ * Call: Bukkit -> Bungee + *

+ * Bad Requests: + * - Did not include uuid * * @author Rsl1122 */ @@ -23,13 +27,12 @@ public class PostInspectPluginsTabWebAPI extends WebAPI { @Override public Response onRequest(IPlan plugin, Map variables) { String uuidS = variables.get("uuid"); - String sender = variables.get("sender"); - if (Verify.notNull(uuidS, sender)) { - return badRequest("uuid or sender not included"); + if (uuidS == null) { + return badRequest("uuid not included"); } UUID uuid = UUID.fromString(uuidS); - UUID serverUUID = UUID.fromString(sender); + UUID serverUUID = UUID.fromString(variables.get("sender")); String html = variables.get("html"); ((BungeeInformationManager) plugin.getInfoManager()).cachePluginsTabContent(serverUUID, uuid, html); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestPluginsTabWebAPI.java index 4862adb8e..ae3d6b2d7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestPluginsTabWebAPI.java @@ -20,7 +20,13 @@ import java.util.Map; import java.util.UUID; /** - * //TODO Class Javadoc Comment + * WebAPI for requesting Bungee Server to request Plugins tab contents from every server. + *

+ * Call: Bukkit -> Bungee + *

+ * Bad Requests: + * - Called a Bukkit Server + * - Did not include uuid variable * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/SessionLengthDistributionGraphCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/SessionLengthDistributionGraphCreator.java deleted file mode 100644 index 928c5ae18..000000000 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/SessionLengthDistributionGraphCreator.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package main.java.com.djrapitops.plan.utilities.html.graphs; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * @author Rsl1122 - */ -@Deprecated // Not going to be used TODO REMOVE -public class SessionLengthDistributionGraphCreator { - - /** - * Constructor used to hide the public constructor - */ - private SessionLengthDistributionGraphCreator() { - throw new IllegalStateException("Utility class"); - } - - /** - * Creates a data series of session lengths for Sessions bar chart. - *

- * Contains values from 0 up to 120 minutes - * - * @param lengths Lengths of all sessions in a list. - * @return Data for HighCharts series. - */ - public static String createDataSeries(List lengths) { - Map bars = getValues(lengths); - List keys = new ArrayList<>(bars.keySet()); - Collections.sort(keys); - - StringBuilder arrayBuilder = new StringBuilder("["); - int i = 0; - int size = keys.size(); - for (Long key : keys) { - if (key > 120) { - break; - } - Integer value = bars.get(key); - arrayBuilder.append("['").append(key - 5).append(" - ").append(key).append(" min',").append(value).append("]"); - if (i < size) { - arrayBuilder.append(", "); - } - i++; - } - arrayBuilder.append("]"); - return arrayBuilder.toString(); - } - - private static Map getValues(Collection lengths) { - List unused = new ArrayList<>(lengths); - Map values = new HashMap<>(); - long lengthInMinutes = 5; - - while (!unused.isEmpty() || lengthInMinutes <= 120) { - long length = lengthInMinutes * 60 * 1000; - List lessThan = unused.stream().filter(l -> l < length).collect(Collectors.toList()); - int amount = lessThan.size(); - if (amount != 0) { - values.put(lengthInMinutes, amount); - unused.removeAll(lessThan); - } - lengthInMinutes += 5; - } - return values; - } -} diff --git a/Plan/src/main/resources/Placeholders.txt b/Plan/src/main/resources/Placeholders.txt index e2fc5c674..85bb819a3 100644 --- a/Plan/src/main/resources/Placeholders.txt +++ b/Plan/src/main/resources/Placeholders.txt @@ -23,7 +23,6 @@ ${playerKillCount} num ${mobKillCount} num ${deathCount} num -// TODO All these after SessionData has been updated. ${sessionCountDay} num ${sessionCountWeek} num ${playtimeDay} timeamount @@ -132,9 +131,6 @@ ${punchCardSeries} ${playersGraphColor} // done - -${gmData} // TODO Remove -${gmTotal} timeamount // TODO Remove ${gmColors} // TODO Move to World Graph // done diff --git a/Plan/src/main/resources/server - Example.html b/Plan/src/main/resources/server - Example.html index b6a2a17d5..106de0bf3 100644 --- a/Plan/src/main/resources/server - Example.html +++ b/Plan/src/main/resources/server - Example.html @@ -537,26 +537,6 @@ y: ${banned} }] }; - var gmData = ${gmData}; - var gmSeries = { - name: 'GM Usage', - colorByPoint: true, - data: [{ - name: 'Survival', - y: gmData[0], - sliced: true, - selected: true - }, { - name: 'Creative', - y: gmData[1] - }, { - name: 'Adventure', - y: gmData[2] - }, { - name: 'Spectator', - y: gmData[3] - }] - }; var worldSeries = { name: 'World Playtime', colorByPoint: true, diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/queue/QueueTest.java b/Plan/test/main/java/com/djrapitops/plan/data/cache/queue/QueueTest.java deleted file mode 100644 index bf87ae79e..000000000 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/queue/QueueTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package main.java.com.djrapitops.plan.data.cache.queue; - -import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.database.Database; -import main.java.com.djrapitops.plan.database.databases.SQLiteDB; -import main.java.com.djrapitops.plan.systems.cache.DataCache; -import main.java.com.djrapitops.plan.utilities.MiscUtils; -import org.bukkit.plugin.java.JavaPlugin; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import test.java.utils.TestInit; - -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import static org.powermock.api.mockito.PowerMockito.when; - -// TODO Rewrite -@RunWith(PowerMockRunner.class) -@PrepareForTest({JavaPlugin.class}) -public class QueueTest { - - private Database db; - - @Before - public void setUp() throws Exception { - TestInit t = TestInit.init(); - Plan plan = t.getPlanMock(); - - db = new SQLiteDB(plan, "debug" + MiscUtils.getTime()); - db.init(); - when(plan.getDB()).thenReturn(db); - - DataCache dataCache = new DataCache(plan); - when(plan.getDataCache()).thenReturn(dataCache); - } - - @After - public void tearDown() throws SQLException { - db.close(); - } - - @Test - public void testProcessQueue() { - List processCalls = new ArrayList<>(); - List errors = new ArrayList<>(); - // TODO Rewrite - } -} diff --git a/Plan/test/main/java/com/djrapitops/plan/database/tables/ActionsTest.java b/Plan/test/main/java/com/djrapitops/plan/database/tables/ActionsTest.java index ab4de9473..fed2d1d6c 100644 --- a/Plan/test/main/java/com/djrapitops/plan/database/tables/ActionsTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/database/tables/ActionsTest.java @@ -4,11 +4,6 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -/** - * //TODO Class Javadoc Comment - * - * @author Rsl1122 - */ public class ActionsTest { @Test diff --git a/Plan/test/main/java/com/djrapitops/plan/systems/cache/SessionCacheTest.java b/Plan/test/main/java/com/djrapitops/plan/systems/cache/SessionCacheTest.java index 16d58e831..eb811b433 100644 --- a/Plan/test/main/java/com/djrapitops/plan/systems/cache/SessionCacheTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/systems/cache/SessionCacheTest.java @@ -10,11 +10,6 @@ import java.util.UUID; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -/** - * //TODO Class Javadoc Comment - * - * @author Rsl1122 - */ public class SessionCacheTest { private final UUID uuid = MockUtils.getPlayerUUID(); diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/html/HtmlStructureTest.java b/Plan/test/main/java/com/djrapitops/plan/utilities/html/HtmlStructureTest.java index 8ae475356..23106a7c1 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/html/HtmlStructureTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/utilities/html/HtmlStructureTest.java @@ -19,11 +19,6 @@ import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; -/** - * //TODO Class Javadoc Comment - * - * @author Rsl1122 - */ @RunWith(PowerMockRunner.class) @PrepareForTest(JavaPlugin.class) public class HtmlStructureTest { diff --git a/Plan/test/test/java/utils/RandomData.java b/Plan/test/test/java/utils/RandomData.java index 6d1b89745..84213c172 100644 --- a/Plan/test/test/java/utils/RandomData.java +++ b/Plan/test/test/java/utils/RandomData.java @@ -11,6 +11,7 @@ import org.apache.commons.lang3.RandomStringUtils; import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; public class RandomData { @@ -65,7 +66,12 @@ public class RandomData { } public static List randomUserData() { - return new ArrayList<>(); - // TODO Rewrite + List test = new ArrayList<>(); + for (int i = 0; i < 20; i++) { + UserInfo info = new UserInfo(UUID.randomUUID(), randomString(10), r.nextLong(), r.nextBoolean(), r.nextBoolean()); + info.setLastSeen(r.nextLong()); + test.add(info); + } + return test; } }