Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
* Fixed flags being ignored
* Improvements to update checker
  • Loading branch information
Im-Fran committed Aug 14, 2022
1 parent 2037f87 commit 36ca959
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group 'com.songoda'
version '3.2.1'
version '3.2.2'

repositories {
mavenLocal()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/songoda/serverjars/ServerJars.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public static void main(final String[] args) throws IOException, NoSuchAlgorithm
"ServerJars.com Made with love by Songoda <3\n");
Utils.debug("Loading CommandLineHandler...");
isFirstStart = !CFG_FILE.exists();
config.init();
new CommandLineHandler(args);
config.init();
Utils.debug("Initializing configuration...");
config.load();

Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/songoda/serverjars/UpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
import java.util.concurrent.TimeUnit;

public class UpdateChecker {
private static final String GITHUB_PROJECT = "ServerJars/updater";
private static final String API_URL = "https://api.github.com/repos/" + GITHUB_PROJECT + "/releases/latest";
private static final String DOWNLOAD_URL = "https://github.com/" + GITHUB_PROJECT;
private static final String API_URL = "https://api.github.com/repos/ServerJars/Updater/releases/latest";
private static final String DOWNLOAD_URL = "https://github.com/ServerJars/Updater/releases/latest";

public UpdateChecker(ConfigHandler cfg) {
if (cfg.isUpdateAvailable() &&
Expand Down Expand Up @@ -68,7 +67,7 @@ boolean checkForUpdates() throws IOException {

con.setRequestProperty("User-Agent", "ServerJars-Updater/@version@(" +
System.getProperty("os.name") + "; " +
System.getProperty("os.arch") + ") (+https://github.com/ServerJars/updater#readme)");
System.getProperty("os.arch") + ") (+https://github.com/ServerJars/Updater#readme)");

con.setInstanceFollowRedirects(true);

Expand All @@ -87,8 +86,10 @@ boolean checkForUpdates() throws IOException {
version = version.substring(1);
}

String current = "@version@";

try {
return Version.parse(version).compareTo(Version.parse("@version@".startsWith("v") ? "@version@".substring(1) : "@version@")) > 0;
return Version.parse(version).compareTo(Version.parse(current.startsWith("v") ? current.substring(1) : current)) > 0;
} catch (IllegalArgumentException ignore) {
// One of the versions is not a valid SemVer
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public CommandLineHandler(String[] args) {
// Find the option
Option option = Arrays.stream(options).filter(it -> arg.matches(Utils.regexFromGlob(it.getName()))).findFirst().orElse(null);
if (option != null) {
// Check if it's a single option
if (!option.isSingle() && optionsFound == 1) {
if ((!option.isSingle() && optionsFound >= 1) || (option.isSingle() && optionsFound == 1)) {
// Run the option
option.run(arg);
}
Expand Down

0 comments on commit 36ca959

Please sign in to comment.