Skip to content

Commit

Permalink
1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
wode490390 committed Feb 25, 2020
1 parent f691e6d commit e0d1ab4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bstats-nukkit-lite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.bstats</groupId>
<artifactId>bstats-nukkit-lite</artifactId>
<version>1.6</version>
<version>1.7</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
6 changes: 4 additions & 2 deletions bstats-nukkit-lite/src/examples/java/ExamplePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ public class ExamplePlugin extends PluginBase {

@Override
public void onEnable() {
// All you have to do is adding this line in your onEnable method:
MetricsLite metrics = new MetricsLite(this);
// All you have to do is adding the following two lines in your onEnable method.
// You can find the plugin ids of your plugins on the page https://bstats.org/what-is-my-plugin-id
int pluginId = 1234; // <-- Replace with the id of your plugin!
MetricsLite metrics = new MetricsLite(this, pluginId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,20 @@ public class MetricsLite {
// The plugin
private final Plugin plugin;

// The plugin id
private final int pluginId;

/**
* Class constructor.
*
* @param plugin The plugin which stats should be submitted.
* @param pluginId The id of the plugin.
* It can be found at <a href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
*/
public MetricsLite(Plugin plugin) {
public MetricsLite(Plugin plugin, int pluginId) {
Preconditions.checkNotNull(plugin);
this.plugin = plugin;
this.pluginId = pluginId;

// Get the config file
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
Expand Down Expand Up @@ -192,6 +198,7 @@ public JsonObject getPluginData() {
String pluginVersion = plugin.getDescription().getVersion();

data.addProperty("pluginName", pluginName); // Append the name of the plugin
data.addProperty("id", pluginId); // Append the id of the plugin
data.addProperty("pluginVersion", pluginVersion); // Append the version of the plugin

JsonArray customCharts = new JsonArray();
Expand Down
2 changes: 1 addition & 1 deletion bstats-nukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.bstats</groupId>
<artifactId>bstats-nukkit</artifactId>
<version>1.6</version>
<version>1.7</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
6 changes: 4 additions & 2 deletions bstats-nukkit/src/examples/java/ExamplePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ public class ExamplePlugin extends PluginBase {

@Override
public void onEnable() {
// All you have to do is adding this line in your onEnable method:
Metrics metrics = new Metrics(this);
// All you have to do is adding the following two lines in your onEnable method.
// You can find the plugin ids of your plugins on the page https://bstats.org/what-is-my-plugin-id
int pluginId = 1234; // <-- Replace with the id of your plugin!
Metrics metrics = new Metrics(this, pluginId);

// Optional: Add custom charts
metrics.addCustomChart(new Metrics.SimplePie("chart_id", () -> "My value"));
Expand Down
9 changes: 8 additions & 1 deletion bstats-nukkit/src/main/java/org/bstats/nukkit/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,23 @@ public class Metrics {
// The plugin
private final Plugin plugin;

// The plugin id
private final int pluginId;

// A list with all custom charts
private final List<CustomChart> charts = new ArrayList<>();

/**
* Class constructor.
*
* @param plugin The plugin which stats should be submitted.
* @param pluginId The id of the plugin.
* It can be found at <a href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
*/
public Metrics(Plugin plugin) {
public Metrics(Plugin plugin, int pluginId) {
Preconditions.checkNotNull(plugin);
this.plugin = plugin;
this.pluginId = pluginId;

// Get the config file
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
Expand Down Expand Up @@ -208,6 +214,7 @@ public JsonObject getPluginData() {
String pluginVersion = plugin.getDescription().getVersion();

data.addProperty("pluginName", pluginName); // Append the name of the plugin
data.addProperty("id", pluginId); // Append the id of the plugin
data.addProperty("pluginVersion", pluginVersion); // Append the version of the plugin

JsonArray customCharts = new JsonArray();
Expand Down

0 comments on commit e0d1ab4

Please # to comment.