Add bStats metrics.
Introduces the bStats metrics library to the plugin. This first commit contains just a single custom chart, the `store_type`, which will help figure out which stores to focus on for performance optimization and such.
This commit is contained in:
@@ -2,6 +2,7 @@ package org.mobarena.stats;
|
||||
|
||||
import com.garbagemule.MobArena.MobArena;
|
||||
import com.garbagemule.MobArena.commands.CommandHandler;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@@ -12,6 +13,7 @@ import org.mobarena.stats.command.ExportCommand;
|
||||
import org.mobarena.stats.command.GlobalStatsCommand;
|
||||
import org.mobarena.stats.command.ImportCommand;
|
||||
import org.mobarena.stats.command.PlayerStatsCommand;
|
||||
import org.mobarena.stats.metrics.StoreTypeChart;
|
||||
import org.mobarena.stats.platform.AsyncBukkitExecutor;
|
||||
import org.mobarena.stats.platform.SyncBukkitExecutor;
|
||||
import org.mobarena.stats.session.SessionListener;
|
||||
@@ -79,6 +81,7 @@ public class MobArenaStatsPlugin extends JavaPlugin implements MobArenaStats {
|
||||
createConfigFile();
|
||||
setupExecutors();
|
||||
setupCommands();
|
||||
setupMetrics();
|
||||
} catch (Exception up) {
|
||||
// If setup fails, we can't recover, so throw up
|
||||
throw new RuntimeException(up);
|
||||
@@ -131,6 +134,11 @@ public class MobArenaStatsPlugin extends JavaPlugin implements MobArenaStats {
|
||||
handler.register(ImportCommand.class);
|
||||
}
|
||||
|
||||
private void setupMetrics() {
|
||||
Metrics metrics = new Metrics(this, 11932);
|
||||
metrics.addCustomChart(new StoreTypeChart(this));
|
||||
}
|
||||
|
||||
private void reload() {
|
||||
try {
|
||||
createSessionStore();
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.mobarena.stats.metrics;
|
||||
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.mobarena.stats.MobArenaStatsPlugin;
|
||||
import org.mobarena.stats.store.StatsStore;
|
||||
|
||||
public class StoreTypeChart extends SimplePie {
|
||||
|
||||
public StoreTypeChart(MobArenaStatsPlugin plugin) {
|
||||
super("store_type", () -> {
|
||||
StatsStore store = plugin.getStatsStore();
|
||||
if (store == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// If the store isn't null, it means whatever type is set in
|
||||
// the config-file is valid and has already been parsed, so
|
||||
// we can just extract and submit it.
|
||||
Configuration config = plugin.getConfig();
|
||||
ConfigurationSection section = config.getConfigurationSection("store");
|
||||
return section.getString("type");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user