Added Hooks and "players per server" Metrics charts

This commit is contained in:
Florian CUNY 2019-08-10 14:00:46 +02:00
parent 8119b5c99e
commit 795cc562aa

View File

@ -5,6 +5,7 @@ import java.util.Map;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import world.bentobox.bentobox.api.addons.GameModeAddon;
/**
@ -34,11 +35,13 @@ public class BStats {
}
private void registerCustomMetrics() {
// Simple Pie Charts
// Pie Charts
registerDefaultLanguageChart();
registerDatabaseTypeChart();
registerAddonsChart();
registerGameModeAddonsChart();
registerHooksChart();
registerPlayersPerServerChart();
// Single Line charts
registerIslandsCountChart();
@ -103,4 +106,32 @@ public class BStats {
return values;
}));
}
/**
* Sends the enabled Hooks of this server.
* @since 1.6.0
*/
private void registerHooksChart() {
metrics.addCustomChart(new Metrics.AdvancedPie("hooks", () -> {
Map<String, Integer> values = new HashMap<>();
plugin.getHooks().getHooks().forEach(hook -> values.put(hook.getPluginName(), 1));
return values;
}));
}
/**
* Sends the "category" this server is in depending on how many players it has.
* @since 1.6.0
*/
private void registerPlayersPerServerChart() {
metrics.addCustomChart(new Metrics.SimplePie("playersPerServer", () -> {
int players = Bukkit.getOnlinePlayers().size();
if (players <= 10) return "0-10";
else if (players <= 30) return "11-30";
else if (players <= 50) return "31-50";
else if (players <= 100) return "51-100";
else if (players <= 200) return "101-200";
else return "201+";
}));
}
}