Merge branch '13.4'
This commit is contained in:
@@ -10,12 +10,15 @@ import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.system.bstats.Metrics;
|
||||
import net.t2code.t2codelib.SPIGOT.system.cmd.CmdExecuter;
|
||||
import net.t2code.t2codelib.SPIGOT.system.cmd.ReportLogStorage;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.ConfigCreate;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.LanguagesCreate;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@@ -30,7 +33,7 @@ public final class T2CodeLibMain extends JavaPlugin {
|
||||
private static List<String> autor;
|
||||
private static String version;
|
||||
|
||||
private static Boolean nmIsLoad = true;
|
||||
private static Boolean mmIsLoad = true;
|
||||
private static Boolean load = false;
|
||||
|
||||
@Override
|
||||
@@ -39,7 +42,11 @@ public final class T2CodeLibMain extends JavaPlugin {
|
||||
plugin = this;
|
||||
autor = plugin.getDescription().getAuthors();
|
||||
version = plugin.getDescription().getVersion();
|
||||
this.adventure = BukkitAudiences.create(this);
|
||||
try {
|
||||
adventure = BukkitAudiences.create(this);
|
||||
} catch (Exception e) {
|
||||
mmIsLoad = false;
|
||||
}
|
||||
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
String prefix = Util.getPrefix();
|
||||
|
||||
@@ -56,10 +63,12 @@ public final class T2CodeLibMain extends JavaPlugin {
|
||||
T2Csend.warning(plugin, "The 1.20.* is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net");
|
||||
T2Csend.console(prefix);
|
||||
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
if (!SelectLibConfig.getT2cTestDevelopment()) {
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
T2Csend.console(prefix + " §3Server run on: §6" + T2CmcVersion.getMcVersion() + " / " + T2CmcVersion.getNms());
|
||||
@@ -90,13 +99,16 @@ public final class T2CodeLibMain extends JavaPlugin {
|
||||
SelectLibConfig.onSelect();
|
||||
SelectLibMsg.onSelect();
|
||||
|
||||
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getSpigotID(), Util.getDiscord());
|
||||
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord(), SelectLibConfig.getUpdateCheckOnJoin(), SelectLibConfig.getSeePreReleaseUpdates(),
|
||||
SelectLibConfig.getUpdateCheckTimeInterval());
|
||||
Metrics.Bstats(plugin, Util.getBstatsID());
|
||||
if (SelectLibConfig.getBungee()){
|
||||
if (SelectLibConfig.getBungee()) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
|
||||
}
|
||||
|
||||
ReportLogStorage.load();
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
|
||||
checkIsBungee();
|
||||
T2Ctemplate.onLoadFooter(prefix, long_);
|
||||
load = true;
|
||||
}
|
||||
@@ -105,6 +117,7 @@ public final class T2CodeLibMain extends JavaPlugin {
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
if (!load) return;
|
||||
ReportLogStorage.save();
|
||||
if (SelectLibConfig.getInventoriesCloseByServerStop()) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.closeInventory();
|
||||
@@ -113,7 +126,7 @@ public final class T2CodeLibMain extends JavaPlugin {
|
||||
|
||||
Vault.vaultDisable();
|
||||
T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
if (nmIsLoad) {
|
||||
if (mmIsLoad) {
|
||||
if (this.adventure != null) {
|
||||
this.adventure.close();
|
||||
this.adventure = null;
|
||||
@@ -155,14 +168,27 @@ public final class T2CodeLibMain extends JavaPlugin {
|
||||
|
||||
private static BukkitAudiences adventure;
|
||||
|
||||
public static BukkitAudiences adventure() {
|
||||
public BukkitAudiences getAdventure() {
|
||||
if (adventure == null) {
|
||||
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
|
||||
}
|
||||
return adventure;
|
||||
}
|
||||
|
||||
public static Boolean getNmIsLoad() {
|
||||
return nmIsLoad;
|
||||
private static void checkIsBungee() {
|
||||
File config = new File("spigot.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
isBungee = yamlConfiguration.getBoolean("settings.bungeecord");
|
||||
}
|
||||
|
||||
private static Boolean isBungee;
|
||||
|
||||
public static Boolean getIsBungee() {
|
||||
return isBungee;
|
||||
}
|
||||
|
||||
public static Boolean getMmIsLoad() {
|
||||
return mmIsLoad;
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,9 @@
|
||||
package net.t2code.t2codelib.SPIGOT.system;
|
||||
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.system.CreateReportLog;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import net.t2code.t2codelib.T2CupdateObject;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -15,6 +13,7 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
|
||||
@@ -25,7 +24,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());
|
||||
Commands.info(sender);
|
||||
return false;
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
@@ -34,24 +33,16 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
case "pl":
|
||||
case "version":
|
||||
case "ver":
|
||||
T2Ctemplate.sendInfo(sender,T2CodeLibMain.getPlugin(), Util.getSpigotID(),Util.getDiscord(),null, Util.getInfoText());
|
||||
Commands.info(sender);
|
||||
return false;
|
||||
case "updateinfo":
|
||||
Commands.updateInfo(sender,args);
|
||||
return false;
|
||||
case "reloadconfig":
|
||||
SelectLibConfig.onSelect();
|
||||
return false;
|
||||
case "debug":
|
||||
if (args.length != 2) {
|
||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
||||
return false;
|
||||
}
|
||||
if ("createreportlog".equals(args[1].toLowerCase())) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CreateReportLog.create(sender);
|
||||
}
|
||||
});
|
||||
} else T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
||||
Commands.debug(sender,args);
|
||||
return false;
|
||||
|
||||
default:
|
||||
@@ -65,6 +56,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
put("debug", "t2code.admin");
|
||||
put("info", "t2code.admin");
|
||||
put("reloadconfig", "t2code.admin");
|
||||
put("updateinfo", "t2code.admin");
|
||||
}};
|
||||
|
||||
@Override
|
||||
@@ -82,8 +74,31 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
|
||||
if (args.length == 2 && args[0].equalsIgnoreCase("debug")) {
|
||||
if (sender.hasPermission("t2code.admin")) {
|
||||
if (hasPermission(p, arg1.get("debug")) && passend("debug", args[1])) {
|
||||
list.add("createReportLog");
|
||||
if (hasPermission(p, arg1.get("debug"))) {
|
||||
if (passend("createReportLog",args[1])) list.add("createReportLog");
|
||||
if (passend("deleteReportLog",args[1])) list.add("deleteReportLog");
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
if (args.length == 2 && args[0].equalsIgnoreCase("updateinfo")) {
|
||||
if (sender.hasPermission("t2code.admin")) {
|
||||
if (hasPermission(p, arg1.get("updateinfo"))) {
|
||||
for (Map.Entry<String, T2CupdateObject> pl : T2CupdateAPI.pluginVersions.entrySet()){
|
||||
if (passend(pl.getValue().pluginName,args[1])) list.add(pl.getValue().pluginName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
if (args.length == 3 && args[0].equalsIgnoreCase("debug")&& args[1].equalsIgnoreCase("deleteReportLog")) {
|
||||
if (sender.hasPermission("t2code.admin")) {
|
||||
if (hasPermission(p, arg1.get("debug"))) {
|
||||
for (String st : ReportLogStorage.list){
|
||||
if (passend(st,args[2])) list.add(st);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
@@ -0,0 +1,80 @@
|
||||
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Commands {
|
||||
public static void info(CommandSender sender) {
|
||||
T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText());
|
||||
}
|
||||
|
||||
public static void debug(CommandSender sender, String[] args) {
|
||||
if (args.length < 2) {
|
||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
||||
return;
|
||||
}
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "createreportlog":
|
||||
switch (args.length){
|
||||
case 2:
|
||||
if (sender instanceof Player) {
|
||||
T2Csend.sender(sender, "<dark_red>The debug zip file is <red>automatically uploaded</red> to T2Code's servers<br>and <red>automatically deleted</red> " +
|
||||
"after <red>14</red> days!<br>The file can also be deleted manually by you via command!</dark_red><br><dark_green><hover:show_text:'<yellow>Confirm the" +
|
||||
" upload</yellow>'><click:run_command:'/t2c debug createReportLog confirmupload'>upload</click></hover></dark_green> <dark_gray>|</dark_gray> " +
|
||||
"<gold><hover:show_text:'<red>Do not upload</red>'><click:run_command:'/t2c debug createReportLog noupload'>keep the file on your server</click></hover></gold>");
|
||||
} else T2Csend.sender(sender, "<dark_red>The debug zip file is <red>automatically uploaded</red> to T2Code's servers</dark_red>" +
|
||||
"<br><dark_red>and <red>automatically deleted</red> after <red>14</red> days!</dark_red>" +
|
||||
"<br><dark_red>The file can also be deleted manually by you via command!</dark_red>" +
|
||||
"<br><green>Confirm the upload with the command:</green>" +
|
||||
"<br><yellow>/t2c debug createReportLog confirmupload</yellow>" +
|
||||
"<br><red>Keep the file on your server and do not upload it with the command:</red>" +
|
||||
"<br><yellow>/t2c debug createReportLog noupload</yellow>");
|
||||
break;
|
||||
case 3:
|
||||
Boolean upload = args[2].equalsIgnoreCase("confirmupload");
|
||||
Bukkit.getScheduler().runTaskAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
CreateReportLog.create(sender, upload);
|
||||
} catch (IOException e) {
|
||||
T2Csend.sender(sender, Util.getPrefix() + " <red>An error occurred while creating a report log! Please look in the console!</red>");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "deletereportlog":
|
||||
if (args.length != 3) {
|
||||
T2Csend.sender(sender, "§4Use: §7/t2code debug deleteReportLog [id]");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
CreateReportLog.delete(args[2], sender);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog/deleteReportLog");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateInfo(CommandSender sender, String[] args) {
|
||||
T2Csend.sender(sender, T2CupdateAPI.updateInfo(args, sender instanceof Player));
|
||||
}
|
||||
}
|
@@ -1,45 +1,66 @@
|
||||
package net.t2code.t2codelib.SPIGOT.system;
|
||||
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
||||
|
||||
import net.t2code.luckyBox.api.LuckyBoxAPI;
|
||||
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.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.Vault;
|
||||
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.Server;
|
||||
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.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
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, Boolean confirmUpload) 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());
|
||||
|
||||
File directory = new File(T2CodeLibMain.getPath() + "/DebugLogs");
|
||||
File directoryTemp = new File("T2CDebugLogsTemp");
|
||||
if (!directory.exists()) {
|
||||
directory.mkdir();
|
||||
}
|
||||
if (!directoryTemp.exists()) {
|
||||
directoryTemp.mkdir();
|
||||
}
|
||||
|
||||
File file = new File(T2CodeLibMain.getPath(), "/DebugLogs/T2CodeLog.txt");
|
||||
File file = new File("T2CDebugLogsTemp/T2CodeLog.txt");
|
||||
PrintWriter pWriter = null;
|
||||
try {
|
||||
pWriter = new PrintWriter(new FileWriter(file.getPath()));
|
||||
String timeStamp = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy").format(Calendar.getInstance().getTime());
|
||||
pWriter.println("Created on: " + timeStamp);
|
||||
pWriter.println("Created on: " + timeStamp + " - from: " + sender.getName());
|
||||
pWriter.println();
|
||||
pWriter.println("Server Bukkit version: " + T2CmcVersion.getBukkitVersion());
|
||||
pWriter.println("Server run on: " + T2CmcVersion.getMcVersion());
|
||||
pWriter.println("Server NMS: " + T2CmcVersion.getNms());
|
||||
pWriter.println();
|
||||
pWriter.println("Online Mode: " + Bukkit.getOnlineMode());
|
||||
pWriter.println("Bungee Mode: " + T2CodeLibMain.getIsBungee());
|
||||
pWriter.println("Server Port: " + Bukkit.getServer().getPort());
|
||||
pWriter.println();
|
||||
pWriter.println("Worlds: " + Bukkit.getWorlds());
|
||||
pWriter.println("OP-Player:");
|
||||
for (OfflinePlayer player : Bukkit.getOperators()) {
|
||||
@@ -80,7 +101,6 @@ public class CreateReportLog {
|
||||
pWriter.println("T2C-LuckyBox isV: " + LuckyBoxAPI.isV());
|
||||
pWriter.println();
|
||||
}
|
||||
pWriter.println();
|
||||
pWriter.println("OfflinePlayers: ");
|
||||
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||
pWriter.println(" - " + player.getName() + " - " + player.getUniqueId());
|
||||
@@ -89,8 +109,9 @@ public class CreateReportLog {
|
||||
pWriter.println("Plugins amount: " + Bukkit.getPluginManager().getPlugins().length);
|
||||
pWriter.println("Plugins: ");
|
||||
for (Plugin pl : Bukkit.getPluginManager().getPlugins()) {
|
||||
pWriter.println(" - " + pl.getName() + " - " + pl.getDescription().getVersion() + " - Enabled: " + pl.isEnabled() + " - Autors: " + pl.getDescription()
|
||||
.getAuthors() + " - Website: " + pl.getDescription().getWebsite());
|
||||
pWriter.println(" - " + pl.getName() + " - " + pl.getDescription().getVersion() + " - Enabled: " + pl.isEnabled() + " - Autors: "
|
||||
+ pl.getDescription().getAuthors() + " - SoftDepend: " + pl.getDescription().getSoftDepend() + " - Depend: " + pl.getDescription().getDepend()
|
||||
+ " LoadBefore: " + pl.getDescription().getLoadBefore() + " - Website: " + pl.getDescription().getWebsite());
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
@@ -101,9 +122,9 @@ public class CreateReportLog {
|
||||
}
|
||||
}
|
||||
|
||||
String filePath = T2CodeLibMain.getPath() + "/DebugLogs/T2CodeLog.txt";
|
||||
String filePath = "T2CDebugLogsTemp/T2CodeLog.txt";
|
||||
String log = "logs/latest.log";
|
||||
String zipPath = "plugins/T2CodeLib/DebugLogs/T2CLog-" + timeStampFile + ".zip";
|
||||
String zipPath = "T2CDebugLogsTemp/T2CLog-" + timeStampFile + ".zip";
|
||||
try (ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(zipPath))) {
|
||||
File fileToZip = new File(filePath);
|
||||
zip.putNextEntry(new ZipEntry(fileToZip.getName()));
|
||||
@@ -120,11 +141,53 @@ public class CreateReportLog {
|
||||
e.printStackTrace();
|
||||
}
|
||||
file.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);
|
||||
File zipFile = new File(zipPath);
|
||||
|
||||
if (!confirmUpload){
|
||||
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);
|
||||
|
||||
Files.move(Paths.get(zipPath),Paths.get(directory+"/"+zipFile.getName()));
|
||||
zipFile.delete();
|
||||
directoryTemp.delete();
|
||||
return;
|
||||
}
|
||||
|
||||
HttpClient httpclient = new DefaultHttpClient();
|
||||
HttpPost httppost = new HttpPost("https://debug.t2code.net/uploadFile");
|
||||
|
||||
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();
|
||||
directoryTemp.delete();
|
||||
if (sender instanceof Player) {
|
||||
T2Csend.sender(sender, ("[prefix] <green>A DebugLog zip has been created." +
|
||||
"<br>[prefix] <green>You can download it <click:open_url:'[url]'><gold><hover:show_text:'<yellow>Download the debug file</yellow>'>here</hover></gold></click>." +
|
||||
"<br>[prefix] <green>Please enter the following key in the ticket: <gold><click:copy_to_clipboard:[key]><hover:show_text:'<yellow>Copy to clipboard</yellow>'>[key]</hover></click></gold></green>" +
|
||||
"<br>[prefix] <dark_red>Do not share the download URL with anyone!</dark_red>" +
|
||||
"<br><hover:show_text:'<yellow>Click to delete</yellow>'><click:run_command:'/t2code debug deleteReportLog [key]'>[prefix] <green>You can <b>delte</b> yor Debug-File by clicking me.</green>" +
|
||||
"<br>[prefix] <color:#910d06>(If you do not delete the debug file, it will be deleted automatically after <red>14</red> days!)</color></click></hover>")
|
||||
.replace("[key]", fileID).replace("[url]", downloadURL).replace("[prefix]",Util.getPrefix()));
|
||||
}
|
||||
T2Csend.console(Util.getPrefix() + (" <gold>A DebugLog zip has been created. You can download it here:</gold> <yellow>[url]</yellow>" +
|
||||
"<br><gold>Please enter the following key in the ticket:</gold> <yellow>[key]</yellow>." +
|
||||
"<br><dark_red>Do not share the download URL with anyone!</dark_red>" +
|
||||
"<br><color:#910d06>(If you do not delete the debug file, it will be deleted automatically after <red>14</red> days!)</color>" +
|
||||
"<br><dark_red>You can delte yor Debug-File with the following command:</dark_red> <red>/t2code debug deleteReportLog [key]</red>.")
|
||||
.replace("[key]", fileID).replace("[url]", downloadURL));
|
||||
ReportLogStorage.add(fileID);
|
||||
}
|
||||
|
||||
private static void pluginToDebug(String pluginName, ZipOutputStream zip) throws IOException {
|
||||
@@ -190,4 +253,18 @@ public class CreateReportLog {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
int response = con.getResponseCode();
|
||||
if (response == 200) {
|
||||
ReportLogStorage.remove(arg);
|
||||
T2Csend.sender(sender, "<green>Deleted report: <yellow>" + arg);
|
||||
} else {
|
||||
T2Csend.sender(sender, "<green>Error while deleting report: <yellow>" + arg);
|
||||
}
|
||||
con.disconnect();
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
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.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ReportLogStorage {
|
||||
public static List<String> list = new ArrayList<>();
|
||||
|
||||
protected static File config = new File(T2CodeLibMain.getPath(), "/DebugLogs/T2CodeReportKeys.yml");
|
||||
protected static YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
public static void add(String key) {
|
||||
list.add(key);
|
||||
save();
|
||||
}
|
||||
|
||||
public static void remove(String key) {
|
||||
list.remove(key);
|
||||
save();
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
if (list == null) return;
|
||||
yamlConfiguration.set("Keys", list);
|
||||
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
if (!config.exists()) return;
|
||||
list = yamlConfiguration.getStringList("Keys");
|
||||
}
|
||||
}
|
@@ -24,6 +24,7 @@ public class ConfigCreate {
|
||||
|
||||
T2Cconfig.set("Plugin.UpdateCheck.OnJoin", true, yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.UpdateCheck.TimeInterval", 60, yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.UpdateCheck.SeePreReleaseUpdates", true, yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.language", "english", yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("BungeeCord.Enable", false, yamlConfiguration);
|
||||
|
@@ -7,29 +7,34 @@ import java.io.File;
|
||||
|
||||
public class SelectLibConfig {
|
||||
|
||||
private static Boolean UpdateCheckOnJoin;
|
||||
private static Boolean t2cTestDevelopment;
|
||||
private static Integer UpdateCheckTimeInterval;
|
||||
private static Boolean Debug;
|
||||
private static Boolean updateCheckOnJoin;
|
||||
private static Boolean t2cTestDevelopment = false;
|
||||
private static Integer updateCheckTimeInterval;
|
||||
private static Boolean seePreReleaseUpdates;
|
||||
private static Boolean debug;
|
||||
private static String language;
|
||||
private static Boolean bungee;
|
||||
private static Boolean InventoriesCloseByServerStop;
|
||||
private static Boolean inventoriesCloseByServerStop;
|
||||
|
||||
public static void onSelect() {
|
||||
File config = new File(T2CodeLibMain.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheck.OnJoin");
|
||||
t2cTestDevelopment = yamlConfiguration.getBoolean("t2cTestDevelopment");
|
||||
UpdateCheckTimeInterval = yamlConfiguration.getInt("Plugin.UpdateCheck.TimeInterval");
|
||||
Debug = yamlConfiguration.getBoolean("Plugin.Debug");
|
||||
if (yamlConfiguration.contains("t2cTestDevelopment")){
|
||||
t2cTestDevelopment = yamlConfiguration.getBoolean("t2cTestDevelopment");
|
||||
}
|
||||
|
||||
updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheck.OnJoin");
|
||||
updateCheckTimeInterval = yamlConfiguration.getInt("Plugin.UpdateCheck.TimeInterval");
|
||||
seePreReleaseUpdates = yamlConfiguration.getBoolean("Plugin.UpdateCheck.SeePreReleaseUpdates");
|
||||
debug = yamlConfiguration.getBoolean("Plugin.Debug");
|
||||
language = yamlConfiguration.getString("Plugin.language");
|
||||
bungee = yamlConfiguration.getBoolean("BungeeCord.Enable");
|
||||
InventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop");
|
||||
inventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop");
|
||||
}
|
||||
|
||||
public static Boolean getUpdateCheckOnJoin() {
|
||||
return UpdateCheckOnJoin;
|
||||
return updateCheckOnJoin;
|
||||
}
|
||||
|
||||
public static Boolean getT2cTestDevelopment() {
|
||||
@@ -37,11 +42,15 @@ public class SelectLibConfig {
|
||||
}
|
||||
|
||||
public static Integer getUpdateCheckTimeInterval() {
|
||||
return UpdateCheckTimeInterval;
|
||||
return updateCheckTimeInterval;
|
||||
}
|
||||
|
||||
public static Boolean getSeePreReleaseUpdates() {
|
||||
return seePreReleaseUpdates;
|
||||
}
|
||||
|
||||
public static Boolean getDebug() {
|
||||
return Debug;
|
||||
return debug;
|
||||
}
|
||||
|
||||
public static String getLanguage() {
|
||||
@@ -53,7 +62,7 @@ public class SelectLibConfig {
|
||||
}
|
||||
|
||||
public static Boolean getInventoriesCloseByServerStop() {
|
||||
return InventoriesCloseByServerStop;
|
||||
return inventoriesCloseByServerStop;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user