Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-16 04:50:07 +01:00
Allow dumps to be created even if GeyserServer failed to start (#4930)
Dieser Commit ist enthalten in:
Ursprung
3d7e62a408
Commit
61ae5debd4
@ -113,13 +113,15 @@ public class DumpCommand extends GeyserCommand {
|
|||||||
source.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.dump.collecting", source.locale()));
|
source.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.dump.collecting", source.locale()));
|
||||||
String dumpData;
|
String dumpData;
|
||||||
try {
|
try {
|
||||||
|
DumpInfo dump = new DumpInfo(geyser, addLog);
|
||||||
|
|
||||||
if (offlineDump) {
|
if (offlineDump) {
|
||||||
DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
|
DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
|
||||||
// Make arrays easier to read
|
// Make arrays easier to read
|
||||||
prettyPrinter.indentArraysWith(new DefaultIndenter(" ", "\n"));
|
prettyPrinter.indentArraysWith(new DefaultIndenter(" ", "\n"));
|
||||||
dumpData = MAPPER.writer(prettyPrinter).writeValueAsString(new DumpInfo(addLog));
|
dumpData = MAPPER.writer(prettyPrinter).writeValueAsString(dump);
|
||||||
} else {
|
} else {
|
||||||
dumpData = MAPPER.writeValueAsString(new DumpInfo(addLog));
|
dumpData = MAPPER.writeValueAsString(dump);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
source.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.commands.dump.collect_error", source.locale()));
|
source.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.commands.dump.collect_error", source.locale()));
|
||||||
|
@ -81,7 +81,7 @@ public class DumpInfo {
|
|||||||
private final FlagsInfo flagsInfo;
|
private final FlagsInfo flagsInfo;
|
||||||
private final List<ExtensionInfo> extensionInfo;
|
private final List<ExtensionInfo> extensionInfo;
|
||||||
|
|
||||||
public DumpInfo(boolean addLog) {
|
public DumpInfo(GeyserImpl geyser, boolean addLog) {
|
||||||
this.versionInfo = new VersionInfo();
|
this.versionInfo = new VersionInfo();
|
||||||
|
|
||||||
this.cpuCount = Runtime.getRuntime().availableProcessors();
|
this.cpuCount = Runtime.getRuntime().availableProcessors();
|
||||||
@ -91,7 +91,7 @@ public class DumpInfo {
|
|||||||
|
|
||||||
this.gitInfo = new GitInfo(GeyserImpl.BUILD_NUMBER, GeyserImpl.COMMIT.substring(0, 7), GeyserImpl.COMMIT, GeyserImpl.BRANCH, GeyserImpl.REPOSITORY);
|
this.gitInfo = new GitInfo(GeyserImpl.BUILD_NUMBER, GeyserImpl.COMMIT.substring(0, 7), GeyserImpl.COMMIT, GeyserImpl.BRANCH, GeyserImpl.REPOSITORY);
|
||||||
|
|
||||||
this.config = GeyserImpl.getInstance().getConfig();
|
this.config = geyser.getConfig();
|
||||||
this.floodgate = new Floodgate();
|
this.floodgate = new Floodgate();
|
||||||
|
|
||||||
String md5Hash = "unknown";
|
String md5Hash = "unknown";
|
||||||
@ -107,7 +107,7 @@ public class DumpInfo {
|
|||||||
//noinspection UnstableApiUsage
|
//noinspection UnstableApiUsage
|
||||||
sha256Hash = byteSource.hash(Hashing.sha256()).toString();
|
sha256Hash = byteSource.hash(Hashing.sha256()).toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (GeyserImpl.getInstance().getConfig().isDebugMode()) {
|
if (this.config.isDebugMode()) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,18 +116,22 @@ public class DumpInfo {
|
|||||||
this.ramInfo = new RamInfo();
|
this.ramInfo = new RamInfo();
|
||||||
|
|
||||||
if (addLog) {
|
if (addLog) {
|
||||||
this.logsInfo = new LogsInfo();
|
this.logsInfo = new LogsInfo(geyser);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.userPlatforms = new Object2IntOpenHashMap<>();
|
this.userPlatforms = new Object2IntOpenHashMap<>();
|
||||||
for (GeyserSession session : GeyserImpl.getInstance().getSessionManager().getAllSessions()) {
|
for (GeyserSession session : geyser.getSessionManager().getAllSessions()) {
|
||||||
DeviceOs device = session.getClientData().getDeviceOs();
|
DeviceOs device = session.getClientData().getDeviceOs();
|
||||||
userPlatforms.put(device, userPlatforms.getOrDefault(device, 0) + 1);
|
userPlatforms.put(device, userPlatforms.getOrDefault(device, 0) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.connectionAttempts = GeyserImpl.getInstance().getGeyserServer().getConnectionAttempts();
|
if (geyser.getGeyserServer() != null) {
|
||||||
|
this.connectionAttempts = geyser.getGeyserServer().getConnectionAttempts();
|
||||||
|
} else {
|
||||||
|
this.connectionAttempts = 0; // Fallback if Geyser failed to fully startup
|
||||||
|
}
|
||||||
|
|
||||||
this.bootstrapInfo = GeyserImpl.getInstance().getBootstrap().getDumpInfo();
|
this.bootstrapInfo = geyser.getBootstrap().getDumpInfo();
|
||||||
|
|
||||||
this.flagsInfo = new FlagsInfo();
|
this.flagsInfo = new FlagsInfo();
|
||||||
|
|
||||||
@ -244,10 +248,10 @@ public class DumpInfo {
|
|||||||
public static class LogsInfo {
|
public static class LogsInfo {
|
||||||
private String link;
|
private String link;
|
||||||
|
|
||||||
public LogsInfo() {
|
public LogsInfo(GeyserImpl geyser) {
|
||||||
try {
|
try {
|
||||||
Map<String, String> fields = new HashMap<>();
|
Map<String, String> fields = new HashMap<>();
|
||||||
fields.put("content", FileUtils.readAllLines(GeyserImpl.getInstance().getBootstrap().getLogsPath()).collect(Collectors.joining("\n")));
|
fields.put("content", FileUtils.readAllLines(geyser.getBootstrap().getLogsPath()).collect(Collectors.joining("\n")));
|
||||||
|
|
||||||
JsonNode logData = GeyserImpl.JSON_MAPPER.readTree(WebUtils.postForm("https://api.mclo.gs/1/log", fields));
|
JsonNode logData = GeyserImpl.JSON_MAPPER.readTree(WebUtils.postForm("https://api.mclo.gs/1/log", fields));
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren