From 533bddb442c867df0e1b31f3daf3118714d028d9 Mon Sep 17 00:00:00 2001 From: Tobias de Bruijn Date: Sat, 5 Jun 2021 09:37:32 +0200 Subject: [PATCH] Added anonymous metrics --- build.gradle | 7 +++--- gradle.properties | 2 +- .../harotorch/ConfigurationHandler.java | 19 +++++++++++++-- .../nl/thedutchmc/harotorch/HaroTorch.java | 23 +++++++++++++++---- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 863b391..426415a 100644 --- a/build.gradle +++ b/build.gradle @@ -17,9 +17,9 @@ allprojects { targetCompatibility = 1.11 repositories { - jcenter() - maven{ url "https://hub.spigotmc.org/nexus/content/repositories/snapshots" } - maven{ url "https://oss.sonatype.org/content/repositories/snapshots" } + mavenCentral() + maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots" } + maven { url "https://oss.sonatype.org/content/repositories/snapshots" } maven { url 'https://jitpack.io' } } @@ -41,6 +41,7 @@ dependencies { compile 'commons-io:commons-io:2.6' compile 'com.github.TheDutchMC:BukkitReflectionUtil:1.1' compile 'com.github.TheDutchMC:HttpLib:1.1' + compile 'dev.array21:pluginstatlib:1.0.5' } task testJar(type: ShadowJar) { diff --git a/gradle.properties b/gradle.properties index ce303e0..648ca21 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ -pluginVersion = 2.3.0 +pluginVersion = 2.3.1 pluginGroup = nl.thedutchmc.harotorch pluginName = HaroTorch \ No newline at end of file diff --git a/src/main/java/nl/thedutchmc/harotorch/ConfigurationHandler.java b/src/main/java/nl/thedutchmc/harotorch/ConfigurationHandler.java index af34801..07ed910 100644 --- a/src/main/java/nl/thedutchmc/harotorch/ConfigurationHandler.java +++ b/src/main/java/nl/thedutchmc/harotorch/ConfigurationHandler.java @@ -18,8 +18,8 @@ public class ConfigurationHandler { private HaroTorch plugin; - public String torchBlock, activeLang; - public Boolean enableTorchParticles, allowRemoveNotOwnedTorch, onlyBlockHostileMobs; + public String torchBlock, activeLang, statUuid; + public Boolean enableTorchParticles, allowRemoveNotOwnedTorch, onlyBlockHostileMobs, disableStat; public Integer torchRange, torchHighlightRange, torchHighlightTime, torchAoeParticleHeight, commandCooldown; /** @@ -68,9 +68,13 @@ public void readConfig() { torchBlock = this.getConfig().getString("torchBlock"); activeLang = this.getConfig().getString("activeLang"); + String statUuid = this.getConfig().getString("statUuid"); + this.statUuid = statUuid != null ? statUuid : ""; + enableTorchParticles = this.getConfig().getBoolean("enableTorchParticles"); allowRemoveNotOwnedTorch = this.getConfig().getBoolean("allowRemoveNotOwnedTorch"); onlyBlockHostileMobs = this.getConfig().getBoolean("onlyBlockHostileMobs"); + disableStat = this.getConfig().getBoolean("disableStat"); torchRange = this.getConfig().getInt("torchRange"); torchHighlightRange = this.getConfig().getInt("torchHighlightRange"); @@ -109,4 +113,15 @@ public void readConfig() { recipeKeys.put(key, m); } } + + public void setUuid(String uuid) { + this.statUuid = uuid; + + this.getConfig().set("statUuid", uuid); + try { + this.config.save(file); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/src/main/java/nl/thedutchmc/harotorch/HaroTorch.java b/src/main/java/nl/thedutchmc/harotorch/HaroTorch.java index 3f0148c..73bf264 100644 --- a/src/main/java/nl/thedutchmc/harotorch/HaroTorch.java +++ b/src/main/java/nl/thedutchmc/harotorch/HaroTorch.java @@ -8,6 +8,8 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; +import dev.array21.pluginstatlib.PluginStat; +import dev.array21.pluginstatlib.PluginStat.PluginStatBuilder; import net.md_5.bungee.api.ChatColor; import nl.thedutchmc.harotorch.commands.TorchCommandExecutor; import nl.thedutchmc.harotorch.commands.TorchCommandTabCompleter; @@ -36,6 +38,18 @@ public void run() { CONFIG = new ConfigurationHandler(this); CONFIG.loadConfig(); + String jVersion = System.getProperty("java.version"); + System.out.println(jVersion); + if(!CONFIG.disableStat) { + PluginStat stat = PluginStatBuilder.createDefault() + .setLogErrFn(this::logWarn) + .setSetUuidFn(CONFIG::setUuid) + .setUuid(CONFIG.statUuid) + .build(); + + stat.start(); + } + LangHandler langHandler = new LangHandler(this); langHandler.load(); @@ -65,7 +79,6 @@ public void run() { Bukkit.getPluginManager().registerEvents(new BlockPhysicsEventListener(), this); Bukkit.getPluginManager().registerEvents(new BlockBurnEventListener(), this); - //Commands this.getCommand("torch").setExecutor(new TorchCommandExecutor(this)); this.getCommand("torch").setTabCompleter(new TorchCommandTabCompleter()); @@ -98,12 +111,12 @@ public void onDisable() { logInfo(LangHandler.activeLang.getLangMessages().get("goodbye")); } - public void logInfo(String log) { - this.getLogger().info(log); + public void logInfo(Object log) { + this.getLogger().info(log.toString()); } - public void logWarn(String log) { - this.getLogger().warning(log); + public void logWarn(Object log) { + this.getLogger().warning(log.toString()); } public static ConfigurationHandler getConfigHandler() {