Skip to content

Commit

Permalink
Fix UpdateHandler?
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Oct 24, 2024
1 parent fc4aa60 commit 1118d5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/main/java/xyz/nifeather/morph/updates/UpdateHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ private void onUpdateReqFinish(String responseStr, int reqId,
throw new NullDependencyException("Null version number from response: " + gson.toJson(matchMeta));
}

if (currentVersion.equals(latestVersion))
var compare = currentVersion.compare(latestVersion);

if (compare == VersionHandling.CompareResult.EQUAL)
{
logger.info("Already on the latest version for " + Bukkit.getMinecraftVersion());

Expand All @@ -210,7 +212,7 @@ private void onUpdateReqFinish(String responseStr, int reqId,
return;
}

if (latestVersion.compare(currentVersion) == VersionHandling.CompareResult.OLDER)
if (compare == VersionHandling.CompareResult.NEWER)
{
logger.info("Your version is newer than released for %s!".formatted(Bukkit.getMinecraftVersion()));

Expand Down
23 changes: 10 additions & 13 deletions src/main/java/xyz/nifeather/morph/updates/VersionHandling.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public boolean equals(Object o)
/**
* 将此版本和另一版本比对
* @param other
* @return
* @return NEWER: other版本比这个版本高,反之OLDER或者EQUAL
*/
public CompareResult compare(VersionInfo other)
{
Expand All @@ -74,20 +74,17 @@ public CompareResult compare(VersionInfo other)
{
return CompareResult.EQUAL;
}
else if (majorCompare == CompareResult.NEWER
|| minorCompare == CompareResult.NEWER
|| patchCompare == CompareResult.NEWER)
{
return CompareResult.OLDER;
}
else if (majorCompare == CompareResult.OLDER
|| minorCompare == CompareResult.OLDER
|| patchCompare == CompareResult.OLDER)
{

if (majorCompare == CompareResult.NEWER)
return CompareResult.NEWER;

if (minorCompare == CompareResult.NEWER)
return CompareResult.NEWER;

if (patchCompare == CompareResult.NEWER)
return CompareResult.NEWER;
}

return CompareResult.NOT_ON_SAME_CHANNEL;
return CompareResult.OLDER;
}

/**
Expand Down

0 comments on commit 1118d5d

Please sign in to comment.