3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 09:00:09 +01:00

Use existing ProtocolVersion#getProtocol when possible (#3720)

Dieser Commit ist enthalten in:
EnZaXD 2024-02-27 14:02:16 +01:00 committet von GitHub
Ursprung 26a8e5fef1
Commit 3c0930c62f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
3 geänderte Dateien mit 5 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -139,7 +139,7 @@ public interface ProtocolManager {
@Deprecated @Deprecated
default @Nullable List<ProtocolPathEntry> getProtocolPath(int clientVersion, int serverVersion) { default @Nullable List<ProtocolPathEntry> getProtocolPath(int clientVersion, int serverVersion) {
return getProtocolPath(ProtocolVersion.getProtocol(VersionType.RELEASE, clientVersion), ProtocolVersion.getProtocol(VersionType.RELEASE, serverVersion)); return getProtocolPath(ProtocolVersion.getProtocol(clientVersion), ProtocolVersion.getProtocol(serverVersion));
} }
/** /**

Datei anzeigen

@ -162,7 +162,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
private BlockedProtocolVersions loadBlockedProtocolVersions() { private BlockedProtocolVersions loadBlockedProtocolVersions() {
List<Integer> blockProtocols = getListSafe("block-protocols", Integer.class, "Invalid blocked version protocol found in config: '%s'"); List<Integer> blockProtocols = getListSafe("block-protocols", Integer.class, "Invalid blocked version protocol found in config: '%s'");
List<String> blockVersions = getListSafe("block-versions", String.class, "Invalid blocked version found in config: '%s'"); List<String> blockVersions = getListSafe("block-versions", String.class, "Invalid blocked version found in config: '%s'");
ObjectSet<ProtocolVersion> blockedProtocols = blockProtocols.stream().map(integer -> ProtocolVersion.getProtocol(VersionType.RELEASE, integer)).collect(ObjectOpenHashSet::of, ObjectSet::add, ObjectSet::addAll); ObjectSet<ProtocolVersion> blockedProtocols = blockProtocols.stream().map(ProtocolVersion::getProtocol).collect(ObjectOpenHashSet::of, ObjectSet::add, ObjectSet::addAll);
ProtocolVersion lowerBound = ProtocolVersion.unknown; ProtocolVersion lowerBound = ProtocolVersion.unknown;
ProtocolVersion upperBound = ProtocolVersion.unknown; ProtocolVersion upperBound = ProtocolVersion.unknown;
for (String s : blockVersions) { for (String s : blockVersions) {

Datei anzeigen

@ -45,20 +45,20 @@ public abstract class AbstractProtocolDetectorService implements ProtocolDetecto
lock.readLock().unlock(); lock.readLock().unlock();
} }
if (detectedProtocol != -1) { if (detectedProtocol != -1) {
return ProtocolVersion.getProtocol(VersionType.RELEASE, detectedProtocol); return ProtocolVersion.getProtocol(detectedProtocol);
} }
// Step 2. Check config (CME moment?) // Step 2. Check config (CME moment?)
final Map<String, Integer> servers = configuredServers(); final Map<String, Integer> servers = configuredServers();
final Integer protocol = servers.get(serverName); final Integer protocol = servers.get(serverName);
if (protocol != null) { if (protocol != null) {
return ProtocolVersion.getProtocol(VersionType.RELEASE, protocol); return ProtocolVersion.getProtocol(protocol);
} }
// Step 3. Use Default (CME moment intensifies?) // Step 3. Use Default (CME moment intensifies?)
final Integer defaultProtocol = servers.get("default"); final Integer defaultProtocol = servers.get("default");
if (defaultProtocol != null) { if (defaultProtocol != null) {
return ProtocolVersion.getProtocol(VersionType.RELEASE, defaultProtocol); return ProtocolVersion.getProtocol(defaultProtocol);
} }
// Step 4: Use the proxy's lowest supported... *cries* // Step 4: Use the proxy's lowest supported... *cries*