From 89c3683cbc2695fb2b12317737479c8a23650e06 Mon Sep 17 00:00:00 2001 From: datatags Date: Sat, 10 Feb 2024 10:29:25 -0800 Subject: [PATCH] Fix version checking; add bStats --- build.gradle | 12 ++++++++++-- .../UltraCosmeticsGUIAddon.java | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 2e2e546..75d7114 100644 --- a/build.gradle +++ b/build.gradle @@ -2,10 +2,11 @@ import org.apache.tools.ant.filters.ReplaceTokens plugins { id 'java-library' + id("com.github.johnrengelman.shadow") version "8.1.1" } group 'me.datatags' -version '1.1' +version '1.1.1' repositories { mavenLocal() @@ -25,7 +26,8 @@ repositories { dependencies { compileOnly 'org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT' // TODO: change this to a tag that works - implementation 'com.github.UltraCosmetics:UltraCosmetics:master-SNAPSHOT' + compileOnly 'com.github.UltraCosmetics:UltraCosmetics:master-SNAPSHOT' + implementation 'org.bstats:bstats-bukkit:3.0.2' } processResources { @@ -35,3 +37,9 @@ processResources { 'VERSION' : project.version, ] } + +shadowJar { + minimize() + def path = 'me.datatags.ultracosmeticsguiaddon.shaded' + relocate('org.bstats', path + '.bstats') +} diff --git a/src/main/java/me/datatags/ultracosmeticsguiaddon/UltraCosmeticsGUIAddon.java b/src/main/java/me/datatags/ultracosmeticsguiaddon/UltraCosmeticsGUIAddon.java index 251b32d..9e8aabf 100644 --- a/src/main/java/me/datatags/ultracosmeticsguiaddon/UltraCosmeticsGUIAddon.java +++ b/src/main/java/me/datatags/ultracosmeticsguiaddon/UltraCosmeticsGUIAddon.java @@ -2,6 +2,7 @@ import be.isach.ultracosmetics.UltraCosmetics; import be.isach.ultracosmetics.UltraCosmeticsData; +import org.bstats.bukkit.Metrics; import org.bukkit.plugin.java.JavaPlugin; public class UltraCosmeticsGUIAddon extends JavaPlugin { @@ -9,10 +10,16 @@ public class UltraCosmeticsGUIAddon extends JavaPlugin { public void onEnable() { UltraCosmetics ultraCosmetics = UltraCosmeticsData.get().getPlugin(); String version = ultraCosmetics.getDescription().getVersion().split("-")[0]; + String minor = version.substring(2); + // If there's more than two components to the version, strip it down to 2 so we can parse it as a number + if (minor.contains(".")) { + version = version.substring(0, 2) + minor.substring(0, minor.indexOf('.')); + } if (Double.parseDouble(version) < 3.4) { throw new IllegalStateException("This addon requires UltraCosmetics 3.4 or higher!"); } // Registers itself in order to avoid assuming the existence of UCAddon at runtime new GUIAddon(ultraCosmetics, this); + new Metrics(this, 20962); } }