Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,18 @@ private void printVersionInfo(V version) {
@Override
public boolean isSupported(HangarVersion version) {
return version.platformDependencies().get(Platform.PAPER)
.contains(plugin.getServer().getMinecraftVersion());
.contains(plugin.getServer().getMinecraftVersion())
&& (notifySnapshotReleases() || version.);
}

@Override
public boolean notifySnapshotReleases() {
return versionRunning;
}

@Override
public boolean isConsidered(V version) {
return notifySnapshotReleases() || version.preRelease() != null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,11 @@ public interface PluginVersionChecker {
* @see #checkLatestVersion()
*/
void checkVersion();

/**
* Determines whether snapshot releases should trigger notifications.
*
* @return {@code true} if snapshot releases should trigger notifications, otherwise {@code false}
*/
boolean notifySnapshotReleases();
}
10 changes: 10 additions & 0 deletions version-checker/src/main/java/core/version/VersionChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ public interface VersionChecker<N, V extends Version> {
*/
boolean isSupported(N version);

/**
* Determines whether the provided version is considered acceptable based on specific criteria.
*
* @param version the version to evaluate
* @return true if the version meets the criteria, false otherwise
*/
default boolean isConsidered(V version) {
return true;
}

/**
* Asynchronously retrieves the latest available version.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public CompletableFuture<Optional<V>> retrieveLatestSupportedVersion() {
return retrieveGitHubReleases().thenApply(versions -> versions.stream()
.filter(this::isSupported)
.map(this::parseVersion)
.filter(this::isConsidered)
.max(Version::compareTo));
}

Expand All @@ -87,6 +88,7 @@ public Set<V> getSupportedVersions() {
return releases.stream()
.filter(this::isSupported)
.map(this::parseVersion)
.filter(this::isConsidered)
.collect(Collectors.toUnmodifiableSet());
}

Expand All @@ -101,6 +103,7 @@ public Optional<V> getLatestSupportedVersion() {
return releases.stream()
.filter(this::isSupported)
.map(this::parseVersion)
.filter(this::isConsidered)
.max(Version::compareTo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public CompletableFuture<Optional<V>> retrieveLatestSupportedVersion() {
return retrieveHangarVersions().thenApply(versions -> versions.stream()
.filter(this::isSupported)
.map(this::parseVersion)
.filter(this::isConsidered)
.max(Version::compareTo));
}

Expand All @@ -83,6 +84,7 @@ public Set<V> getSupportedVersions() {
return versions.stream()
.filter(this::isSupported)
.map(this::parseVersion)
.filter(this::isConsidered)
.collect(Collectors.toUnmodifiableSet());
}

Expand All @@ -97,6 +99,7 @@ public Optional<V> getLatestSupportedVersion() {
return versions.stream()
.filter(this::isSupported)
.map(this::parseVersion)
.filter(this::isConsidered)
.max(Version::compareTo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public CompletableFuture<Optional<V>> retrieveLatestSupportedVersion() {
return retrieveModrinthVersions().thenApply(versions -> versions.stream()
.filter(this::isSupported)
.map(this::parseVersion)
.filter(this::isConsidered)
.max(Version::compareTo));
}

Expand All @@ -81,6 +82,7 @@ public Set<V> getSupportedVersions() {
return versions.stream()
.filter(this::isSupported)
.map(this::parseVersion)
.filter(this::isConsidered)
.collect(Collectors.toUnmodifiableSet());
}

Expand All @@ -95,6 +97,7 @@ public Optional<V> getLatestSupportedVersion() {
return versions.stream()
.filter(this::isSupported)
.map(this::parseVersion)
.filter(this::isConsidered)
.max(Version::compareTo);
}

Expand Down
Loading