Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-16 04:50:08 +01:00
Use RedirectProtocolVersion#getOrigin in InitialBaseProtocol if possible (#4110)
This way, we should be able to get rid of manually adding the base protocol in projects like ViaAprilFools: https://github.com/ViaVersion/ViaAprilFools/blob/main/common/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/Protocol3D_SharewareTo1_14.java#L87
Dieser Commit ist enthalten in:
Ursprung
1dde24bb68
Commit
78abf8be00
@ -24,8 +24,9 @@ import java.util.Comparator;
|
|||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special protocol version that compares to another version. This can be used for e.g. April Fool versions which are depending
|
* A {@link ProtocolVersion} with the version type {@link VersionType#SPECIAL} that compares equal to the given
|
||||||
* on vanilla game versions.
|
* origin version. The origin version will also be used in {@link com.viaversion.viaversion.protocols.base.InitialBaseProtocol}
|
||||||
|
* to determine the correct base protocol.
|
||||||
*/
|
*/
|
||||||
public class RedirectProtocolVersion extends ProtocolVersion {
|
public class RedirectProtocolVersion extends ProtocolVersion {
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ import com.viaversion.viaversion.api.protocol.version.VersionType;
|
|||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
import com.viaversion.viaversion.exception.CancelException;
|
import com.viaversion.viaversion.exception.CancelException;
|
||||||
import com.viaversion.viaversion.exception.InformativeException;
|
import com.viaversion.viaversion.exception.InformativeException;
|
||||||
|
import com.viaversion.viaversion.protocol.RedirectProtocolVersion;
|
||||||
import com.viaversion.viaversion.protocol.version.BaseVersionProvider;
|
import com.viaversion.viaversion.protocol.version.BaseVersionProvider;
|
||||||
import com.viaversion.viaversion.protocols.base.packet.BaseClientboundPacket;
|
import com.viaversion.viaversion.protocols.base.packet.BaseClientboundPacket;
|
||||||
import com.viaversion.viaversion.protocols.base.packet.BasePacketTypesProvider;
|
import com.viaversion.viaversion.protocols.base.packet.BasePacketTypesProvider;
|
||||||
@ -99,11 +100,15 @@ public class InitialBaseProtocol extends AbstractProtocol<BaseClientboundPacket,
|
|||||||
ProtocolPipeline pipeline = info.getPipeline();
|
ProtocolPipeline pipeline = info.getPipeline();
|
||||||
|
|
||||||
// Special versions might compare equal to normal versions and would break this getter,
|
// Special versions might compare equal to normal versions and would break this getter,
|
||||||
// platforms need to add the base protocols manually in this case
|
// platforms either need to use the RedirectProtocolVersion API or add the base protocols manually
|
||||||
if (serverProtocol.getVersionType() != VersionType.SPECIAL) {
|
if (serverProtocol.getVersionType() != VersionType.SPECIAL) {
|
||||||
for (final Protocol protocol : protocolManager.getBaseProtocols(serverProtocol)) {
|
for (final Protocol protocol : protocolManager.getBaseProtocols(serverProtocol)) {
|
||||||
pipeline.add(protocol);
|
pipeline.add(protocol);
|
||||||
}
|
}
|
||||||
|
} else if (serverProtocol instanceof RedirectProtocolVersion version) {
|
||||||
|
for (final Protocol protocol : protocolManager.getBaseProtocols(version.getOrigin())) {
|
||||||
|
pipeline.add(protocol);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add other protocols
|
// Add other protocols
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren