mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-03 09:30:17 +01:00
Made addons opt-in by default to the addons metrics
This commit is contained in:
parent
7a7ca42383
commit
1eadddee47
@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Poslovitch
|
* @author Poslovitch
|
||||||
@ -35,13 +36,12 @@ public class BStats {
|
|||||||
// Simple Pie Charts
|
// Simple Pie Charts
|
||||||
registerDefaultLanguageChart();
|
registerDefaultLanguageChart();
|
||||||
registerDatabaseTypeChart();
|
registerDatabaseTypeChart();
|
||||||
|
registerAddonsChart();
|
||||||
|
registerGameModeAddonsChart();
|
||||||
|
|
||||||
// Single Line charts
|
// Single Line charts
|
||||||
registerIslandsCountChart();
|
registerIslandsCountChart();
|
||||||
registerIslandsCreatedChart();
|
registerIslandsCreatedChart();
|
||||||
|
|
||||||
// Simple Bar Charts
|
|
||||||
registerAddonsChart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerDefaultLanguageChart() {
|
private void registerDefaultLanguageChart() {
|
||||||
@ -76,16 +76,30 @@ public class BStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends the enabled addons of this server.
|
* Sends the enabled addons (except GameModeAddons) of this server.
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
private void registerAddonsChart() {
|
private void registerAddonsChart() {
|
||||||
metrics.addCustomChart(new Metrics.SimpleBarChart("addons", () -> {
|
metrics.addCustomChart(new Metrics.AdvancedPie("addons", () -> {
|
||||||
Map<String, Integer> map = new HashMap<>();
|
Map<String, Integer> values = new HashMap<>();
|
||||||
plugin.getAddonsManager().getEnabledAddons().stream()
|
plugin.getAddonsManager().getEnabledAddons().stream()
|
||||||
.filter(addon -> addon.getDescription().isMetrics())
|
.filter(addon -> !(addon instanceof GameModeAddon) && addon.getDescription().isMetrics())
|
||||||
.forEach(addon -> map.put(addon.getDescription().getName(), 1));
|
.forEach(addon -> values.put(addon.getDescription().getName(), 1));
|
||||||
return map;
|
return values;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends the enabled GameModeAddons of this server.
|
||||||
|
* @since 1.4.0
|
||||||
|
*/
|
||||||
|
private void registerGameModeAddonsChart() {
|
||||||
|
metrics.addCustomChart(new Metrics.AdvancedPie("gameModeAddons", () -> {
|
||||||
|
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;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ public class AddonClassLoader extends URLClassLoader {
|
|||||||
private AddonDescription asDescription(YamlConfiguration data) {
|
private AddonDescription asDescription(YamlConfiguration data) {
|
||||||
AddonDescription.Builder builder = new AddonDescription.Builder(data.getString("main"), data.getString("name"), data.getString("version"))
|
AddonDescription.Builder builder = new AddonDescription.Builder(data.getString("main"), data.getString("name"), data.getString("version"))
|
||||||
.authors(data.getString("authors"))
|
.authors(data.getString("authors"))
|
||||||
.metrics(data.getBoolean("metrics", false))
|
.metrics(data.getBoolean("metrics", true))
|
||||||
.repository(data.getString("repository", ""));
|
.repository(data.getString("repository", ""));
|
||||||
|
|
||||||
if (data.getString("depend") != null) {
|
if (data.getString("depend") != null) {
|
||||||
|
@ -111,7 +111,7 @@ public final class AddonDescription {
|
|||||||
private @NonNull List<String> authors = new ArrayList<>();
|
private @NonNull List<String> authors = new ArrayList<>();
|
||||||
private @NonNull List<String> dependencies = new ArrayList<>();
|
private @NonNull List<String> dependencies = new ArrayList<>();
|
||||||
private @NonNull List<String> softDependencies = new ArrayList<>();
|
private @NonNull List<String> softDependencies = new ArrayList<>();
|
||||||
private boolean metrics = false;
|
private boolean metrics = true;
|
||||||
private @NonNull String repository = "";
|
private @NonNull String repository = "";
|
||||||
/**
|
/**
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
|
Loading…
Reference in New Issue
Block a user