This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Former-commit-id: d6d77aa
- Loading branch information
xishift
committed
Jul 13, 2020
1 parent
991248b
commit 01a8948
Showing
8 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4.0.1 | ||
5.0.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/me/ishift/epicguard/core/task/UpdateCheckerTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package me.ishift.epicguard.core.task; | ||
|
||
import me.ishift.epicguard.core.EpicGuard; | ||
import me.ishift.epicguard.core.util.UpdateChecker; | ||
|
||
public class UpdateCheckerTask implements Runnable { | ||
private final EpicGuard epicGuard; | ||
|
||
public UpdateCheckerTask(EpicGuard epicGuard) { | ||
this.epicGuard = epicGuard; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
UpdateChecker.checkForUpdates(this.epicGuard); | ||
|
||
if (UpdateChecker.isAvailable()) { | ||
this.epicGuard.getLogger().info("New update is available"); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/me/ishift/epicguard/core/util/UpdateChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package me.ishift.epicguard.core.util; | ||
|
||
import me.ishift.epicguard.core.EpicGuard; | ||
|
||
public final class UpdateChecker { | ||
private static final String CHECK_URL = "https://raw.githubusercontent.com/xishift/EpicGuard/master/files/version.info"; | ||
private static String remoteVersion; | ||
private static boolean available; | ||
|
||
public static void checkForUpdates(EpicGuard epicGuard) { | ||
remoteVersion = URLUtils.readString(CHECK_URL); | ||
int latest = Integer.parseInt(remoteVersion.replace(".", "")); | ||
int current = Integer.parseInt(epicGuard.getVersion().replace(".", "")); | ||
|
||
available = latest > current; | ||
} | ||
|
||
public static boolean isAvailable() { | ||
return available; | ||
} | ||
|
||
public static String getRemoteVersion() { | ||
return remoteVersion; | ||
} | ||
|
||
private UpdateChecker() {} | ||
} |