Skip to content

Commit cb0886e

Browse files
committed
fix comprasion
1 parent e276b3d commit cb0886e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/main/java/gg/quartzdev/lib/qlibpaper/UpdateChecker.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44
import com.google.gson.JsonElement;
55
import com.google.gson.JsonParser;
66
import gg.quartzdev.lib.qlibpaper.lang.GenericMessages;
7+
import io.papermc.paper.threadedregions.scheduler.AsyncScheduler;
78
import net.kyori.adventure.audience.Audience;
8-
import net.kyori.adventure.text.Component;
99
import org.apache.maven.artifact.versioning.ComparableVersion;
1010
import org.bukkit.Bukkit;
11-
import org.bukkit.command.CommandSender;
1211
import org.bukkit.entity.Player;
1312
import org.bukkit.plugin.java.JavaPlugin;
1413
import org.jetbrains.annotations.Nullable;
1514

16-
import java.awt.*;
1715
import java.io.IOException;
1816
import java.io.InputStream;
1917
import java.net.HttpURLConnection;
@@ -70,7 +68,7 @@ private JsonArray getSupportedVersions(){
7068
}
7169

7270
/**
73-
* Checks for updates asynchronously
71+
* Checks for updates asynchronously using Papers {@link AsyncScheduler}
7472
* @param plugin the instance of the plugin that will be used to run the async task
7573
* @param currentVersion the current version of the plugin
7674
* @param toNotify the {@link Player} to notify the results. The results will always be logged even if this is null
@@ -87,7 +85,7 @@ public void checkForUpdates(String currentVersion, @Nullable Player toNotify){
8785
}
8886
for(JsonElement version : versions){
8987
String versionString = version.getAsJsonObject().get("version_number").getAsString();
90-
if(compareVersionStrings(currentVersion, versionString) == -1){
88+
if(compareVersionStrings(currentVersion, versionString) < 0){
9189
Audience audience = toNotify == null ? Bukkit.getConsoleSender() : Audience.audience(toNotify, Bukkit.getConsoleSender());
9290
Sender.message(audience, GenericMessages.UPDATE_AVAILABLE
9391
.parse("version", versionString).get());
@@ -103,7 +101,7 @@ public void checkForUpdates(String currentVersion, @Nullable Player toNotify){
103101
* Compares two version strings
104102
* @param currentVersion The current version
105103
* @param otherVersion The version to compare to
106-
* @return -1 if currentVersion is older than otherVersion, 0 if they are equal, 1 if currentVersion is newer than otherVersion
104+
* @return less than zero if currentVersion is older than otherVersion, 0 if they are equal, greater than zero if currentVersion is newer than otherVersion
107105
*/
108106
public int compareVersionStrings(String currentVersion, String otherVersion){
109107
ComparableVersion currentVersionComparable = new ComparableVersion(currentVersion);

0 commit comments

Comments
 (0)