Implements #185 ( Fix #185 )

This commit is contained in:
Rsl1122 2017-07-25 12:14:30 +03:00
parent 3769c303fb
commit 173d5c2f7e
2 changed files with 71 additions and 3 deletions

View File

@ -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<Plan> {
}
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<Plan> {
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<Plan> {
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");
}

View File

@ -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<String>() {
@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<String>() {
@Override
public String call() throws Exception {
return setting;
}
}));
}
}