3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-07-03 22:18:04 +02:00

Don't require a base protocol for current version in BaseProtocol (#3709)

Dieser Commit ist enthalten in:
EnZaXD 2024-02-23 15:13:33 +01:00 committet von GitHub
Ursprung 4e1d4a75b2
Commit 7640342165
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
3 geänderte Dateien mit 11 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -78,10 +78,9 @@ public interface ProtocolManager {
* The standard base protocols deal with status and login packets for userconnection initialization.
*
* @param serverVersion server protocol version
* @return base protocol for the given server protocol version
* @throws IllegalStateException if no base protocol could be found
* @return base protocol for the given server protocol version if present, else null
*/
Protocol getBaseProtocol(ProtocolVersion serverVersion);
@Nullable Protocol getBaseProtocol(ProtocolVersion serverVersion);
/**
* Returns an immutable collection of registered protocols.

Datei anzeigen

@ -363,13 +363,13 @@ public class ProtocolManagerImpl implements ProtocolManager {
}
@Override
public Protocol getBaseProtocol(ProtocolVersion serverVersion) {
public @Nullable Protocol getBaseProtocol(ProtocolVersion serverVersion) {
for (Pair<Range<ProtocolVersion>, Protocol> rangeProtocol : Lists.reverse(baseProtocols)) {
if (rangeProtocol.key().contains(serverVersion)) {
return rangeProtocol.value();
}
}
throw new IllegalStateException("No Base Protocol for " + serverVersion);
return null;
}
@Override

Datei anzeigen

@ -80,8 +80,14 @@ public class BaseProtocol extends AbstractProtocol<BaseClientboundPacket, BaseCl
// Add Base Protocol
ProtocolPipeline pipeline = info.getPipeline();
// Special versions might compare equal to normal versions and would break this getter
if (serverProtocol.getVersionType() != VersionType.SPECIAL) {
pipeline.add(protocolManager.getBaseProtocol(serverProtocol));
final Protocol baseProtocol = protocolManager.getBaseProtocol(serverProtocol);
// Platforms might add their base protocol manually (e.g. SPECIAL versions)
if (baseProtocol != null) {
pipeline.add(baseProtocol);
}
}
// Add other protocols