diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index 1f5e80426..1de873510 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -143,7 +143,7 @@ public class PlanBungee extends BungeePlugin implements IPlan { Log.logDebug("Enable", "WebServer Initialization"); Log.info(Locale.get(Msg.ENABLED).toString()); if (Settings.ANALYSIS_EXPORT.isTrue()) { - RunnableFactory.createNew(new HtmlExport(this)); + RunnableFactory.createNew(new HtmlExport(this)).runTaskAsynchronously(); } } catch (Exception e) { Log.error("Plugin Failed to Initialize Correctly."); 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 c2d47018f..94cc0f9d8 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 @@ -11,6 +11,7 @@ import main.java.com.djrapitops.plan.api.exceptions.ParseException; import main.java.com.djrapitops.plan.api.exceptions.WebAPIConnectionFailException; import main.java.com.djrapitops.plan.api.exceptions.WebAPIException; import main.java.com.djrapitops.plan.api.exceptions.WebAPINotFoundException; +import main.java.com.djrapitops.plan.settings.Settings; import main.java.com.djrapitops.plan.systems.cache.DataCache; import main.java.com.djrapitops.plan.systems.info.parsing.NetworkPageParser; import main.java.com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; @@ -24,6 +25,7 @@ import main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit.InspectWebA import main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit.IsOnlineWebAPI; import main.java.com.djrapitops.plan.systems.webserver.webapi.bungee.RequestPluginsTabWebAPI; import main.java.com.djrapitops.plan.utilities.MiscUtils; +import main.java.com.djrapitops.plan.utilities.file.export.HtmlExport; import main.java.com.djrapitops.plan.utilities.html.HtmlStructure; import java.io.IOException; @@ -369,7 +371,11 @@ public class BungeeInformationManager extends InformationManager { @Override public void updateNetworkPageContent() { - PageCache.cachePage("analysisPage:" + MiscUtils.getIPlan().getServerUuid(), () -> new AnalysisPageResponse(this)); + UUID serverUUID = MiscUtils.getIPlan().getServerUuid(); + PageCache.cachePage("analysisPage:" + serverUUID, () -> new AnalysisPageResponse(this)); + if (Settings.ANALYSIS_EXPORT.isTrue()) { + HtmlExport.exportServer(plugin, serverUUID); + } } public void sendConfigSettings() { 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 b676314ad..3c5f668e3 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 @@ -1,4 +1,4 @@ -/* +/* * 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 */ @@ -206,14 +206,17 @@ public class ResponseHandler extends APIResponseHandler { return PageCache.loadPage("notFound: " + error, () -> new NotFoundResponse(error)); } - plugin.getInfoManager().cachePlayer(uuid); - Response response = PageCache.loadPage("inspectPage: " + uuid); - // TODO Create a new method that places NotFoundResponse to PageCache instead. - if (response == null || response.getContent().contains("No Bukkit Servers were online to process this request")) { - PageCache.cachePage("inspectPage: " + uuid, () -> new InspectPageResponse(plugin.getInfoManager(), uuid)); - response = PageCache.loadPage("inspectPage: " + uuid); + if (plugin.getDB().wasSeenBefore(uuid)) { + plugin.getInfoManager().cachePlayer(uuid); + Response response = PageCache.loadPage("inspectPage: " + uuid); + // TODO Create a new method that places NotFoundResponse to PageCache instead. + if (response == null || response.getContent().contains("No Bukkit Servers were online to process this request")) { + PageCache.cachePage("inspectPage: " + uuid, () -> new InspectPageResponse(plugin.getInfoManager(), uuid)); + response = PageCache.loadPage("inspectPage: " + uuid); + } + return response; } - return response; + return new NotFoundResponse("Player has not played on this server."); } private Response notFoundResponse() { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java index 91d4d9822..7f863da0b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java @@ -2,10 +2,7 @@ package main.java.com.djrapitops.plan.systems.webserver.response; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; -import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.api.API; import main.java.com.djrapitops.plan.api.IPlan; -import main.java.com.djrapitops.plan.data.PlayerProfile; import main.java.com.djrapitops.plan.data.container.GeoInfo; import main.java.com.djrapitops.plan.data.container.Session; import main.java.com.djrapitops.plan.data.container.UserInfo; @@ -79,8 +76,6 @@ public class PlayersPageResponse extends Response { throw new IllegalArgumentException("No players"); } - API planAPI = Plan.getPlanAPI(); - int i = 0; int maxPlayers = Settings.MAX_PLAYERS_PLAYERS_PAGE.getNumber(); if (maxPlayers <= 0) { @@ -91,14 +86,15 @@ public class PlayersPageResponse extends Response { break; } UUID uuid = userInfo.getUuid(); - String[] playerData = new String[6]; String playerName = userInfo.getName(); - String link = Html.LINK_EXTERNAL.parse(planAPI.getPlayerInspectPageLink(playerName), playerName); + String link = Html.LINK_EXTERNAL.parse("../player/" + playerName, playerName); List sessions = sessionsByUser.getOrDefault(uuid, new ArrayList<>()); int sessionCount = sessions.size(); - long playtime = sessionCount != 0 ? PlayerProfile.getPlaytime(sessions.stream()) : 0L; + long playtime = sessionCount != 0 ? sessions.stream().map(Session::getLength) + .mapToLong(p -> p) + .sum() : 0L; long registered = userInfo.getRegistered(); long lastSeen = lastSeenForAllPlayers.getOrDefault(uuid, 0L); List geoInfoList = geoInfos.getOrDefault(uuid, new ArrayList<>()); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/AnalysisExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/AnalysisExport.java index bea12100c..8f26d2ff8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/AnalysisExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/AnalysisExport.java @@ -32,7 +32,10 @@ public class AnalysisExport extends SpecificExport { } catch (IOException e) { Log.toLog(this.getClass().getName(), e); } finally { - this.cancel(); + try { + this.cancel(); + } catch (IllegalArgumentException ignore) { + } } } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/HtmlExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/HtmlExport.java index 370496427..91e235a49 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/HtmlExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/HtmlExport.java @@ -71,7 +71,10 @@ public class HtmlExport extends SpecificExport { } catch (IOException | SQLException e) { Log.toLog(this.getClass().getName(), e); } finally { - this.cancel(); + try { + this.cancel(); + } catch (IllegalArgumentException ignore) { + } } } @@ -181,12 +184,8 @@ public class HtmlExport extends SpecificExport { File to = new File(outputFolder, outputFile); to.mkdirs(); if (to.exists()) { - if (overwrite) { - to.delete(); - to.createNewFile(); - } else { - return; - } + to.delete(); + to.createNewFile(); } export(to, lines); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/PlayerExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/PlayerExport.java index 276112e9b..c75c056a0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/PlayerExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/PlayerExport.java @@ -32,7 +32,10 @@ public class PlayerExport extends SpecificExport { } catch (IOException e) { Log.toLog(this.getClass().getName(), e); } finally { - this.cancel(); + try { + this.cancel(); + } catch (IllegalArgumentException ignore) { + } } } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java index 0228d4ecb..61aa663de 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java @@ -7,7 +7,6 @@ package main.java.com.djrapitops.plan.utilities.file.export; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.AbsRunnable; -import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.settings.Settings; import main.java.com.djrapitops.plan.systems.webserver.PageCache; import main.java.com.djrapitops.plan.systems.webserver.response.Response; @@ -51,7 +50,7 @@ public abstract class SpecificExport extends AbsRunnable { } return folder; } - File dataFolder = Plan.getInstance().getDataFolder(); + File dataFolder = MiscUtils.getIPlan().getDataFolder(); File folder = new File(dataFolder, path); folder.mkdirs(); return folder; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/Html.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/Html.java index 5031135aa..b489e9cc9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/Html.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/Html.java @@ -88,7 +88,7 @@ public enum Html { TABLELINE_3("${0}${1}${2}"), TABLELINE_4("${0}${1}${2}${3}"), TABLELINE_PLAYERS("${0}${1}${3}${4}${6}" + "${8}${9}"), - TABLELINE_PLAYERS_PLAYERS_PAGE("${0}${2}${4}${5}" + "${6}${7}"), + TABLELINE_PLAYERS_PLAYERS_PAGE("${0}${2}${3}${4}" + "${5}${6}"), TABLELINE_3_CUSTOMKEY("${1}${3}${5}"), TABLELINE_3_CUSTOMKEY_1("${1}${2}${3}"); diff --git a/Plan/src/main/resources/web/network.html b/Plan/src/main/resources/web/network.html index b434ea3f1..be5cb1b74 100644 --- a/Plan/src/main/resources/web/network.html +++ b/Plan/src/main/resources/web/network.html @@ -311,7 +311,7 @@ - +