Skip to content

Commit

Permalink
Remove metrics inclusion and check enabled state without loading classes
Browse files Browse the repository at this point in the history
  • Loading branch information
rainbowdashlabs committed Jun 30, 2024
1 parent 9cd39cf commit 4b49b08
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
1 change: 0 additions & 1 deletion metrics/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
description = "Wrapper for bstats"

dependencies {
api("org.bstats", "bstats-bukkit", "3.0.2")
compileOnly(libs.spigot)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,25 @@

package de.eldoria.eldoutilities.metrics;

import org.bstats.bukkit.Metrics;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;

/**
* Wrapper for the Metrics class of bstats. Just because they removed this shitty isEnabled() function.
* Helper for the Metrics class of bstats. Just because they removed this shitty isEnabled() function.
*/
public class EldoMetrics extends Metrics {
private final boolean enabled;
public class EldoMetrics {

/**
* Creates a new Metrics instance.
* Check if metrics are enabled
*
* @param plugin Your plugin instance.
* @param serviceId The id of the service.
* @return true if enabled
*/
public EldoMetrics(JavaPlugin plugin, int serviceId) {
super(plugin, serviceId);
public static boolean isEnabled(Plugin plugin) {
var bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
var configFile = new File(bStatsFolder, "config.yml");
var config = YamlConfiguration.loadConfiguration(configFile);
enabled = config.getBoolean("enabled", true);
}

/**
* Check if metrics are enabled
*
* @return true if enabled
*/
public boolean isEnabled() {
return enabled;
return config.getBoolean("enabled", true);
}
}

0 comments on commit 4b49b08

Please sign in to comment.