Skip to content

Commit

Permalink
feat: add bStats, update spigot ID, bump to 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Jan 12, 2024
1 parent 92659b4 commit edfeac2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import net.william278.huskclaims.config.TrustLevels;
import net.william278.huskclaims.database.Database;
import net.william278.huskclaims.event.BukkitEventDispatcher;
import net.william278.huskclaims.highlighter.BlockUpdateHighlighter;
import net.william278.huskclaims.highlighter.Highlighter;
import net.william278.huskclaims.hook.BukkitHookProvider;
import net.william278.huskclaims.hook.Hook;
Expand All @@ -54,6 +55,8 @@
import net.william278.huskclaims.util.BlockProvider;
import net.william278.huskclaims.util.BukkitBlockProvider;
import net.william278.huskclaims.util.BukkitTask;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
Expand Down Expand Up @@ -125,6 +128,30 @@ public void loadAPI() {
BukkitHuskClaimsAPI.register(this);
}

@Override
public void loadMetrics() {
try {
final Metrics metrics = new Metrics(this, BSTATS_PLUGIN_ID);
metrics.addCustomChart(new SimplePie("is_cross_server",
() -> settings.getCrossServer().isEnabled() ? "true" : "false")
);
metrics.addCustomChart(new SimplePie("language",
() -> settings.getLanguage().toLowerCase())
);
metrics.addCustomChart(new SimplePie("database_type",
() -> settings.getDatabase().getType().getDisplayName())
);
metrics.addCustomChart(new SimplePie("highlighter_type",
() -> getHighlighter() instanceof BlockUpdateHighlighter ? "Block Updates" : "Display Entities")
);
getBroker().ifPresent(broker -> metrics.addCustomChart(new SimplePie("broker_type",
() -> settings.getCrossServer().getBrokerType().getDisplayName()
)));
} catch (Exception e) {
log(Level.WARNING, "Failed to initialize plugin metrics", e);
}
}

@Override
public void disablePlugin() {
log(Level.INFO, "Disabling HuskClaims...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ default void initialize() {
loadClaimBlockScheduler();
loadHooks();
loadAPI();
loadMetrics();
} catch (Throwable e) {
log(Level.SEVERE, "An error occurred whilst initializing HuskClaims", e);
disablePlugin();
Expand Down Expand Up @@ -116,6 +117,13 @@ default void unloadAPI() {
HuskClaimsAPI.unregister();
}

/**
* Load plugin metrics
*
* @since 1.0
*/
void loadMetrics();

/**
* Disable the plugin
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
*/
public interface MetaProvider {

int SPIGOT_RESOURCE_ID = 100000; //todo set this
int SPIGOT_RESOURCE_ID = 114467;
int BSTATS_PLUGIN_ID = 20728;

/**
* Get a list of all {@link ClaimWorld}s
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ javaVersion=17
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
org.gradle.daemon=true

plugin_version=1.0
plugin_version=1.0.1
plugin_archive=huskclaims
plugin_description=A clean, cross-server compatible grief prevention plugin

Expand Down

0 comments on commit edfeac2

Please sign in to comment.