mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 17:15:47 +00:00
ability to upload log.txt file
This commit is contained in:
parent
c96691325b
commit
06453db90c
@ -70,6 +70,7 @@ public class BetterRTP extends JavaPlugin {
|
||||
public void onDisable() {
|
||||
invs.closeAll();
|
||||
queue.unload();
|
||||
rtpLogger.unload();
|
||||
/*if (this.adventure != null) {
|
||||
this.adventure.close();
|
||||
this.adventure = null;
|
||||
|
@ -47,6 +47,11 @@ public class RTPLogger {
|
||||
return format.format(new Date());
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
if (handler != null)
|
||||
handler.close();
|
||||
}
|
||||
|
||||
static class MyFormatter extends Formatter {
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
|
@ -10,6 +10,7 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class LogUploader {
|
||||
|
||||
@ -50,17 +51,6 @@ public class LogUploader {
|
||||
|
||||
@Nullable
|
||||
public static String post(File file) {
|
||||
FileConfiguration config = new YamlConfiguration();
|
||||
try {
|
||||
config.load(file);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
// Convert the config file to a YAML string
|
||||
String requestBody = config.saveToString();
|
||||
|
||||
// Create the connection to the server
|
||||
try {
|
||||
URL url = new URL(UPLOAD_URL);
|
||||
@ -70,9 +60,13 @@ public class LogUploader {
|
||||
connection.setDoOutput(true);
|
||||
|
||||
try (OutputStream outputStream = connection.getOutputStream()) {
|
||||
byte[] input = requestBody.getBytes(StandardCharsets.UTF_8);
|
||||
Scanner scan = new Scanner(file);
|
||||
while(scan.hasNextLine()){
|
||||
String str = scan.nextLine();
|
||||
byte[] input = (str + System.lineSeparator()).getBytes(StandardCharsets.UTF_8);
|
||||
outputStream.write(input, 0, input.length);
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder response = new StringBuilder();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user