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:
parent
610cb74868
commit
c72edafd0a
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>T2CodeLib</artifactId>
|
<artifactId>T2CodeLib</artifactId>
|
||||||
<version>15.6</version>
|
<version>15.7</version>
|
||||||
<!--version>VERSION_snapshot-0</version-->
|
<!--version>VERSION_snapshot-0</version-->
|
||||||
<!--version>VERSION_beta-0</version-->
|
<!--version>VERSION_beta-0</version-->
|
||||||
<!--version>VERSION_dev-0</version-->
|
<!--version>VERSION_dev-0</version-->
|
||||||
|
@ -50,20 +50,20 @@ public class T2CBupdateCheckerGit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSONObject obj = new JSONObject(data);
|
JSONObject obj = new JSONObject(data);
|
||||||
String UpdateName = obj.getString("name");
|
String updateTitle = obj.getString("name");
|
||||||
String tag_name = obj.getString("tag_name");
|
String version = obj.getString("tag_name");
|
||||||
String body = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''");
|
String updateDescription = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''");
|
||||||
String updateurl = obj.getString("html_url");
|
String updateUrl = obj.getString("html_url");
|
||||||
boolean prerelease = obj.getBoolean("prerelease");
|
boolean preRelease = obj.getBoolean("prerelease");
|
||||||
|
|
||||||
String date = obj.getString("published_at");
|
String date = obj.getString("published_at");
|
||||||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||||
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
|
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
|
||||||
Date parsedDate = inputFormat.parse(date);
|
Date parsedDate = inputFormat.parse(date);
|
||||||
String formattedDate = outputFormat.format(parsedDate);
|
String publishedAt = outputFormat.format(parsedDate);
|
||||||
|
|
||||||
JSONArray downloadArray = obj.getJSONArray("assets");
|
JSONArray downloadArray = obj.getJSONArray("assets");
|
||||||
String gitURL = updateurl;
|
String gitURL = updateUrl;
|
||||||
String downloadURL;
|
String downloadURL;
|
||||||
if (downloadArray.isEmpty()) {
|
if (downloadArray.isEmpty()) {
|
||||||
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
|
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
|
||||||
@ -71,12 +71,12 @@ public class T2CBupdateCheckerGit {
|
|||||||
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
|
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!prerelease) {
|
if (!preRelease) {
|
||||||
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
|
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);
|
consumer.accept(webData);
|
||||||
} catch (Exception var10) {
|
} catch (Exception var10) {
|
||||||
Boolean load = false;
|
Boolean load = false;
|
||||||
|
@ -2,6 +2,8 @@ package net.t2code.t2codelib.SPIGOT.api.messages;
|
|||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||||
|
import net.t2code.t2codelib.T2CupdateWebData;
|
||||||
|
import net.t2code.t2codelib.UpdateType;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -71,6 +73,7 @@ public class T2Ctemplate {
|
|||||||
public static void onLoadFooter(String prefix, Long long_, String v) {
|
public static void onLoadFooter(String prefix, Long long_, String v) {
|
||||||
onLoadFooter(prefix, long_);
|
onLoadFooter(prefix, long_);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onLoadFooter(String prefix, Long long_) {
|
public static void onLoadFooter(String prefix, Long long_) {
|
||||||
onLoadSeparateStroke(prefix);
|
onLoadSeparateStroke(prefix);
|
||||||
T2Csend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
T2Csend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||||
@ -81,16 +84,14 @@ public class T2Ctemplate {
|
|||||||
* @param autor
|
* @param autor
|
||||||
* @param spigot
|
* @param spigot
|
||||||
* @param discord
|
* @param discord
|
||||||
*
|
|
||||||
* @deprecated reason this method is deprecated <br/>
|
* @deprecated reason this method is deprecated <br/>
|
||||||
* {will be removed in next version} <br/>
|
* {will be removed in next version} <br/>
|
||||||
* use {@link #onDisable(Plugin)} instead like this:
|
* use {@link #onDisable(String, Plugin)} instead like this:
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* <blockquote><pre>
|
* <blockquote><pre>
|
||||||
* onDisable(getPlugin())
|
* onDisable(getPlugin())
|
||||||
* </pre></blockquote>
|
* </pre></blockquote>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void onDisable(String prefix, List<String> autor, String version, String spigot, String discord) {
|
public static void onDisable(String prefix, List<String> autor, String version, String spigot, String discord) {
|
||||||
@ -108,15 +109,32 @@ public class T2Ctemplate {
|
|||||||
|
|
||||||
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, Boolean premiumVerified, String text) {
|
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, Boolean premiumVerified, String text) {
|
||||||
String pluginVersion = plugin.getDescription().getVersion();
|
String pluginVersion = plugin.getDescription().getVersion();
|
||||||
String publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData.getVersion();
|
String publicVersion = "";
|
||||||
boolean update = !publicVersion.equalsIgnoreCase(pluginVersion);
|
boolean update;
|
||||||
boolean player = sender instanceof Player;
|
String stNVersion;
|
||||||
|
T2CupdateWebData webData;
|
||||||
|
try {
|
||||||
|
webData = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
webData = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (webData != null) {
|
||||||
|
publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData.getVersion();
|
||||||
|
update = !publicVersion.equalsIgnoreCase(pluginVersion);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
update = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean player = sender instanceof Player;
|
||||||
String stPlugin = "<dark_red>║</dark_red> <yellow>Plugin:</yellow> <gold>[pl]</gold>".replace("[pl]", plugin.getName());
|
String stPlugin = "<dark_red>║</dark_red> <yellow>Plugin:</yellow> <gold>[pl]</gold>".replace("[pl]", plugin.getName());
|
||||||
String stVersion = "<dark_red>║</dark_red> <yellow>Version:</yellow> <gold>[ver]</gold>".replace("[ver]", pluginVersion);
|
String stVersion = "<dark_red>║</dark_red> <yellow>Version:</yellow> <gold>[ver]</gold>".replace("[ver]", pluginVersion);
|
||||||
String stAutor = "<dark_red>║</dark_red> <yellow>Autor(s):</yellow> <gold>[autor]</gold>".replace("[autor]", plugin.getDescription().getAuthors().toString());
|
String stAutor = "<dark_red>║</dark_red> <yellow>Autor(s):</yellow> <gold>[autor]</gold>".replace("[autor]", plugin.getDescription().getAuthors().toString());
|
||||||
String stNVersion = "<dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]", publicVersion);
|
|
||||||
String stStable = "<dark_red>║</dark_red> <yellow>Stable version available:</yellow> [up]".replace("[up]", update ? "<dark_green>YES</dark_green>" : "<red>no</red>");
|
String stUpdate = "<dark_red>║</dark_red> <yellow>New version available:</yellow> [up]".replace("[up]", webData != null ? update ?
|
||||||
|
"<dark_green>YES</dark_green>" : "<red>no</red>" : "<b><dark_red>It could not be checked for updates!</dark_red></b>");
|
||||||
|
stNVersion = update ? "<br><dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]",player ? "<hover:show_text:'<yellow>Click for the update information</yellow>'><click:run_command:'/t2code updateinfo "+plugin.getName()+"'>"+publicVersion+"</click></hover>":publicVersion) : "";
|
||||||
String stLinkPlayer = "<dark_red>║</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> "
|
String stLinkPlayer = "<dark_red>║</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> "
|
||||||
.replace("[slink]", "https://www.spigotmc.org/resources/" + spigotID)
|
.replace("[slink]", "https://www.spigotmc.org/resources/" + spigotID)
|
||||||
+ "<dark_red>-</dark_red> <dark_purple><hover:show_text:'<green>Go to the T2Code Support Discord</green>'><click:open_url:'[dlink]'>Discord</click></hover></dark_purple>"
|
+ "<dark_red>-</dark_red> <dark_purple><hover:show_text:'<green>Go to the T2Code Support Discord</green>'><click:open_url:'[dlink]'>Discord</click></hover></dark_purple>"
|
||||||
@ -124,16 +142,17 @@ public class T2Ctemplate {
|
|||||||
String stLinkConsole = "<dark_red>║</dark_red> <yellow>Spigot:</yellow> <gold>https://www.spigotmc.org/resources/" + spigotID + "</gold>"
|
String stLinkConsole = "<dark_red>║</dark_red> <yellow>Spigot:</yellow> <gold>https://www.spigotmc.org/resources/" + spigotID + "</gold>"
|
||||||
+ "<br><dark_red>║</dark_red> <yellow>Discord:</yellow> <gold>" + discord + "</gold>";
|
+ "<br><dark_red>║</dark_red> <yellow>Discord:</yellow> <gold>" + discord + "</gold>";
|
||||||
String stLink = player ? stLinkPlayer : stLinkConsole;
|
String stLink = player ? stLinkPlayer : stLinkConsole;
|
||||||
String pr = premiumVerified != null ? "<br><dark_red>║</dark_red> <yellow>Premium verified:</yellow> [pr]".replace("[pr]", premiumVerified ? "<dark_green>YES</dark_green>" : "<red>NO</red>") : "";
|
String pr = premiumVerified != null ? "<br><dark_red>║</dark_red> <yellow>Premium verified:</yellow> [pr]".replace("[pr]",
|
||||||
|
premiumVerified ? "<dark_green>YES</dark_green>" : "<red>NO</red>") : "";
|
||||||
|
|
||||||
String stMSG = text == null || text.equals("") ? "" : "<br><dark_red>║</dark_red> " + text + "<br>";
|
String stMSG = text == null || text.equals("") ? "" : "<br><dark_red>║</dark_red> " + text;
|
||||||
T2Csend.sender(sender, "<dark_red>╔════════════════════════════════</dark_red>"
|
T2Csend.sender(sender, "<br><dark_red>╔════════════════════════════════</dark_red>"
|
||||||
+ "<br>" + stPlugin
|
+ "<br>" + stPlugin
|
||||||
|
+ "<br>" + stVersion
|
||||||
+ stMSG
|
+ stMSG
|
||||||
+ stVersion
|
|
||||||
+ "<br>" + stAutor
|
+ "<br>" + stAutor
|
||||||
+ "<br>" + stNVersion
|
+ "<br>" + stUpdate
|
||||||
+ "<br>" + stStable
|
+ stNVersion
|
||||||
+ "<br>" + stLink
|
+ "<br>" + stLink
|
||||||
+ pr
|
+ pr
|
||||||
+ "<br><dark_red>╚════════════════════════════════</dark_red>");
|
+ "<br><dark_red>╚════════════════════════════════</dark_red>");
|
||||||
|
@ -6,6 +6,7 @@ import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
|||||||
import net.t2code.t2codelib.UpdateType;
|
import net.t2code.t2codelib.UpdateType;
|
||||||
import net.t2code.t2codelib.T2CupdateObject;
|
import net.t2code.t2codelib.T2CupdateObject;
|
||||||
import net.t2code.t2codelib.T2CupdateWebData;
|
import net.t2code.t2codelib.T2CupdateWebData;
|
||||||
|
import net.t2code.t2codelib.Util;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
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] <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]";
|
"[prefix]";
|
||||||
|
|
||||||
String value;
|
String updateStatusVersion;
|
||||||
|
|
||||||
if (webData.isPreRelease()) {
|
if (webData.isPreRelease()) {
|
||||||
//todo if (!SelectLibConfig.getSeePreReleaseUpdates()) return;
|
//todo if (!SelectLibConfig.getSeePreReleaseUpdates()) return;
|
||||||
value = UpdateType.PRERELEASE.text;
|
updateStatusVersion = UpdateType.PRERELEASE.text;
|
||||||
if (publicVersion.toLowerCase().contains("dev")) {
|
if (publicVersion.toLowerCase().contains("dev")) {
|
||||||
value = UpdateType.DEVELOPMENT.text;
|
updateStatusVersion = UpdateType.DEVELOPMENT.text;
|
||||||
}
|
}
|
||||||
if (publicVersion.toLowerCase().contains("beta")) {
|
if (publicVersion.toLowerCase().contains("beta")) {
|
||||||
value = UpdateType.BETA.text;
|
updateStatusVersion = UpdateType.BETA.text;
|
||||||
}
|
}
|
||||||
if (publicVersion.toLowerCase().contains("snapshot")) {
|
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));
|
.replace("[plv]", pluginVersion).replace("[puv]", publicVersion).replace("[dc]", discord));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Plugin plugin) {
|
public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Plugin plugin) {
|
||||||
String publicVersion = webData.getVersion();
|
String publicVersion = webData.getVersion();
|
||||||
String pluginVersion = plugin.getDescription().getVersion();
|
String pluginVersion = plugin.getDescription().getVersion();
|
||||||
String value;
|
String updateStatusVersion;
|
||||||
if (webData.isPreRelease()) {
|
if (webData.isPreRelease()) {
|
||||||
value = UpdateType.PRERELEASE.text;
|
updateStatusVersion = UpdateType.PRERELEASE.text;
|
||||||
if (publicVersion.toLowerCase().contains("dev")) {
|
if (publicVersion.toLowerCase().contains("dev")) {
|
||||||
value = UpdateType.DEVELOPMENT.text;
|
updateStatusVersion = UpdateType.DEVELOPMENT.text;
|
||||||
}
|
}
|
||||||
if (publicVersion.toLowerCase().contains("beta")) {
|
if (publicVersion.toLowerCase().contains("beta")) {
|
||||||
value = UpdateType.BETA.text;
|
updateStatusVersion = UpdateType.BETA.text;
|
||||||
}
|
}
|
||||||
if (publicVersion.toLowerCase().contains("snapshot")) {
|
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 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 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 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 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 {
|
try {
|
||||||
object = T2CupdateAPI.pluginVersions.get(args[1]);
|
object = T2CupdateAPI.pluginVersions.get(args[1]);
|
||||||
} catch (Exception e) {
|
} 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;
|
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 pluginName = T2CupdateAPI.pluginVersions.get(args[1]).pluginName;
|
||||||
String pluginVersion = T2CupdateAPI.pluginVersions.get(args[1]).pluginVersion;
|
String pluginVersion = T2CupdateAPI.pluginVersions.get(args[1]).pluginVersion;
|
||||||
|
|
||||||
@ -162,7 +167,7 @@ public class T2CupdateAPI {
|
|||||||
|
|
||||||
String text;
|
String text;
|
||||||
|
|
||||||
text = "<dark_red>╔══════════════════════</dark_red>";
|
text = "<br><dark_red>╔══════════════════════</dark_red>";
|
||||||
text = text + pluginNameString;
|
text = text + pluginNameString;
|
||||||
text = text + pluginVersionString;
|
text = text + pluginVersionString;
|
||||||
text = text + updateInfoString.replace("[value]", object.updateAvailable ? "Update available" : "Info about your version");
|
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.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@ -98,19 +99,19 @@ public class T2CupdateCheckerGit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSONObject obj = new JSONObject(data);
|
JSONObject obj = new JSONObject(data);
|
||||||
String UpdateName = obj.getString("name");
|
String updateTitle = obj.getString("name");
|
||||||
String tag_name = obj.getString("tag_name");
|
String version = obj.getString("tag_name");
|
||||||
String body = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''").replace("**", "");
|
String updateDescription = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''").replace("**", "");
|
||||||
String updateurl = obj.getString("html_url");
|
String updateUrl = obj.getString("html_url");
|
||||||
boolean prerelease = obj.getBoolean("prerelease");
|
boolean preRelease = obj.getBoolean("prerelease");
|
||||||
|
|
||||||
String date = obj.getString("published_at");
|
String date = obj.getString("published_at");
|
||||||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||||
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
|
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
|
||||||
Date parsedDate = inputFormat.parse(date);
|
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");
|
JSONArray downloadArray = obj.getJSONArray("assets");
|
||||||
String downloadURL;
|
String downloadURL;
|
||||||
if (downloadArray.isEmpty()) {
|
if (downloadArray.isEmpty()) {
|
||||||
@ -119,14 +120,14 @@ public class T2CupdateCheckerGit {
|
|||||||
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
|
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!prerelease) {
|
if (!preRelease) {
|
||||||
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
|
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);
|
consumer.accept(webData);
|
||||||
} catch (Exception var10) {
|
} catch (Exception exception) {
|
||||||
Boolean load = false;
|
Boolean load = false;
|
||||||
if (T2CupdateAPI.pluginVersions.containsKey(plugin.getName())) {
|
if (T2CupdateAPI.pluginVersions.containsKey(plugin.getName())) {
|
||||||
load = T2CupdateAPI.pluginVersions.get(plugin.getName()).load;
|
load = T2CupdateAPI.pluginVersions.get(plugin.getName()).load;
|
||||||
@ -140,7 +141,9 @@ public class T2CupdateCheckerGit {
|
|||||||
updateCheckOnJoin
|
updateCheckOnJoin
|
||||||
);
|
);
|
||||||
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
|
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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,13 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
Commands.updateInfo(sender, args);
|
Commands.updateInfo(sender, args);
|
||||||
return false;
|
return false;
|
||||||
|
// case "plugininfo": todo
|
||||||
|
// if (!sender.hasPermission("t2code.admin")) {
|
||||||
|
// T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// Commands.updateInfo(sender, args);
|
||||||
|
// return false;
|
||||||
case "reloadconfig":
|
case "reloadconfig":
|
||||||
if (!sender.hasPermission("t2code.admin")) {
|
if (!sender.hasPermission("t2code.admin")) {
|
||||||
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
||||||
@ -74,7 +81,8 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
Commands.test(sender, args);
|
Commands.test(sender, args);
|
||||||
return false;
|
return false;
|
||||||
case "serverid":if (!sender.hasPermission("t2code.admin")) {
|
case "serverid":
|
||||||
|
if (!sender.hasPermission("t2code.admin")) {
|
||||||
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.t2code.t2codelib;
|
package net.t2code.t2codelib;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -13,7 +14,7 @@ public class Util {
|
|||||||
|
|
||||||
|
|
||||||
public static String getInfoText() {
|
public static String getInfoText() {
|
||||||
return "";
|
return "<yellow>Description:</yellow> <gold>"+T2CodeLibMain.getPlugin().getDescription().getDescription()+"</gold>" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPrefix() {
|
public static String getPrefix() {
|
||||||
|
@ -3,7 +3,7 @@ version: '${project.version}'
|
|||||||
main: net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain
|
main: net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
prefix: T2CodeLib
|
prefix: T2CodeLib
|
||||||
authors: [ JaTiTV, Jkobs ]
|
authors: [ JaTiTV ]
|
||||||
description: Library from T2Code Plugins
|
description: Library from T2Code Plugins
|
||||||
website: https://spigotmc.org/resources/96388/
|
website: https://spigotmc.org/resources/96388/
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
|
Loading…
Reference in New Issue
Block a user