Fix bungeecord dump logs after 9fb5090

This commit is contained in:
rtm516 2021-08-25 11:31:12 +01:00
parent 9fb509010a
commit 65e85eb853
No known key found for this signature in database
GPG key ID: 331715B8B007C67A
3 changed files with 20 additions and 10 deletions

View file

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

View file

@ -52,6 +52,7 @@ import java.net.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
@Getter
public class DumpInfo {
@ -201,7 +202,7 @@ public class DumpInfo {
public LogsInfo() {
try {
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));

View file

@ -35,10 +35,12 @@ import java.io.*;
import java.lang.annotation.Annotation;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.MessageDigest;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class FileUtils {
@ -220,7 +222,21 @@ public class FileUtils {
}
return bytes;
} 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);
}
}