Send the bStats ID

This commit is contained in:
NotMyFault 2020-01-24 18:10:19 +01:00
parent 0953b5627e
commit 312b2ad1a8

View File

@ -79,6 +79,9 @@ public class Metrics {
// The plugin // The plugin
private final Plugin plugin; private final Plugin plugin;
// The plugin id
private final int bstatsId;
// A list with all custom charts // A list with all custom charts
private final List<CustomChart> charts = new ArrayList<>(); private final List<CustomChart> charts = new ArrayList<>();
@ -86,13 +89,14 @@ public class Metrics {
* Class constructor. * Class constructor.
* *
* @param plugin The plugin which stats should be submitted. * @param plugin The plugin which stats should be submitted.
* @param bstatsId ID of the plugin * @param bstatsId The ID of the plugin. It can be found in the url when you open the plugin on bStats.
*/ */
public Metrics(Plugin plugin, int bstatsId) { public Metrics(Plugin plugin, int bstatsId) {
if (plugin == null) { if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null!"); throw new IllegalArgumentException("Plugin cannot be null!");
} }
this.plugin = plugin; this.plugin = plugin;
this.bstatsId = bstatsId;
// Get the config file // Get the config file
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats"); File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
@ -207,6 +211,7 @@ public class Metrics {
String pluginVersion = plugin.getDescription().getVersion(); String pluginVersion = plugin.getDescription().getVersion();
data.put("pluginName", pluginName); // Append the name of the plugin data.put("pluginName", pluginName); // Append the name of the plugin
data.put("id", bstatsId); // Append the id of the plugin
data.put("pluginVersion", pluginVersion); // Append the version of the plugin data.put("pluginVersion", pluginVersion); // Append the version of the plugin
JSONArray customCharts = new JSONArray(); JSONArray customCharts = new JSONArray();
for (CustomChart customChart : charts) { for (CustomChart customChart : charts) {