improve bStats

Former-commit-id: fcd3aae1b301475c6f8fc2a64bbd6728d0daf6fc
This commit is contained in:
Ghost_chu committed 2018-10-06 20:21:11 +08:00
1 parent e901dd82f7
commit 8192716d65
2 files changed
+6 -4

No files matched your search

@@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@@ -141,6 +142,8 @@ public class Metrics {
}
// 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 ;)
submitData();
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
@@ -187,7 +190,7 @@ public class Metrics {
*
* @return The server specific data.
*/
private JSONObject getServerData() {
public JSONObject getServerData() {
// Minecraft specific data
int playerAmount;
try {
@@ -231,7 +234,7 @@ public class Metrics {
/**
* Collects the data and sends it afterwards.
*/
private void submitData() {
public void submitData() {
final JSONObject data = getServerData();
JSONArray pluginData = new JSONArray();
@@ -26,7 +26,6 @@ import java.util.UUID;
import javax.net.ssl.HttpsURLConnection;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@@ -267,7 +266,7 @@ public class QuickShop extends JavaPlugin {
metrics.addCustomChart(new Metrics.SimplePie("use-protect-structuregrow",() ->use_protect_structuregrow));
metrics.addCustomChart(new Metrics.SimplePie("use-protect-explode",() -> use_protect_explode));
metrics.addCustomChart(new Metrics.SimplePie("use-protect-hopper", () ->use_protect_hopper));
metrics.submitData(); //Submit now!
}else {
getLogger().info("You have disabled mertics, Skipping...");
}