Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ repositories {
maven("https://repo.oraxen.com/releases") // Oraxen
maven("https://storehouse.okaeri.eu/repository/maven-public/") // Okaeri Config
maven("https://repo.papermc.io/repository/maven-public/") // PaperLib
maven("https://repo.faststats.dev/releases") // FastStats
maven { githubPackage("apdevteam/movecraft")(this) } // Movecraft
}

Expand Down Expand Up @@ -99,6 +100,7 @@ dependencies {
}
}
}
implementation("dev.faststats.metrics:bukkit:0.22.0")

// Plugin Compatability
compileOnly("com.sk89q:worldguard:6.1") // https://dev.bukkit.org/projects/worldedit/files
Expand Down Expand Up @@ -165,6 +167,7 @@ tasks {
relocate("org.bson", "$pack.bson")
relocate("io.papermc.lib", "$pack.paperlib")
relocate("com.zaxxer.hikari", "$pack.hikari")
relocate("dev.faststats", "$pack.faststats")

archiveClassifier.set("")
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/dre/brewery/BIngredients.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public ItemStack cook(int state, Player brewer) {
}
brew.save(potionMeta);
potion.setItemMeta(potionMeta);
plugin.getBreweryStats().metricsForCreate(false);
plugin.getMetrics().getBstatsBrewery().metricsForCreate(false);

return potion;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/dre/brewery/BPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.dre.brewery.configuration.ConfigManager;
import com.dre.brewery.configuration.files.Config;
import com.dre.brewery.configuration.files.Lang;
import com.dre.brewery.integration.metrics.faststats.FastStats;
import com.dre.brewery.lore.BrewLore;
import com.dre.brewery.recipe.BEffect;
import com.dre.brewery.utility.BUtil;
Expand Down Expand Up @@ -55,7 +56,6 @@
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -212,7 +212,7 @@ public static boolean drink(Brew brew, Player player, @Nullable ItemMeta meta, @
if (brew.hasRecipe()) {
brew.getCurrentRecipe().applyDrinkFeatures(player, brew.getQuality());
}
BreweryPlugin.getInstance().getBreweryStats().forDrink(brew);
BreweryPlugin.getInstance().getMetrics().getBstatsBrewery().forDrink(brew);

int brewAlc = drinkEvent.getAddedAlcohol();
int quality = drinkEvent.getQuality();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/dre/brewery/Brew.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -890,7 +889,7 @@ public ItemStack createItem(@Nullable BRecipe recipe, boolean event, @Nullable P
}
save(potionMeta);
potion.setItemMeta(potionMeta);
BreweryPlugin.getInstance().getBreweryStats().metricsForCreate(true);
BreweryPlugin.getInstance().getMetrics().getBstatsBrewery().metricsForCreate(true);
return potion;
}

Expand Down
14 changes: 8 additions & 6 deletions src/main/java/com/dre/brewery/BreweryPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
import com.dre.brewery.integration.LandsHook;
import com.dre.brewery.integration.PlaceholderAPIHook;
import com.dre.brewery.integration.barrel.BlockLockerBarrel;
import com.dre.brewery.integration.bstats.BreweryStats;
import com.dre.brewery.integration.bstats.BreweryXStats;
import com.dre.brewery.integration.metrics.Metrics;
import com.dre.brewery.integration.metrics.bstats.BStatsBrewery;
import com.dre.brewery.integration.metrics.bstats.BStatsBreweryX;
import com.dre.brewery.integration.listeners.ChestShopListener;
import com.dre.brewery.integration.listeners.IntegrationListener;
import com.dre.brewery.integration.listeners.ShopKeepersListener;
Expand Down Expand Up @@ -91,7 +92,7 @@ public final class BreweryPlugin extends JavaPlugin {


private final Map<String, Function<ItemLoader, Ingredient>> ingredientLoaders = new HashMap<>(); // Registrations
private BreweryStats breweryStats; // Metrics
private Metrics metrics;

{
// Basically just racing to be the first code to execute.
Expand Down Expand Up @@ -152,7 +153,7 @@ public void onEnable() {
ConfigManager.loadRecipes();
ConfigManager.loadDistortWords();
ConfigManager.loadSeed();
this.breweryStats = new BreweryStats(); // Load metrics
this.metrics = new Metrics();


Logging.log("Minecraft version&7:&a " + MCVersion.getVersion());
Expand Down Expand Up @@ -196,8 +197,7 @@ public void onEnable() {

addonManager.enableAddons();
// Setup Metrics
this.breweryStats.setupBStats();
new BreweryXStats().setupBStats();
this.metrics.enable();

// Register command and aliases
PluginCommand defaultCommand = getCommand("breweryx");
Expand Down Expand Up @@ -274,6 +274,8 @@ public void onDisable() {
// Stop schedulers
BreweryPlugin.getScheduler().cancelTasks(this);

this.metrics.disable();

// save Data to Disk
if (dataManager != null) dataManager.exit(true, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void execute(BreweryPlugin breweryPlugin, Lang lang, CommandSender sender
//if (sender instanceof ConsoleCommandSender && !sender.isOp()) return;

Logging.msg(sender, "Drunk Players: " + BPlayer.numDrunkPlayers());
Logging.msg(sender, "Brews created: " + BreweryPlugin.getInstance().getBreweryStats().brewsCreated);
Logging.msg(sender, "Brews created: " + BreweryPlugin.getInstance().getMetrics().getBstatsBrewery().brewsCreated);
Logging.msg(sender, "Barrels built: " + Barrel.getAllBarrels().size());
Logging.msg(sender, "Cauldrons boiling: " + BCauldron.bcauldrons.size());
Logging.msg(sender, "Number of Recipes: " + BRecipe.getAllRecipes().size());
Expand Down
50 changes: 50 additions & 0 deletions src/main/java/com/dre/brewery/integration/metrics/Metrics.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* BreweryX Bukkit-Plugin for an alternate brewing process
* Copyright (C) 2024-2026 The Brewery Team
*
* This file is part of BreweryX.
*
* BreweryX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BreweryX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with BreweryX. If not, see <http://www.gnu.org/licenses/gpl-3.0.html>.
*/

package com.dre.brewery.integration.metrics;

import com.dre.brewery.integration.metrics.bstats.BStatsBrewery;
import com.dre.brewery.integration.metrics.bstats.BStatsBreweryX;
import com.dre.brewery.integration.metrics.faststats.FastStats;
import lombok.Getter;

@Getter
public class Metrics {

private final FastStats fastStats;
private final BStatsBrewery bstatsBrewery;
private final BStatsBreweryX bStatsBreweryX;

public Metrics() {
this.fastStats = new FastStats();
this.bstatsBrewery = new BStatsBrewery();
this.bStatsBreweryX = new BStatsBreweryX();
}

public void enable() {
fastStats.enable();
bstatsBrewery.setupBStats();
bStatsBreweryX.setupBStats();
}

public void disable() {
fastStats.disable();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Violations will result in a ban of your plugin and account from bStats.
*/

package com.dre.brewery.integration.bstats;
package com.dre.brewery.integration.metrics.bstats;

import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
Expand Down Expand Up @@ -51,7 +51,7 @@
import java.util.zip.GZIPOutputStream;

// Copied from bStats because Gradle wasn't returning the right class
public class Metrics {
public class BStats {

private final Plugin plugin;

Expand All @@ -64,7 +64,7 @@ public class Metrics {
* @param serviceId The id of the service. It can be found at <a
* href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
*/
public Metrics(JavaPlugin plugin, int serviceId) {
public BStats(JavaPlugin plugin, int serviceId) {
this.plugin = plugin;
// Get the config file
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* along with BreweryX. If not, see <http://www.gnu.org/licenses/gpl-3.0.html>.
*/

package com.dre.brewery.integration.bstats;
package com.dre.brewery.integration.metrics.bstats;

import com.dre.brewery.BCauldron;
import com.dre.brewery.BPlayer;
Expand All @@ -28,10 +28,10 @@
import com.dre.brewery.Wakeup;
import com.dre.brewery.configuration.ConfigManager;
import com.dre.brewery.configuration.files.Config;
import com.dre.brewery.integration.bstats.Metrics.AdvancedPie;
import com.dre.brewery.integration.bstats.Metrics.DrilldownPie;
import com.dre.brewery.integration.bstats.Metrics.SimplePie;
import com.dre.brewery.integration.bstats.Metrics.SingleLineChart;
import com.dre.brewery.integration.metrics.bstats.BStats.AdvancedPie;
import com.dre.brewery.integration.metrics.bstats.BStats.DrilldownPie;
import com.dre.brewery.integration.metrics.bstats.BStats.SimplePie;
import com.dre.brewery.integration.metrics.bstats.BStats.SingleLineChart;
import com.dre.brewery.recipe.BRecipe;
import com.dre.brewery.utility.Logging;
import org.bukkit.Bukkit;
Expand All @@ -42,7 +42,7 @@
/**
* General stats written by the original author of Brewery.
*/
public class BreweryStats {
public class BStatsBrewery {

private static final int BSTATS_ID = 3494;

Expand Down Expand Up @@ -76,12 +76,12 @@ public void forDrink(Brew brew) {

public void setupBStats() {
try {
Metrics metrics = new Metrics(BreweryPlugin.getInstance(), BSTATS_ID);
metrics.addCustomChart(new SingleLineChart("drunk_players", BPlayer::numDrunkPlayers));
metrics.addCustomChart(new SingleLineChart("brews_in_existence", () -> brewsCreated));
metrics.addCustomChart(new SingleLineChart("barrels_built", Barrel.getAllBarrels()::size));
metrics.addCustomChart(new SingleLineChart("cauldrons_boiling", BCauldron.bcauldrons::size));
metrics.addCustomChart(new AdvancedPie("brew_quality", () -> {
BStats bstats = new BStats(BreweryPlugin.getInstance(), BSTATS_ID);
bstats.addCustomChart(new SingleLineChart("drunk_players", BPlayer::numDrunkPlayers));
bstats.addCustomChart(new SingleLineChart("brews_in_existence", () -> brewsCreated));
bstats.addCustomChart(new SingleLineChart("barrels_built", Barrel.getAllBarrels()::size));
bstats.addCustomChart(new SingleLineChart("cauldrons_boiling", BCauldron.bcauldrons::size));
bstats.addCustomChart(new AdvancedPie("brew_quality", () -> {
Map<String, Integer> map = new HashMap<>(8);
map.put("excellent", exc);
map.put("good", good);
Expand All @@ -90,14 +90,14 @@ public void setupBStats() {
map.put("terrible", terr);
return map;
}));
metrics.addCustomChart(new AdvancedPie("brews_created", () -> {
bstats.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", () -> {
bstats.addCustomChart(new SimplePie("number_of_recipes", () -> {
int recipes = BRecipe.getAllRecipes().size();
if (recipes < 7) {
return "Less than 7";
Expand Down Expand Up @@ -128,7 +128,7 @@ public void setupBStats() {
}

}));
metrics.addCustomChart(new SimplePie("cauldron_particles", () -> {
bstats.addCustomChart(new SimplePie("cauldron_particles", () -> {
if (!config.isEnableCauldronParticles()) {
return "disabled";
}
Expand All @@ -137,7 +137,7 @@ public void setupBStats() {
}
return "enabled";
}));
metrics.addCustomChart(new SimplePie("wakeups", () -> {
bstats.addCustomChart(new SimplePie("wakeups", () -> {
if (!config.isEnableWake()) {
return "disabled";
}
Expand All @@ -154,7 +154,7 @@ public void setupBStats() {
return "More than 20";
}
}));
metrics.addCustomChart(new SimplePie("v2_mc_version", () -> {
bstats.addCustomChart(new SimplePie("v2_mc_version", () -> {
String mcv = Bukkit.getBukkitVersion();
mcv = mcv.substring(0, mcv.indexOf('.', 2));
int index = mcv.indexOf('-');
Expand All @@ -168,7 +168,7 @@ public void setupBStats() {
return "undef";
}
}));
metrics.addCustomChart(new DrilldownPie("plugin_mc_version", () -> {
bstats.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));
Expand All @@ -187,9 +187,9 @@ public void setupBStats() {
map.put(BreweryPlugin.getInstance().getDescription().getVersion(), innerMap);
return map;
}));
metrics.addCustomChart(new SimplePie("language", config::getLanguage));
metrics.addCustomChart(new SimplePie("config_scramble", () -> config.isEnableEncode() ? "enabled" : "disabled"));
metrics.addCustomChart(new SimplePie("config_lore_color", () -> {
bstats.addCustomChart(new SimplePie("language", config::getLanguage));
bstats.addCustomChart(new SimplePie("config_scramble", () -> config.isEnableEncode() ? "enabled" : "disabled"));
bstats.addCustomChart(new SimplePie("config_lore_color", () -> {
if (config.isColorInBarrels()) {
if (config.isColorInBrewer()) {
return "both";
Expand All @@ -204,7 +204,7 @@ public void setupBStats() {
}
}
}));
metrics.addCustomChart(new SimplePie("config_always_show", () -> {
bstats.addCustomChart(new SimplePie("config_always_show", () -> {
if (config.isAlwaysShowQuality()) {
if (config.isAlwaysShowAlc()) {
return "both";
Expand Down
Loading
Loading