13.4_SNAPSHOT-2

This commit is contained in:
2022-11-15 00:36:25 +01:00
parent 8114035cd9
commit d27ef185e6
9 changed files with 88 additions and 33 deletions

View File

@@ -1,5 +1,6 @@
package net.t2code.t2codelib.SPIGOT.api.update;
import com.sun.org.apache.xpath.internal.operations.Bool;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.UpdateType;
@@ -17,7 +18,7 @@ public class T2CupdateAPI {
public static HashMap<String, T2CupdateObject> pluginVersions = new HashMap<>();
public static void join(Plugin plugin, String prefix, String perm, Player player, Integer spigotID, String discord) {
if (!SelectLibConfig.getUpdateCheckOnJoin()) {
if (! pluginVersions.get(plugin.getName()).updateCheckOnJoin) {
return;
}
if (!player.hasPermission(perm) && !player.isOp()) {
@@ -33,7 +34,6 @@ public class T2CupdateAPI {
return;
}
T2CupdateWebData webData = pluginVersions.get(plugin.getName()).webData;
String pluginVersion = plugin.getDescription().getVersion();
if (!pluginVersions.get(plugin.getName()).updateAvailable) return;
new BukkitRunnable() {
@Override
@@ -61,7 +61,7 @@ public class T2CupdateAPI {
String value;
if (webData.isPreRelease()) {
if (!SelectLibConfig.getSeePreReleaseUpdates()) return;
//todo if (!SelectLibConfig.getSeePreReleaseUpdates()) return;
value = UpdateType.PRERELEASE.text;
if (publicVersion.toLowerCase().contains("dev")) {
value = UpdateType.DEVELOPMENT.text;
@@ -180,7 +180,9 @@ public class T2CupdateAPI {
plugin.getDescription().getVersion(),
new T2CupdateWebData("OLD", update_version, "", "https://www.spigotmc.org/resources/" + spigotID, "",
"https://www.spigotmc.org/resources/" + spigotID, false),
false, !plugin.getDescription().getVersion().equals(update_version)
false,
!plugin.getDescription().getVersion().equals(update_version),
true
);
pluginVersions.put(plugin.getName(), update);
if (pluginVersions.get(plugin.getName()).updateAvailable) {
@@ -199,13 +201,16 @@ public class T2CupdateAPI {
update.load = true;
}
}
}, prefix, plugin.getDescription().getVersion());
}, prefix, plugin.getDescription().getVersion(),true,true,60);
}
}.runTaskTimerAsynchronously(plugin, 0L, SelectLibConfig.getUpdateCheckTimeInterval() * 60 * 20L);
}
public static void onUpdateCheck(Plugin plugin, String prefix, String gitKey, Integer spigotID, String discord) {
public static void onUpdateCheck(Plugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
if (!SelectLibConfig.getSeePreReleaseUpdates()) {
RepoURL = RepoURL + "&pre-release=false";
}
if (!RepoURL.contains("?limit=1")) {
RepoURL = RepoURL + "?limit=1";
}
@@ -219,7 +224,8 @@ public class T2CupdateAPI {
plugin.getDescription().getVersion(),
webData,
false,
!plugin.getDescription().getVersion().equals(webData.getVersion())
!plugin.getDescription().getVersion().equals(webData.getVersion()),
updateCheckOnJoin
);
pluginVersions.put(plugin.getName(), update);
if (pluginVersions.get(plugin.getName()).updateAvailable) {
@@ -238,8 +244,8 @@ public class T2CupdateAPI {
update.load = true;
}
}
}, plugin.getDescription().getVersion(), spigotID, finalRepoURL);
}, plugin.getDescription().getVersion(), spigotID, finalRepoURL, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
}
}.runTaskTimerAsynchronously(plugin, 0L, SelectLibConfig.getUpdateCheckTimeInterval() * 60 * 20L);
}.runTaskTimerAsynchronously(plugin, 0L, timeInterval * 60 * 20L);
}
}

View File

@@ -19,7 +19,7 @@ public class T2CupdateChecker {
this.resourceId = resourceId;
}
public void getVersion(Consumer<String> consumer, String Prefix, String pluginVersion) {
public void getVersion(Consumer<String> consumer, String Prefix, String pluginVersion, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
if (!plugin.isEnabled()) {
return;
}
@@ -64,7 +64,9 @@ public class T2CupdateChecker {
pluginVersion,
null,
load,
false
false,
updateCheckOnJoin
);
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());

View File

@@ -21,7 +21,7 @@ public class T2CupdateCheckerGit {
this.plugin = plugin;
}
public void getVersion(Consumer<T2CupdateWebData> consumer, String pluginVersion, Integer spigotID, String URL) {
public void getVersion(Consumer<T2CupdateWebData> consumer, String pluginVersion, Integer spigotID, String URL, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
if (!plugin.isEnabled()) {
return;
}
@@ -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("'","''").replace("**","");
String body = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''").replace("**", "");
String updateurl = obj.getString("html_url");
boolean prerelease = obj.getBoolean("prerelease");
@@ -80,7 +80,8 @@ public class T2CupdateCheckerGit {
pluginVersion,
null,
load,
false
false,
updateCheckOnJoin
);
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());