diff --git a/pom.xml b/pom.xml
index 9a9b5a34..f576504a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,7 @@
com.osiris.autoplug.client
autoplug-client
- 7.2.24
+ 7.2.25
jar
AutoPlug-Client
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/CurseForgeAPI.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/CurseForgeAPI.java
index 4bc0eb76..14994411 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/CurseForgeAPI.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/CurseForgeAPI.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022 Osiris-Team.
+ * Copyright (c) 2022-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
@@ -45,7 +45,7 @@ public SearchResult searchUpdate(MinecraftMod mod, String mcVersion, boolean che
String type = ".jar";
String downloadUrl = null;
byte code = 0;
- String modInfo = mod.name + "/" + (Server.isFabric ? "fabric" : "forge");
+ String modInfo = mod.getName() + "/" + (Server.isFabric ? "fabric" : "forge");
try {
if (!isIdNumber) { // Determine project id, since we only got slug
try {
@@ -57,7 +57,8 @@ public SearchResult searchUpdate(MinecraftMod mod, String mcVersion, boolean che
}
if (mod.curseforgeId == null) throw new Exception("Failed to determine curseforge-id!");
modInfo += "/" + mod.curseforgeId;
- url = baseUrl + "/mods/" + mod.curseforgeId + "/files?gameVersion=" + mcVersion;
+ url = baseUrl + "/mods/" + mod.curseforgeId + "/files" +
+ (mod.forceLatest ? "" : "?gameVersion=" + mcVersion);
url = new UtilsURL().clean(url);
AL.debug(this.getClass(), modInfo + " fetch details from: " + url);
JsonArray arr;
@@ -65,7 +66,8 @@ public SearchResult searchUpdate(MinecraftMod mod, String mcVersion, boolean che
arr = new CurseForgeJson().getJsonObject(url).get("data").getAsJsonArray();
} catch (Exception e) {
if (!isInt(mod.curseforgeId)) { // Try another url, with slug replaced _ with -
- url = baseUrl + "/mods/" + mod.curseforgeId.replace("_", "-") + "/files?gameVersion=" + mcVersion;
+ url = baseUrl + "/mods/" + mod.curseforgeId.replace("_", "-") + "/files" +
+ (mod.forceLatest ? "" : "?gameVersion=" + mcVersion);
url = new UtilsURL().clean(url);
AL.debug(this.getClass(), modInfo + " fetch details from: " + url);
arr = new CurseForgeJson().getJsonObject(url).get("data").getAsJsonArray();
@@ -83,10 +85,14 @@ public SearchResult searchUpdate(MinecraftMod mod, String mcVersion, boolean che
for (int i = arr.size() - 1; i >= 0; i--) {
JsonObject tempRelease = arr.get(i).getAsJsonObject();
boolean isVersionCompatible = false, isModLoaderCompatible = false;
- for (JsonElement el : tempRelease.get("gameVersions").getAsJsonArray()) {
- if (el.getAsString().equals(mcVersion)) {
- isVersionCompatible = true;
- break;
+ if (mod.forceLatest) {
+ isVersionCompatible = true;
+ } else {
+ for (JsonElement el : tempRelease.get("gameVersions").getAsJsonArray()) {
+ if (el.getAsString().equals(mcVersion)) {
+ isVersionCompatible = true;
+ break;
+ }
}
}
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/MinecraftMod.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/MinecraftMod.java
index 5985422d..abd477bf 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/MinecraftMod.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/MinecraftMod.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022 Osiris-Team.
+ * Copyright (c) 2022-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
@@ -9,18 +9,19 @@
package com.osiris.autoplug.client.tasks.updater.mods;
public class MinecraftMod {
- public String installationPath, name, modrinthId, curseforgeId, customDownloadURL;
+ public String installationPath, modrinthId, curseforgeId, customDownloadURL;
public boolean ignoreContentType;
public String githubRepoName, githubAssetName;
public String jenkinsProjectUrl, jenkinsArtifactName;
public int jenkinsBuildId;
- private String author, version;
+ public boolean forceLatest;
+ private String name, author, version;
public MinecraftMod(String installationPath, String name, String version,
String author, String modrinthId, String curseforgeId,
String customDownloadURL) {
this.installationPath = installationPath;
- this.name = name;
+ setName(name);
setAuthor(author);
setVersion(version);
this.modrinthId = modrinthId;
@@ -28,6 +29,15 @@ public MinecraftMod(String installationPath, String name, String version,
this.customDownloadURL = customDownloadURL;
}
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ if (name != null)
+ this.name = name.replaceAll(":", ""); // Before passing over remove : numbers and dots
+ }
+
public String getVersion() {
return version;
}
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/ModrinthAPI.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/ModrinthAPI.java
index 753bc098..9b8dd416 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/ModrinthAPI.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/ModrinthAPI.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022 Osiris-Team.
+ * Copyright (c) 2022-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
@@ -59,7 +59,7 @@ public SearchResult searchUpdate(MinecraftMod mod, String mcVersion) {
if (!isInt(mod.modrinthId)) { // Try another url, with slug replaced _ with -
url = baseUrl + "/project/" + mod.modrinthId.replace("_", "-")
+ "/version?loaders=[\"" +
- (Server.isFabric ? "fabric" : "forge") + "\"]&game_versions=[\"" + mcVersion + "\"]";
+ (Server.isFabric ? "fabric" : "forge") + "\"]" + (mod.forceLatest ? "" : "&game_versions=[\"" + mcVersion + "\"]");
AL.debug(this.getClass(), url);
release = Json.getAsJsonArray(url)
.get(0).getAsJsonObject();
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/TaskModsUpdater.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/TaskModsUpdater.java
index d13d4056..cd1cc90c 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/TaskModsUpdater.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/TaskModsUpdater.java
@@ -91,6 +91,8 @@ public void runAtStart() throws Exception {
"If there are mods that weren't found by the search-algorithm, you can add an id (spigot or bukkit) and a custom link (optional & must be a static link to the latest mod jar).\n" +
"modrinth-id: Is the 'Project-ID' and can be found on the mods modrinth site inside of the 'About' box, under 'Technical Information' at the bottom left.\n" +
"curseforge-id: Is also called 'Project-ID' and can be found on the mods curseforge site inside of the 'About' box at the right.\n" +
+ "ignore-content-type: If true, does not check if the downloaded file is of type jar or zip, and downloads it anyway.\n" +
+ "force-latest: If true, does not search for updates compatible with this Minecraft version and simply picks the latest release.\n" +
"custom-download-url: must be a static url to the mods latest jar file.\n" +
"alternatives.github.repo-name: Example: 'EssentialsX/Essentials' (can be found in its url: https://github.com/EssentialsX/Essentials)\n" +
"alternatives.github.asset-name: Example: 'EssentialsX' (wrong: 'EssentialsX-1.7.23.jar', we discard the version info).\n" +
@@ -117,8 +119,8 @@ public void runAtStart() throws Exception {
for (MinecraftMod installedMod :
allMods) {
try {
- final String plName = installedMod.name;
- if (installedMod.name == null || installedMod.name.isEmpty())
+ final String plName = installedMod.getName();
+ if (installedMod.getName() == null || installedMod.getName().isEmpty())
throw new Exception("The mods name couldn't be determined for '" + installedMod.installationPath + "'!");
YamlSection exclude = modsConfig.put(name, plName, "exclude").setDefValues("false");
@@ -128,6 +130,7 @@ public void runAtStart() throws Exception {
YamlSection modrinthId = modsConfig.put(name, plName, "modrinth-id");
YamlSection curseforgeId = modsConfig.put(name, plName, "curseforge-id");
YamlSection ignoreContentType = modsConfig.put(name, plName, "ignore-content-type").setDefValues("false");
+ YamlSection forceLatest = modsConfig.put(name, plName, "force-latest").setDefValues("false");
YamlSection customDownloadURL = modsConfig.put(name, plName, "custom-download-url");
YamlSection githubRepoUrl = modsConfig.put(name, plName, "alternatives", "github", "repo-name");
YamlSection githubAssetName = modsConfig.put(name, plName, "alternatives", "github", "asset-name");
@@ -142,6 +145,7 @@ public void runAtStart() throws Exception {
installedMod.modrinthId = modrinthId.asString();
installedMod.curseforgeId = (curseforgeId.asString());
installedMod.ignoreContentType = (ignoreContentType.asBoolean());
+ installedMod.forceLatest = (forceLatest.asBoolean());
installedMod.customDownloadURL = (customDownloadURL.asString());
installedMod.githubRepoName = (githubRepoUrl.asString());
installedMod.githubAssetName = (githubAssetName.asString());
@@ -154,7 +158,7 @@ public void runAtStart() throws Exception {
&& (modrinthId.asString() == null)
&& (curseforgeId.asString() == null)) {
exclude.setValues("true");
- this.addWarning("Mod " + installedMod.name + " is missing 'version' in its internal config file and was excluded.");
+ this.addWarning("Mod " + installedMod.getName() + " is missing 'version' in its internal config file and was excluded.");
}
// Check for missing version in internal config
@@ -164,7 +168,7 @@ public void runAtStart() throws Exception {
&& jenkinsArtifactName.asString() == null
&& githubAssetName.asString() == null) {
exclude.setValues("true");
- this.addWarning("Mod " + installedMod.name + " is missing 'author' or 'authors' in its internal config file and was excluded.");
+ this.addWarning("Mod " + installedMod.getName() + " is missing 'author' or 'authors' in its internal config file and was excluded.");
}
if (exclude.asBoolean())
@@ -172,7 +176,7 @@ public void runAtStart() throws Exception {
else
includedMods.add(installedMod);
} catch (DuplicateKeyException e) {
- addWarning(new BWarning(this, e, "Duplicate mod '" + installedMod.name + "' (or mod name from its internal config) found in your mods directory. " +
+ addWarning(new BWarning(this, e, "Duplicate mod '" + installedMod.getName() + "' (or mod name from its internal config) found in your mods directory. " +
"Its recommended to remove it."));
} catch (Exception e) {
addWarning(new BWarning(this, e));
@@ -220,7 +224,7 @@ public void runAtStart() throws Exception {
for (MinecraftMod mod :
includedMods) {
try {
- setStatus("Initialising update check for " + mod.name + "...");
+ setStatus("Initialising update check for " + mod.getName() + "...");
if (mod.jenkinsProjectUrl != null) { // JENKINS MOD
sizeJenkinsMods++;
activeFutures.add(executorService.submit(() -> new ResourceFinder().findByJenkinsUrl(mod)));
@@ -234,7 +238,7 @@ public void runAtStart() throws Exception {
activeFutures.add(executorService.submit(() -> new ResourceFinder().findByModrinthOrCurseforge(mod, finalMcVersion, updaterConfig.mods_update_check_name_for_mod_loader.asBoolean())));
}
} catch (Exception e) {
- this.getWarnings().add(new BWarning(this, e, "Critical error while searching for update for '" + mod.name + "' mod!"));
+ this.getWarnings().add(new BWarning(this, e, "Critical error while searching for update for '" + mod.getName() + "' mod!"));
}
}
@@ -254,33 +258,33 @@ public void runAtStart() throws Exception {
activeFutures.remove(finishedFuture);
SearchResult result = finishedFuture.get();
results.add(result);
- MinecraftMod pl = result.mod;
+ MinecraftMod mod = result.mod;
byte code = result.getResultCode();
String type = result.getDownloadType(); // The file type to download (Note: When 'external' is returned nothing will be downloaded. Working on a fix for this!)
String latest = result.getLatestVersion(); // The latest version as String
String downloadUrl = result.getDownloadUrl(); // The download url for the latest version
String resultmodrinthId = result.getSpigotId();
String resultBukkitId = result.getBukkitId();
- this.setStatus("Checked '" + pl.name + "' mod (" + results.size() + "/" + includedSize + ")");
+ this.setStatus("Checked '" + mod.getName() + "' mod (" + results.size() + "/" + includedSize + ")");
if (code == 0 || code == 1) {
- doDownloadLogic(pl, result);
+ doDownloadLogic(mod, result);
} else if (code == 2)
if (result.getException() != null)
- getWarnings().add(new BWarning(this, result.getException(), "There was an api-error for " + pl.name + "!"));
+ getWarnings().add(new BWarning(this, result.getException(), "There was an api-error for " + mod.getName() + "!"));
else
- getWarnings().add(new BWarning(this, new Exception("There was an api-error for " + pl.name + "!")));
+ getWarnings().add(new BWarning(this, new Exception("There was an api-error for " + mod.getName() + "!")));
else if (code == 3)
- getWarnings().add(new BWarning(this, new Exception("Mod " + pl.name + " was not found by the search-algorithm! Specify an id in /autoplug/mods.yml file.")));
+ getWarnings().add(new BWarning(this, new Exception("Mod " + mod.getName() + " was not found by the search-algorithm! Specify an id in /autoplug/mods.yml file.")));
else
getWarnings().add(new BWarning(this, new Exception("Unknown error occurred! Code: " + code + "."), "Notify the developers. Fastest way is through discord (https://discord.gg/GGNmtCC)."));
try {
- YamlSection mmodrinthId = modsConfig.get(modsConfigName, pl.name, "modrinth-id");
+ YamlSection mmodrinthId = modsConfig.get(modsConfigName, mod.getName(), "modrinth-id");
if (resultmodrinthId != null
&& (mmodrinthId.asString() == null || mmodrinthId.asInt() == 0)) // Because we can get a "null" string from the server
mmodrinthId.setValues(resultmodrinthId);
- YamlSection mBukkitId = modsConfig.get(modsConfigName, pl.name, "bukkit-id");
+ YamlSection mBukkitId = modsConfig.get(modsConfigName, mod.getName(), "bukkit-id");
if (resultBukkitId != null
&& (mmodrinthId.asString() == null || mmodrinthId.asInt() == 0)) // Because we can get a "null" string from the server
mBukkitId.setValues(resultBukkitId);
@@ -309,7 +313,7 @@ else if (code == 3)
SearchResult matchingResult = null;
for (SearchResult result :
results) {
- if (result.mod.name.equals(download.getPlName())) {
+ if (result.mod.getName().equals(download.getPlName())) {
matchingResult = result;
break;
}
@@ -318,9 +322,9 @@ else if (code == 3)
throw new Exception("This should not happen! Please report to the devs!");
if (download.mod.modrinthId != null)
- modsConfig.put(modsConfigName, download.mod.name, "modrinth-id").setValues(download.mod.modrinthId);
+ modsConfig.put(modsConfigName, download.mod.getName(), "modrinth-id").setValues(download.mod.modrinthId);
if (download.mod.curseforgeId != null)
- modsConfig.put(modsConfigName, download.mod.name, "modrinth-id").setValues(download.mod.curseforgeId);
+ modsConfig.put(modsConfigName, download.mod.getName(), "modrinth-id").setValues(download.mod.curseforgeId);
if (download.isDownloadSuccessful())
matchingResult.setResultCode((byte) 5);
@@ -369,29 +373,29 @@ private void doDownloadLogic(@NotNull MinecraftMod mod, SearchResult result) {
if (mod.customDownloadURL != null) downloadUrl = mod.customDownloadURL;
if (code == 0) {
- //getSummary().add("Mod " +pl.name+ " is already on the latest version (" + pl.getVersion() + ")"); // Only for testing right now
+ //getSummary().add("Mod " +pl.getName()+ " is already on the latest version (" + pl.getVersion() + ")"); // Only for testing right now
} else {
updatesAvailable++;
try {
// Update the in-memory config
- YamlSection mLatest = modsConfig.get(modsConfigName, mod.name, "latest-version");
+ YamlSection mLatest = modsConfig.get(modsConfigName, mod.getName(), "latest-version");
mLatest.setValues(latest); // Gets saved later
} catch (Exception e) {
getWarnings().add(new BWarning(this, e));
}
if (userProfile.equals(notifyProfile)) {
- addInfo("NOTIFY: Mod '" + mod.name + "' has an update available (" + mod.getVersion() + " -> " + latest + "). Download url: " + downloadUrl);
+ addInfo("NOTIFY: Mod '" + mod.getName() + "' has an update available (" + mod.getVersion() + " -> " + latest + "). Download url: " + downloadUrl);
} else {
// Make sure that plName and plLatestVersion do not contain any slashes (/ or \) that could break the file name
UtilsFile utilsFile = new UtilsFile();
- mod.name = utilsFile.getValidFileName(mod.name);
+ mod.setName(utilsFile.getValidFileName(mod.getName()));
latest = utilsFile.getValidFileName(latest);
if (type.equals(".jar") || type.equals("external")) { // Note that "external" support is kind off random and strongly dependent on what modrinth devs are doing
if (userProfile.equals(manualProfile)) {
- File cache_dest = new File(GD.WORKING_DIR + "/autoplug/downloads/" + mod.name + "[" + latest + "].jar");
- TaskModDownload task = new TaskModDownload("ModDownloader", getManager(), mod.name,
+ File cache_dest = new File(GD.WORKING_DIR + "/autoplug/downloads/" + mod.getName() + "[" + latest + "].jar");
+ TaskModDownload task = new TaskModDownload("ModDownloader", getManager(), mod.getName(),
latest, downloadUrl, mod.ignoreContentType, userProfile, cache_dest);
task.mod = mod;
task.searchResult = result;
@@ -399,8 +403,8 @@ private void doDownloadLogic(@NotNull MinecraftMod mod, SearchResult result) {
task.start();
} else {
File oldPl = new File(mod.installationPath);
- File dest = new File(GD.WORKING_DIR + "/mods/" + mod.name + "-LATEST-" + "[" + latest + "]" + ".jar");
- TaskModDownload task = new TaskModDownload("ModDownloader", getManager(), mod.name,
+ File dest = new File(GD.WORKING_DIR + "/mods/" + mod.getName() + "-LATEST-" + "[" + latest + "]" + ".jar");
+ TaskModDownload task = new TaskModDownload("ModDownloader", getManager(), mod.getName(),
latest, downloadUrl, mod.ignoreContentType, userProfile, dest, oldPl);
task.mod = mod;
task.searchResult = result;
@@ -408,7 +412,7 @@ private void doDownloadLogic(@NotNull MinecraftMod mod, SearchResult result) {
task.start();
}
} else
- getWarnings().add(new BWarning(this, new Exception("Failed to download mod update(" + latest + ") for " + mod.name + " because of unsupported type: " + type)));
+ getWarnings().add(new BWarning(this, new Exception("Failed to download mod update(" + latest + ") for " + mod.getName() + " because of unsupported type: " + type)));
}
}
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/MinecraftPlugin.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/MinecraftPlugin.java
index 6a010a1b..8e4d60d1 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/MinecraftPlugin.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/MinecraftPlugin.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Osiris-Team.
+ * Copyright (c) 2021-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
@@ -113,7 +113,8 @@ public String getName() {
}
public void setName(String name) {
- this.name = name;
+ if (name != null)
+ this.name = name.replaceAll(":", ""); // Before passing over remove :
}
public String getVersion() {
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/GithubSearch.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/GithubSearch.java
index 7c7faae5..6fe4dfe1 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/GithubSearch.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/GithubSearch.java
@@ -33,7 +33,7 @@ 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 (new UtilsVersion().compare(version, latestVersion)) {
+ if (new UtilsVersion().isSecondBigger(version, latestVersion)) {
resultCode = 1;
// Contains JsonObjects sorted by their asset-names lengths, from smallest to longest.
// The following does that sorting.
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/bukkit/Bukkit.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/bukkit/Bukkit.java
index 04bdeff1..a4983491 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/bukkit/Bukkit.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/bukkit/Bukkit.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Osiris-Team.
+ * Copyright (c) 2021-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
@@ -75,7 +75,7 @@ public String search(String pl_name, String pl_version) {
boolean resultVersion;
OUTPUT_PLUGIN_VERSION = latest.get("name").toString(); //API is just shit
AL.info("Comparing versions: " + OUTPUT_PLUGIN_VERSION + " with " + pl_version);
- resultVersion = new UtilsVersion().compare(pl_version, OUTPUT_PLUGIN_VERSION); // result = true
+ resultVersion = new UtilsVersion().isSecondBigger(pl_version, OUTPUT_PLUGIN_VERSION); // result = true
if (resultVersion) {
AL.info("New Version found for: " + INPUT_PLUGIN_NAME + " From -> " + pl_version + " to -> " + OUTPUT_PLUGIN_VERSION);
String final_url = latest.get("downloadUrl").toString();
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/bukkit/BukkitSearchById.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/bukkit/BukkitSearchById.java
index 537eb280..fe4879b8 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/bukkit/BukkitSearchById.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/bukkit/BukkitSearchById.java
@@ -53,7 +53,7 @@ public SearchResult search(MinecraftPlugin plugin) {
code = 2;
}
- if (new UtilsVersion().compare(plugin.getVersion(), latest)) code = 1;
+ if (new UtilsVersion().isSecondBigger(plugin.getVersion(), latest)) code = 1;
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);
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/spigot/SpigotSearchById.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/spigot/SpigotSearchById.java
index 7a581ff1..0e367d3e 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/spigot/SpigotSearchById.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/spigot/SpigotSearchById.java
@@ -46,7 +46,7 @@ public SearchResult search(MinecraftPlugin plugin) {
// If not external download over the spiget api
downloadUrl = "https://api.spiget.org/v2/resources/" + spigotId + "/download";
- if (new UtilsVersion().compare(plugin.getVersion(), latest))
+ if (new UtilsVersion().isSecondBigger(plugin.getVersion(), latest))
code = 1;
} catch (Exception e) {
exception = e;
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/self/TaskSelfUpdater.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/self/TaskSelfUpdater.java
index 01fe24fd..92a801ea 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/self/TaskSelfUpdater.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/self/TaskSelfUpdater.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Osiris-Team.
+ * Copyright (c) 2021-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
@@ -97,7 +97,7 @@ private void doUpdating(String url) throws Exception {
// Check if the latest version is bigger than our current one.
File downloadsDir = new File(GD.WORKING_DIR + "/autoplug/downloads");
downloadsDir.mkdirs();
- if (!(new UtilsVersion().compare(currentVersion, version))) {
+ if (!(new UtilsVersion().isSecondBigger(currentVersion, version))) {
finish("AutoPlug is on the latest version!");
return;
}
diff --git a/src/main/java/com/osiris/autoplug/client/utils/UtilsConfig.java b/src/main/java/com/osiris/autoplug/client/utils/UtilsConfig.java
index a473a7a2..71c558a7 100644
--- a/src/main/java/com/osiris/autoplug/client/utils/UtilsConfig.java
+++ b/src/main/java/com/osiris/autoplug/client/utils/UtilsConfig.java
@@ -33,6 +33,9 @@
*/
public class UtilsConfig {
+ private final List ymlServerKeys = new GeneralConfig().server_key.getKeys();
+ private final List ymlSteamLogin = new UpdaterConfig().server_steamcmd_login.getKeys();
+
public UtilsConfig() throws NotLoadedException, YamlReaderException, YamlWriterException, IOException, IllegalKeyException, DuplicateKeyException, IllegalListException {
}
@@ -72,9 +75,6 @@ public void checkForDeprecatedSections(Yaml yaml) throws YamlWriterException, IO
yaml.unlockFile();
}
- private final List ymlServerKeys = new GeneralConfig().server_key.getKeys();
- private final List ymlSteamLogin = new UpdaterConfig().server_steamcmd_login.getKeys();
-
public void printAllModulesToDebugExceptServerKey(@NotNull List modules, String serverKey) {
try {
UtilsYamlSection utils = new UtilsYamlSection();
diff --git a/src/main/java/com/osiris/autoplug/client/utils/UtilsVersion.java b/src/main/java/com/osiris/autoplug/client/utils/UtilsVersion.java
index 40e600c8..4ef43d08 100644
--- a/src/main/java/com/osiris/autoplug/client/utils/UtilsVersion.java
+++ b/src/main/java/com/osiris/autoplug/client/utils/UtilsVersion.java
@@ -16,41 +16,41 @@
public class UtilsVersion {
/**
- * Compares the current version with the latest
- * version and returns true if the latest version is
- * bigger than the current version.
+ * Compares the first version with the second
+ * version and returns true if the second version is
+ * bigger than the first version.
*
- * @param currentVersion
- * @param latestVersion
+ * @param firstVersion
+ * @param secondVersion
* @return
*/
- public boolean compare(@Nullable String currentVersion, @Nullable String latestVersion) {
+ public boolean isSecondBigger(@Nullable String firstVersion, @Nullable String secondVersion) {
try {
- Objects.requireNonNull(currentVersion);
- Objects.requireNonNull(latestVersion);
+ Objects.requireNonNull(firstVersion);
+ Objects.requireNonNull(secondVersion);
// First duplicate the strings so the original ones don't get altered
- String currentVersionDUPLICATE = currentVersion;
- String latestVersionDUPLICATE = latestVersion;
+ String firstVersionDUPLICATE = firstVersion;
+ String secondVersionDUPLICATE = secondVersion;
// Remove left and right spaces
- currentVersionDUPLICATE = currentVersionDUPLICATE.trim();
- latestVersionDUPLICATE = latestVersionDUPLICATE.trim();
+ firstVersionDUPLICATE = firstVersionDUPLICATE.trim();
+ secondVersionDUPLICATE = secondVersionDUPLICATE.trim();
- if (!currentVersionDUPLICATE.contains(".") && !latestVersionDUPLICATE.contains(".")) {
- return Integer.parseInt(latestVersionDUPLICATE) > Integer.parseInt(currentVersionDUPLICATE);
+ if (!firstVersionDUPLICATE.contains(".") && !secondVersionDUPLICATE.contains(".")) {
+ return Integer.parseInt(secondVersionDUPLICATE) > Integer.parseInt(firstVersionDUPLICATE);
}
// Remove everything except numbers and dots
- currentVersionDUPLICATE = currentVersionDUPLICATE.replaceAll("[^0-9.]", "");
- latestVersionDUPLICATE = latestVersionDUPLICATE.replaceAll("[^0-9.]", "");
+ firstVersionDUPLICATE = firstVersionDUPLICATE.replaceAll("[^0-9.]", "");
+ secondVersionDUPLICATE = secondVersionDUPLICATE.replaceAll("[^0-9.]", "");
- if (currentVersionDUPLICATE.isEmpty()) throw new Exception("Empty currentVersion string!");
- if (latestVersionDUPLICATE.isEmpty()) throw new Exception("Empty latestVersion string!");
+ if (firstVersionDUPLICATE.isEmpty()) throw new Exception("Empty currentVersion string!");
+ if (secondVersionDUPLICATE.isEmpty()) throw new Exception("Empty latestVersion string!");
// If there are dots in the string we split it up
- String[] arrCurrent = currentVersionDUPLICATE.split("\\.");
- String[] arrLatest = latestVersionDUPLICATE.split("\\.");
+ String[] arrCurrent = firstVersionDUPLICATE.split("\\.");
+ String[] arrLatest = secondVersionDUPLICATE.split("\\.");
// Latest version is shorter thus current version is newer.
if (arrLatest.length == arrCurrent.length) {