Skip to content

Commit

Permalink
Update modrinth version checker to find version info instead of build…
Browse files Browse the repository at this point in the history
… date
  • Loading branch information
Blast-MC committed Dec 15, 2023
1 parent 48c134e commit 3136aa7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jar {

manifest {
attributes(
'Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ").format(new Date())
'Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").format(new Date())
)
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/gg/projecteden/titan/update/TitanUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,13 @@ public static void checkForUpdates() {
Titan.log("Found " + modrinthVersions.size() + " possible version" + (modrinthVersions.size() == 1 ? "" : "s"));

ModrinthVersion modrinthVersion = modrinthVersions.stream()
// Build Date will always be before the modrinth publish date. Check that the new version is at least 2 minutes older than current
.filter(version -> {
long diffInMillies = Math.abs(buildDate.getTime() - version.getDatePublished().getTime());
long diff = TimeUnit.MINUTES.convert(diffInMillies, TimeUnit.MILLISECONDS);
return diff >= 2;
})
.min(Comparator.comparing(ModrinthVersion::getDatePublished))
.max(Comparator.comparing(ModrinthVersion::getDatePublished))
.orElse(null);

if (modrinthVersion == null)
return;

if (buildDate.after(modrinthVersion.getDatePublished()))
if (modrinthVersion.getVersion_number().equals(Titan.version()))
return;

Titan.log("Found Modrinth update!");
Expand Down

0 comments on commit 3136aa7

Please sign in to comment.