mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-28 21:56:33 +01:00
*
This commit is contained in:
parent
b0a82a4cd7
commit
8a50c27ebc
@ -128,7 +128,9 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlatformVersion() {
|
public String getPlatformVersion() {
|
||||||
return Bukkit.getVersion();
|
String bukkitVersion = Bukkit.getVersion();
|
||||||
|
int index = bukkitVersion.indexOf("MC: ");
|
||||||
|
return index == -1 ? bukkitVersion : bukkitVersion.substring(index + 4, bukkitVersion.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupInjector() {
|
public void setupInjector() {
|
||||||
|
@ -3,8 +3,10 @@ package com.boydti.fawe.util.metrics;
|
|||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.configuration.file.YamlConfiguration;
|
import com.boydti.fawe.configuration.file.YamlConfiguration;
|
||||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -45,6 +47,7 @@ public class BStats implements Closeable {
|
|||||||
private final String serverVersion;
|
private final String serverVersion;
|
||||||
private final String pluginVersion;
|
private final String pluginVersion;
|
||||||
private Thread task;
|
private Thread task;
|
||||||
|
private Gson gson = new Gson();
|
||||||
|
|
||||||
// Is bStats enabled on this server?
|
// Is bStats enabled on this server?
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
@ -62,6 +65,10 @@ public class BStats implements Closeable {
|
|||||||
this("FastAsyncWorldEdit", Fawe.get().getVersion().toString(), Fawe.imp().getPlatformVersion(), Fawe.imp().getPlatform(), Fawe.imp().isOnlineMode());
|
this("FastAsyncWorldEdit", Fawe.get().getVersion().toString(), Fawe.imp().getPlatformVersion(), Fawe.imp().getPlatform(), Fawe.imp().isOnlineMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPlayerCount() {
|
||||||
|
return Fawe.imp() == null ? 1 : Fawe.imp().getPlayerCount();
|
||||||
|
}
|
||||||
|
|
||||||
private BStats(String plugin, String pluginVersion, String serverVersion, String platform, boolean online) {
|
private BStats(String plugin, String pluginVersion, String serverVersion, String platform, boolean online) {
|
||||||
this.url = "https://bStats.org/submitData/" + platform;
|
this.url = "https://bStats.org/submitData/" + platform;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -70,8 +77,6 @@ public class BStats implements Closeable {
|
|||||||
this.platform = platform;
|
this.platform = platform;
|
||||||
this.online = online;
|
this.online = online;
|
||||||
|
|
||||||
StringBuilder data = new StringBuilder();
|
|
||||||
|
|
||||||
File configFile = new File(getJarFile().getParentFile(), "bStats" + File.separator + "config.yml");
|
File configFile = new File(getJarFile().getParentFile(), "bStats" + File.separator + "config.yml");
|
||||||
|
|
||||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
@ -161,9 +166,10 @@ public class BStats implements Closeable {
|
|||||||
try {
|
try {
|
||||||
if (enabled) Thread.sleep(TimeUnit.MINUTES.toMillis(30));
|
if (enabled) Thread.sleep(TimeUnit.MINUTES.toMillis(30));
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
submitData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.task.start();
|
this.task.start();
|
||||||
@ -178,6 +184,14 @@ public class BStats implements Closeable {
|
|||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
enabled = false;
|
enabled = false;
|
||||||
|
if (task != null) {
|
||||||
|
task.interrupt();
|
||||||
|
try {
|
||||||
|
task.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -186,7 +200,7 @@ public class BStats implements Closeable {
|
|||||||
* @return The server specific data.
|
* @return The server specific data.
|
||||||
*/
|
*/
|
||||||
private JsonObject getServerData() {
|
private JsonObject getServerData() {
|
||||||
int playerAmount = Fawe.imp() != null ? Fawe.imp().getPlayerCount() : 1;
|
int playerAmount = getPlayerCount();
|
||||||
int onlineMode = online ? 1 : 0;
|
int onlineMode = online ? 1 : 0;
|
||||||
|
|
||||||
int managedServers = 1;
|
int managedServers = 1;
|
||||||
@ -229,8 +243,11 @@ public class BStats implements Closeable {
|
|||||||
Object plugin = metrics.getClass().getMethod("getPluginData").invoke(metrics);
|
Object plugin = metrics.getClass().getMethod("getPluginData").invoke(metrics);
|
||||||
if (plugin instanceof JsonObject) {
|
if (plugin instanceof JsonObject) {
|
||||||
pluginData.add((JsonObject) plugin);
|
pluginData.add((JsonObject) plugin);
|
||||||
|
} else {
|
||||||
|
pluginData.add(gson.fromJson(plugin.toString(), JsonObject.class));
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
|
|
||||||
|
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | NullPointerException | JsonSyntaxException ignored) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
data.add("plugins", pluginData);
|
data.add("plugins", pluginData);
|
||||||
|
Loading…
Reference in New Issue
Block a user