Skip to content

Commit

Permalink
Requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sgdc3 committed Oct 23, 2018
1 parent a67a706 commit 90e2465
Show file tree
Hide file tree
Showing 18 changed files with 66 additions and 160 deletions.
89 changes: 8 additions & 81 deletions .gitignore
@@ -1,86 +1,13 @@
# Git
*.orig
!.gitignore

# Windows
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
*.stackdump
[Dd]esktop.ini
$RECYCLE.BIN/
*.lnk

# Linux
*~
.fuse_hidden*
.directory
.Trash-*
.nfs*

# MacOS
.DS_Store
.AppleDouble
.LSOverride
._*

# Java
*.class
*.log
*.ctxt
.mtj.tmp/
*.jar
*.war
*.nar
*.ear
hs_err_pid*

# Maven
# compile output
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties

# Intellij
# IntelliJ files
.idea
*.iml
*.java___jb_tmp___
.idea/*
*.ipr
*.iws
/out/
.idea_modules/
out
gen

# Eclipse
*.pydevproject
.metadata
.gradle
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.project
.externalToolBuilders/
*.launch
.cproject
# eclipse files
.settings
.classpath
.buildpath
.target

# NetBeans
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
.nb-gradle/
.project
2 changes: 1 addition & 1 deletion LICENSE
Expand Up @@ -162,4 +162,4 @@ General Public License ever published by the Free Software Foundation.
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
Library.
2 changes: 1 addition & 1 deletion README.md
@@ -1,3 +1,3 @@
# bStats Metrics classes
This repo includes the metrics classes for Bukkit/Spigot, Bungeecord and Sponge.
A tutorial on how to include them into your project can be found [here](https://bstats.org/getting-started/metrics-class).
A tutorial on how to include them into your project can be found [here](https://bstats.org/getting-started/metrics-class).
2 changes: 1 addition & 1 deletion bstats-bukkit-lite/pom.xml
Expand Up @@ -28,4 +28,4 @@
</dependency>
</dependencies>

</project>
</project>
Expand Up @@ -107,8 +107,7 @@ public MetricsLite(Plugin plugin) {
).copyDefaults(true);
try {
config.save(configFile);
} catch (IOException ignored) {
}
} catch (IOException ignored) { }
}

// Load the data
Expand All @@ -123,8 +122,7 @@ public MetricsLite(Plugin plugin) {
service.getField("B_STATS_VERSION"); // Our identifier :)
found = true; // We aren't the first
break;
} catch (NoSuchFieldException ignored) {
}
} catch (NoSuchFieldException ignored) { }
}
// Register our service
Bukkit.getServicesManager().register(MetricsLite.class, this, plugin, ServicePriority.Normal);
Expand Down Expand Up @@ -158,12 +156,7 @@ public void run() {
}
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
submitData();
}
});
Bukkit.getScheduler().runTask(plugin, () -> submitData());
}
}, 1000 * 60 * 5, 1000 * 60 * 30);
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
Expand Down Expand Up @@ -254,8 +247,7 @@ private void submitData() {
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
}
}
} catch (NoSuchFieldException ignored) {
}
} catch (NoSuchFieldException ignored) { }
}

data.put("plugins", pluginData);
Expand All @@ -281,7 +273,7 @@ public void run() {
* Sends the data to the bStats server.
*
* @param plugin Any plugin. It's just used to get a logger instance.
* @param data The data to send.
* @param data The data to send.
* @throws Exception If the request failed.
*/
private static void sendData(Plugin plugin, JSONObject data) throws Exception {
Expand Down Expand Up @@ -347,4 +339,4 @@ private static byte[] compress(final String str) throws IOException {
return outputStream.toByteArray();
}

}
}
2 changes: 1 addition & 1 deletion bstats-bukkit/pom.xml
Expand Up @@ -28,4 +28,4 @@
</dependency>
</dependencies>

</project>
</project>
2 changes: 1 addition & 1 deletion bstats-bukkit/src/examples/java/ExamplePlugin.java
Expand Up @@ -12,4 +12,4 @@ public void onEnable() {
metrics.addCustomChart(new Metrics.SimplePie("chart_id", () -> "My value"));
}

}
}
37 changes: 14 additions & 23 deletions bstats-bukkit/src/main/java/org/bstats/bukkit/Metrics.java
Expand Up @@ -108,8 +108,7 @@ public Metrics(Plugin plugin) {
).copyDefaults(true);
try {
config.save(configFile);
} catch (IOException ignored) {
}
} catch (IOException ignored) { }
}

// Load the data
Expand All @@ -127,8 +126,7 @@ public Metrics(Plugin plugin) {
service.getField("B_STATS_VERSION"); // Our identifier :)
found = true; // We aren't the first
break;
} catch (NoSuchFieldException ignored) {
}
} catch (NoSuchFieldException ignored) { }
}
// Register our service
Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal);
Expand Down Expand Up @@ -174,12 +172,7 @@ public void run() {
}
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
submitData();
}
});
Bukkit.getScheduler().runTask(plugin, () -> submitData());
}
}, 1000 * 60 * 5, 1000 * 60 * 30);
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
Expand Down Expand Up @@ -275,11 +268,9 @@ private void submitData() {
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
try {
pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider()));
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
}
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
}
} catch (NoSuchFieldException ignored) {
}
} catch (NoSuchFieldException ignored) { }
}

data.put("plugins", pluginData);
Expand All @@ -305,7 +296,7 @@ public void run() {
* Sends the data to the bStats server.
*
* @param plugin Any plugin. It's just used to get a logger instance.
* @param data The data to send.
* @param data The data to send.
* @throws Exception If the request failed.
*/
private static void sendData(Plugin plugin, JSONObject data) throws Exception {
Expand Down Expand Up @@ -424,7 +415,7 @@ public static class SimplePie extends CustomChart {
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SimplePie(String chartId, Callable<String> callable) {
Expand Down Expand Up @@ -455,7 +446,7 @@ public static class AdvancedPie extends CustomChart {
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
Expand Down Expand Up @@ -499,7 +490,7 @@ public static class DrilldownPie extends CustomChart {
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
Expand Down Expand Up @@ -548,7 +539,7 @@ public static class SingleLineChart extends CustomChart {
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SingleLineChart(String chartId, Callable<Integer> callable) {
Expand Down Expand Up @@ -580,7 +571,7 @@ public static class MultiLineChart extends CustomChart {
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
Expand Down Expand Up @@ -625,7 +616,7 @@ public static class SimpleBarChart extends CustomChart {
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
Expand Down Expand Up @@ -663,7 +654,7 @@ public static class AdvancedBarChart extends CustomChart {
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
Expand Down Expand Up @@ -701,4 +692,4 @@ protected JSONObject getChartData() throws Exception {
}
}

}
}
Expand Up @@ -207,8 +207,7 @@ private void submitData() {
if (plugin instanceof JsonObject) {
pluginData.add((JsonObject) plugin);
}
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
}
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
}

data.add("plugins", pluginData);
Expand Down Expand Up @@ -272,8 +271,7 @@ private Class<?> getFirstBStatsClass() {
try {
// Let's check if a class with the given name exists.
return Class.forName(className);
} catch (ClassNotFoundException ignored) {
}
} catch (ClassNotFoundException ignored) { }
}
writeFile(tempFile, getClass().getName());
return getClass();
Expand Down Expand Up @@ -307,7 +305,7 @@ private String readFile(File file) throws IOException {
/**
* Writes a String to a file. It also adds a note for the user,
*
* @param file The file to write to. Cannot be null.
* @param file The file to write to. Cannot be null.
* @param lines The lines to write.
* @throws IOException If something did not work :(
*/
Expand All @@ -330,7 +328,7 @@ private void writeFile(File file, String... lines) throws IOException {
* Sends the data to the bStats server.
*
* @param plugin Any plugin. It's just used to get a logger instance.
* @param data The data to send.
* @param data The data to send.
* @throws Exception If the request failed.
*/
private static void sendData(Plugin plugin, JsonObject data) throws Exception {
Expand Down Expand Up @@ -394,4 +392,4 @@ private static byte[] compress(final String str) throws IOException {
return outputStream.toByteArray();
}

}
}
2 changes: 1 addition & 1 deletion bstats-bungeecord/pom.xml
Expand Up @@ -36,4 +36,4 @@
</dependency>
</dependencies>

</project>
</project>
2 changes: 1 addition & 1 deletion bstats-bungeecord/src/examples/java/ExamplePlugin.java
Expand Up @@ -14,4 +14,4 @@ public void onEnable() {
metrics.addCustomChart(new Metrics.SimplePie("chart_id", () -> "My value"));
}

}
}

0 comments on commit 90e2465

Please sign in to comment.