mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 05:28:59 +00:00
Move stats to own file
This commit is contained in:
@@ -203,6 +203,7 @@ public class BCauldron {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
byte data = block.getData();
|
byte data = block.getData();
|
||||||
if (data > 3) {
|
if (data > 3) {
|
||||||
data = 3;
|
data = 3;
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class BIngredients {
|
|||||||
}
|
}
|
||||||
brew.save(potionMeta);
|
brew.save(potionMeta);
|
||||||
potion.setItemMeta(potionMeta);
|
potion.setItemMeta(potionMeta);
|
||||||
P.p.metricsForCreate(false);
|
P.p.stats.metricsForCreate(false);
|
||||||
|
|
||||||
return potion;
|
return potion;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ public class BPlayer {
|
|||||||
if (brew.hasRecipe()) {
|
if (brew.hasRecipe()) {
|
||||||
brew.getCurrentRecipe().applyDrinkFeatures(player, brew.getQuality());
|
brew.getCurrentRecipe().applyDrinkFeatures(player, brew.getQuality());
|
||||||
}
|
}
|
||||||
P.p.metricsForDrink(brew);
|
P.p.stats.forDrink(brew);
|
||||||
|
|
||||||
int brewAlc = drinkEvent.getAddedAlcohol();
|
int brewAlc = drinkEvent.getAddedAlcohol();
|
||||||
int quality = drinkEvent.getQuality();
|
int quality = drinkEvent.getQuality();
|
||||||
|
|||||||
@@ -827,7 +827,7 @@ public class Brew implements Cloneable {
|
|||||||
}
|
}
|
||||||
save(potionMeta);
|
save(potionMeta);
|
||||||
potion.setItemMeta(potionMeta);
|
potion.setItemMeta(potionMeta);
|
||||||
P.p.metricsForCreate(true);
|
P.p.stats.metricsForCreate(true);
|
||||||
return potion;
|
return potion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-179
@@ -38,9 +38,8 @@ import com.dre.brewery.listeners.*;
|
|||||||
import com.dre.brewery.recipe.*;
|
import com.dre.brewery.recipe.*;
|
||||||
import com.dre.brewery.utility.BUtil;
|
import com.dre.brewery.utility.BUtil;
|
||||||
import com.dre.brewery.utility.LegacyUtil;
|
import com.dre.brewery.utility.LegacyUtil;
|
||||||
|
import com.dre.brewery.utility.Stats;
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.bstats.bukkit.Metrics;
|
|
||||||
import org.bstats.charts.*;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -82,9 +81,7 @@ public class P extends JavaPlugin {
|
|||||||
public LanguageReader languageReader;
|
public LanguageReader languageReader;
|
||||||
|
|
||||||
// Metrics
|
// Metrics
|
||||||
public int brewsCreated;
|
public Stats stats = new Stats();
|
||||||
public int brewsCreatedCmd; // Created by command
|
|
||||||
public int exc, good, norm, bad, terr; // Brews drunken with quality
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@@ -135,7 +132,7 @@ public class P extends JavaPlugin {
|
|||||||
BData.readData();
|
BData.readData();
|
||||||
|
|
||||||
// Setup Metrics
|
// Setup Metrics
|
||||||
setupMetrics();
|
stats.setupBStats();
|
||||||
|
|
||||||
// Listeners
|
// Listeners
|
||||||
blockListener = new BlockListener();
|
blockListener = new BlockListener();
|
||||||
@@ -310,179 +307,6 @@ public class P extends JavaPlugin {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupMetrics() {
|
|
||||||
try {
|
|
||||||
Metrics metrics = new Metrics(this, 3494);
|
|
||||||
metrics.addCustomChart(new SingleLineChart("drunk_players", BPlayer::numDrunkPlayers));
|
|
||||||
metrics.addCustomChart(new SingleLineChart("brews_in_existence", () -> brewsCreated));
|
|
||||||
metrics.addCustomChart(new SingleLineChart("barrels_built", Barrel.barrels::size));
|
|
||||||
metrics.addCustomChart(new SingleLineChart("cauldrons_boiling", BCauldron.bcauldrons::size));
|
|
||||||
metrics.addCustomChart(new AdvancedPie("brew_quality", () -> {
|
|
||||||
Map<String, Integer> map = new HashMap<>(8);
|
|
||||||
map.put("excellent", exc);
|
|
||||||
map.put("good", good);
|
|
||||||
map.put("normal", norm);
|
|
||||||
map.put("bad", bad);
|
|
||||||
map.put("terrible", terr);
|
|
||||||
return map;
|
|
||||||
}));
|
|
||||||
metrics.addCustomChart(new AdvancedPie("brews_created", () -> {
|
|
||||||
Map<String, Integer> map = new HashMap<>(4);
|
|
||||||
map.put("by command", brewsCreatedCmd);
|
|
||||||
map.put("brewing", brewsCreated - brewsCreatedCmd);
|
|
||||||
return map;
|
|
||||||
}));
|
|
||||||
|
|
||||||
metrics.addCustomChart(new SimplePie("number_of_recipes", () -> {
|
|
||||||
int recipes = BRecipe.getAllRecipes().size();
|
|
||||||
if (recipes < 7) {
|
|
||||||
return "Less than 7";
|
|
||||||
} else if (recipes < 11) {
|
|
||||||
return "7-10";
|
|
||||||
} else if (recipes == 11) {
|
|
||||||
// There were 11 default recipes, so show this as its own slice
|
|
||||||
return "11";
|
|
||||||
} else if (recipes == 20) {
|
|
||||||
// There are 20 default recipes, so show this as its own slice
|
|
||||||
return "20";
|
|
||||||
} else if (recipes <= 29) {
|
|
||||||
if (recipes % 2 == 0) {
|
|
||||||
return recipes + "-" + (recipes + 1);
|
|
||||||
} else {
|
|
||||||
return (recipes - 1) + "-" + recipes;
|
|
||||||
}
|
|
||||||
} else if (recipes < 35) {
|
|
||||||
return "30-34";
|
|
||||||
} else if (recipes < 40) {
|
|
||||||
return "35-39";
|
|
||||||
} else if (recipes < 45) {
|
|
||||||
return "40-44";
|
|
||||||
} else if (recipes <= 50) {
|
|
||||||
return "45-50";
|
|
||||||
} else {
|
|
||||||
return "More than 50";
|
|
||||||
}
|
|
||||||
|
|
||||||
}));
|
|
||||||
metrics.addCustomChart(new SimplePie("cauldron_particles", () -> {
|
|
||||||
if (!BConfig.enableCauldronParticles) {
|
|
||||||
return "disabled";
|
|
||||||
}
|
|
||||||
if (BConfig.minimalParticles) {
|
|
||||||
return "minimal";
|
|
||||||
}
|
|
||||||
return "enabled";
|
|
||||||
}));
|
|
||||||
metrics.addCustomChart(new SimplePie("wakeups", () -> {
|
|
||||||
if (!BConfig.enableWake) {
|
|
||||||
return "disabled";
|
|
||||||
}
|
|
||||||
int wakeups = Wakeup.wakeups.size();
|
|
||||||
if (wakeups == 0) {
|
|
||||||
return "0";
|
|
||||||
} else if (wakeups <= 5) {
|
|
||||||
return "1-5";
|
|
||||||
} else if (wakeups <= 10) {
|
|
||||||
return "6-10";
|
|
||||||
} else if (wakeups <= 20) {
|
|
||||||
return "11-20";
|
|
||||||
} else {
|
|
||||||
return "More than 20";
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
metrics.addCustomChart(new SimplePie("v2_mc_version", () -> {
|
|
||||||
String mcv = Bukkit.getBukkitVersion();
|
|
||||||
mcv = mcv.substring(0, mcv.indexOf('.', 2));
|
|
||||||
int index = mcv.indexOf('-');
|
|
||||||
if (index > -1) {
|
|
||||||
mcv = mcv.substring(0, index);
|
|
||||||
}
|
|
||||||
if (mcv.matches("^\\d\\.\\d{1,2}$")) {
|
|
||||||
// Start, digit, dot, 1-2 digits, end
|
|
||||||
return mcv;
|
|
||||||
} else {
|
|
||||||
return "undef";
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
metrics.addCustomChart(new DrilldownPie("plugin_mc_version", () -> {
|
|
||||||
Map<String, Map<String, Integer>> map = new HashMap<>(3);
|
|
||||||
String mcv = Bukkit.getBukkitVersion();
|
|
||||||
mcv = mcv.substring(0, mcv.indexOf('.', 2));
|
|
||||||
int index = mcv.indexOf('-');
|
|
||||||
if (index > -1) {
|
|
||||||
mcv = mcv.substring(0, index);
|
|
||||||
}
|
|
||||||
if (mcv.matches("^\\d\\.\\d{1,2}$")) {
|
|
||||||
// Start, digit, dot, 1-2 digits, end
|
|
||||||
mcv = "MC " + mcv;
|
|
||||||
} else {
|
|
||||||
mcv = "undef";
|
|
||||||
}
|
|
||||||
Map<String, Integer> innerMap = new HashMap<>(3);
|
|
||||||
innerMap.put(mcv, 1);
|
|
||||||
map.put(getDescription().getVersion(), innerMap);
|
|
||||||
return map;
|
|
||||||
}));
|
|
||||||
metrics.addCustomChart(new SimplePie("language", () -> language));
|
|
||||||
metrics.addCustomChart(new SimplePie("config_scramble", () -> BConfig.enableEncode ? "enabled" : "disabled"));
|
|
||||||
metrics.addCustomChart(new SimplePie("config_lore_color", () -> {
|
|
||||||
if (BConfig.colorInBarrels) {
|
|
||||||
if (BConfig.colorInBrewer) {
|
|
||||||
return "both";
|
|
||||||
} else {
|
|
||||||
return "in barrels";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (BConfig.colorInBrewer) {
|
|
||||||
return "in distiller";
|
|
||||||
} else {
|
|
||||||
return "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
metrics.addCustomChart(new SimplePie("config_always_show", () -> {
|
|
||||||
if (BConfig.alwaysShowQuality) {
|
|
||||||
if (BConfig.alwaysShowAlc) {
|
|
||||||
return "both";
|
|
||||||
} else {
|
|
||||||
return "quality stars";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (BConfig.alwaysShowAlc) {
|
|
||||||
return "alc content";
|
|
||||||
} else {
|
|
||||||
return "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
} catch (Exception | LinkageError e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void metricsForCreate(boolean byCmd) {
|
|
||||||
if (brewsCreated == Integer.MAX_VALUE) return;
|
|
||||||
brewsCreated++;
|
|
||||||
if (byCmd) {
|
|
||||||
if (brewsCreatedCmd == Integer.MAX_VALUE) return;
|
|
||||||
brewsCreatedCmd++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void metricsForDrink(Brew brew) {
|
|
||||||
if (brew.getQuality() >= 9) {
|
|
||||||
exc++;
|
|
||||||
} else if (brew.getQuality() >= 7) {
|
|
||||||
good++;
|
|
||||||
} else if (brew.getQuality() >= 5) {
|
|
||||||
norm++;
|
|
||||||
} else if (brew.getQuality() >= 3) {
|
|
||||||
bad++;
|
|
||||||
} else {
|
|
||||||
terr++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Utility
|
// Utility
|
||||||
|
|
||||||
public void msg(CommandSender sender, String msg) {
|
public void msg(CommandSender sender, String msg) {
|
||||||
|
|||||||
@@ -65,13 +65,13 @@ public class BData {
|
|||||||
int hash = data.getInt("brewsCreatedH");
|
int hash = data.getInt("brewsCreatedH");
|
||||||
// Check the hash to prevent tampering with statistics
|
// Check the hash to prevent tampering with statistics
|
||||||
if (brewsCreated.hashCode() == hash) {
|
if (brewsCreated.hashCode() == hash) {
|
||||||
P.p.brewsCreated = brewsCreated.get(0);
|
P.p.stats.brewsCreated = brewsCreated.get(0);
|
||||||
P.p.brewsCreatedCmd = brewsCreated.get(1);
|
P.p.stats.brewsCreatedCmd = brewsCreated.get(1);
|
||||||
P.p.exc = brewsCreated.get(2);
|
P.p.stats.exc = brewsCreated.get(2);
|
||||||
P.p.good = brewsCreated.get(3);
|
P.p.stats.good = brewsCreated.get(3);
|
||||||
P.p.norm = brewsCreated.get(4);
|
P.p.stats.norm = brewsCreated.get(4);
|
||||||
P.p.bad = brewsCreated.get(5);
|
P.p.stats.bad = brewsCreated.get(5);
|
||||||
P.p.terr = brewsCreated.get(6);
|
P.p.stats.terr = brewsCreated.get(6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,17 +120,17 @@ public class BData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store how many legacy brews were created
|
// Store how many legacy brews were created
|
||||||
if (P.p.brewsCreated <= 0) {
|
if (P.p.stats.brewsCreated <= 0) {
|
||||||
P.p.brewsCreated = 0;
|
P.p.stats.brewsCreated = 0;
|
||||||
P.p.brewsCreatedCmd = 0;
|
P.p.stats.brewsCreatedCmd = 0;
|
||||||
P.p.exc = 0;
|
P.p.stats.exc = 0;
|
||||||
P.p.good = 0;
|
P.p.stats.good = 0;
|
||||||
P.p.norm = 0;
|
P.p.stats.norm = 0;
|
||||||
P.p.bad = 0;
|
P.p.stats.bad = 0;
|
||||||
P.p.terr = 0;
|
P.p.stats.terr = 0;
|
||||||
if (!Brew.noLegacy()) {
|
if (!Brew.noLegacy()) {
|
||||||
for (int i = Brew.legacyPotions.size(); i > 0; i--) {
|
for (int i = Brew.legacyPotions.size(); i > 0; i--) {
|
||||||
P.p.metricsForCreate(false);
|
P.p.stats.metricsForCreate(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,13 +76,13 @@ public class DataSave extends BukkitRunnable {
|
|||||||
Brew.writePrevSeeds(data);
|
Brew.writePrevSeeds(data);
|
||||||
|
|
||||||
List<Integer> brewsCreated = new ArrayList<>(7);
|
List<Integer> brewsCreated = new ArrayList<>(7);
|
||||||
brewsCreated.add(P.p.brewsCreated);
|
brewsCreated.add(P.p.stats.brewsCreated);
|
||||||
brewsCreated.add(P.p.brewsCreatedCmd);
|
brewsCreated.add(P.p.stats.brewsCreatedCmd);
|
||||||
brewsCreated.add(P.p.exc);
|
brewsCreated.add(P.p.stats.exc);
|
||||||
brewsCreated.add(P.p.good);
|
brewsCreated.add(P.p.stats.good);
|
||||||
brewsCreated.add(P.p.norm);
|
brewsCreated.add(P.p.stats.norm);
|
||||||
brewsCreated.add(P.p.bad);
|
brewsCreated.add(P.p.stats.bad);
|
||||||
brewsCreated.add(P.p.terr);
|
brewsCreated.add(P.p.stats.terr);
|
||||||
data.set("brewsCreated", brewsCreated);
|
data.set("brewsCreated", brewsCreated);
|
||||||
data.set("brewsCreatedH", brewsCreated.hashCode());
|
data.set("brewsCreatedH", brewsCreated.hashCode());
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public class LWCBarrel {
|
|||||||
if (listener.getListener() instanceof LWCPlayerListener) {
|
if (listener.getListener() instanceof LWCPlayerListener) {
|
||||||
try {
|
try {
|
||||||
listener.callEvent(lwcEvent);
|
listener.callEvent(lwcEvent);
|
||||||
|
//noinspection deprecation
|
||||||
if (lwcEvent.isCancelled()) {
|
if (lwcEvent.isCancelled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public class WGBarrel7 implements WGBarrel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public boolean checkAccess(Player player, Block spigot, Plugin plugin) {
|
public boolean checkAccess(Player player, Block spigot, Plugin plugin) {
|
||||||
WorldGuardPlugin wg = (WorldGuardPlugin) plugin;
|
WorldGuardPlugin wg = (WorldGuardPlugin) plugin;
|
||||||
WorldGuardPlatform platform = WorldGuard.getInstance().getPlatform();
|
WorldGuardPlatform platform = WorldGuard.getInstance().getPlatform();
|
||||||
|
|||||||
@@ -415,6 +415,7 @@ public class CommandListener implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
ItemStack hand = P.use1_9 ? player.getInventory().getItemInMainHand() : player.getItemInHand();
|
ItemStack hand = P.use1_9 ? player.getInventory().getItemInMainHand() : player.getItemInHand();
|
||||||
if (hand != null) {
|
if (hand != null) {
|
||||||
p.msg(sender, p.languageReader.get("CMD_Configname", hand.getType().name().toLowerCase(Locale.ENGLISH)));
|
p.msg(sender, p.languageReader.get("CMD_Configname", hand.getType().name().toLowerCase(Locale.ENGLISH)));
|
||||||
@@ -548,7 +549,7 @@ public class CommandListener implements CommandExecutor {
|
|||||||
if (sender instanceof ConsoleCommandSender && !sender.isOp()) return;
|
if (sender instanceof ConsoleCommandSender && !sender.isOp()) return;
|
||||||
|
|
||||||
P.p.msg(sender, "Drunk Players: " + BPlayer.numDrunkPlayers());
|
P.p.msg(sender, "Drunk Players: " + BPlayer.numDrunkPlayers());
|
||||||
P.p.msg(sender, "Brews created: " + P.p.brewsCreated);
|
P.p.msg(sender, "Brews created: " + P.p.stats.brewsCreated);
|
||||||
P.p.msg(sender, "Barrels built: " + Barrel.barrels.size());
|
P.p.msg(sender, "Barrels built: " + Barrel.barrels.size());
|
||||||
P.p.msg(sender, "Cauldrons boiling: " + BCauldron.bcauldrons.size());
|
P.p.msg(sender, "Cauldrons boiling: " + BCauldron.bcauldrons.size());
|
||||||
P.p.msg(sender, "Number of Recipes: " + BRecipe.getAllRecipes().size());
|
P.p.msg(sender, "Number of Recipes: " + BRecipe.getAllRecipes().size());
|
||||||
|
|||||||
@@ -103,7 +103,9 @@ public class BEffect {
|
|||||||
|
|
||||||
duration *= 20;
|
duration *= 20;
|
||||||
if (!P.use1_14) {
|
if (!P.use1_14) {
|
||||||
duration /= type.getDurationModifier();
|
@SuppressWarnings("deprecation")
|
||||||
|
double modifier = type.getDurationModifier();
|
||||||
|
duration /= modifier;
|
||||||
}
|
}
|
||||||
return type.createEffect(duration, lvl - 1);
|
return type.createEffect(duration, lvl - 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,8 +166,9 @@ public abstract class RecipeItem implements Cloneable {
|
|||||||
if (P.use1_13) {
|
if (P.use1_13) {
|
||||||
return new SimpleItem(item.getType());
|
return new SimpleItem(item.getType());
|
||||||
} else {
|
} else {
|
||||||
//noinspection deprecation
|
@SuppressWarnings("deprecation")
|
||||||
return new SimpleItem(item.getType(), item.getDurability());
|
short durability = item.getDurability();
|
||||||
|
return new SimpleItem(item.getType(), durability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rItem;
|
return rItem;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import static com.dre.brewery.BCauldron.EMPTY;
|
|||||||
import static com.dre.brewery.BCauldron.FULL;
|
import static com.dre.brewery.BCauldron.FULL;
|
||||||
import static com.dre.brewery.BCauldron.SOME;
|
import static com.dre.brewery.BCauldron.SOME;
|
||||||
|
|
||||||
@SuppressWarnings("JavaReflectionMemberAccess")
|
@SuppressWarnings({"JavaReflectionMemberAccess", "deprecation"})
|
||||||
public class LegacyUtil {
|
public class LegacyUtil {
|
||||||
|
|
||||||
private static Method GET_MATERIAL;
|
private static Method GET_MATERIAL;
|
||||||
|
|||||||
@@ -0,0 +1,195 @@
|
|||||||
|
package com.dre.brewery.utility;
|
||||||
|
|
||||||
|
import com.dre.brewery.*;
|
||||||
|
import com.dre.brewery.filedata.BConfig;
|
||||||
|
import com.dre.brewery.recipe.BRecipe;
|
||||||
|
import org.bstats.bukkit.Metrics;
|
||||||
|
import org.bstats.charts.AdvancedPie;
|
||||||
|
import org.bstats.charts.DrilldownPie;
|
||||||
|
import org.bstats.charts.SimplePie;
|
||||||
|
import org.bstats.charts.SingleLineChart;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Stats {
|
||||||
|
|
||||||
|
public int brewsCreated;
|
||||||
|
public int brewsCreatedCmd; // Created by command
|
||||||
|
public int exc, good, norm, bad, terr; // Brews drunken with quality
|
||||||
|
|
||||||
|
public void metricsForCreate(boolean byCmd) {
|
||||||
|
if (brewsCreated == Integer.MAX_VALUE) return;
|
||||||
|
brewsCreated++;
|
||||||
|
if (byCmd) {
|
||||||
|
if (brewsCreatedCmd == Integer.MAX_VALUE) return;
|
||||||
|
brewsCreatedCmd++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forDrink(Brew brew) {
|
||||||
|
if (brew.getQuality() >= 9) {
|
||||||
|
exc++;
|
||||||
|
} else if (brew.getQuality() >= 7) {
|
||||||
|
good++;
|
||||||
|
} else if (brew.getQuality() >= 5) {
|
||||||
|
norm++;
|
||||||
|
} else if (brew.getQuality() >= 3) {
|
||||||
|
bad++;
|
||||||
|
} else {
|
||||||
|
terr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupBStats() {
|
||||||
|
try {
|
||||||
|
Metrics metrics = new Metrics(P.p, 3494);
|
||||||
|
metrics.addCustomChart(new SingleLineChart("drunk_players", BPlayer::numDrunkPlayers));
|
||||||
|
metrics.addCustomChart(new SingleLineChart("brews_in_existence", () -> brewsCreated));
|
||||||
|
metrics.addCustomChart(new SingleLineChart("barrels_built", Barrel.barrels::size));
|
||||||
|
metrics.addCustomChart(new SingleLineChart("cauldrons_boiling", BCauldron.bcauldrons::size));
|
||||||
|
metrics.addCustomChart(new AdvancedPie("brew_quality", () -> {
|
||||||
|
Map<String, Integer> map = new HashMap<>(8);
|
||||||
|
map.put("excellent", exc);
|
||||||
|
map.put("good", good);
|
||||||
|
map.put("normal", norm);
|
||||||
|
map.put("bad", bad);
|
||||||
|
map.put("terrible", terr);
|
||||||
|
return map;
|
||||||
|
}));
|
||||||
|
metrics.addCustomChart(new AdvancedPie("brews_created", () -> {
|
||||||
|
Map<String, Integer> map = new HashMap<>(4);
|
||||||
|
map.put("by command", brewsCreatedCmd);
|
||||||
|
map.put("brewing", brewsCreated - brewsCreatedCmd);
|
||||||
|
return map;
|
||||||
|
}));
|
||||||
|
|
||||||
|
metrics.addCustomChart(new SimplePie("number_of_recipes", () -> {
|
||||||
|
int recipes = BRecipe.getAllRecipes().size();
|
||||||
|
if (recipes < 7) {
|
||||||
|
return "Less than 7";
|
||||||
|
} else if (recipes < 11) {
|
||||||
|
return "7-10";
|
||||||
|
} else if (recipes == 11) {
|
||||||
|
// There were 11 default recipes, so show this as its own slice
|
||||||
|
return "11";
|
||||||
|
} else if (recipes == 20) {
|
||||||
|
// There are 20 default recipes, so show this as its own slice
|
||||||
|
return "20";
|
||||||
|
} else if (recipes <= 29) {
|
||||||
|
if (recipes % 2 == 0) {
|
||||||
|
return recipes + "-" + (recipes + 1);
|
||||||
|
} else {
|
||||||
|
return (recipes - 1) + "-" + recipes;
|
||||||
|
}
|
||||||
|
} else if (recipes < 35) {
|
||||||
|
return "30-34";
|
||||||
|
} else if (recipes < 40) {
|
||||||
|
return "35-39";
|
||||||
|
} else if (recipes < 45) {
|
||||||
|
return "40-44";
|
||||||
|
} else if (recipes <= 50) {
|
||||||
|
return "45-50";
|
||||||
|
} else {
|
||||||
|
return "More than 50";
|
||||||
|
}
|
||||||
|
|
||||||
|
}));
|
||||||
|
metrics.addCustomChart(new SimplePie("cauldron_particles", () -> {
|
||||||
|
if (!BConfig.enableCauldronParticles) {
|
||||||
|
return "disabled";
|
||||||
|
}
|
||||||
|
if (BConfig.minimalParticles) {
|
||||||
|
return "minimal";
|
||||||
|
}
|
||||||
|
return "enabled";
|
||||||
|
}));
|
||||||
|
metrics.addCustomChart(new SimplePie("wakeups", () -> {
|
||||||
|
if (!BConfig.enableWake) {
|
||||||
|
return "disabled";
|
||||||
|
}
|
||||||
|
int wakeups = Wakeup.wakeups.size();
|
||||||
|
if (wakeups == 0) {
|
||||||
|
return "0";
|
||||||
|
} else if (wakeups <= 5) {
|
||||||
|
return "1-5";
|
||||||
|
} else if (wakeups <= 10) {
|
||||||
|
return "6-10";
|
||||||
|
} else if (wakeups <= 20) {
|
||||||
|
return "11-20";
|
||||||
|
} else {
|
||||||
|
return "More than 20";
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
metrics.addCustomChart(new SimplePie("v2_mc_version", () -> {
|
||||||
|
String mcv = Bukkit.getBukkitVersion();
|
||||||
|
mcv = mcv.substring(0, mcv.indexOf('.', 2));
|
||||||
|
int index = mcv.indexOf('-');
|
||||||
|
if (index > -1) {
|
||||||
|
mcv = mcv.substring(0, index);
|
||||||
|
}
|
||||||
|
if (mcv.matches("^\\d\\.\\d{1,2}$")) {
|
||||||
|
// Start, digit, dot, 1-2 digits, end
|
||||||
|
return mcv;
|
||||||
|
} else {
|
||||||
|
return "undef";
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
metrics.addCustomChart(new DrilldownPie("plugin_mc_version", () -> {
|
||||||
|
Map<String, Map<String, Integer>> map = new HashMap<>(3);
|
||||||
|
String mcv = Bukkit.getBukkitVersion();
|
||||||
|
mcv = mcv.substring(0, mcv.indexOf('.', 2));
|
||||||
|
int index = mcv.indexOf('-');
|
||||||
|
if (index > -1) {
|
||||||
|
mcv = mcv.substring(0, index);
|
||||||
|
}
|
||||||
|
if (mcv.matches("^\\d\\.\\d{1,2}$")) {
|
||||||
|
// Start, digit, dot, 1-2 digits, end
|
||||||
|
mcv = "MC " + mcv;
|
||||||
|
} else {
|
||||||
|
mcv = "undef";
|
||||||
|
}
|
||||||
|
Map<String, Integer> innerMap = new HashMap<>(3);
|
||||||
|
innerMap.put(mcv, 1);
|
||||||
|
map.put(P.p.getDescription().getVersion(), innerMap);
|
||||||
|
return map;
|
||||||
|
}));
|
||||||
|
metrics.addCustomChart(new SimplePie("language", () -> P.p.language));
|
||||||
|
metrics.addCustomChart(new SimplePie("config_scramble", () -> BConfig.enableEncode ? "enabled" : "disabled"));
|
||||||
|
metrics.addCustomChart(new SimplePie("config_lore_color", () -> {
|
||||||
|
if (BConfig.colorInBarrels) {
|
||||||
|
if (BConfig.colorInBrewer) {
|
||||||
|
return "both";
|
||||||
|
} else {
|
||||||
|
return "in barrels";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (BConfig.colorInBrewer) {
|
||||||
|
return "in distiller";
|
||||||
|
} else {
|
||||||
|
return "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
metrics.addCustomChart(new SimplePie("config_always_show", () -> {
|
||||||
|
if (BConfig.alwaysShowQuality) {
|
||||||
|
if (BConfig.alwaysShowAlc) {
|
||||||
|
return "both";
|
||||||
|
} else {
|
||||||
|
return "quality stars";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (BConfig.alwaysShowAlc) {
|
||||||
|
return "alc content";
|
||||||
|
} else {
|
||||||
|
return "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
} catch (Exception | LinkageError e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user