Skip to content

Commit f9ff893

Browse files
committed
Changes to updater
1 parent 37aa7bf commit f9ff893

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.xxmicloxx</groupId>
77
<artifactId>NoteBlockAPI</artifactId>
8-
<version>1.3</version>
8+
<version>1.3-SNAPSHOT</version>
99
<name>NoteBlockAPI</name>
1010

1111
<properties>

src/main/java/com/xxmicloxx/NoteBlockAPI/NoteBlockAPI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void run() {
151151
}
152152
}, 1);
153153

154-
getServer().getScheduler().runTaskLaterAsynchronously(this, new Runnable() {
154+
getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
155155

156156
@Override
157157
public void run() {
@@ -163,7 +163,7 @@ public void run() {
163163
Bukkit.getLogger().info(String.format("[%s] Cannot receive update from Spigot resource page!", plugin.getDescription().getName()));
164164
}
165165
}
166-
}, 20*10);
166+
}, 20*10, 20 * 60 * 60 * 24);
167167

168168
new MathUtils();
169169
}

src/main/java/com/xxmicloxx/NoteBlockAPI/utils/Updater.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99

1010
public class Updater {
1111

12-
public static boolean checkUpdate(String resource, String actualVersion) throws MalformedURLException, IOException{
12+
public static boolean checkUpdate(String resource, String actualVersion) throws MalformedURLException, IOException{
13+
boolean snapshot = false;
14+
if (actualVersion.contains("-SNAPSHOT")){
15+
snapshot = true;
16+
actualVersion = actualVersion.replace("-SNAPSHOT","");
17+
}
18+
1319
Float version = getVersionNumber(actualVersion);
1420

1521
URLConnection con = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + resource).openConnection();
@@ -19,7 +25,7 @@ public static boolean checkUpdate(String resource, String actualVersion) throws
1925

2026
Float newVer = getVersionNumber(newVersion);
2127

22-
return newVer > version;
28+
return snapshot ? newVer >= version : newVer > version;
2329
}
2430

2531
private static Float getVersionNumber(String version){

0 commit comments

Comments
 (0)