mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2024-11-21 11:55:15 +01:00
Add 1.20.5 packets
This commit is contained in:
parent
6587d0d179
commit
251bc6c39f
@ -0,0 +1,41 @@
|
|||||||
|
package com.viaversion.aas.codec.packet.configuration;
|
||||||
|
|
||||||
|
import com.viaversion.aas.codec.packet.Packet;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class ConfigurationTransfer implements Packet {
|
||||||
|
|
||||||
|
private String host;
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception {
|
||||||
|
host = Type.STRING.read(byteBuf);
|
||||||
|
port = Type.VAR_INT.readPrimitive(byteBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception {
|
||||||
|
Type.STRING.write(byteBuf, host);
|
||||||
|
Type.VAR_INT.writePrimitive(byteBuf, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHost(String host) {
|
||||||
|
this.host = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPort(int port) {
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.viaversion.aas.codec.packet.handshake;
|
package com.viaversion.aas.codec.packet.handshake;
|
||||||
|
|
||||||
import com.viaversion.aas.codec.packet.Packet;
|
import com.viaversion.aas.codec.packet.Packet;
|
||||||
|
import com.viaversion.aas.util.IntendedState;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
@ -12,13 +13,18 @@ public class Handshake implements Packet {
|
|||||||
private String address;
|
private String address;
|
||||||
private int port;
|
private int port;
|
||||||
private State nextState;
|
private State nextState;
|
||||||
|
private IntendedState intendedState;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception {
|
public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception {
|
||||||
protocolId = Type.VAR_INT.readPrimitive(byteBuf);
|
protocolId = Type.VAR_INT.readPrimitive(byteBuf);
|
||||||
address = Type.STRING.read(byteBuf);
|
address = Type.STRING.read(byteBuf);
|
||||||
port = byteBuf.readUnsignedShort();
|
port = byteBuf.readUnsignedShort();
|
||||||
nextState = State.values()[Type.VAR_INT.readPrimitive(byteBuf)];
|
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_5)) {
|
||||||
|
intendedState = IntendedState.values()[Type.VAR_INT.readPrimitive(byteBuf) - 1];
|
||||||
|
} else {
|
||||||
|
nextState = State.values()[Type.VAR_INT.readPrimitive(byteBuf)];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -26,7 +32,11 @@ public class Handshake implements Packet {
|
|||||||
Type.VAR_INT.writePrimitive(byteBuf, protocolId);
|
Type.VAR_INT.writePrimitive(byteBuf, protocolId);
|
||||||
Type.STRING.write(byteBuf, address);
|
Type.STRING.write(byteBuf, address);
|
||||||
byteBuf.writeShort(port);
|
byteBuf.writeShort(port);
|
||||||
byteBuf.writeByte(nextState.ordinal()); // var int is too small, fits in a byte
|
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_5)) {
|
||||||
|
Type.VAR_INT.writePrimitive(byteBuf, intendedState.ordinal() + 1);
|
||||||
|
} else {
|
||||||
|
byteBuf.writeByte(nextState.ordinal()); // var int is too small, fits in a byte
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProtocolId() {
|
public int getProtocolId() {
|
||||||
@ -60,4 +70,12 @@ public class Handshake implements Packet {
|
|||||||
public void setNextState(State nextState) {
|
public void setNextState(State nextState) {
|
||||||
this.nextState = nextState;
|
this.nextState = nextState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IntendedState getIntendedState() {
|
||||||
|
return intendedState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIntendedState(IntendedState intendedState) {
|
||||||
|
this.intendedState = intendedState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ public class CryptoRequest implements Packet {
|
|||||||
private String serverId;
|
private String serverId;
|
||||||
private PublicKey publicKey;
|
private PublicKey publicKey;
|
||||||
private byte[] nonce;
|
private byte[] nonce;
|
||||||
|
private boolean authenticate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception {
|
public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception {
|
||||||
@ -30,6 +31,9 @@ public class CryptoRequest implements Packet {
|
|||||||
.generatePublic(new X509EncodedKeySpec(UtilKt.readByteArray(byteBuf, byteBuf.readUnsignedShort())));
|
.generatePublic(new X509EncodedKeySpec(UtilKt.readByteArray(byteBuf, byteBuf.readUnsignedShort())));
|
||||||
nonce = UtilKt.readByteArray(byteBuf, byteBuf.readUnsignedShort());
|
nonce = UtilKt.readByteArray(byteBuf, byteBuf.readUnsignedShort());
|
||||||
}
|
}
|
||||||
|
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_5)) {
|
||||||
|
authenticate = byteBuf.readBoolean();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,6 +51,9 @@ public class CryptoRequest implements Packet {
|
|||||||
byteBuf.writeShort(nonce.length);
|
byteBuf.writeShort(nonce.length);
|
||||||
byteBuf.writeBytes(nonce);
|
byteBuf.writeBytes(nonce);
|
||||||
}
|
}
|
||||||
|
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_5)) {
|
||||||
|
byteBuf.writeBoolean(authenticate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServerId() {
|
public String getServerId() {
|
||||||
@ -72,4 +79,12 @@ public class CryptoRequest implements Packet {
|
|||||||
public void setNonce(byte[] nonce) {
|
public void setNonce(byte[] nonce) {
|
||||||
this.nonce = nonce;
|
this.nonce = nonce;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAuthenticate() {
|
||||||
|
return authenticate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthenticate(boolean authenticate) {
|
||||||
|
this.authenticate = authenticate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
20
src/main/java/com/viaversion/aas/util/IntendedState.java
Normal file
20
src/main/java/com/viaversion/aas/util/IntendedState.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package com.viaversion.aas.util;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
|
|
||||||
|
public enum IntendedState {
|
||||||
|
|
||||||
|
STATUS(State.STATUS),
|
||||||
|
LOGIN(State.LOGIN),
|
||||||
|
TRANSFER(State.LOGIN);
|
||||||
|
|
||||||
|
private final State state;
|
||||||
|
|
||||||
|
IntendedState(State state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public State getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
@ -3,10 +3,7 @@ package com.viaversion.aas.codec.packet
|
|||||||
import com.google.common.collect.Range
|
import com.google.common.collect.Range
|
||||||
import com.google.common.collect.RangeMap
|
import com.google.common.collect.RangeMap
|
||||||
import com.google.common.collect.TreeRangeMap
|
import com.google.common.collect.TreeRangeMap
|
||||||
import com.viaversion.aas.codec.packet.configuration.ConfigurationDisconnect
|
import com.viaversion.aas.codec.packet.configuration.*
|
||||||
import com.viaversion.aas.codec.packet.configuration.ConfigurationKeepAlive
|
|
||||||
import com.viaversion.aas.codec.packet.configuration.ConfigurationPluginMessage
|
|
||||||
import com.viaversion.aas.codec.packet.configuration.FinishConfig
|
|
||||||
import com.viaversion.aas.codec.packet.handshake.Handshake
|
import com.viaversion.aas.codec.packet.handshake.Handshake
|
||||||
import com.viaversion.aas.codec.packet.login.*
|
import com.viaversion.aas.codec.packet.login.*
|
||||||
import com.viaversion.aas.codec.packet.play.*
|
import com.viaversion.aas.codec.packet.play.*
|
||||||
@ -90,6 +87,9 @@ object PacketRegistry {
|
|||||||
ProtocolVersion.v1_20_2..ProtocolVersion.v1_20_3 to ClientboundConfigurationPackets1_20_2.KEEP_ALIVE.id,
|
ProtocolVersion.v1_20_2..ProtocolVersion.v1_20_3 to ClientboundConfigurationPackets1_20_2.KEEP_ALIVE.id,
|
||||||
ProtocolVersion.v1_20_5.singleton to ClientboundConfigurationPackets1_20_5.KEEP_ALIVE.id
|
ProtocolVersion.v1_20_5.singleton to ClientboundConfigurationPackets1_20_5.KEEP_ALIVE.id
|
||||||
))
|
))
|
||||||
|
register(State.CONFIGURATION, Direction.CLIENTBOUND, ::ConfigurationTransfer, Range.atLeast(ProtocolVersion.v1_20_5),
|
||||||
|
ClientboundConfigurationPackets1_20_5.TRANSFER.id)
|
||||||
|
|
||||||
register(State.CONFIGURATION, Direction.SERVERBOUND, ::ConfigurationPluginMessage, mapOf(
|
register(State.CONFIGURATION, Direction.SERVERBOUND, ::ConfigurationPluginMessage, mapOf(
|
||||||
ProtocolVersion.v1_20_2..ProtocolVersion.v1_20_3 to ServerboundConfigurationPackets1_20_2.CUSTOM_PAYLOAD.id,
|
ProtocolVersion.v1_20_2..ProtocolVersion.v1_20_3 to ServerboundConfigurationPackets1_20_2.CUSTOM_PAYLOAD.id,
|
||||||
ProtocolVersion.v1_20_5.singleton to ServerboundConfigurationPackets1_20_5.CUSTOM_PAYLOAD.id
|
ProtocolVersion.v1_20_5.singleton to ServerboundConfigurationPackets1_20_5.CUSTOM_PAYLOAD.id
|
||||||
|
@ -13,6 +13,7 @@ class LoginSuccess : Packet {
|
|||||||
lateinit var id: UUID
|
lateinit var id: UUID
|
||||||
lateinit var username: String
|
lateinit var username: String
|
||||||
private val properties = mutableListOf<SignableProperty>()
|
private val properties = mutableListOf<SignableProperty>()
|
||||||
|
private var strictErrorHandling: Boolean = false
|
||||||
|
|
||||||
override fun decode(byteBuf: ByteBuf, protocolVersion: ProtocolVersion) {
|
override fun decode(byteBuf: ByteBuf, protocolVersion: ProtocolVersion) {
|
||||||
id = when {
|
id = when {
|
||||||
@ -34,6 +35,9 @@ class LoginSuccess : Packet {
|
|||||||
this.properties.add(SignableProperty(name, value, signature))
|
this.properties.add(SignableProperty(name, value, signature))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_5)) {
|
||||||
|
strictErrorHandling = byteBuf.readBoolean()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun encode(byteBuf: ByteBuf, protocolVersion: ProtocolVersion) {
|
override fun encode(byteBuf: ByteBuf, protocolVersion: ProtocolVersion) {
|
||||||
@ -55,5 +59,8 @@ class LoginSuccess : Packet {
|
|||||||
Type.OPTIONAL_STRING.write(byteBuf, property.signature)
|
Type.OPTIONAL_STRING.write(byteBuf, property.signature)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_5)) {
|
||||||
|
byteBuf.writeBoolean(strictErrorHandling)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user