From 322ed7723297ca1e795e03d0747a7fc336691d8e Mon Sep 17 00:00:00 2001 From: Model 3 Date: Tue, 18 Sep 2018 06:56:24 -0700 Subject: [PATCH] Force Metrics to submit to TFM even if the plugin is renamed (#119) --- TotalFreedomMod.iml | 1 + pom.xml | 2 +- .../totalfreedommod/command/CommandLoader.java | 2 +- .../totalfreedom/totalfreedommod/player/FPlayer.java | 5 ++--- src/main/java/org/bstats/Metrics.java | 11 ++++------- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/TotalFreedomMod.iml b/TotalFreedomMod.iml index bbc02624..8f727c3b 100644 --- a/TotalFreedomMod.iml +++ b/TotalFreedomMod.iml @@ -13,6 +13,7 @@ + diff --git a/pom.xml b/pom.xml index bb5cef97..5179d298 100644 --- a/pom.xml +++ b/pom.xml @@ -146,7 +146,7 @@ provided - diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/CommandLoader.java b/src/main/java/me/totalfreedom/totalfreedommod/command/CommandLoader.java index 0a6e60d4..c0920815 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/CommandLoader.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/CommandLoader.java @@ -31,7 +31,7 @@ public class CommandLoader extends FreedomService handler.setOnlyPlayerMessage(ChatColor.RED + "This command can only be used by players."); handler.loadFrom(FreedomCommand.class.getPackage()); - handler.registerAll("TotalFreedomMod", true); + handler.registerAll(plugin.getDescription().getName(), true); FLog.info("Loaded " + handler.getExecutors().size() + " commands."); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java index d33d16ef..682f4a1b 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java @@ -306,12 +306,12 @@ public class FPlayer { if (getPlayer() != null) { - FUtil.adminAction("TotalFreedom", "Unmuting " + getPlayer().getName(), false); + FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Unmuting " + getPlayer().getName(), false); setMuted(false); } else { - FUtil.adminAction("TotalFreedom", "Unmuting " + getName(), false); + FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Unmuting " + getName(), false); plugin.mu.MUTED_PLAYERS.remove(getName()); } } @@ -343,7 +343,6 @@ public class FPlayer this.inAdminchat = inAdminchat; } - public boolean inAdminChat() { return this.inAdminchat; diff --git a/src/main/java/org/bstats/Metrics.java b/src/main/java/org/bstats/Metrics.java index 8b426624..0990cfbd 100644 --- a/src/main/java/org/bstats/Metrics.java +++ b/src/main/java/org/bstats/Metrics.java @@ -18,6 +18,7 @@ import java.util.concurrent.Callable; import java.util.logging.Level; import java.util.zip.GZIPOutputStream; import javax.net.ssl.HttpsURLConnection; +import me.totalfreedom.totalfreedommod.util.FLog; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; @@ -34,7 +35,6 @@ import org.json.simple.JSONObject; */ public class Metrics { - static { // You can use the property to disable the check in your test environment @@ -91,7 +91,6 @@ public class Metrics // Check if the config file exists if (!config.isSet("serverUuid")) { - // Add default values config.addDefault("enabled", true); // Every server gets it's unique random id. @@ -201,10 +200,9 @@ public class Metrics { JSONObject data = new JSONObject(); - String pluginName = plugin.getDescription().getName(); String pluginVersion = plugin.getDescription().getVersion(); - data.put("pluginName", pluginName); // Append the name of the plugin + data.put("pluginName", "TotalFreedomMod"); // Append the name of the plugin data.put("pluginVersion", pluginVersion); // Append the version of the plugin JSONArray customCharts = new JSONArray(); for (CustomChart customChart : charts) @@ -321,7 +319,7 @@ public class Metrics // Something went wrong! :( if (logFailedRequests) { - plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e); + FLog.warning("Could not submit plugin stats of " + plugin.getName() + e); } } } @@ -429,7 +427,7 @@ public class Metrics { if (logFailedRequests) { - Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t); + FLog.warning("Failed to get data for custom chart with id " + chartId + t); } return null; } @@ -768,6 +766,5 @@ public class Metrics data.put("values", values); return data; } - } } \ No newline at end of file