Skip to content

Commit

Permalink
8.2.12
Browse files Browse the repository at this point in the history
- fix github/jenkins checkers not returning download url if already on latest, which caused issues if you had force-update enabled
- made plugins top comment regarding this clearer
  • Loading branch information
Osiris-Team committed Aug 24, 2024
1 parent bd58003 commit cdacdf6
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 91 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ AUTO-GENERATED FILE, CHANGES SHOULD BE DONE IN ./JPM.java or ./src/main/java/JPM
<modelVersion>4.0.0</modelVersion>
<groupId>com.osiris.autoplug.client</groupId>
<artifactId>AutoPlug-Client</artifactId>
<version>8.2.11</version>
<version>8.2.12</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>8</java.version>
<version>8.2.11</version>
<version>8.2.12</version>
<main-class>com.osiris.autoplug.client.Main</main-class>
<slf4j.version>2.0.13</slf4j.version>
<name>AutoPlug-Client</name>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/JPM.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ThisProject(List<String> args) {
// Override default configurations
this.groupId = "com.osiris.autoplug.client";
this.artifactId = "AutoPlug-Client";
this.version = "8.2.11";
this.version = "8.2.12";
this.mainClass = "com.osiris.autoplug.client.Main";
this.jarName = "AutoPlug-Client-original.jar";
this.fatJarName = "AutoPlug-Client.jar";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public PluginsConfig() throws IOException, DuplicateKeyException, YamlReaderExce
"If there are any questions or you just want chat, join our Discord: https://discord.gg/GGNmtCC\n" +
"\n" +
"#######################################################################################################################\n" +
"\n" +
"\n" +
"IMPORTANT: Before changing a setting in this file, make sure to read its explanation below! This will save you and me a lot of time in some cases.\n" +
"\n" +
"\n" +
"This file contains detailed information about your installed plugins. It is fetched from each plugins 'plugin.yml' file (located inside their jars).\n" +
"Example configuration for the EssentialsX plugin with each setting explained:\n" +
" Essentials: \n" +
Expand All @@ -53,7 +58,7 @@ public PluginsConfig() throws IOException, DuplicateKeyException, YamlReaderExce
" custom-check-url: #### Must link to a json file which contains a list/array of plugin versions where each item/object contains specific keys for version (\"version_number\", \"version\") and download URL (\"download_url\", \"download\", \"file\", \"download_file\").\n" +
" custom-download-url: #### Must be a static url to the plugins latest jar file.\n" +
" ignore-content-type: false #### When downloading a file the file host is asked for the file-type which must be .jar, when true this check is not performed.\n" +
" force-update: false #### If true, downloads the update every time even if its already on the latest version.\n" +
" force-update: false #### If true, downloads the update every time even if its already on the latest version. Do NOT enable, unless you have a really good reason to.\n" +
" alternatives: #### below both alternatives are used for demonstration purposes, make sure to use only one)\n" +
" github: \n" +
" repo-name: EssentialsX/Essentials #### Provided by you #### Can be found in its url: https://github.com/EssentialsX/Essentials\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ public UpdaterConfig() throws IOException, DuplicateKeyException, YamlReaderExce
put(name, "server-updater").setCountTopLineBreaks(1);
server_updater = put(name, "server-updater", "enable").setDefValues("true");

server_updater_profile = put(name, "server-updater", "profile").setDefValues("AUTOMATIC");
server_updater_profile = put(name, "server-updater", "profile").setDefValues("AUTOMATIC").setComments(
"Note that your servers jar/executable NAME will not be updated, even if set to AUTOMATIC, to increase compatibility with external scripts or other programs.",
"The actual content/file will update though, thus rename it to something like server.jar, and do not include version info to prevent confusion.");
server_software = put(name, "server-updater", "software").setDefValues("paper").setComments(
"Select your favorite server software. Enter the name below. Supported software:\n" +
"- Minecraft (paper, waterfall, travertine, velocity, purpur, fabric," +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,54 +33,55 @@ public SearchResult search(String githubRepoName, String githubAssetName, String
latestVersion = latestRelease.get("tag_name").getAsString();
if (latestVersion != null)
latestVersion = latestVersion.replaceAll("[^0-9.]", ""); // Before passing over remove everything except numbers and dots
if (Version.isLatestBigger(version, latestVersion == null ? "0" : latestVersion)) {

if(latestVersion == null) latestVersion = "";
if (Version.isLatestBigger(version, latestVersion == null ? "0" : latestVersion))
resultType = SearchResult.Type.UPDATE_AVAILABLE;
// Contains JsonObjects sorted by their asset-names lengths, from smallest to longest.
// The following does that sorting.
List<JsonObject> sortedArtifactObjects = new ArrayList<>();
for (JsonElement e :
latestRelease.getAsJsonArray("assets")) {
JsonObject obj = e.getAsJsonObject();
String name = obj.get("name").getAsString();
if (sortedArtifactObjects.size() == 0) sortedArtifactObjects.add(obj);
else {
int finalIndex = 0;
boolean isSmaller = false;
for (int i = 0; i < sortedArtifactObjects.size(); i++) {
String n = sortedArtifactObjects.get(i).get("name").getAsString();
if (name.length() < n.length()) {
isSmaller = true;
finalIndex = i;
break;
}

// Contains JsonObjects sorted by their asset-names lengths, from smallest to longest.
// The following does that sorting.
List<JsonObject> sortedArtifactObjects = new ArrayList<>();
for (JsonElement e :
latestRelease.getAsJsonArray("assets")) {
JsonObject obj = e.getAsJsonObject();
String name = obj.get("name").getAsString();
if (sortedArtifactObjects.size() == 0) sortedArtifactObjects.add(obj);
else {
int finalIndex = 0;
boolean isSmaller = false;
for (int i = 0; i < sortedArtifactObjects.size(); i++) {
String n = sortedArtifactObjects.get(i).get("name").getAsString();
if (name.length() < n.length()) {
isSmaller = true;
finalIndex = i;
break;
}
if (!isSmaller) sortedArtifactObjects.add(obj);
else sortedArtifactObjects.add(finalIndex, obj);
}
if (!isSmaller) sortedArtifactObjects.add(obj);
else sortedArtifactObjects.add(finalIndex, obj);
}
}

// Find asset-name containing our provided asset-name
for (JsonObject obj : sortedArtifactObjects) {
String n = obj.get("name").getAsString();
if (n.contains(githubAssetName)) {
fileName = n;
downloadUrl = obj.get("browser_download_url").getAsString();
if (fileName.contains("."))
downloadType = fileName.substring(fileName.lastIndexOf("."));
break;
}
// Find asset-name containing our provided asset-name
for (JsonObject obj : sortedArtifactObjects) {
String n = obj.get("name").getAsString();
if (n.contains(githubAssetName)) {
fileName = n;
downloadUrl = obj.get("browser_download_url").getAsString();
if (fileName.contains("."))
downloadType = fileName.substring(fileName.lastIndexOf("."));
break;
}
}

if (downloadUrl == null) {
List<String> names = new ArrayList<>();
for (JsonObject obj :
sortedArtifactObjects) {
String n = obj.get("name").getAsString();
names.add(n);
}
throw new Exception("Failed to find an asset-name containing '" + githubAssetName + "' inside of " + Arrays.toString(names.toArray()));
if (downloadUrl == null) {
List<String> names = new ArrayList<>();
for (JsonObject obj :
sortedArtifactObjects) {
String n = obj.get("name").getAsString();
names.add(n);
}

throw new Exception("Failed to find an asset-name containing '" + githubAssetName + "' inside of " + Arrays.toString(names.toArray()));
}
} catch (Exception e) {
exception = e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,58 +32,58 @@ public SearchResult search(String project_url, String providedArtifactName, int
JsonObject json_last_successful_build = json_project.get("lastSuccessfulBuild").getAsJsonObject();
latest_build_id = json_last_successful_build.get("number").getAsInt();
latestVersion = String.valueOf(latest_build_id);
if (latest_build_id > build_id) {
if (latest_build_id > build_id)
resultType = SearchResult.Type.UPDATE_AVAILABLE;
String buildUrl = json_last_successful_build.get("url").getAsString();
if (!buildUrl.endsWith("api/json"))
buildUrl = buildUrl + (buildUrl.endsWith("/") ? "" : "/") + "api/json";
JsonArray arrayArtifacts = Json.getAsObject(buildUrl).getAsJsonArray("artifacts");

// Contains JsonObjects sorted by their artifact names lengths, from smallest to longest.
// The following does that sorting.
List<JsonObject> sortedArtifactObjects = new ArrayList<>();
for (JsonElement e :
arrayArtifacts) {
JsonObject obj = e.getAsJsonObject();
String name = obj.get("fileName").getAsString();
if (sortedArtifactObjects.size() == 0) sortedArtifactObjects.add(obj);
else {
int finalIndex = 0;
boolean isSmaller = false;
for (int i = 0; i < sortedArtifactObjects.size(); i++) {
String n = sortedArtifactObjects.get(i).get("fileName").getAsString();
if (name.length() < n.length()) {
isSmaller = true;
finalIndex = i;
break;
}
String buildUrl = json_last_successful_build.get("url").getAsString();
if (!buildUrl.endsWith("api/json"))
buildUrl = buildUrl + (buildUrl.endsWith("/") ? "" : "/") + "api/json";
JsonArray arrayArtifacts = Json.getAsObject(buildUrl).getAsJsonArray("artifacts");

// Contains JsonObjects sorted by their artifact names lengths, from smallest to longest.
// The following does that sorting.
List<JsonObject> sortedArtifactObjects = new ArrayList<>();
for (JsonElement e :
arrayArtifacts) {
JsonObject obj = e.getAsJsonObject();
String name = obj.get("fileName").getAsString();
if (sortedArtifactObjects.size() == 0) sortedArtifactObjects.add(obj);
else {
int finalIndex = 0;
boolean isSmaller = false;
for (int i = 0; i < sortedArtifactObjects.size(); i++) {
String n = sortedArtifactObjects.get(i).get("fileName").getAsString();
if (name.length() < n.length()) {
isSmaller = true;
finalIndex = i;
break;
}
if (!isSmaller) sortedArtifactObjects.add(obj);
else sortedArtifactObjects.add(finalIndex, obj);
}
if (!isSmaller) sortedArtifactObjects.add(obj);
else sortedArtifactObjects.add(finalIndex, obj);
}
}

// Find artifact-name containing our provided artifact-name
for (JsonObject obj : sortedArtifactObjects) {
String n = obj.get("fileName").getAsString();
if (n.contains(providedArtifactName)) {
fileName = n;
download_url = project_url + "/" + latest_build_id + "/artifact/" + obj.get("relativePath").getAsString();
if (fileName.contains("."))
downloadType = fileName.substring(fileName.lastIndexOf("."));
break;
}
// Find artifact-name containing our provided artifact-name
for (JsonObject obj : sortedArtifactObjects) {
String n = obj.get("fileName").getAsString();
if (n.contains(providedArtifactName)) {
fileName = n;
download_url = project_url + "/" + latest_build_id + "/artifact/" + obj.get("relativePath").getAsString();
if (fileName.contains("."))
downloadType = fileName.substring(fileName.lastIndexOf("."));
break;
}
}

if (download_url == null) {
List<String> names = new ArrayList<>();
for (JsonObject obj :
sortedArtifactObjects) {
String n = obj.get("fileName").getAsString();
names.add(n);
}
throw new Exception("Failed to find an artifact-name containing '" + providedArtifactName + "' inside of '" + Arrays.toString(names.toArray()) + "'!");
if (download_url == null) {
List<String> names = new ArrayList<>();
for (JsonObject obj :
sortedArtifactObjects) {
String n = obj.get("fileName").getAsString();
names.add(n);
}
throw new Exception("Failed to find an artifact-name containing '" + providedArtifactName + "' inside of '" + Arrays.toString(names.toArray()) + "'!");
}
} catch (Exception e) {
exception = e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public SearchResult search(MinecraftPlugin plugin) {
latest = json.get("name").getAsString();
if (latest != null)
latest = latest.replaceAll("[^0-9.]", ""); // Before passing over remove everything except numbers and dots

if(latest == null) latest = "";
if (Version.isLatestBigger(plugin.getVersion(), latest))
code = SearchResult.Type.UPDATE_AVAILABLE;

downloadUrl = json.get("downloadUrl").getAsString();
Matcher m = Pattern.compile("[.][^.]+$")
.matcher(json.get("fileName").getAsString());
Expand All @@ -53,9 +58,6 @@ public SearchResult search(MinecraftPlugin plugin) {
code = SearchResult.Type.API_ERROR;
}

if (Version.isLatestBigger(plugin.getVersion(), latest == null ? "0" : latest))
code = SearchResult.Type.UPDATE_AVAILABLE;

AL.debug(this.getClass(), "[" + plugin.getName() + "] Finished check with results: code:" + code + " latest:" + latest + " downloadURL:" + downloadUrl + " type:" + downloadType + " ");
SearchResult result = new SearchResult(plugin, code, latest, downloadUrl, downloadType, null, String.valueOf(bukkitId), false);
result.setException(exception);
Expand Down

0 comments on commit cdacdf6

Please sign in to comment.