mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 13:15:28 +01:00
Added Hooks and "players per server" Metrics charts
This commit is contained in:
parent
8119b5c99e
commit
795cc562aa
@ -5,6 +5,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,11 +35,13 @@ public class BStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerCustomMetrics() {
|
private void registerCustomMetrics() {
|
||||||
// Simple Pie Charts
|
// Pie Charts
|
||||||
registerDefaultLanguageChart();
|
registerDefaultLanguageChart();
|
||||||
registerDatabaseTypeChart();
|
registerDatabaseTypeChart();
|
||||||
registerAddonsChart();
|
registerAddonsChart();
|
||||||
registerGameModeAddonsChart();
|
registerGameModeAddonsChart();
|
||||||
|
registerHooksChart();
|
||||||
|
registerPlayersPerServerChart();
|
||||||
|
|
||||||
// Single Line charts
|
// Single Line charts
|
||||||
registerIslandsCountChart();
|
registerIslandsCountChart();
|
||||||
@ -103,4 +106,32 @@ public class BStats {
|
|||||||
return values;
|
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+";
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user