15.7
- Bugfix: If a t2code plugin could not be checked for an update, it was not possible to use the info command of the respective plugin and the command '/t2c updateinfo <plugin>'. - The message at the command '/t2code updatinfo <plugin>' was slightly adjusted
This commit is contained in:
@@ -6,6 +6,7 @@ import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import net.t2code.t2codelib.UpdateType;
|
||||
import net.t2code.t2codelib.T2CupdateObject;
|
||||
import net.t2code.t2codelib.T2CupdateWebData;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -68,44 +69,44 @@ public class T2CupdateAPI {
|
||||
"[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;
|
||||
String updateStatusVersion;
|
||||
|
||||
if (webData.isPreRelease()) {
|
||||
//todo if (!SelectLibConfig.getSeePreReleaseUpdates()) return;
|
||||
value = UpdateType.PRERELEASE.text;
|
||||
updateStatusVersion = UpdateType.PRERELEASE.text;
|
||||
if (publicVersion.toLowerCase().contains("dev")) {
|
||||
value = UpdateType.DEVELOPMENT.text;
|
||||
updateStatusVersion = UpdateType.DEVELOPMENT.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("beta")) {
|
||||
value = UpdateType.BETA.text;
|
||||
updateStatusVersion = UpdateType.BETA.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("snapshot")) {
|
||||
value = UpdateType.SNAPSHOT.text;
|
||||
updateStatusVersion = UpdateType.SNAPSHOT.text;
|
||||
}
|
||||
} else value = UpdateType.STABLE.text;
|
||||
} else updateStatusVersion = UpdateType.STABLE.text;
|
||||
|
||||
T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", value).replace("[link]", webData.getUpdateUrl())
|
||||
T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", updateStatusVersion).replace("[link]", webData.getUpdateUrl())
|
||||
.replace("[plv]", pluginVersion).replace("[puv]", publicVersion).replace("[dc]", discord));
|
||||
}
|
||||
|
||||
public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Plugin plugin) {
|
||||
String publicVersion = webData.getVersion();
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
String value;
|
||||
String updateStatusVersion;
|
||||
if (webData.isPreRelease()) {
|
||||
value = UpdateType.PRERELEASE.text;
|
||||
updateStatusVersion = UpdateType.PRERELEASE.text;
|
||||
if (publicVersion.toLowerCase().contains("dev")) {
|
||||
value = UpdateType.DEVELOPMENT.text;
|
||||
updateStatusVersion = UpdateType.DEVELOPMENT.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("beta")) {
|
||||
value = UpdateType.BETA.text;
|
||||
updateStatusVersion = UpdateType.BETA.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("snapshot")) {
|
||||
value = UpdateType.SNAPSHOT.text;
|
||||
updateStatusVersion = UpdateType.SNAPSHOT.text;
|
||||
}
|
||||
} else value = UpdateType.STABLE.text;
|
||||
} else updateStatusVersion = UpdateType.STABLE.text;
|
||||
String h = "<br><dark_red>╔══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
|
||||
String s1 = "<br><dark_red>║</dark_red> <color:#6e90ff>A new [value] version was found!</color>".replace("[value]", value);
|
||||
String s1 = "<br><dark_red>║</dark_red> <color:#6e90ff>A new [value] version was found!</color>".replace("[value]", updateStatusVersion);
|
||||
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>";
|
||||
@@ -119,9 +120,13 @@ public class T2CupdateAPI {
|
||||
try {
|
||||
object = T2CupdateAPI.pluginVersions.get(args[1]);
|
||||
} catch (Exception e) {
|
||||
return "Das Plugin " + args[1] + " gibts net"; // todo
|
||||
return Util.getPrefix() + " <red>The plugin <yellow>" + args[1] + "</yellow> is not registered in the update checker of T2Code!</red>";
|
||||
}
|
||||
if (object == null) return Util.getPrefix() + " <red>The plugin <yellow>" + args[1] + "</yellow> is not registered in the update checker of T2Code!</red>";
|
||||
T2CupdateWebData webData = object.webData;
|
||||
if (webData == null) {
|
||||
return Util.getPrefix() + " <b><dark_red>It could not be checked for updates with the plugin <yellow>" + args[1] + "</yellow>!</dark_red></b>";
|
||||
}
|
||||
String pluginName = T2CupdateAPI.pluginVersions.get(args[1]).pluginName;
|
||||
String pluginVersion = T2CupdateAPI.pluginVersions.get(args[1]).pluginVersion;
|
||||
|
||||
@@ -162,7 +167,7 @@ public class T2CupdateAPI {
|
||||
|
||||
String text;
|
||||
|
||||
text = "<dark_red>╔══════════════════════</dark_red>";
|
||||
text = "<br><dark_red>╔══════════════════════</dark_red>";
|
||||
text = text + pluginNameString;
|
||||
text = text + pluginVersionString;
|
||||
text = text + updateInfoString.replace("[value]", object.updateAvailable ? "Update available" : "Info about your version");
|
||||
|
@@ -15,6 +15,7 @@ import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -33,7 +34,7 @@ public class T2CupdateCheckerGit {
|
||||
String finalRepoURL = RepoURL;
|
||||
|
||||
Integer finalInterval;
|
||||
if (timeInterval < 1){
|
||||
if (timeInterval < 1) {
|
||||
finalInterval = 1;
|
||||
} else finalInterval = timeInterval;
|
||||
|
||||
@@ -98,19 +99,19 @@ public class T2CupdateCheckerGit {
|
||||
return;
|
||||
}
|
||||
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("'", "''").replace("**", "");
|
||||
String updateurl = obj.getString("html_url");
|
||||
boolean prerelease = obj.getBoolean("prerelease");
|
||||
String updateTitle = obj.getString("name");
|
||||
String version = obj.getString("tag_name");
|
||||
String updateDescription = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''").replace("**", "");
|
||||
String updateUrl = obj.getString("html_url");
|
||||
boolean preRelease = obj.getBoolean("prerelease");
|
||||
|
||||
String date = obj.getString("published_at");
|
||||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
|
||||
Date parsedDate = inputFormat.parse(date);
|
||||
String formattedDate = outputFormat.format(parsedDate);
|
||||
String publishedAt = outputFormat.format(parsedDate);
|
||||
|
||||
String gitURL = updateurl;
|
||||
String gitURL = updateUrl;
|
||||
JSONArray downloadArray = obj.getJSONArray("assets");
|
||||
String downloadURL;
|
||||
if (downloadArray.isEmpty()) {
|
||||
@@ -119,14 +120,14 @@ public class T2CupdateCheckerGit {
|
||||
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
|
||||
}
|
||||
|
||||
if (!prerelease) {
|
||||
if (!preRelease) {
|
||||
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
|
||||
updateurl = "https://www.spigotmc.org/resources/" + spigotID;
|
||||
updateUrl = "https://www.spigotmc.org/resources/" + spigotID;
|
||||
}
|
||||
|
||||
T2CupdateWebData webData = new T2CupdateWebData(UpdateName, tag_name, body, updateurl, formattedDate, downloadURL, gitURL, prerelease);
|
||||
T2CupdateWebData webData = new T2CupdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease);
|
||||
consumer.accept(webData);
|
||||
} catch (Exception var10) {
|
||||
} catch (Exception exception) {
|
||||
Boolean load = false;
|
||||
if (T2CupdateAPI.pluginVersions.containsKey(plugin.getName())) {
|
||||
load = T2CupdateAPI.pluginVersions.get(plugin.getName()).load;
|
||||
@@ -140,7 +141,9 @@ public class T2CupdateCheckerGit {
|
||||
updateCheckOnJoin
|
||||
);
|
||||
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
|
||||
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());
|
||||
|
||||
T2Csend.error(this.plugin,"§4 Cannot look for updates: " + exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user