Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Use getters instead of inlining
Dieser Commit ist enthalten in:
Ursprung
1129c17489
Commit
c8029bdbdf
@ -71,7 +71,7 @@ public class ProtocolVersion {
|
|||||||
public static ProtocolVersion register(int version, int snapshotVersion, String name, @Nullable VersionRange versionRange) {
|
public static ProtocolVersion register(int version, int snapshotVersion, String name, @Nullable VersionRange versionRange) {
|
||||||
ProtocolVersion protocol = new ProtocolVersion(version, snapshotVersion, name, versionRange);
|
ProtocolVersion protocol = new ProtocolVersion(version, snapshotVersion, name, versionRange);
|
||||||
versionList.add(protocol);
|
versionList.add(protocol);
|
||||||
versions.put(protocol.version, protocol);
|
versions.put(protocol.getVersion(), protocol);
|
||||||
if (protocol.isSnapshot()) {
|
if (protocol.isSnapshot()) {
|
||||||
versions.put(protocol.getFullSnapshotVersion(), protocol);
|
versions.put(protocol.getFullSnapshotVersion(), protocol);
|
||||||
}
|
}
|
||||||
@ -103,19 +103,19 @@ public class ProtocolVersion {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static ProtocolVersion getClosest(String protocol) {
|
public static ProtocolVersion getClosest(String protocol) {
|
||||||
for (ProtocolVersion version : versions.values()) {
|
for (ProtocolVersion version : versions.values()) {
|
||||||
String name = version.name;
|
String name = version.getName();
|
||||||
if (name.equals(protocol)) {
|
if (name.equals(protocol)) {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version.versionWildcard) {
|
if (version.isVersionWildcard()) {
|
||||||
// Test against the major version as well as with the ".x" prefix
|
// Test against the major version as well as with the ".x" prefix
|
||||||
String majorVersion = name.substring(0, name.length() - 2);
|
String majorVersion = name.substring(0, name.length() - 2);
|
||||||
if (majorVersion.equals(protocol) || (protocol.startsWith(name.substring(0, name.length() - 1)))) {
|
if (majorVersion.equals(protocol) || (protocol.startsWith(name.substring(0, name.length() - 1)))) {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
} else if (version.isRange()) {
|
} else if (version.isRange()) {
|
||||||
if (version.includedVersions.contains(protocol)) {
|
if (version.getIncludedVersions().contains(protocol)) {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren