From 1d4f3237b844fce25b1d2b9e9428fe95bd72b0de Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 1 Sep 2017 17:32:06 +0300 Subject: [PATCH] Fix compile issues, Added player counts to analysis page --- .../systems/info/parsing/AnalysisPageParser.java | 12 ++++++++++++ .../com/djrapitops/plan/database/DatabaseTest.java | 4 ++-- .../com/djrapitops/plan/utilities/MiscUtilsTest.java | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) 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 44cbd768e..644e3e09e 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 @@ -4,9 +4,11 @@ */ package main.java.com.djrapitops.plan.systems.info.parsing; +import com.djrapitops.plugin.utilities.Compatibility; import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.exceptions.ParseException; +import main.java.com.djrapitops.plan.bungee.PlanBungee; import main.java.com.djrapitops.plan.data.AnalysisData; import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.file.FileUtil; @@ -35,10 +37,20 @@ public class AnalysisPageParser extends PageParser { addValue("tabContentPlugins", data.replacePluginsTabLayout()); addValue("serverName", Settings.SERVER_NAME.toString()); addValue("timeZone", MiscUtils.getTimeZoneOffsetHours()); + + addValue("playersMax", plugin.getVariable().getMaxPlayers()); + addValue("playersOnline", getPlayersOnline()); try { return HtmlUtils.replacePlaceholders(FileUtil.getStringFromResource("server.html"), placeHolders); } catch (FileNotFoundException e) { throw new ParseException(e); } } + + private int getPlayersOnline() { + if (Compatibility.isBukkitAvailable()) { + return plugin.fetch().getOnlinePlayers().size(); + } + return ((PlanBungee) plugin).getProxy().getOnlineCount(); + } } \ No newline at end of file diff --git a/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java b/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java index 8ada76aad..90a4582bc 100644 --- a/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java @@ -60,7 +60,7 @@ public class DatabaseTest { db = new SQLiteDB(plan, "debug" + MiscUtils.getTime()); db.init(); - db.getServerTable().saveCurrentServerInfo(new ServerInfo(-1, TestInit.getServerUUID(), "ServerName", "")); + db.getServerTable().saveCurrentServerInfo(new ServerInfo(-1, TestInit.getServerUUID(), "ServerName", "", 20)); File f = new File(plan.getDataFolder(), "Errors.txt"); rows = FileUtil.lines(f).size(); @@ -609,7 +609,7 @@ public class DatabaseTest { assertFalse(bungeeInfo.isPresent()); UUID bungeeUUID = UUID.randomUUID(); - ServerInfo bungeeCord = new ServerInfo(-1, bungeeUUID, "BungeeCord", "Random:1234"); + ServerInfo bungeeCord = new ServerInfo(-1, bungeeUUID, "BungeeCord", "Random:1234", 20); serverTable.saveCurrentServerInfo(bungeeCord); bungeeCord.setId(2); diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java b/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java index 3d6f3c51b..1207f6230 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java @@ -157,7 +157,7 @@ public class MiscUtilsTest { db = new SQLiteDB(plan, "debug" + MiscUtils.getTime()); db.init(); - db.getServerTable().saveCurrentServerInfo(new ServerInfo(-1, TestInit.getServerUUID(), "ServerName", "")); + db.getServerTable().saveCurrentServerInfo(new ServerInfo(-1, TestInit.getServerUUID(), "ServerName", "", 20)); when(plan.getDB()).thenReturn(db); }