Add more bStats metrics.

The goal with these specific metrics is to figure out if some of the arena settings can be removed. If everyone uses the same values for these settings, there is no point in having the added complexity in the code.
This commit is contained in:
Andreas Troelsen 2018-06-22 23:03:05 +02:00
parent 2aecea401d
commit b2064bf33f
6 changed files with 97 additions and 0 deletions

View File

@ -6,7 +6,12 @@ import com.garbagemule.MobArena.framework.ArenaMaster;
import com.garbagemule.MobArena.listeners.MAGlobalListener;
import com.garbagemule.MobArena.listeners.MagicSpellsListener;
import com.garbagemule.MobArena.metrics.ArenaCountChart;
import com.garbagemule.MobArena.metrics.ClassChestsChart;
import com.garbagemule.MobArena.metrics.ClassCountChart;
import com.garbagemule.MobArena.metrics.FoodRegenChart;
import com.garbagemule.MobArena.metrics.IsolatedChatChart;
import com.garbagemule.MobArena.metrics.MonsterInfightChart;
import com.garbagemule.MobArena.metrics.PvpEnabledChart;
import com.garbagemule.MobArena.metrics.VaultChart;
import com.garbagemule.MobArena.signs.ArenaSign;
import com.garbagemule.MobArena.signs.SignBootstrap;
@ -269,6 +274,11 @@ public class MobArena extends JavaPlugin
metrics.addCustomChart(new VaultChart(this));
metrics.addCustomChart(new ArenaCountChart(this));
metrics.addCustomChart(new ClassCountChart(this));
metrics.addCustomChart(new ClassChestsChart(this));
metrics.addCustomChart(new FoodRegenChart(this));
metrics.addCustomChart(new IsolatedChatChart(this));
metrics.addCustomChart(new MonsterInfightChart(this));
metrics.addCustomChart(new PvpEnabledChart(this));
}
private void loadAbilities() {

View File

@ -0,0 +1,18 @@
package com.garbagemule.MobArena.metrics;
import com.garbagemule.MobArena.MobArena;
import com.garbagemule.MobArena.framework.Arena;
import org.bstats.bukkit.Metrics;
public class ClassChestsChart extends Metrics.SimplePie {
public ClassChestsChart(MobArena plugin) {
super("class_chests_pie", () -> usesClassChests(plugin) ? "Yes" : "No");
}
private static boolean usesClassChests(MobArena plugin) {
return plugin.getArenaMaster().getArenas().stream()
.anyMatch(arena -> arena.getSettings().getBoolean("use-class-chests", false));
}
}

View File

@ -0,0 +1,17 @@
package com.garbagemule.MobArena.metrics;
import com.garbagemule.MobArena.MobArena;
import org.bstats.bukkit.Metrics;
public class FoodRegenChart extends Metrics.SimplePie {
public FoodRegenChart(MobArena plugin) {
super("food_regen_pie", () -> usesFoodRegen(plugin) ? "Yes" : "No");
}
private static boolean usesFoodRegen(MobArena plugin) {
return plugin.getArenaMaster().getArenas().stream()
.anyMatch(arena -> arena.getSettings().getBoolean("food-regen", false));
}
}

View File

@ -0,0 +1,18 @@
package com.garbagemule.MobArena.metrics;
import com.garbagemule.MobArena.MobArena;
import com.garbagemule.MobArena.framework.Arena;
import org.bstats.bukkit.Metrics;
public class IsolatedChatChart extends Metrics.SimplePie {
public IsolatedChatChart(MobArena plugin) {
super("isolated_chat_pie", () -> usesIsolatedChat(plugin) ? "Yes" : "No");
}
private static boolean usesIsolatedChat(MobArena plugin) {
return plugin.getArenaMaster().getArenas().stream()
.anyMatch(Arena::hasIsolatedChat);
}
}

View File

@ -0,0 +1,17 @@
package com.garbagemule.MobArena.metrics;
import com.garbagemule.MobArena.MobArena;
import org.bstats.bukkit.Metrics;
public class MonsterInfightChart extends Metrics.SimplePie {
public MonsterInfightChart(MobArena plugin) {
super("monster_infight_pie", () -> usesMonsterInfight(plugin) ? "Yes" : "No");
}
private static boolean usesMonsterInfight(MobArena plugin) {
return plugin.getArenaMaster().getArenas().stream()
.anyMatch(arena -> arena.getSettings().getBoolean("monster-infight", false));
}
}

View File

@ -0,0 +1,17 @@
package com.garbagemule.MobArena.metrics;
import com.garbagemule.MobArena.MobArena;
import org.bstats.bukkit.Metrics;
public class PvpEnabledChart extends Metrics.SimplePie {
public PvpEnabledChart(MobArena plugin) {
super("pvp_enabled_pie", () -> hasPvpEnabled(plugin) ? "Yes" : "No");
}
private static boolean hasPvpEnabled(MobArena plugin) {
return plugin.getArenaMaster().getArenas().stream()
.anyMatch(arena -> arena.getSettings().getBoolean("pvp-enabled", false));
}
}