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() {
|
public void onDisable() {
|
||||||
invs.closeAll();
|
invs.closeAll();
|
||||||
queue.unload();
|
queue.unload();
|
||||||
|
rtpLogger.unload();
|
||||||
/*if (this.adventure != null) {
|
/*if (this.adventure != null) {
|
||||||
this.adventure.close();
|
this.adventure.close();
|
||||||
this.adventure = null;
|
this.adventure = null;
|
||||||
|
@ -47,6 +47,11 @@ public class RTPLogger {
|
|||||||
return format.format(new Date());
|
return format.format(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unload() {
|
||||||
|
if (handler != null)
|
||||||
|
handler.close();
|
||||||
|
}
|
||||||
|
|
||||||
static class MyFormatter extends Formatter {
|
static class MyFormatter extends Formatter {
|
||||||
@Override
|
@Override
|
||||||
public String format(LogRecord record) {
|
public String format(LogRecord record) {
|
||||||
|
@ -10,6 +10,7 @@ import java.net.HttpURLConnection;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class LogUploader {
|
public class LogUploader {
|
||||||
|
|
||||||
@ -50,17 +51,6 @@ public class LogUploader {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String post(File file) {
|
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
|
// Create the connection to the server
|
||||||
try {
|
try {
|
||||||
URL url = new URL(UPLOAD_URL);
|
URL url = new URL(UPLOAD_URL);
|
||||||
@ -70,8 +60,12 @@ public class LogUploader {
|
|||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
|
|
||||||
try (OutputStream outputStream = connection.getOutputStream()) {
|
try (OutputStream outputStream = connection.getOutputStream()) {
|
||||||
byte[] input = requestBody.getBytes(StandardCharsets.UTF_8);
|
Scanner scan = new Scanner(file);
|
||||||
outputStream.write(input, 0, input.length);
|
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();
|
StringBuilder response = new StringBuilder();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user