diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java index 3bde5e5..da6cbc1 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java @@ -97,8 +97,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter { if (sender.hasPermission("t2code.admin")) { if (hasPermission(p, arg1.get("debug"))) { for (String st : ReportLogStorage.list){ - String[] string = st.split(" - "); - if (passend(st,args[2])) list.add(string[0]); + if (passend(st,args[2])) list.add(st); } } } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Commands.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Commands.java index b9bda7d..9c1bd36 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Commands.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Commands.java @@ -43,7 +43,7 @@ public class Commands { return; } try { - CreateReportLog.delete(args[2]); + CreateReportLog.delete(args[2], sender); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CreateReportLog.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CreateReportLog.java index cca7e31..0410c69 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CreateReportLog.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CreateReportLog.java @@ -155,7 +155,7 @@ public class CreateReportLog { T2Csend.console(Util.getPrefix() + " §6A DebugLog zip has been created. You can download it here: url.\n§6Please enter the following key in the ticket: §e[key].\n§4Do not share the download URL with anyone!\nYou can delte yor Debug-File with the following command: /t2code debug deleteReportLog key.".replace("[key]",fileID).replace("url",downloadURL)); } else T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog zip has been created. You can download it here: url.\n§6Please enter the following key in the ticket: §e[key].\n§4Do not share the download URL with anyone!\nYou can delte yor Debug-File with the following command: /t2code debug deleteReportLog key.".replace("[key]",fileID).replace("url",downloadURL)); - ReportLogStorage.add(fileID +" - "+downloadURL); + ReportLogStorage.add(fileID); } private static void pluginToDebug(String pluginName, ZipOutputStream zip) throws IOException { @@ -222,10 +222,17 @@ public class CreateReportLog { } } - public static void delete(String arg) throws IOException { - URL url = new URL("https://debug.t2code.net/delte/" + arg); + public static void delete(String arg, CommandSender sender) throws IOException { + URL url = new URL("https://debug.t2code.net/delete/" + arg); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("GET"); - ReportLogStorage.remove(arg); + int response = con.getResponseCode(); + if(response == 200){ + ReportLogStorage.remove(arg); + T2Csend.sender(sender,"Deleted report: " + arg); + }else { + T2Csend.sender(sender,"Error while deleting report: " + arg); + } + con.disconnect(); } } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/ReportLogStorage.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/ReportLogStorage.java index b626ef3..f99d53d 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/ReportLogStorage.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/ReportLogStorage.java @@ -2,17 +2,15 @@ package net.t2code.t2codelib.SPIGOT.system.cmd; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import org.bukkit.configuration.file.YamlConfiguration; - import java.io.File; import java.io.IOException; -import java.security.PublicKey; import java.util.ArrayList; import java.util.List; public class ReportLogStorage { public static List list = new ArrayList<>(); - protected static File config = new File("T2CodeReportKeys.yml"); + protected static File config = new File(T2CodeLibMain.getPath(),"T2CodeReportKeys.yml"); protected static YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); public static void add(String key){ @@ -26,7 +24,7 @@ public class ReportLogStorage { } public static void save(){ - if (list.isEmpty()) return; + if (list == null) return; yamlConfiguration.set("Keys",list); try {