mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-08 17:38:28 +01:00
Implement 3 bar charts: addons, gamemodes, hooks (#1790)
BStats supports sending Bar chart data, however, it does not display it via their site directly. It can be called manually, to view. PieChart does not work very well for addons and hooks. BarChart however allows viewing each addon separately. This change allows sending data to the server about bar charts.
This commit is contained in:
parent
759ba522f4
commit
69f7b49469
@ -8,6 +8,7 @@ import java.util.UUID;
|
||||
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.AdvancedPie;
|
||||
import org.bstats.charts.SimpleBarChart;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bstats.charts.SingleLineChart;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -63,6 +64,11 @@ public class BStats {
|
||||
// Single Line charts
|
||||
registerIslandsCountChart();
|
||||
registerIslandsCreatedChart();
|
||||
|
||||
// Bar Charts
|
||||
registerAddonsBarChart();
|
||||
registerGameModeAddonsBarChart();
|
||||
registerHooksBarChart();
|
||||
}
|
||||
|
||||
private void registerDefaultLanguageChart() {
|
||||
@ -185,4 +191,44 @@ public class BStats {
|
||||
return values;
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the enabled addons (except GameModeAddons) of this server as bar chart.
|
||||
* @since 1.17.1
|
||||
*/
|
||||
private void registerAddonsBarChart() {
|
||||
metrics.addCustomChart(new SimpleBarChart("addonsBar", () -> {
|
||||
Map<String, Integer> values = new HashMap<>();
|
||||
plugin.getAddonsManager().getEnabledAddons().stream()
|
||||
.filter(addon -> !(addon instanceof GameModeAddon) && addon.getDescription().isMetrics())
|
||||
.forEach(addon -> values.put(addon.getDescription().getName(), 1));
|
||||
return values;
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the enabled GameModeAddons of this server as a bar chart.
|
||||
* @since 1.17.1
|
||||
*/
|
||||
private void registerGameModeAddonsBarChart() {
|
||||
metrics.addCustomChart(new SimpleBarChart("gameModeAddonsBar", () -> {
|
||||
Map<String, Integer> values = new HashMap<>();
|
||||
plugin.getAddonsManager().getGameModeAddons().stream()
|
||||
.filter(gameModeAddon -> gameModeAddon.getDescription().isMetrics())
|
||||
.forEach(gameModeAddon -> values.put(gameModeAddon.getDescription().getName(), 1));
|
||||
return values;
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the enabled Hooks of this server as a bar chart.
|
||||
* @since 1.17.1
|
||||
*/
|
||||
private void registerHooksBarChart() {
|
||||
metrics.addCustomChart(new SimpleBarChart("hooksBar", () -> {
|
||||
Map<String, Integer> values = new HashMap<>();
|
||||
plugin.getHooks().getHooks().forEach(hook -> values.put(hook.getPluginName(), 1));
|
||||
return values;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user