Skip to content

Commit

Permalink
Added anonymous metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasDeBruijn committed Jun 5, 2021
1 parent 9148e26 commit 533bddb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
}

Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pluginVersion = 2.3.0
pluginVersion = 2.3.1
pluginGroup = nl.thedutchmc.harotorch
pluginName = HaroTorch
19 changes: 17 additions & 2 deletions src/main/java/nl/thedutchmc/harotorch/ConfigurationHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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();
}
}
}
23 changes: 18 additions & 5 deletions src/main/java/nl/thedutchmc/harotorch/HaroTorch.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 533bddb

Please sign in to comment.