mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 09:59:49 -05:00
Revert the changes for getServerData
Former-commit-id: daf6c4096f89053a91ca8a4f87c486d58071c3d4 [formerly 43e31b1db9fa7181fe9495645ea42834bb78e8df] Former-commit-id: 32ac36b7a3081e140ffd4222146a3c77698b35e6
This commit is contained in:
1 parent
0ee65c892a
commit
bdfb1e1e24
4 files changed
+4
-55
No files matched your search
@@ -218,14 +218,12 @@ public class QuickShop extends JavaPlugin {
|
||||
getConfig().set("config-version", 1);
|
||||
|
||||
updateConfig(getConfig().getInt("config-version"));
|
||||
|
||||
/* It will generate a new UUID above updateConfig */
|
||||
//noinspection ConstantConditions
|
||||
serverUniqueID = UUID.fromString(getConfig().getString("server-uuid"));
|
||||
sentryErrorReporter = new SentryErrorReporter(this);
|
||||
|
||||
/* Process Metrics and Sentry error reporter. */
|
||||
metrics = new Metrics(this);
|
||||
serverUniqueID = UUID.fromString(getConfig().getString("server-uuid"));
|
||||
sentryErrorReporter = new SentryErrorReporter(this);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Paste {
|
||||
//finalReport.append("Fork: "+plugin.+"\n");
|
||||
finalReport.append("================================================\n");
|
||||
finalReport.append("System:\n");
|
||||
JSONObject serverData = Util.getServerData();
|
||||
JSONObject serverData = plugin.getMetrics().getServerData();
|
||||
finalReport.append("\tOS: ").append(serverData.get("osName")).append("\n");
|
||||
finalReport.append("\tArch: ").append(serverData.get("osArch")).append("\n");
|
||||
finalReport.append("\tVersion: ").append(serverData.get("osVersion")).append("\n");
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SentryErrorReporter {
|
||||
sentryClient = SentryClientFactory.sentryClient(this.dsn);
|
||||
context = sentryClient.getContext();
|
||||
Util.debugLog("Setting basic report data...");
|
||||
JSONObject serverData = Util.getServerData();
|
||||
JSONObject serverData = plugin.getMetrics().getPluginData();
|
||||
//context.addTag("plugin_version", QuickShop.getVersion());
|
||||
context.addTag("system_os", String.valueOf(serverData.get("osName")));
|
||||
context.addTag("system_arch", String.valueOf(serverData.get("osArch")));
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.maxgamer.quickshop.Util;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.*;
|
||||
@@ -26,7 +25,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.maxgamer.quickshop.Database.MySQLCore;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.DisplayItem;
|
||||
@@ -253,53 +251,6 @@ public class Util {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server specific data.
|
||||
*
|
||||
* @return The server specific data.
|
||||
* author by bStats
|
||||
*/
|
||||
public static JSONObject getServerData() {
|
||||
// Minecraft specific data
|
||||
int playerAmount;
|
||||
try {
|
||||
// Around MC 1.8 the return type was changed to a collection from an array,
|
||||
// This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
|
||||
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
|
||||
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
|
||||
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
|
||||
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
|
||||
} catch (Exception e) {
|
||||
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
|
||||
}
|
||||
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
||||
String bukkitVersion = org.bukkit.Bukkit.getVersion();
|
||||
bukkitVersion = bukkitVersion.substring(bukkitVersion.indexOf("MC: ") + 4, bukkitVersion.length() - 1);
|
||||
|
||||
// OS/Java specific data
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
String osName = System.getProperty("os.name");
|
||||
String osArch = System.getProperty("os.arch");
|
||||
String osVersion = System.getProperty("os.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
|
||||
data.put("serverUUID", plugin.getServerUniqueID());
|
||||
|
||||
data.put("playerAmount", playerAmount);
|
||||
data.put("onlineMode", onlineMode);
|
||||
data.put("bukkitVersion", bukkitVersion);
|
||||
|
||||
data.put("javaVersion", javaVersion);
|
||||
data.put("osName", osName);
|
||||
data.put("osArch", osArch);
|
||||
data.put("osVersion", osVersion);
|
||||
data.put("coreCount", coreCount);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chest attached to the given chest. The given block must be a
|
||||
* chest.
|
||||
|
||||
Reference in new issue
Block a user