From eb39a22d819ec8bdda41b2d8205951483193daa3 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Sun, 22 Sep 2024 11:26:20 +0200 Subject: [PATCH] Add bStats actually 2.0.5 --- pom.xml | 33 ++++++++++++++++++- .../java/eu/m724/giants/GiantsPlugin.java | 14 +++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 258f8e9..85c8e15 100644 --- a/pom.xml +++ b/pom.xml @@ -42,6 +42,12 @@ + + org.bstats + bstats-bukkit + 3.0.2 + compile + @@ -55,11 +61,36 @@ org.apache.maven.plugins maven-release-plugin - 3.0.1 + 3.1.1 true + + org.apache.maven.plugins + maven-shade-plugin + 3.6.0 + + false + true + full + + + org.bstats + + eu.m724.giants + + + + + + package + + shade + + + + diff --git a/src/main/java/eu/m724/giants/GiantsPlugin.java b/src/main/java/eu/m724/giants/GiantsPlugin.java index 9823dad..438ca14 100644 --- a/src/main/java/eu/m724/giants/GiantsPlugin.java +++ b/src/main/java/eu/m724/giants/GiantsPlugin.java @@ -1,5 +1,6 @@ package eu.m724.giants; +import org.bstats.bukkit.Metrics; import org.bukkit.Location; import org.bukkit.command.CommandExecutor; import org.bukkit.entity.Giant; @@ -7,6 +8,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.plugin.java.JavaPlugin; import java.io.File; +import java.lang.reflect.Constructor; public class GiantsPlugin extends JavaPlugin implements CommandExecutor { private final File configFile = new File(getDataFolder(), "config.yml"); @@ -25,7 +27,17 @@ public class GiantsPlugin extends JavaPlugin implements CommandExecutor { getCommand("giants").setExecutor(new GiantsCommand(this, configuration)); giantProcessor.start(); - } + + // bStats is optional + try { + Class clazz = Class.forName("eu.m724.giants.bukkit.Metrics"); + Constructor constructor = clazz.getDeclaredConstructor(JavaPlugin.class, int.class); + constructor.newInstance(this, 14131); + getLogger().info("Enabled bStats"); + } catch (Exception e) { + getLogger().info("Not using bStats (" + e.getClass().getName() + ")"); + } + } // TODO api, untested