mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 17:15:47 +00:00
added logs uploaded for info and queue commands
This commit is contained in:
parent
3f3cbcfddf
commit
bfcfe4985a
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
||||
<groupId>me.SuperRonanCraft</groupId>
|
||||
<artifactId>BetterRTP</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>4.0.0-DEVBUILD</version>
|
||||
<version>3.6.3</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
@ -6,6 +6,7 @@ import me.SuperRonanCraft.BetterRTP.player.commands.Commands;
|
||||
import me.SuperRonanCraft.BetterRTP.player.events.EventListener;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.Permissions;
|
||||
import me.SuperRonanCraft.BetterRTP.references.RTPLogger;
|
||||
import me.SuperRonanCraft.BetterRTP.references.WarningHandler;
|
||||
import me.SuperRonanCraft.BetterRTP.references.database.DatabaseHandler;
|
||||
import me.SuperRonanCraft.BetterRTP.references.depends.DepEconomy;
|
||||
@ -26,6 +27,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class BetterRTP extends JavaPlugin {
|
||||
private final Permissions perms = new Permissions();
|
||||
@ -45,6 +47,7 @@ public class BetterRTP extends JavaPlugin {
|
||||
@Getter private final WarningHandler warningHandler = new WarningHandler();
|
||||
//@Getter private BukkitAudiences adventure;
|
||||
@Getter private boolean PlaceholderAPI;
|
||||
@Getter private final RTPLogger rtpLogger = new RTPLogger();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@ -141,6 +144,7 @@ public class BetterRTP extends JavaPlugin {
|
||||
databaseHandler.load();
|
||||
files.loadAll();
|
||||
settings.load();
|
||||
rtpLogger.setup(this);
|
||||
invs.load();
|
||||
cooldowns.load();
|
||||
rtp.load();
|
||||
@ -152,7 +156,6 @@ public class BetterRTP extends JavaPlugin {
|
||||
}
|
||||
|
||||
public static void debug(String str) {
|
||||
if (getInstance().getSettings().isDebug())
|
||||
getInstance().getLogger().info(str);
|
||||
getInstance().getLogger().info(str);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,9 @@ public enum RTPCommandType {
|
||||
TEST(new CmdTest(), true),
|
||||
VERSION(new CmdVersion()),
|
||||
WORLD(new CmdWorld()),
|
||||
DEV(new CmdDeveloper(), true);
|
||||
DEV(new CmdDeveloper(), true),
|
||||
LOGGER(new CmdLogger(), true),
|
||||
;
|
||||
|
||||
private final RTPCommand cmd;
|
||||
private boolean debugOnly = false;
|
||||
|
@ -1,28 +1,42 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTP_SETUP_TYPE;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.effects.RTPEffect_Particles;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.effects.RTPEffect_Particles;
|
||||
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.messages.Message;
|
||||
import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueHandler;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldDefault;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||
import me.SuperRonanCraft.BetterRTP.references.web.LogUploader;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import scala.concurrent.impl.FutureConvertersImpl;
|
||||
import xyz.xenondevs.particle.ParticleEffect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class CmdInfo implements RTPCommand, RTPCommandHelpable {
|
||||
|
||||
@ -39,14 +53,26 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
|
||||
else if (args[1].equalsIgnoreCase(CmdInfoSub.POTION_EFFECTS.name()))
|
||||
infoEffects(sendi);
|
||||
else if (args[1].equalsIgnoreCase(CmdInfoSub.WORLD.name())) {
|
||||
if (args.length > 2 && Bukkit.getWorld(args[2]) != null) {
|
||||
sendInfoWorld(sendi, infoGetWorld(sendi, Bukkit.getWorld(args[2]), null, null));
|
||||
} else if (sendi instanceof Player) { //Personalize with permission groups
|
||||
Player player = (Player) sendi;
|
||||
World world = player.getWorld();
|
||||
sendInfoWorld(sendi, infoGetWorld(sendi, world, player, null));
|
||||
} else
|
||||
infoWorld(sendi);
|
||||
World world = null;
|
||||
Player player = null;
|
||||
if (args.length > 2) {
|
||||
world = Bukkit.getWorld(args[2]);
|
||||
if (world == null) {
|
||||
MessagesCore.DISABLED_WORLD.send(sendi, args[2]);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
MessagesCore.DISABLED_WORLD.send(sendi, "NULL");
|
||||
return;
|
||||
}
|
||||
if (args.length > 3) {
|
||||
player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
MessagesCore.NOTONLINE.send(sendi, args[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
sendInfoWorld(sendi, infoGetWorld(sendi, world, player, null), label, args);
|
||||
} else if (args[1].equalsIgnoreCase(CmdInfoSub.PLAYER.name())) {
|
||||
World world = null;
|
||||
Player player = null;
|
||||
@ -61,10 +87,10 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
|
||||
}
|
||||
if (world == null)
|
||||
world = player.getWorld();
|
||||
sendInfoWorld(sendi, infoGetWorld(sendi, world, player, null));
|
||||
sendInfoWorld(sendi, infoGetWorld(sendi, world, player, null), label, args);
|
||||
}
|
||||
} else
|
||||
infoWorld(sendi);
|
||||
infoWorld(sendi, label, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,18 +136,46 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
|
||||
}
|
||||
|
||||
//World
|
||||
public static void sendInfoWorld(CommandSender sendi, List<String> list) { //Send info
|
||||
public static void sendInfoWorld(CommandSender sendi, List<String> list, String label, String[] args) { //Send info
|
||||
boolean upload = Arrays.asList(args).contains("_UPLOAD_");
|
||||
list.add(0, "&e&m-----&6 BetterRTP &8| Info &e&m-----");
|
||||
list.forEach(str ->
|
||||
list.set(list.indexOf(str), Message.color(str)));
|
||||
sendi.sendMessage(list.toArray(new String[0]));
|
||||
list.forEach(str -> list.set(list.indexOf(str), Message.color(str)));
|
||||
|
||||
String cmd = "/" + label + " " + String.join(" ", args);
|
||||
if (!upload) {
|
||||
sendi.sendMessage(list.toArray(new String[0]));
|
||||
if (sendi instanceof Player) {
|
||||
TextComponent component = new TextComponent(Message.color("&7- &7Click to upload command log to &flogs.ronanplugins.com"));
|
||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd + " _UPLOAD_"));
|
||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.color("&6Suggested command&f: &7" + "/betterrtp " + String.join(" ", args) + " _UPLOAD_")).create()));
|
||||
((Player) sendi).spigot().sendMessage(component);
|
||||
} else {
|
||||
sendi.sendMessage("Execute `" + cmd + " _UPLOAD_`" + " to upload command log to https://logs.ronanplugins.com");
|
||||
}
|
||||
} else {
|
||||
list.add(0, "Command: " + cmd);
|
||||
list.forEach(str -> list.set(list.indexOf(str), ChatColor.stripColor(str)));
|
||||
CompletableFuture.runAsync(() -> {
|
||||
String key = LogUploader.post(list);
|
||||
if (key == null) {
|
||||
Message.sms(sendi, new ArrayList<>(Collections.singletonList("&cAn error occured attempting to upload log!")), null);
|
||||
} else {
|
||||
try {
|
||||
JSONObject json = (JSONObject) new JSONParser().parse(key);
|
||||
Message.sms(sendi, Arrays.asList(" ", Message.getPrefix(Message_RTP.msg) + "&aLog uploaded! &fView&7: &6https://logs.ronanplugins.com/" + json.get("key")), null);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void infoWorld(CommandSender sendi) { //All worlds
|
||||
private void infoWorld(CommandSender sendi, String label, String[] args) { //All worlds
|
||||
List<String> info = new ArrayList<>();
|
||||
for (World w : Bukkit.getWorlds())
|
||||
info.addAll(infoGetWorld(sendi, w, null, null));
|
||||
sendInfoWorld(sendi, info);
|
||||
sendInfoWorld(sendi, info, label, args);
|
||||
}
|
||||
|
||||
public static List<String> infoGetWorld(CommandSender sendi, World world, Player player, WorldPlayer _rtpworld) { //Specific world
|
||||
@ -212,13 +266,21 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
|
||||
info.add(cmd.name().toLowerCase());
|
||||
} else if (args.length == 3) {
|
||||
if (CmdInfoSub.WORLD.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
for (World world : Bukkit.getWorlds())
|
||||
if (world.getName().toLowerCase().startsWith(args[2].toLowerCase()))
|
||||
info.add(world.getName());
|
||||
} else if (CmdInfoSub.PLAYER.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (p.getName().toLowerCase().startsWith(args[2].toLowerCase()))
|
||||
info.add(p.getName());
|
||||
}
|
||||
for (World world : Bukkit.getWorlds())
|
||||
if (world.getName().toLowerCase().startsWith(args[2].toLowerCase()))
|
||||
info.add(world.getName());
|
||||
}
|
||||
} else if (args.length == 4) {
|
||||
if (CmdInfoSub.WORLD.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (p.getName().toLowerCase().startsWith(args[3].toLowerCase()))
|
||||
info.add(p.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return info;
|
||||
|
@ -0,0 +1,38 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandType;
|
||||
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP_Info;
|
||||
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesUsage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CmdLogger implements RTPCommand {
|
||||
|
||||
public String getName() {
|
||||
return "logger";
|
||||
}
|
||||
public void execute(CommandSender sendi, String label, String[] args) {
|
||||
|
||||
}
|
||||
|
||||
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean permission(CommandSender sendi) {
|
||||
return PermissionNode.ADMIN.check(sendi);
|
||||
}
|
||||
|
||||
public void usage(CommandSender sendi, String label) {
|
||||
}
|
||||
}
|
@ -7,17 +7,30 @@ import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||
import me.SuperRonanCraft.BetterRTP.references.database.DatabaseHandler;
|
||||
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.messages.Message;
|
||||
import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueData;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueHandler;
|
||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||
import me.SuperRonanCraft.BetterRTP.references.web.LogUploader;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class CmdQueue implements RTPCommand {
|
||||
|
||||
@ -31,21 +44,48 @@ public class CmdQueue implements RTPCommand {
|
||||
World world = args.length > 1 ? Bukkit.getWorld(args[1]) : null;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(BetterRTP.getInstance(), () -> {
|
||||
if (world != null) {
|
||||
sendInfo(sendi, queueGetWorld(p, world));
|
||||
sendInfo(sendi, queueGetWorld(p, world), label, args);
|
||||
} else
|
||||
queueWorlds(p);
|
||||
queueWorlds(p, label, args);
|
||||
});
|
||||
}
|
||||
|
||||
//World
|
||||
public static void sendInfo(CommandSender sendi, List<String> list) { //Send info
|
||||
public static void sendInfo(CommandSender sendi, List<String> list, String label, String[] args) { //Send info
|
||||
boolean upload = Arrays.asList(args).contains("_UPLOAD_");
|
||||
list.add(0, "&e&m-----&6 BetterRTP &8| Queue &e&m-----");
|
||||
list.forEach(str ->
|
||||
list.set(list.indexOf(str), Message.color(str)));
|
||||
sendi.sendMessage(list.toArray(new String[0]));
|
||||
list.forEach(str -> list.set(list.indexOf(str), Message.color(str)));
|
||||
String cmd = "/" + label + " " + String.join(" ", args);
|
||||
if (!upload) {
|
||||
sendi.sendMessage(list.toArray(new String[0]));
|
||||
if (sendi instanceof Player) {
|
||||
TextComponent component = new TextComponent(Message.color("&7- &7Click to upload command log to &flogs.ronanplugins.com"));
|
||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd + " _UPLOAD_"));
|
||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.color("&6Suggested command&f: &7" + "/betterrtp " + String.join(" ", args) + " _UPLOAD_")).create()));
|
||||
((Player) sendi).spigot().sendMessage(component);
|
||||
} else {
|
||||
sendi.sendMessage("Execute `" + cmd + " _UPLOAD_`" + " to upload command log to https://logs.ronanplugins.com");
|
||||
}
|
||||
} else {
|
||||
list.add(0, "Command: " + cmd);
|
||||
list.forEach(str -> list.set(list.indexOf(str), ChatColor.stripColor(str)));
|
||||
CompletableFuture.runAsync(() -> {
|
||||
String key = LogUploader.post(list);
|
||||
if (key == null) {
|
||||
Message.sms(sendi, new ArrayList<>(Collections.singletonList("&cAn error occured attempting to upload log!")), null);
|
||||
} else {
|
||||
try {
|
||||
JSONObject json = (JSONObject) new JSONParser().parse(key);
|
||||
Message.sms(sendi, Arrays.asList(" ", Message.getPrefix(Message_RTP.msg) + "&aLog uploaded! &fView&7: &6https://logs.ronanplugins.com/" + json.get("key")), null);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void queueWorlds(Player p) { //All worlds
|
||||
private void queueWorlds(Player p, String label, String[] args) { //All worlds
|
||||
List<String> info = new ArrayList<>();
|
||||
int locs = 0;
|
||||
for (World w : Bukkit.getWorlds()) {
|
||||
@ -54,7 +94,7 @@ public class CmdQueue implements RTPCommand {
|
||||
locs += list.size();
|
||||
}
|
||||
info.add("&eTotal of &a%amount% &egenerated locations".replace("%amount%", String.valueOf(locs)));
|
||||
sendInfo(p, info);
|
||||
sendInfo(p, info, label, args);
|
||||
}
|
||||
|
||||
private static List<String> queueGetWorld(Player player, World world) { //Specific world
|
||||
|
@ -55,7 +55,7 @@ public class RTPEffect_Particles {
|
||||
effects.add(ParticleEffect.ASH);
|
||||
getPl().getLogger().severe("The particle '" + typeTrying + "' doesn't exist! Default particle enabled... " +
|
||||
"Try using '/rtp info particles' to get a list of available particles");
|
||||
} catch (ExceptionInInitializerError e2) {
|
||||
} catch (ExceptionInInitializerError | NoClassDefFoundError e2) {
|
||||
effects.clear();
|
||||
getPl().getLogger().severe("The particle '" + typeTrying + "' created a fatal error when loading particles! Your MC version isn't supported!");
|
||||
enabled = false;
|
||||
@ -63,7 +63,7 @@ public class RTPEffect_Particles {
|
||||
shape = config.getString("Particles.Shape").toUpperCase();
|
||||
if (!Arrays.asList(shapeTypes).contains(shape)) {
|
||||
getPl().getLogger().severe("The particle shape '" + shape + "' doesn't exist! Default particle shape enabled...");
|
||||
getPl().getLogger().severe("Try using '/rtp info shapes' to get a list of shapes, or: " + Arrays.asList(shapeTypes).toString());
|
||||
getPl().getLogger().severe("Try using '/rtp info shapes' to get a list of shapes, or: " + Arrays.asList(shapeTypes));
|
||||
shape = shapeTypes[0];
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.*;
|
||||
|
||||
public class RTPLogger {
|
||||
|
||||
static Handler fileHandler = null;
|
||||
private Logger LOGGER;
|
||||
|
||||
public void setup(BetterRTP plugin) {
|
||||
this.LOGGER = plugin.getLogger();
|
||||
if (plugin.getSettings().isDebug())
|
||||
LOGGER.setLevel(Level.ALL);
|
||||
else
|
||||
LOGGER.setLevel(Level.WARNING);
|
||||
try {
|
||||
fileHandler = new FileHandler(plugin.getDataFolder().getAbsoluteFile() + File.separator + "data.log");
|
||||
SimpleFormatter simple = new SimpleFormatter();
|
||||
fileHandler.setFormatter(simple);
|
||||
LOGGER.addHandler(fileHandler);//adding Handler for file
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.web;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -10,39 +11,46 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class LogUploader {
|
||||
|
||||
private static final String UPLOAD_URL = "https://logs.ronanplugins.com/documents";
|
||||
public static final String KEY_URL = "https://logs.ronanplugins.com/";
|
||||
|
||||
public static void main(String[] requestBody) throws IOException {
|
||||
URL url = new URL(UPLOAD_URL);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "text/plain");
|
||||
connection.setDoOutput(true);
|
||||
public static String post(List<String> requestBody) {
|
||||
try {
|
||||
URL url = new URL(UPLOAD_URL);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "text/plain");
|
||||
connection.setDoOutput(true);
|
||||
|
||||
//String requestBody = "This is the raw body of text.";
|
||||
//String requestBody = "This is the raw body of text.";
|
||||
|
||||
try (OutputStream outputStream = connection.getOutputStream()) {
|
||||
for (String str : requestBody) {
|
||||
byte[] input = str.getBytes(StandardCharsets.UTF_8);
|
||||
outputStream.write(input, 0, input.length);
|
||||
try (OutputStream outputStream = connection.getOutputStream()) {
|
||||
for (String str : requestBody) {
|
||||
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()))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
response.append(line);
|
||||
StringBuilder response = new StringBuilder();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
response.append(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(response);
|
||||
return response.toString();
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendConfigAsPostRequest() throws IOException {
|
||||
FileConfiguration config = getConfig();
|
||||
public static String sendConfigAsPostRequest(FileOther.FILETYPE file) throws IOException {
|
||||
FileConfiguration config = file.getConfig();
|
||||
|
||||
// Convert the config file to a YAML string
|
||||
String requestBody = config.saveToString();
|
||||
@ -67,6 +75,7 @@ public class LogUploader {
|
||||
}
|
||||
}
|
||||
|
||||
return response.toString();
|
||||
//getLogger().log(Level.INFO, "Response: " + response.toString());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user