13.4_SNAPSHOT-2

- From now on a different temporary path is used to create the debug zip to avoid data garbage.
- The design of the update messages was changed
This commit is contained in:
2022-11-14 22:37:36 +01:00
parent f9b0b512b9
commit f0b5b2e65b
8 changed files with 127 additions and 104 deletions

View File

@@ -50,12 +50,12 @@ public class T2CupdateAPI {
return;
}
String st = "[prefix]<br>" +
"<click:open_url:'[link]'><hover:show_text:'<gold>You can download it here: <yellow>[link]</yellow></gold>'>[prefix] <gold>A new</gold> [value] <gold>version was" +
" found!</gold></hover></click><br>" +
"<click:open_url:'[link]'><hover:show_text:'<gold>You can download it here: <yellow>[link]</yellow></gold>'>[prefix] <red>[plv]</red> <gray>-></gray> " +
"<click:open_url:'[link]'><hover:show_text:'<color:#6e90ff>You can download it here: <yellow>[link]</yellow></color>'>[prefix] <color:#6e90ff>A new</color> [value] <color:#6e90ff>version was" +
" found!</color></hover></click><br>" +
"<click:open_url:'[link]'><hover:show_text:'<color:#6e90ff>You can download it here: <yellow>[link]</yellow></color>'>[prefix] <red>[plv]</red> <gray>-></gray> " +
"<green>[puv]</green></hover></click><br>" +
"<click:open_url:'[dc]'><hover:show_text:'<yellow>[dc]</yellow>'>[prefix] <gold>You can find more information on Discord.</gold></hover></click><br>" +
"[prefix] <blue><hover:show_text:'<red>Click for more information</red>'><click:run_command:'/t2c updateinfo " + plugin.getName() + "'>Update information</click></hover></blue><br>" +
"<click:open_url:'[dc]'><hover:show_text:'<yellow>[dc]</yellow>'>[prefix] <color:#6e90ff>You can find more information on Discord.</color></hover></click><br>" +
"[prefix] <color:#ff9499><hover:show_text:'<red>Click for more information</red>'><click:run_command:'/t2c updateinfo " + plugin.getName() + "'>Update information</click></hover></color><br>" +
"[prefix]";
String value;
@@ -94,10 +94,10 @@ public class T2CupdateAPI {
}
} else value = UpdateType.STABLE.text;
String h = "<br><dark_red>╔══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
String s1 = "<br><dark_red>║</dark_red> <gold>A new [value] version was found!</gold>".replace("[value]", value);
String s2 = "<br><dark_red>║</dark_red> <gold>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</gold> <green>" + webData.getVersion() + "</green>";
String s3 = "<br><dark_red>║</dark_red> <gold>You can download it here:</gold> <yellow>" + webData.getUpdateUrl() + "</yellow>";
String s4 = "<br><dark_red>║</dark_red> <gold>You can find more information on Discord:</gold> <yellow>" + discord + "</yellow>";
String s1 = "<br><dark_red>║</dark_red> <color:#6e90ff>A new [value] version was found!</color>".replace("[value]", value);
String s2 = "<br><dark_red>║</dark_red> <color:#6e90ff>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</color> <green>" + webData.getVersion() + "</green>";
String s3 = "<br><dark_red>║</dark_red> <color:#6e90ff>You can download it here:</color> <yellow>" + webData.getUpdateUrl() + "</yellow>";
String s4 = "<br><dark_red>║</dark_red> <color:#6e90ff>You can find more information on Discord:</color> <yellow>" + discord + "</yellow>";
String f = "<br><dark_red>╚══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
String text = h + s1 + s2 + s3 + s4 + f;
T2Csend.console(text);
@@ -135,17 +135,18 @@ public class T2CupdateAPI {
String updateUpdate = webData.getUpdateUrl();
String updateDescription = webData.getUpdateDescription();
String pluginNameString = "<br><dark_red>║</dark_red> <yellow>Plugin:</yellow> <color:#5eff89>" + pluginName + "</color>";
String pluginVersionString = "<br><dark_red>║</dark_red> <yellow>Your version:</yellow> <color:#5eff89>" + pluginVersion + "</color>";
String updateInfoString = "<br><dark_red>║</dark_red> <color:#308aff>[value]:</color>";
String updateTitleString = "<br><dark_red>║</dark_red> <yellow>Title:</yellow> <color:#5eff89>" + updateTitle + "</color>";
String updateVersionString = "<br><dark_red>║</dark_red> <yellow>Version:</yellow> <color:#5eff89>" + updateVersion + "</color>";
String updateAtString = "<br><dark_red>║</dark_red> <yellow>Published on:</yellow> <color:#5eff89>" + updateAt + "</color>";
String updateTypeString = "<br><dark_red>║</dark_red> <yellow>Version type:</yellow> <color:#5eff89>" + updateType + "</color>";
String pluginNameString = "<br><dark_red>║</dark_red> <color:#6e90ff>Plugin:</color> <color:#5eff89>" + pluginName + "</color>";
String pluginVersionString = "<br><dark_red>║</dark_red> <color:#6e90ff>Your version:</color> <color:#5eff89>" + pluginVersion + "</color>";
String updateInfoString = "<br><dark_red>║</dark_red> <color:#09ff00>[value]:</color>";
String updateTitleString = "<br><dark_red>║</dark_red> <color:#6e90ff>Title:</color> <color:#5eff89>" + updateTitle + "</color>";
String updateVersionString = "<br><dark_red>║</dark_red> <color:#6e90ff>Version:</color> <color:#5eff89>" + updateVersion + "</color>";
String updateAtString = "<br><dark_red>║</dark_red> <color:#6e90ff>Published on:</color> <color:#5eff89>" + updateAt + "</color>";
String updateTypeString = "<br><dark_red>║</dark_red> <color:#6e90ff>Version type:</color> <color:#5eff89>" + updateType + "</color>";
String updateButton;
if (player) {
updateButton = "<br><dark_red>║</dark_red> <color:#5eff89><hover:show_text:'<gold>" + updateUpdate + "</gold>'><click:open_url:'" + updateUpdate + "'>Download</click></hover></color> <dark_gray>|</dark_gray> <blue><hover:show_text:'" + updateDescription + "'>Update Description</hover></blue>";
updateButton = "<br><dark_red>║</dark_red> <color:#5eff89><hover:show_text:'<gold>" + updateUpdate + "</gold>'><click:open_url:'" + updateUpdate
+ "'>Download</click></hover></color> <dark_gray>|</dark_gray> <color:#ff9499><hover:show_text:'" + updateDescription + "'>Update Description</hover></color>";
} else updateButton = "<br><dark_red>║</dark_red> <color:#5eff89>Download:</color> <gold>" + updateUpdate + "</gold>";
String text;
@@ -158,8 +159,7 @@ public class T2CupdateAPI {
if (object.updateAvailable) text = text + updateVersionString;
if (!updateTitle.equals("OLD")) text = text + updateAtString;
if (!updateTitle.equals("OLD")) text = text + updateTypeString;
if (object.updateAvailable)
text = text + updateButton;
text = text + updateButton;
if (updateTitle.equals("OLD")) text = text + "<br><dark_gray>This plugin does not have the new update checker yet, so there is no exact update / " +
"version information available!</dark_gray>";
@@ -190,7 +190,7 @@ public class T2CupdateAPI {
update.load = true;
sendUpdateMsg(prefix, discord, update.webData, plugin);
}
}.runTaskLaterAsynchronously(plugin, 600L);
}.runTaskLaterAsynchronously(plugin, 200L);
} else sendUpdateMsg(prefix, discord, update.webData, plugin);
} else {
if (!update.load) {
@@ -203,7 +203,8 @@ public class T2CupdateAPI {
}.runTaskTimerAsynchronously(plugin, 0L, SelectLibConfig.getUpdateCheckTimeInterval() * 60 * 20L);
}
public static void onUpdateCheck(Plugin plugin, String prefix, String RepoURL, Integer spigotID, String discord) {
public static void onUpdateCheck(Plugin plugin, String prefix, String gitKey, Integer spigotID, String discord) {
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
if (!RepoURL.contains("?limit=1")) {
RepoURL = RepoURL + "?limit=1";
}

View File

@@ -45,7 +45,7 @@ public class T2CupdateCheckerGit {
JSONObject obj = new JSONObject(data);
String UpdateName = obj.getString("name");
String tag_name = obj.getString("tag_name");
String body = obj.getString("body").replace("\n","<br>").replace("\r","").replace("'","''");
String body = obj.getString("body").replace("\n","<br>").replace("\r","").replace("'","''").replace("**","");
String updateurl = obj.getString("html_url");
boolean prerelease = obj.getBoolean("prerelease");

View File

@@ -29,6 +29,7 @@ public class Commands {
try {
CreateReportLog.create(sender);
} 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);
}
}

View File

@@ -38,11 +38,15 @@ public class CreateReportLog {
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()));
@@ -117,9 +121,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()));
@@ -152,12 +156,13 @@ public class CreateReportLog {
String fileType = obj.getString("fileType");
Integer fileSize = obj.getInt("size");
zipFile.delete();
directoryTemp.delete();
if (sender instanceof Player) {
T2Csend.sender(sender, Util.getPrefix() + ("<green>A DebugLog zip has been created. You can download it <click:open_url:'[url]'>" +
"<gold><hover:show_text:'<yellow>Download the debug file</yellow>'>here</hover></gold></click>. 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><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));
"<green>You can <hover:show_text:'<yellow>Click to delete</yellow>'><b>delte</b></hover> 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:" +
" §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].")