3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 06:50:09 +01:00

Fix bungeecord dump logs after 9fb5090

Dieser Commit ist enthalten in:
rtm516 2021-08-25 11:31:12 +01:00
Ursprung 9fb509010a
Commit 65e85eb853
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 331715B8B007C67A
3 geänderte Dateien mit 20 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -174,14 +174,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
@Override @Override
public Path getLogsPath() { public Path getLogsPath() {
boolean isBungeeCord = getProxy().getName().equals("BungeeCord"); return Paths.get(getProxy().getName().equals("BungeeCord") ? "proxy.log.0" : "logs/latest.log");
Path getFork;
if (isBungeeCord) {
getFork = Paths.get("proxy.log.0");
} else {
getFork = Paths.get("logs/latest.log");
}
return getFork;
} }
@Nullable @Nullable

Datei anzeigen

@ -52,6 +52,7 @@ import java.net.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.stream.Collectors;
@Getter @Getter
public class DumpInfo { public class DumpInfo {
@ -201,7 +202,7 @@ public class DumpInfo {
public LogsInfo() { public LogsInfo() {
try { try {
Map<String, String> fields = new HashMap<>(); Map<String, String> fields = new HashMap<>();
fields.put("content", String.join("\n", java.nio.file.Files.readAllLines(GeyserConnector.getInstance().getBootstrap().getLogsPath()))); fields.put("content", FileUtils.readAllLines(GeyserConnector.getInstance().getBootstrap().getLogsPath()).collect(Collectors.joining("\n")));
JsonNode logData = GeyserConnector.JSON_MAPPER.readTree(WebUtils.postForm("https://api.mclo.gs/1/log", fields)); JsonNode logData = GeyserConnector.JSON_MAPPER.readTree(WebUtils.postForm("https://api.mclo.gs/1/log", fields));

Datei anzeigen

@ -35,10 +35,12 @@ import java.io.*;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
public class FileUtils { public class FileUtils {
@ -220,7 +222,21 @@ public class FileUtils {
} }
return bytes; return bytes;
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("Error while trying to read input stream!"); throw new RuntimeException("Error while trying to read input stream!", e);
}
}
/**
* Read the lines of a file and return it as a stream
*
* @param path File path to read
* @return The lines as a stream
*/
public static Stream<String> readAllLines(Path path) {
try {
return new BufferedReader(new InputStreamReader(java.nio.file.Files.newInputStream(path))).lines();
} catch (IOException e) {
throw new RuntimeException("Error while trying to read file!", e);
} }
} }