mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 11:35:18 +01:00
Don't require a base protocol for current version in BaseProtocol (#3709)
This commit is contained in:
parent
4e1d4a75b2
commit
7640342165
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user