This commit is contained in:
filoghost 2017-03-03 22:19:55 +01:00
parent 20acd2fc82
commit a5c947998b

View File

@ -57,14 +57,11 @@ public final class SimpleUpdater {
JSONArray filesArray = (JSONArray) readJson("https://api.curseforge.com/servermods/files?projectIds=" + projectId); JSONArray filesArray = (JSONArray) readJson("https://api.curseforge.com/servermods/files?projectIds=" + projectId);
if (filesArray.size() == 0) { if (filesArray.size() == 0) {
// The array cannot be empty, there must be at least one file. The project ID is not valid. // The array cannot be empty, there must be at least one file. The project ID is not valid or curse returned a wrong response.
plugin.getLogger().warning("The author of this plugin has misconfigured the Updater system.");
plugin.getLogger().warning("The project ID (" + projectId + ") provided for updating is invalid.");
plugin.getLogger().warning("Please notify the author of this error.");
return; return;
} }
String updateName = (String) ((JSONObject) filesArray.get(filesArray.size() - 1)).get("name"); String updateName = (String) ((JSONObject) filesArray.get(filesArray.size() - 1)).get("name");
final String newVersion = extractVersion(updateName); final String newVersion = extractVersion(updateName);
if (newVersion == null) { if (newVersion == null) {
@ -92,7 +89,7 @@ public final class SimpleUpdater {
plugin.getLogger().warning("Unable to check for updates: unhandled exception."); plugin.getLogger().warning("Unable to check for updates: unhandled exception.");
} }
} }
}); });
updaterThread.start(); updaterThread.start();
} }
@ -129,7 +126,7 @@ public final class SimpleUpdater {
throw new IllegalArgumentException("fetched version's format is incorrect"); throw new IllegalArgumentException("fetched version's format is incorrect");
} }
// Remove all the "v" from the versions, replace multiple full stops with a single full stop, and split them. // Remove all the "v" from the versions, replace multiple full stops with a single full stop, and split them.
String[] pluginVersionSplit = pluginVersion.replace("v", "").replaceAll("[\\.]{2,}", ".").split("\\."); String[] pluginVersionSplit = pluginVersion.replace("v", "").replaceAll("[\\.]{2,}", ".").split("\\.");
String[] remoteVersionSplit = remoteVersion.replace("v", "").replaceAll("[\\.]{2,}", ".").split("\\."); String[] remoteVersionSplit = remoteVersion.replace("v", "").replaceAll("[\\.]{2,}", ".").split("\\.");