Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 16:40:10 +01:00
Don't require a base protocol for current version in BaseProtocol (#3709)
Dieser Commit ist enthalten in:
Ursprung
4e1d4a75b2
Commit
7640342165
@ -78,10 +78,9 @@ public interface ProtocolManager {
|
|||||||
* The standard base protocols deal with status and login packets for userconnection initialization.
|
* The standard base protocols deal with status and login packets for userconnection initialization.
|
||||||
*
|
*
|
||||||
* @param serverVersion server protocol version
|
* @param serverVersion server protocol version
|
||||||
* @return base protocol for the given server protocol version
|
* @return base protocol for the given server protocol version if present, else null
|
||||||
* @throws IllegalStateException if no base protocol could be found
|
|
||||||
*/
|
*/
|
||||||
Protocol getBaseProtocol(ProtocolVersion serverVersion);
|
@Nullable Protocol getBaseProtocol(ProtocolVersion serverVersion);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an immutable collection of registered protocols.
|
* Returns an immutable collection of registered protocols.
|
||||||
|
@ -363,13 +363,13 @@ public class ProtocolManagerImpl implements ProtocolManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Protocol getBaseProtocol(ProtocolVersion serverVersion) {
|
public @Nullable Protocol getBaseProtocol(ProtocolVersion serverVersion) {
|
||||||
for (Pair<Range<ProtocolVersion>, Protocol> rangeProtocol : Lists.reverse(baseProtocols)) {
|
for (Pair<Range<ProtocolVersion>, Protocol> rangeProtocol : Lists.reverse(baseProtocols)) {
|
||||||
if (rangeProtocol.key().contains(serverVersion)) {
|
if (rangeProtocol.key().contains(serverVersion)) {
|
||||||
return rangeProtocol.value();
|
return rangeProtocol.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("No Base Protocol for " + serverVersion);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,8 +80,14 @@ public class BaseProtocol extends AbstractProtocol<BaseClientboundPacket, BaseCl
|
|||||||
|
|
||||||
// Add Base Protocol
|
// Add Base Protocol
|
||||||
ProtocolPipeline pipeline = info.getPipeline();
|
ProtocolPipeline pipeline = info.getPipeline();
|
||||||
|
|
||||||
|
// Special versions might compare equal to normal versions and would break this getter
|
||||||
if (serverProtocol.getVersionType() != VersionType.SPECIAL) {
|
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
|
// Add other protocols
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren