diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index fb7c06d7b..873d92b96 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -41,6 +41,7 @@ import main.java.com.djrapitops.plan.ui.webserver.WebSocketServer; import main.java.com.djrapitops.plan.utilities.Benchmark; import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.MiscUtils; +import main.java.com.djrapitops.plan.utilities.metrics.BStats; import org.bukkit.Bukkit; import java.io.*; @@ -145,7 +146,7 @@ public class Plan extends BukkitPlugin { } Benchmark.stop("Enable: Analysis refresh task registration"); - Benchmark.start("Enable: Webserver Initialization"); + Benchmark.start("Enable: WebServer Initialization"); // Data view settings boolean webserverIsEnabled = Settings.WEBSERVER_ENABLED.isTrue(); boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue(); @@ -163,7 +164,7 @@ public class Plan extends BukkitPlugin { if (!usingAlternativeIP && serverVariableHolder.getIp().isEmpty()) { Log.infoColor(Phrase.NOTIFY_EMPTY_IP + ""); } - Benchmark.stop("Enable: Webserver Initialization"); + Benchmark.stop("Enable: WebServer Initialization"); registerCommand(new PlanCommand(this)); @@ -171,7 +172,10 @@ public class Plan extends BukkitPlugin { hookHandler = new HookHandler(this); Benchmark.stop("Enable: Hook to 3rd party plugins"); - Log.debug("Verboose debug messages are enabled."); + BStats bStats = new BStats(this); + bStats.registerMetrics(); + + Log.debug("Verbose debug messages are enabled."); Log.info(Phrase.ENABLED + ""); processStatus().finishExecution("Enable"); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/metrics/BStats.java b/Plan/src/main/java/com/djrapitops/plan/utilities/metrics/BStats.java new file mode 100644 index 000000000..023adc9ae --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/metrics/BStats.java @@ -0,0 +1,64 @@ +package main.java.com.djrapitops.plan.utilities.metrics; + +import main.java.com.djrapitops.plan.Plan; +import main.java.com.djrapitops.plan.Settings; +import org.bstats.bukkit.Metrics; + +import java.util.concurrent.Callable; + +public class BStats { + private final Plan plugin; + private Metrics bStats; + + public BStats(Plan plugin) { + this.plugin = plugin; + } + + public void registerMetrics() { + if (bStats == null) { + bStats = new Metrics(plugin); + } + registerConfigSettingGraphs(); + } + + private void registerConfigSettingGraphs() { + boolean webserver = Settings.WEBSERVER_ENABLED.isTrue(); + boolean analysisRefreshEnable = Settings.ANALYSIS_REFRESH_ON_ENABLE.isTrue(); + boolean analysisAutoRefresh = Settings.ANALYSIS_AUTO_REFRESH.getNumber() != -1; + boolean export = Settings.ANALYSIS_EXPORT.isTrue(); + boolean gatherChat = Settings.GATHERCHAT.isTrue(); + boolean gatherKills = Settings.GATHERKILLS.isTrue(); + boolean gatherGMTimes = Settings.GATHERGMTIMES.isTrue(); + boolean gatherCommands = Settings.GATHERCOMMANDS.isTrue(); + + addEnabledDisabledPie("webserver_enabled", webserver); + addEnabledDisabledPie("analysis_enable_refresh", analysisRefreshEnable); + addEnabledDisabledPie("analysis_auto_refresh", analysisAutoRefresh); + addEnabledDisabledPie("html_export", export); + addEnabledDisabledPie("gather_chat", gatherChat); + addEnabledDisabledPie("gather_kills", gatherKills); + addEnabledDisabledPie("gather_gmtimes", gatherGMTimes); + addEnabledDisabledPie("gather_commands", gatherCommands); + + String databaseType = Settings.DB_TYPE.toString(); + addStringSettingPie("database_type", databaseType); + } + + private void addEnabledDisabledPie(String id, boolean setting) { + bStats.addCustomChart(new Metrics.SimplePie(id, new Callable() { + @Override + public String call() throws Exception { + return setting ? "Enabled" : "Disabled"; + } + })); + } + + private void addStringSettingPie(String id, String setting) { + bStats.addCustomChart(new Metrics.SimplePie(id, new Callable() { + @Override + public String call() throws Exception { + return setting; + } + })); + } +}