Greatly improved performance when checking VersionRanges

This commit is contained in:
RaphiMC 2024-06-21 15:23:06 +02:00
parent 4279e089b7
commit 02044a0511
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94

View File

@ -61,7 +61,9 @@ public class VersionRange {
}
public boolean contains(final ProtocolVersion version) {
if (this.ranges.stream().anyMatch(range -> range.contains(version))) return true;
for (VersionRange range : this.ranges) {
if (range.contains(version)) return true;
}
if (this.min == null && this.max == null) return true;
else if (this.min == null) return version.olderThanOrEqualTo(this.max);
else if (this.max == null) return version.newerThanOrEqualTo(this.min);