mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-25 03:55:35 +01:00
*
This commit is contained in:
parent
b0a82a4cd7
commit
8a50c27ebc
@ -128,7 +128,9 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
|
||||
@Override
|
||||
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() {
|
||||
|
@ -11,4 +11,4 @@ public class SpikeBrush implements Brush {
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -3,8 +3,10 @@ package com.boydti.fawe.util.metrics;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.configuration.file.YamlConfiguration;
|
||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -45,6 +47,7 @@ public class BStats implements Closeable {
|
||||
private final String serverVersion;
|
||||
private final String pluginVersion;
|
||||
private Thread task;
|
||||
private Gson gson = new Gson();
|
||||
|
||||
// Is bStats enabled on this server?
|
||||
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());
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
return Fawe.imp() == null ? 1 : Fawe.imp().getPlayerCount();
|
||||
}
|
||||
|
||||
private BStats(String plugin, String pluginVersion, String serverVersion, String platform, boolean online) {
|
||||
this.url = "https://bStats.org/submitData/" + platform;
|
||||
this.plugin = plugin;
|
||||
@ -70,8 +77,6 @@ public class BStats implements Closeable {
|
||||
this.platform = platform;
|
||||
this.online = online;
|
||||
|
||||
StringBuilder data = new StringBuilder();
|
||||
|
||||
File configFile = new File(getJarFile().getParentFile(), "bStats" + File.separator + "config.yml");
|
||||
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
@ -161,9 +166,10 @@ public class BStats implements Closeable {
|
||||
try {
|
||||
if (enabled) Thread.sleep(TimeUnit.MINUTES.toMillis(30));
|
||||
} catch (InterruptedException e) {
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
submitData();
|
||||
}
|
||||
});
|
||||
this.task.start();
|
||||
@ -178,6 +184,14 @@ public class BStats implements Closeable {
|
||||
@Override
|
||||
public void close() {
|
||||
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.
|
||||
*/
|
||||
private JsonObject getServerData() {
|
||||
int playerAmount = Fawe.imp() != null ? Fawe.imp().getPlayerCount() : 1;
|
||||
int playerAmount = getPlayerCount();
|
||||
int onlineMode = online ? 1 : 0;
|
||||
|
||||
int managedServers = 1;
|
||||
@ -229,8 +243,11 @@ public class BStats implements Closeable {
|
||||
Object plugin = metrics.getClass().getMethod("getPluginData").invoke(metrics);
|
||||
if (plugin instanceof JsonObject) {
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user