Init
This commit is contained in:
parent
3bdbaacd64
commit
eb466f0df1
7
pom.xml
7
pom.xml
@ -160,5 +160,12 @@
|
||||
<artifactId>json</artifactId>
|
||||
<version>20220924</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<version>4.3.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -24,7 +25,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
return false;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
T2Ctemplate.sendInfo(sender,T2CodeLibMain.getPlugin(), Util.getSpigotID(),Util.getDiscord(),null, Util.getInfoText());
|
||||
T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText());
|
||||
return false;
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
@ -33,19 +34,39 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
case "pl":
|
||||
case "version":
|
||||
case "ver":
|
||||
T2Ctemplate.sendInfo(sender,T2CodeLibMain.getPlugin(), Util.getSpigotID(),Util.getDiscord(),null, Util.getInfoText());
|
||||
T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText());
|
||||
return false;
|
||||
case "reloadconfig":
|
||||
SelectLibConfig.onSelect();
|
||||
return false;
|
||||
case "debug":
|
||||
if (args.length != 2) {
|
||||
if (args.length < 2) {
|
||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
||||
return false;
|
||||
}
|
||||
if ("createreportlog".equals(args[1].toLowerCase())) {
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "createreportlog":
|
||||
try {
|
||||
CreateReportLog.create(sender);
|
||||
} else T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
break;
|
||||
case "deleteReportLog":
|
||||
if(args.length != 3){
|
||||
T2Csend.sender(sender, "§4Use: §7/t2code debug deleteReportLog [id]");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
CreateReportLog.delete(args[2]);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog/deleteReportLog");
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
||||
default:
|
||||
|
@ -5,13 +5,23 @@ import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.mime.MultipartEntity;
|
||||
import org.apache.http.entity.mime.content.FileBody;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
@ -19,7 +29,7 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class CreateReportLog {
|
||||
protected static void create(CommandSender sender) {
|
||||
protected static void create(CommandSender sender) throws IOException {
|
||||
T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog is created...");
|
||||
String timeStampFile = new SimpleDateFormat("HH_mm_ss-dd_MM_yyyy").format(Calendar.getInstance().getTime());
|
||||
|
||||
@ -113,10 +123,26 @@ public class CreateReportLog {
|
||||
e.printStackTrace();
|
||||
}
|
||||
file.delete();
|
||||
HttpClient httpclient = new DefaultHttpClient();
|
||||
HttpPost httppost = new HttpPost("https://debug.t2code.net/uploadFile");
|
||||
File zipFile = new File(zipPath);
|
||||
FileBody bin = new FileBody(zipFile);
|
||||
MultipartEntity reqEntity = new MultipartEntity();
|
||||
reqEntity.addPart("file", bin);
|
||||
httppost.setEntity(reqEntity);
|
||||
HttpResponse response = httpclient.execute(httppost);
|
||||
HttpEntity resEntity = response.getEntity();
|
||||
String responseString = EntityUtils.toString(resEntity, "UTF-8");
|
||||
JSONObject obj = new JSONObject(responseString);
|
||||
String downloadURL = obj.getString("fileDownloadUri");
|
||||
String fileID = obj.getString("fileID");
|
||||
String fileType = obj.getString("fileType");
|
||||
Integer fileSize = obj.getInt("size");
|
||||
zipFile.delete();
|
||||
if (sender instanceof Player) {
|
||||
T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + zipPath);
|
||||
T2Csend.console(Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + zipPath);
|
||||
} else T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + zipPath);
|
||||
T2Csend.sender(sender, Util.getPrefix() + "<green>A DebugLog zip has been created. You can download it <click:open_url:'url'><gold>here</gold></click>. Please enter the following key in the ticket: <gold>key</gold></green><br><dark_red>Do not share the download URL with anyone!</dark_red><br><click:run_command:'/t2code debug deleteReportLog key'><green>You can <b>delte </b>yor Debug-File by clicking me.</green></click>".replace("key",fileID).replace("url",downloadURL));
|
||||
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: §ekey.\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: §ekey.\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));
|
||||
|
||||
}
|
||||
|
||||
@ -183,4 +209,10 @@ public class CreateReportLog {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void delete(String arg) throws IOException {
|
||||
URL url = new URL("https://debug.t2code.net/delte/" + arg);
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user