From 5515f507faffcb6139a796a562e618c02cff5a1a Mon Sep 17 00:00:00 2001 From: creeper123123321 <7974274+creeper123123321@users.noreply.github.com> Date: Tue, 18 Jun 2024 11:09:28 -0300 Subject: [PATCH] update to viaversion 5 --- build.gradle.kts | 16 +-- .../aas/codec/CompressionCodec.java | 5 +- .../com/viaversion/aas/codec/FrameCodec.java | 5 +- .../packet/common/AbstractCompression.java | 5 +- .../packet/common/AbstractCookieRequest.java | 5 +- .../packet/common/AbstractCookieResponse.java | 9 +- .../packet/common/AbstractSingleChat.java | 12 +- .../packet/common/AbstractSingleJson.java | 5 +- .../ConfigurationPluginMessage.java | 7 +- .../configuration/ConfigurationTransfer.java | 9 +- .../aas/codec/packet/handshake/Handshake.java | 13 ++- .../aas/codec/packet/login/CryptoRequest.java | 13 ++- .../aas/codec/packet/login/LoginStart.java | 15 +-- .../aas/codec/packet/login/PluginRequest.java | 10 +- .../codec/packet/login/PluginResponse.java | 6 +- .../aas/codec/packet/play/PluginMessage.java | 6 +- .../packet/play/ServerboundChatCommand.java | 24 ++-- .../packet/play/ServerboundChatMessage.java | 18 +-- .../aas/config/AspirinViaConfig.java | 3 +- .../aas/platform/AspirinLoader.java | 8 +- .../viaversion/aas/platform/FutureTask.java | 6 - .../provider/AspirinCompressionProvider.java | 2 +- .../provider/AspirinEncryptionProvider.java | 2 +- .../aas/provider/AspirinProfileProvider.java | 4 +- .../aas/provider/AspirinTransferProvider.java | 2 +- .../aas/provider/AspirinVersionProvider.java | 2 +- src/main/kotlin/com/viaversion/aas/Util.kt | 6 +- src/main/kotlin/com/viaversion/aas/VIAaaS.kt | 2 - .../aas/codec/packet/PacketRegistry.kt | 108 +++++++++--------- .../aas/codec/packet/login/CryptoResponse.kt | 22 ++-- .../aas/codec/packet/login/LoginSuccess.kt | 34 +++--- .../aas/command/sub/ConnectionsSubCommand.kt | 2 +- .../aas/command/sub/StopSubCommand.kt | 2 +- .../aas/command/sub/VIAaaSSubCommand.kt | 2 +- .../com/viaversion/aas/config/VIAaaSConfig.kt | 3 +- .../com/viaversion/aas/handler/HandlerUtil.kt | 5 +- .../aas/handler/state/HandlerStateUtil.kt | 5 +- .../aas/handler/state/LoginState.kt | 6 +- .../aas/platform/AspirinPlatform.kt | 1 - 39 files changed, 208 insertions(+), 202 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 837013d..d463c27 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -60,16 +60,16 @@ dependencies { implementation(kotlin("stdlib-jdk8")) implementation(kotlin("reflect")) - val vvVer = "4.10.3-SNAPSHOT" - val vbVer = "4.10.3-SNAPSHOT" - val vrVer = "3.1.2-SNAPSHOT" + val vvVer = "5.0.1-SNAPSHOT" + val vbVer = "5.0.1-SNAPSHOT" + val vrVer = "4.0.0" implementation("com.viaversion:viaversion-common:$vvVer") { isTransitive = false } implementation("com.viaversion:viabackwards-common:$vbVer") { isTransitive = false } implementation("com.viaversion:viarewind-common:$vrVer") { isTransitive = false } - implementation("net.raphimc:ViaAprilFools:2.0.12-SNAPSHOT") - implementation("net.raphimc:ViaLegacy:2.2.23-SNAPSHOT") + implementation("net.raphimc:ViaAprilFools:3.0.1-SNAPSHOT") + implementation("net.raphimc:ViaLegacy:3.0.1-SNAPSHOT") - val nettyVer = "4.1.107.Final" + val nettyVer = "4.1.111.Final" implementation("io.netty:netty-handler-proxy:$nettyVer") implementation("io.netty:netty-resolver-dns:$nettyVer") implementation("io.netty:netty-transport-native-epoll:$nettyVer:linux-aarch_64") @@ -79,13 +79,13 @@ dependencies { implementation("io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.25.Final:linux-aarch_64") implementation("io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.25.Final:linux-x86_64") - implementation("com.google.guava:guava:33.2.0-jre") + implementation("com.google.guava:guava:33.2.1-jre") implementation("com.velocitypowered:velocity-native:3.3.0-SNAPSHOT") implementation("net.coobird:thumbnailator:0.4.20") implementation("org.powernukkit.fastutil:fastutil-lite:8.1.1") implementation("org.yaml:snakeyaml:2.2") - val log4jVer = "2.22.1" + val log4jVer = "2.23.1" val slf4jVer = "2.0.12" implementation("com.lmax:disruptor:3.4.4") implementation("net.minecrell:terminalconsoleappender:1.3.0") diff --git a/src/main/java/com/viaversion/aas/codec/CompressionCodec.java b/src/main/java/com/viaversion/aas/codec/CompressionCodec.java index 9e49315..1c4be29 100644 --- a/src/main/java/com/viaversion/aas/codec/CompressionCodec.java +++ b/src/main/java/com/viaversion/aas/codec/CompressionCodec.java @@ -7,6 +7,7 @@ import com.velocitypowered.natives.util.Natives; import com.viaversion.aas.config.VIAaaSConfig; import com.viaversion.aas.handler.MinecraftHandler; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.channel.ChannelHandlerContext; @@ -89,7 +90,7 @@ public class CompressionCodec extends MessageToMessageCodec { outBuf.writeByte(0); outBuf.writeBytes(msg); } else { - Type.VAR_INT.writePrimitive(outBuf, uncompressedSize); + Types.VAR_INT.writePrimitive(outBuf, uncompressedSize); var compatibleIn = MoreByteBufUtils.ensureCompatible(ctx.alloc(), compressor, msg); try { compressor.deflate(compatibleIn, outBuf); @@ -112,7 +113,7 @@ public class CompressionCodec extends MessageToMessageCodec { protected void decode(ChannelHandlerContext ctx, ByteBuf input, List out) throws Exception { if (!input.isReadable() || !ctx.channel().isActive()) return; - var claimedUncompressedSize = Type.VAR_INT.readPrimitive(input); + var claimedUncompressedSize = Types.VAR_INT.readPrimitive(input); if (claimedUncompressedSize == 0) { // Uncompressed out.add(input.retain()); return; diff --git a/src/main/java/com/viaversion/aas/codec/FrameCodec.java b/src/main/java/com/viaversion/aas/codec/FrameCodec.java index 36acd85..320af20 100644 --- a/src/main/java/com/viaversion/aas/codec/FrameCodec.java +++ b/src/main/java/com/viaversion/aas/codec/FrameCodec.java @@ -2,6 +2,7 @@ package com.viaversion.aas.codec; import com.viaversion.aas.UtilKt; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.exception.CancelDecoderException; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; @@ -31,7 +32,7 @@ public class FrameCodec extends ByteToMessageCodec { in.readerIndex(index); if (result == -1) return; // not readable - int length = Type.VAR_INT.readPrimitive(in); + int length = Types.VAR_INT.readPrimitive(in); if (length >= 2097152 || length < 0) throw UtilKt.getBadLength(); if (!in.isReadable(length)) { @@ -45,7 +46,7 @@ public class FrameCodec extends ByteToMessageCodec { @Override protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception { if (msg.readableBytes() >= 2097152) throw UtilKt.getBadLength(); - Type.VAR_INT.writePrimitive(out, msg.readableBytes()); + Types.VAR_INT.writePrimitive(out, msg.readableBytes()); out.writeBytes(msg); } } diff --git a/src/main/java/com/viaversion/aas/codec/packet/common/AbstractCompression.java b/src/main/java/com/viaversion/aas/codec/packet/common/AbstractCompression.java index b471ae8..58a5c43 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/common/AbstractCompression.java +++ b/src/main/java/com/viaversion/aas/codec/packet/common/AbstractCompression.java @@ -3,6 +3,7 @@ package com.viaversion.aas.codec.packet.common; import com.viaversion.aas.codec.packet.Packet; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -19,11 +20,11 @@ public abstract class AbstractCompression implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - threshold = Type.VAR_INT.readPrimitive(byteBuf); + threshold = Types.VAR_INT.readPrimitive(byteBuf); } @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - Type.VAR_INT.writePrimitive(byteBuf, threshold); + Types.VAR_INT.writePrimitive(byteBuf, threshold); } } diff --git a/src/main/java/com/viaversion/aas/codec/packet/common/AbstractCookieRequest.java b/src/main/java/com/viaversion/aas/codec/packet/common/AbstractCookieRequest.java index bc69ac4..ed9561b 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/common/AbstractCookieRequest.java +++ b/src/main/java/com/viaversion/aas/codec/packet/common/AbstractCookieRequest.java @@ -3,6 +3,7 @@ package com.viaversion.aas.codec.packet.common; import com.viaversion.aas.codec.packet.Packet; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -11,12 +12,12 @@ public abstract class AbstractCookieRequest implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - identifier = Type.STRING.read(byteBuf); + identifier = Types.STRING.read(byteBuf); } @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - Type.STRING.write(byteBuf, identifier); + Types.STRING.write(byteBuf, identifier); } public String getIdentifier() { diff --git a/src/main/java/com/viaversion/aas/codec/packet/common/AbstractCookieResponse.java b/src/main/java/com/viaversion/aas/codec/packet/common/AbstractCookieResponse.java index 606c0ce..8c02743 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/common/AbstractCookieResponse.java +++ b/src/main/java/com/viaversion/aas/codec/packet/common/AbstractCookieResponse.java @@ -3,6 +3,7 @@ package com.viaversion.aas.codec.packet.common; import com.viaversion.aas.codec.packet.Packet; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -12,14 +13,14 @@ public abstract class AbstractCookieResponse implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - id = Type.STRING.read(byteBuf); - payload = Type.OPTIONAL_BYTE_ARRAY_PRIMITIVE.read(byteBuf); + id = Types.STRING.read(byteBuf); + payload = Types.OPTIONAL_BYTE_ARRAY_PRIMITIVE.read(byteBuf); } @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - Type.STRING.write(byteBuf, id); - Type.OPTIONAL_BYTE_ARRAY_PRIMITIVE.write(byteBuf, payload); + Types.STRING.write(byteBuf, id); + Types.OPTIONAL_BYTE_ARRAY_PRIMITIVE.write(byteBuf, payload); } public String getId() { diff --git a/src/main/java/com/viaversion/aas/codec/packet/common/AbstractSingleChat.java b/src/main/java/com/viaversion/aas/codec/packet/common/AbstractSingleChat.java index fad0637..6920849 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/common/AbstractSingleChat.java +++ b/src/main/java/com/viaversion/aas/codec/packet/common/AbstractSingleChat.java @@ -3,9 +3,9 @@ package com.viaversion.aas.codec.packet.common; import com.google.gson.JsonElement; import com.google.gson.JsonParser; import com.viaversion.aas.codec.packet.Packet; +import com.viaversion.nbt.tag.Tag; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.util.ComponentUtil; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -47,18 +47,16 @@ public abstract class AbstractSingleChat implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { if (protocolVersion.olderThan(ProtocolVersion.v1_20_3)) { - msg = JsonParser.parseString(Type.STRING.read(byteBuf)); + msg = JsonParser.parseString(Types.STRING.read(byteBuf)); } else { - msgTag = Type.TAG.read(byteBuf); + msgTag = Types.TAG.read(byteBuf); } } @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { if (protocolVersion.olderThan(ProtocolVersion.v1_20_3)) { - Type.STRING.write(byteBuf, msg.toString()); + Types.STRING.write(byteBuf, msg.toString()); } } - - } diff --git a/src/main/java/com/viaversion/aas/codec/packet/common/AbstractSingleJson.java b/src/main/java/com/viaversion/aas/codec/packet/common/AbstractSingleJson.java index 2d4e5a5..c05c0bf 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/common/AbstractSingleJson.java +++ b/src/main/java/com/viaversion/aas/codec/packet/common/AbstractSingleJson.java @@ -5,6 +5,7 @@ import com.google.gson.JsonParser; import com.viaversion.aas.codec.packet.Packet; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -21,11 +22,11 @@ public abstract class AbstractSingleJson implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - msg = JsonParser.parseString(Type.STRING.read(byteBuf)); + msg = JsonParser.parseString(Types.STRING.read(byteBuf)); } @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - Type.STRING.write(byteBuf, msg.toString()); + Types.STRING.write(byteBuf, msg.toString()); } } diff --git a/src/main/java/com/viaversion/aas/codec/packet/configuration/ConfigurationPluginMessage.java b/src/main/java/com/viaversion/aas/codec/packet/configuration/ConfigurationPluginMessage.java index 5d15407..b9fd1ae 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/configuration/ConfigurationPluginMessage.java +++ b/src/main/java/com/viaversion/aas/codec/packet/configuration/ConfigurationPluginMessage.java @@ -4,6 +4,7 @@ import com.viaversion.aas.UtilKt; import com.viaversion.aas.codec.packet.Packet; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -13,13 +14,13 @@ public class ConfigurationPluginMessage implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - channel = Type.STRING.read(byteBuf); + channel = Types.STRING.read(byteBuf); data = UtilKt.readRemainingBytes(byteBuf); } @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - Type.STRING.write(byteBuf, channel); - Type.REMAINING_BYTES.write(byteBuf, data); + Types.STRING.write(byteBuf, channel); + Types.REMAINING_BYTES.write(byteBuf, data); } } diff --git a/src/main/java/com/viaversion/aas/codec/packet/configuration/ConfigurationTransfer.java b/src/main/java/com/viaversion/aas/codec/packet/configuration/ConfigurationTransfer.java index cbda332..ff35b85 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/configuration/ConfigurationTransfer.java +++ b/src/main/java/com/viaversion/aas/codec/packet/configuration/ConfigurationTransfer.java @@ -3,6 +3,7 @@ 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 com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -13,14 +14,14 @@ public class ConfigurationTransfer implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - host = Type.STRING.read(byteBuf); - port = Type.VAR_INT.readPrimitive(byteBuf); + host = Types.STRING.read(byteBuf); + port = Types.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); + Types.STRING.write(byteBuf, host); + Types.VAR_INT.writePrimitive(byteBuf, port); } public String getHost() { diff --git a/src/main/java/com/viaversion/aas/codec/packet/handshake/Handshake.java b/src/main/java/com/viaversion/aas/codec/packet/handshake/Handshake.java index f4d6046..28a190a 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/handshake/Handshake.java +++ b/src/main/java/com/viaversion/aas/codec/packet/handshake/Handshake.java @@ -4,6 +4,7 @@ import com.viaversion.aas.codec.packet.Packet; import com.viaversion.aas.util.IntendedState; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -15,18 +16,18 @@ public class Handshake implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - protocolId = Type.VAR_INT.readPrimitive(byteBuf); - address = Type.STRING.read(byteBuf); + protocolId = Types.VAR_INT.readPrimitive(byteBuf); + address = Types.STRING.read(byteBuf); port = byteBuf.readUnsignedShort(); - intendedState = IntendedState.values()[Type.VAR_INT.readPrimitive(byteBuf)]; + intendedState = IntendedState.values()[Types.VAR_INT.readPrimitive(byteBuf)]; } @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - Type.VAR_INT.writePrimitive(byteBuf, protocolId); - Type.STRING.write(byteBuf, address); + Types.VAR_INT.writePrimitive(byteBuf, protocolId); + Types.STRING.write(byteBuf, address); byteBuf.writeShort(port); - Type.VAR_INT.writePrimitive(byteBuf, intendedState.ordinal()); + Types.VAR_INT.writePrimitive(byteBuf, intendedState.ordinal()); } public int getProtocolId() { diff --git a/src/main/java/com/viaversion/aas/codec/packet/login/CryptoRequest.java b/src/main/java/com/viaversion/aas/codec/packet/login/CryptoRequest.java index 29486fe..76a2f4a 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/login/CryptoRequest.java +++ b/src/main/java/com/viaversion/aas/codec/packet/login/CryptoRequest.java @@ -5,6 +5,7 @@ import com.viaversion.aas.codec.packet.Packet; import com.viaversion.aas.protocol.AspirinProtocolsKt; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -20,12 +21,12 @@ public class CryptoRequest implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - serverId = Type.STRING.read(byteBuf); + serverId = Types.STRING.read(byteBuf); if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_8) || protocolVersion.equalTo(AspirinProtocolsKt.getSharewareVersion())) { publicKey = KeyFactory.getInstance("RSA") - .generatePublic(new X509EncodedKeySpec(Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf))); - nonce = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf); + .generatePublic(new X509EncodedKeySpec(Types.BYTE_ARRAY_PRIMITIVE.read(byteBuf))); + nonce = Types.BYTE_ARRAY_PRIMITIVE.read(byteBuf); } else { publicKey = KeyFactory.getInstance("RSA") .generatePublic(new X509EncodedKeySpec(UtilKt.readByteArray(byteBuf, byteBuf.readUnsignedShort()))); @@ -39,11 +40,11 @@ public class CryptoRequest implements Packet { @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - Type.STRING.write(byteBuf, serverId); + Types.STRING.write(byteBuf, serverId); if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_8) || protocolVersion.equalTo(AspirinProtocolsKt.getSharewareVersion())) { - Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, publicKey.getEncoded()); - Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, nonce); + Types.BYTE_ARRAY_PRIMITIVE.write(byteBuf, publicKey.getEncoded()); + Types.BYTE_ARRAY_PRIMITIVE.write(byteBuf, nonce); } else { byte[] encodedKey = publicKey.getEncoded(); byteBuf.writeShort(encodedKey.length); diff --git a/src/main/java/com/viaversion/aas/codec/packet/login/LoginStart.java b/src/main/java/com/viaversion/aas/codec/packet/login/LoginStart.java index 0958863..591af6c 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/login/LoginStart.java +++ b/src/main/java/com/viaversion/aas/codec/packet/login/LoginStart.java @@ -4,6 +4,7 @@ import com.viaversion.aas.codec.packet.Packet; import com.viaversion.viaversion.api.minecraft.ProfileKey; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.StringType; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -44,27 +45,27 @@ public class LoginStart implements Packet { username = new StringType(16).read(byteBuf); if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_19) && protocolVersion.olderThan(ProtocolVersion.v1_19_3)) { - profileKey = Type.OPTIONAL_PROFILE_KEY.read(byteBuf); + profileKey = Types.OPTIONAL_PROFILE_KEY.read(byteBuf); } if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_2)) { - profileId = Type.UUID.read(byteBuf); + profileId = Types.UUID.read(byteBuf); } else if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_19_1)) { - profileId = Type.OPTIONAL_UUID.read(byteBuf); + profileId = Types.OPTIONAL_UUID.read(byteBuf); } } @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - Type.STRING.write(byteBuf, username); + Types.STRING.write(byteBuf, username); if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_19) && protocolVersion.olderThan(ProtocolVersion.v1_19_3)) { - Type.OPTIONAL_PROFILE_KEY.write(byteBuf, profileKey); + Types.OPTIONAL_PROFILE_KEY.write(byteBuf, profileKey); } if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_2)) { - Type.UUID.write(byteBuf, profileId); + Types.UUID.write(byteBuf, profileId); } else if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_19_1)) { - Type.OPTIONAL_UUID.write(byteBuf, profileId); + Types.OPTIONAL_UUID.write(byteBuf, profileId); } } } diff --git a/src/main/java/com/viaversion/aas/codec/packet/login/PluginRequest.java b/src/main/java/com/viaversion/aas/codec/packet/login/PluginRequest.java index 246aac6..6f0404b 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/login/PluginRequest.java +++ b/src/main/java/com/viaversion/aas/codec/packet/login/PluginRequest.java @@ -3,7 +3,7 @@ package com.viaversion.aas.codec.packet.login; import com.viaversion.aas.UtilKt; import com.viaversion.aas.codec.packet.Packet; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -14,15 +14,15 @@ public class PluginRequest implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - id = Type.VAR_INT.readPrimitive(byteBuf); - channel = Type.STRING.read(byteBuf); + id = Types.VAR_INT.readPrimitive(byteBuf); + channel = Types.STRING.read(byteBuf); data = UtilKt.readRemainingBytes(byteBuf); } @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - Type.VAR_INT.writePrimitive(byteBuf, id); - Type.STRING.write(byteBuf, channel); + Types.VAR_INT.writePrimitive(byteBuf, id); + Types.STRING.write(byteBuf, channel); byteBuf.writeBytes(data); } diff --git a/src/main/java/com/viaversion/aas/codec/packet/login/PluginResponse.java b/src/main/java/com/viaversion/aas/codec/packet/login/PluginResponse.java index aec3bbd..0811c36 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/login/PluginResponse.java +++ b/src/main/java/com/viaversion/aas/codec/packet/login/PluginResponse.java @@ -3,7 +3,7 @@ package com.viaversion.aas.codec.packet.login; import com.viaversion.aas.UtilKt; import com.viaversion.aas.codec.packet.Packet; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ public class PluginResponse implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - id = Type.VAR_INT.readPrimitive(byteBuf); + id = Types.VAR_INT.readPrimitive(byteBuf); success = byteBuf.readBoolean(); if (success) { data = UtilKt.readRemainingBytes(byteBuf); @@ -23,7 +23,7 @@ public class PluginResponse implements Packet { @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - Type.VAR_INT.writePrimitive(byteBuf, id); + Types.VAR_INT.writePrimitive(byteBuf, id); byteBuf.writeBoolean(success); if (success) { byteBuf.writeBytes(data); diff --git a/src/main/java/com/viaversion/aas/codec/packet/play/PluginMessage.java b/src/main/java/com/viaversion/aas/codec/packet/play/PluginMessage.java index 63a0ecd..c2ff665 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/play/PluginMessage.java +++ b/src/main/java/com/viaversion/aas/codec/packet/play/PluginMessage.java @@ -3,7 +3,7 @@ package com.viaversion.aas.codec.packet.play; import com.viaversion.aas.UtilKt; import com.viaversion.aas.codec.packet.Packet; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -13,7 +13,7 @@ public class PluginMessage implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - channel = Type.STRING.read(byteBuf); + channel = Types.STRING.read(byteBuf); if (protocolVersion.olderThanOrEqualTo(ProtocolVersion.v1_7_6)) { data = UtilKt.readByteArray(byteBuf, readExtendedForgeShort(byteBuf)); } else { @@ -23,7 +23,7 @@ public class PluginMessage implements Packet { @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - Type.STRING.write(byteBuf, channel); + Types.STRING.write(byteBuf, channel); if (protocolVersion.olderThanOrEqualTo(ProtocolVersion.v1_7_6)) { writeExtendedForgeShort(byteBuf, data.length); } diff --git a/src/main/java/com/viaversion/aas/codec/packet/play/ServerboundChatCommand.java b/src/main/java/com/viaversion/aas/codec/packet/play/ServerboundChatCommand.java index cd75c0c..016e469 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/play/ServerboundChatCommand.java +++ b/src/main/java/com/viaversion/aas/codec/packet/play/ServerboundChatCommand.java @@ -3,7 +3,7 @@ package com.viaversion.aas.codec.packet.play; import com.viaversion.aas.codec.packet.Packet; import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -45,34 +45,34 @@ public class ServerboundChatCommand implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - message = Type.STRING.read(byteBuf); + message = Types.STRING.read(byteBuf); timestamp = byteBuf.readLong(); salt = byteBuf.readLong(); - signatures = new ArgumentSignature[Type.VAR_INT.readPrimitive(byteBuf)]; + signatures = new ArgumentSignature[Types.VAR_INT.readPrimitive(byteBuf)]; for (int i = 0; i < signatures.length; i++) { - signatures[i] = new ArgumentSignature(Type.STRING.read(byteBuf), Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)); + signatures[i] = new ArgumentSignature(Types.STRING.read(byteBuf), Types.BYTE_ARRAY_PRIMITIVE.read(byteBuf)); } signedPreview = byteBuf.readBoolean(); if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_19_1)) { - lastSeenMessages = Type.PLAYER_MESSAGE_SIGNATURE_ARRAY.read(byteBuf); - lastReceivedMessage = Type.OPTIONAL_PLAYER_MESSAGE_SIGNATURE.read(byteBuf); + lastSeenMessages = Types.PLAYER_MESSAGE_SIGNATURE_ARRAY.read(byteBuf); + lastReceivedMessage = Types.OPTIONAL_PLAYER_MESSAGE_SIGNATURE.read(byteBuf); } } @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - Type.STRING.write(byteBuf, message); + Types.STRING.write(byteBuf, message); byteBuf.writeLong(timestamp); byteBuf.writeLong(salt); - Type.VAR_INT.writePrimitive(byteBuf, signatures.length); + Types.VAR_INT.writePrimitive(byteBuf, signatures.length); for (ArgumentSignature signature : signatures) { - Type.STRING.write(byteBuf, signature.getArgumentName()); - Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, signature.getSignature()); + Types.STRING.write(byteBuf, signature.getArgumentName()); + Types.BYTE_ARRAY_PRIMITIVE.write(byteBuf, signature.getSignature()); } byteBuf.writeBoolean(signedPreview); if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_19_1)) { - Type.PLAYER_MESSAGE_SIGNATURE_ARRAY.write(byteBuf, lastSeenMessages); - Type.OPTIONAL_PLAYER_MESSAGE_SIGNATURE.write(byteBuf, lastReceivedMessage); + Types.PLAYER_MESSAGE_SIGNATURE_ARRAY.write(byteBuf, lastSeenMessages); + Types.OPTIONAL_PLAYER_MESSAGE_SIGNATURE.write(byteBuf, lastReceivedMessage); } } diff --git a/src/main/java/com/viaversion/aas/codec/packet/play/ServerboundChatMessage.java b/src/main/java/com/viaversion/aas/codec/packet/play/ServerboundChatMessage.java index 81b66a4..f4b5964 100644 --- a/src/main/java/com/viaversion/aas/codec/packet/play/ServerboundChatMessage.java +++ b/src/main/java/com/viaversion/aas/codec/packet/play/ServerboundChatMessage.java @@ -3,7 +3,7 @@ package com.viaversion.aas.codec.packet.play; import com.viaversion.aas.codec.packet.Packet; import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; @@ -18,27 +18,27 @@ public class ServerboundChatMessage implements Packet { @Override public void decode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - message = Type.STRING.read(byteBuf); + message = Types.STRING.read(byteBuf); timestamp = byteBuf.readLong(); salt = byteBuf.readLong(); - signature = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf); + signature = Types.BYTE_ARRAY_PRIMITIVE.read(byteBuf); signedPreview = byteBuf.readBoolean(); if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_19_1)) { - lastSeenMessages = Type.PLAYER_MESSAGE_SIGNATURE_ARRAY.read(byteBuf); - lastReceivedMessage = Type.OPTIONAL_PLAYER_MESSAGE_SIGNATURE.read(byteBuf); + lastSeenMessages = Types.PLAYER_MESSAGE_SIGNATURE_ARRAY.read(byteBuf); + lastReceivedMessage = Types.OPTIONAL_PLAYER_MESSAGE_SIGNATURE.read(byteBuf); } } @Override public void encode(@NotNull ByteBuf byteBuf, ProtocolVersion protocolVersion) throws Exception { - Type.STRING.write(byteBuf, message); + Types.STRING.write(byteBuf, message); byteBuf.writeLong(timestamp); byteBuf.writeLong(salt); - Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, signature); + Types.BYTE_ARRAY_PRIMITIVE.write(byteBuf, signature); byteBuf.writeBoolean(signedPreview); if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_19_1)) { - Type.PLAYER_MESSAGE_SIGNATURE_ARRAY.write(byteBuf, lastSeenMessages); - Type.OPTIONAL_PLAYER_MESSAGE_SIGNATURE.write(byteBuf, lastReceivedMessage); + Types.PLAYER_MESSAGE_SIGNATURE_ARRAY.write(byteBuf, lastSeenMessages); + Types.OPTIONAL_PLAYER_MESSAGE_SIGNATURE.write(byteBuf, lastReceivedMessage); } } diff --git a/src/main/java/com/viaversion/aas/config/AspirinViaConfig.java b/src/main/java/com/viaversion/aas/config/AspirinViaConfig.java index f67069c..68082be 100644 --- a/src/main/java/com/viaversion/aas/config/AspirinViaConfig.java +++ b/src/main/java/com/viaversion/aas/config/AspirinViaConfig.java @@ -1,5 +1,6 @@ package com.viaversion.aas.config; +import com.viaversion.aas.platform.AspirinPlatform; import com.viaversion.viaversion.configuration.AbstractViaConfig; import java.io.File; @@ -13,7 +14,7 @@ public class AspirinViaConfig extends AbstractViaConfig { } public AspirinViaConfig() { - super(new File("config/viaversion.yml")); + super(new File("config/viaversion.yml"), AspirinPlatform.INSTANCE.getLogger()); } @Override diff --git a/src/main/java/com/viaversion/aas/platform/AspirinLoader.java b/src/main/java/com/viaversion/aas/platform/AspirinLoader.java index 63b6e19..53487f9 100644 --- a/src/main/java/com/viaversion/aas/platform/AspirinLoader.java +++ b/src/main/java/com/viaversion/aas/platform/AspirinLoader.java @@ -1,13 +1,13 @@ package com.viaversion.aas.platform; import com.viaversion.aas.provider.*; -import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.provider.TransferProvider; +import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.provider.TransferProvider; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.platform.ViaPlatformLoader; import com.viaversion.viaversion.api.protocol.version.VersionProvider; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CompressionProvider; -import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.providers.EncryptionProvider; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher; +import com.viaversion.viaversion.protocols.v1_8to1_9.provider.CompressionProvider; +import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.provider.EncryptionProvider; +import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.provider.GameProfileFetcher; public class AspirinLoader implements ViaPlatformLoader { @Override diff --git a/src/main/java/com/viaversion/aas/platform/FutureTask.java b/src/main/java/com/viaversion/aas/platform/FutureTask.java index b52e250..f05567f 100644 --- a/src/main/java/com/viaversion/aas/platform/FutureTask.java +++ b/src/main/java/com/viaversion/aas/platform/FutureTask.java @@ -13,12 +13,6 @@ public class FutureTask implements PlatformTask> { this.object = object; } - @Override - @Deprecated - public @Nullable Future getObject() { - return object; - } - @Override public void cancel() { object.cancel(false); diff --git a/src/main/java/com/viaversion/aas/provider/AspirinCompressionProvider.java b/src/main/java/com/viaversion/aas/provider/AspirinCompressionProvider.java index c2c826d..f7ab9b0 100644 --- a/src/main/java/com/viaversion/aas/provider/AspirinCompressionProvider.java +++ b/src/main/java/com/viaversion/aas/provider/AspirinCompressionProvider.java @@ -2,7 +2,7 @@ package com.viaversion.aas.provider; import com.viaversion.aas.handler.HandlerUtilKt; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CompressionProvider; +import com.viaversion.viaversion.protocols.v1_8to1_9.provider.CompressionProvider; import java.util.Objects; diff --git a/src/main/java/com/viaversion/aas/provider/AspirinEncryptionProvider.java b/src/main/java/com/viaversion/aas/provider/AspirinEncryptionProvider.java index ee0ecd1..1786a52 100644 --- a/src/main/java/com/viaversion/aas/provider/AspirinEncryptionProvider.java +++ b/src/main/java/com/viaversion/aas/provider/AspirinEncryptionProvider.java @@ -1,7 +1,7 @@ package com.viaversion.aas.provider; import com.viaversion.viaversion.api.connection.UserConnection; -import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.providers.EncryptionProvider; +import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.provider.EncryptionProvider; public class AspirinEncryptionProvider extends EncryptionProvider { @Override diff --git a/src/main/java/com/viaversion/aas/provider/AspirinProfileProvider.java b/src/main/java/com/viaversion/aas/provider/AspirinProfileProvider.java index 93340f1..0c1c950 100644 --- a/src/main/java/com/viaversion/aas/provider/AspirinProfileProvider.java +++ b/src/main/java/com/viaversion/aas/provider/AspirinProfileProvider.java @@ -1,8 +1,8 @@ package com.viaversion.aas.provider; import com.viaversion.aas.UtilKt; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.model.GameProfile; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher; +import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.model.GameProfile; +import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.provider.GameProfileFetcher; import java.util.UUID; diff --git a/src/main/java/com/viaversion/aas/provider/AspirinTransferProvider.java b/src/main/java/com/viaversion/aas/provider/AspirinTransferProvider.java index e10a999..a7f03a9 100644 --- a/src/main/java/com/viaversion/aas/provider/AspirinTransferProvider.java +++ b/src/main/java/com/viaversion/aas/provider/AspirinTransferProvider.java @@ -1,6 +1,6 @@ package com.viaversion.aas.provider; -import com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.provider.TransferProvider; +import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.provider.TransferProvider; import com.viaversion.viaversion.api.connection.UserConnection; public class AspirinTransferProvider implements TransferProvider { diff --git a/src/main/java/com/viaversion/aas/provider/AspirinVersionProvider.java b/src/main/java/com/viaversion/aas/provider/AspirinVersionProvider.java index 52c8d03..8863302 100644 --- a/src/main/java/com/viaversion/aas/provider/AspirinVersionProvider.java +++ b/src/main/java/com/viaversion/aas/provider/AspirinVersionProvider.java @@ -3,7 +3,7 @@ package com.viaversion.aas.provider; import com.viaversion.aas.handler.MinecraftHandler; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.protocols.base.BaseVersionProvider; +import com.viaversion.viaversion.protocol.version.BaseVersionProvider; public class AspirinVersionProvider extends BaseVersionProvider { @Override diff --git a/src/main/kotlin/com/viaversion/aas/Util.kt b/src/main/kotlin/com/viaversion/aas/Util.kt index faec4da..49769bd 100644 --- a/src/main/kotlin/com/viaversion/aas/Util.kt +++ b/src/main/kotlin/com/viaversion/aas/Util.kt @@ -7,7 +7,7 @@ import com.google.common.primitives.Ints import com.google.gson.JsonObject import com.viaversion.aas.config.VIAaaSConfig import com.viaversion.aas.util.StacklessException -import com.viaversion.viaversion.api.type.Type +import com.viaversion.viaversion.api.type.Types import io.ktor.client.call.body import io.ktor.client.request.* import io.ktor.http.* @@ -44,6 +44,7 @@ import java.security.PublicKey import java.security.SecureRandom import java.util.* import java.util.concurrent.TimeUnit +import java.util.logging.Logger import javax.crypto.Cipher import javax.crypto.spec.SecretKeySpec @@ -51,6 +52,7 @@ val badLength = DecoderException("Invalid length!") val mcLogger = LoggerFactory.getLogger("VIAaaS MC") val webLogger = LoggerFactory.getLogger("VIAaaS Web") val viaaasLogger = LoggerFactory.getLogger("VIAaaS") +val viaaasLoggerJava = Logger.getLogger("VIAaaS") val secureRandom = SecureRandom() @@ -186,7 +188,7 @@ fun writeFlushClose(ch: Channel, obj: Any, delay: Boolean = false) { } } -fun readRemainingBytes(byteBuf: ByteBuf) = Type.REMAINING_BYTES.read(byteBuf)!! +fun readRemainingBytes(byteBuf: ByteBuf) = Types.REMAINING_BYTES.read(byteBuf)!! fun ByteBuf.readByteArray(length: Int) = ByteArray(length).also { readBytes(it) } suspend fun hasJoined(username: String, hash: String): JsonObject { diff --git a/src/main/kotlin/com/viaversion/aas/VIAaaS.kt b/src/main/kotlin/com/viaversion/aas/VIAaaS.kt index f4463b2..cabb297 100644 --- a/src/main/kotlin/com/viaversion/aas/VIAaaS.kt +++ b/src/main/kotlin/com/viaversion/aas/VIAaaS.kt @@ -12,7 +12,6 @@ import com.viaversion.aas.web.ViaWebApp import com.viaversion.viaversion.api.Via import com.viaversion.viaversion.api.protocol.version.ProtocolVersion import com.viaversion.viaversion.api.protocol.version.VersionType -import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3 import io.ktor.server.application.* import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job @@ -68,7 +67,6 @@ private fun initVia() { Via.getManager().configurationProvider.register(VIAaaSConfig) } - Protocol1_20_5To1_20_3.strictErrorHandling = false ProtocolVersion.register(AUTO) registerAspirinProtocols() } diff --git a/src/main/kotlin/com/viaversion/aas/codec/packet/PacketRegistry.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/PacketRegistry.kt index 520f09b..9b07eaf 100644 --- a/src/main/kotlin/com/viaversion/aas/codec/packet/PacketRegistry.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/PacketRegistry.kt @@ -15,30 +15,30 @@ import com.viaversion.aas.util.StacklessException import com.viaversion.viaversion.api.protocol.packet.Direction import com.viaversion.viaversion.api.protocol.packet.State import com.viaversion.viaversion.api.protocol.version.ProtocolVersion -import com.viaversion.viaversion.api.type.Type -import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13 -import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14 -import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15 -import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2 -import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16 -import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17 -import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18 -import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1 -import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ServerboundPackets1_19_1 -import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3 -import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4 -import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19 -import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19 -import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundConfigurationPackets1_20_2 -import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2 -import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundConfigurationPackets1_20_2 -import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2 -import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundConfigurationPackets1_20_5 -import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPackets1_20_5 -import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundConfigurationPackets1_20_5 -import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPackets1_20_5 -import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8 -import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9 +import com.viaversion.viaversion.api.type.Types +import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13 +import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ClientboundPackets1_14 +import com.viaversion.viaversion.protocols.v1_14_4to1_15.packet.ClientboundPackets1_15 +import com.viaversion.viaversion.protocols.v1_15_2to1_16.packet.ClientboundPackets1_16 +import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ClientboundPackets1_16_2 +import com.viaversion.viaversion.protocols.v1_16_4to1_17.packet.ClientboundPackets1_17 +import com.viaversion.viaversion.protocols.v1_17_1to1_18.packet.ClientboundPackets1_18 +import com.viaversion.viaversion.protocols.v1_18_2to1_19.packet.ClientboundPackets1_19 +import com.viaversion.viaversion.protocols.v1_18_2to1_19.packet.ServerboundPackets1_19 +import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.packet.ClientboundPackets1_19_3 +import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ClientboundPackets1_19_4 +import com.viaversion.viaversion.protocols.v1_19to1_19_1.packet.ClientboundPackets1_19_1 +import com.viaversion.viaversion.protocols.v1_19to1_19_1.packet.ServerboundPackets1_19_1 +import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundConfigurationPackets1_20_5 +import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPackets1_20_5 +import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundConfigurationPackets1_20_5 +import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5 +import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundConfigurationPackets1_20_2 +import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundPackets1_20_2 +import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundConfigurationPackets1_20_2 +import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPackets1_20_2 +import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_8 +import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_9 import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBufAllocator import io.netty.util.ReferenceCountUtil @@ -76,30 +76,30 @@ object PacketRegistry { register( State.CONFIGURATION, Direction.CLIENTBOUND, ::ConfigurationCookieRequest, - ProtocolVersion.v1_20_5.singleton, ClientboundConfigurationPackets1_20_5.COOKIE_REQUEST.id + Range.atLeast(ProtocolVersion.v1_20_5), ClientboundConfigurationPackets1_20_5.COOKIE_REQUEST.id ) register( State.CONFIGURATION, Direction.CLIENTBOUND, ::ConfigurationPluginMessage, mapOf( ProtocolVersion.v1_20_2..ProtocolVersion.v1_20_3 to ClientboundConfigurationPackets1_20_2.CUSTOM_PAYLOAD.id, - ProtocolVersion.v1_20_5.singleton to ClientboundConfigurationPackets1_20_5.CUSTOM_PAYLOAD.id + Range.atLeast(ProtocolVersion.v1_20_5) to ClientboundConfigurationPackets1_20_5.CUSTOM_PAYLOAD.id ) ) register( State.CONFIGURATION, Direction.CLIENTBOUND, ::ConfigurationDisconnect, mapOf( ProtocolVersion.v1_20_2..ProtocolVersion.v1_20_3 to ClientboundConfigurationPackets1_20_2.DISCONNECT.id, - ProtocolVersion.v1_20_5.singleton to ClientboundConfigurationPackets1_20_5.DISCONNECT.id + Range.atLeast(ProtocolVersion.v1_20_5) to ClientboundConfigurationPackets1_20_5.DISCONNECT.id ) ) register( State.CONFIGURATION, Direction.CLIENTBOUND, ::FinishConfig, mapOf( ProtocolVersion.v1_20_2..ProtocolVersion.v1_20_3 to ClientboundConfigurationPackets1_20_2.FINISH_CONFIGURATION.id, - ProtocolVersion.v1_20_5.singleton to ClientboundConfigurationPackets1_20_5.FINISH_CONFIGURATION.id + Range.atLeast(ProtocolVersion.v1_20_5) to ClientboundConfigurationPackets1_20_5.FINISH_CONFIGURATION.id ) ) register( State.CONFIGURATION, Direction.CLIENTBOUND, ::ConfigurationKeepAlive, mapOf( 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 + Range.atLeast(ProtocolVersion.v1_20_5) to ClientboundConfigurationPackets1_20_5.KEEP_ALIVE.id ) ) register( @@ -109,24 +109,24 @@ object PacketRegistry { register( State.CONFIGURATION, Direction.SERVERBOUND, ::ConfigurationCookieResponse, - ProtocolVersion.v1_20_5.singleton, ServerboundConfigurationPackets1_20_5.COOKIE_RESPONSE.id + Range.atLeast(ProtocolVersion.v1_20_5), ServerboundConfigurationPackets1_20_5.COOKIE_RESPONSE.id ) 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_5.singleton to ServerboundConfigurationPackets1_20_5.CUSTOM_PAYLOAD.id + Range.atLeast(ProtocolVersion.v1_20_5) to ServerboundConfigurationPackets1_20_5.CUSTOM_PAYLOAD.id ) ) register( State.CONFIGURATION, Direction.SERVERBOUND, ::FinishConfig, mapOf( ProtocolVersion.v1_20_2..ProtocolVersion.v1_20_3 to ServerboundConfigurationPackets1_20_2.FINISH_CONFIGURATION.id, - ProtocolVersion.v1_20_5.singleton to ServerboundConfigurationPackets1_20_5.FINISH_CONFIGURATION.id + Range.atLeast(ProtocolVersion.v1_20_5) to ServerboundConfigurationPackets1_20_5.FINISH_CONFIGURATION.id ) ) register( State.CONFIGURATION, Direction.SERVERBOUND, ::ConfigurationKeepAlive, mapOf( ProtocolVersion.v1_20_2..ProtocolVersion.v1_20_3 to ServerboundConfigurationPackets1_20_2.KEEP_ALIVE.id, - ProtocolVersion.v1_20_5.singleton to ServerboundConfigurationPackets1_20_5.KEEP_ALIVE.id + Range.atLeast(ProtocolVersion.v1_20_5) to ServerboundConfigurationPackets1_20_5.KEEP_ALIVE.id ) ) @@ -146,26 +146,26 @@ object PacketRegistry { ProtocolVersion.v1_19_3.singleton to ClientboundPackets1_19_3.DISCONNECT.id, ProtocolVersion.v1_19_4..ProtocolVersion.v1_20 to ClientboundPackets1_19_4.DISCONNECT.id, ProtocolVersion.v1_20_2..ProtocolVersion.v1_20_3 to ClientboundPackets1_20_2.DISCONNECT.id, - ProtocolVersion.v1_20_5.singleton to ClientboundPackets1_20_5.DISCONNECT.id + ProtocolVersion.v1_20_5..ProtocolVersion.v1_21 to ClientboundPackets1_20_5.DISCONNECT.id ) ) register( State.PLAY, Direction.CLIENTBOUND, ::PluginMessage, mapOf( - ProtocolVersion.v1_7_2..ProtocolVersion.v1_8 to ClientboundPackets1_8.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_9..ProtocolVersion.v1_12_2 to ClientboundPackets1_9.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_13..ProtocolVersion.v1_13_2 to ClientboundPackets1_13.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_14..ProtocolVersion.v1_14_4 to ClientboundPackets1_14.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_15..ProtocolVersion.v1_15_2 to ClientboundPackets1_15.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_16..ProtocolVersion.v1_16_1 to ClientboundPackets1_16.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_16_2..ProtocolVersion.v1_16_4 to ClientboundPackets1_16_2.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_17..ProtocolVersion.v1_17_1 to ClientboundPackets1_17.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_18..ProtocolVersion.v1_18_2 to ClientboundPackets1_18.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_19.singleton to ClientboundPackets1_19.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_19_1.singleton to ClientboundPackets1_19_1.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_19_3.singleton to ClientboundPackets1_19_3.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_19_4..ProtocolVersion.v1_20 to ClientboundPackets1_19_4.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_20_2..ProtocolVersion.v1_20_3 to ClientboundPackets1_20_2.PLUGIN_MESSAGE.id, - ProtocolVersion.v1_20_5.singleton to ClientboundPackets1_20_5.PLUGIN_MESSAGE.id + ProtocolVersion.v1_7_2..ProtocolVersion.v1_8 to ClientboundPackets1_8.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_9..ProtocolVersion.v1_12_2 to ClientboundPackets1_9.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_13..ProtocolVersion.v1_13_2 to ClientboundPackets1_13.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_14..ProtocolVersion.v1_14_4 to ClientboundPackets1_14.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_15..ProtocolVersion.v1_15_2 to ClientboundPackets1_15.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_16..ProtocolVersion.v1_16_1 to ClientboundPackets1_16.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_16_2..ProtocolVersion.v1_16_4 to ClientboundPackets1_16_2.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_17..ProtocolVersion.v1_17_1 to ClientboundPackets1_17.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_18..ProtocolVersion.v1_18_2 to ClientboundPackets1_18.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_19.singleton to ClientboundPackets1_19.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_19_1.singleton to ClientboundPackets1_19_1.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_19_3.singleton to ClientboundPackets1_19_3.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_19_4..ProtocolVersion.v1_20 to ClientboundPackets1_19_4.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_20_2..ProtocolVersion.v1_20_3 to ClientboundPackets1_20_2.CUSTOM_PAYLOAD.id, + ProtocolVersion.v1_20_5..ProtocolVersion.v1_21 to ClientboundPackets1_20_5.CUSTOM_PAYLOAD.id ) ) register( @@ -175,7 +175,7 @@ object PacketRegistry { register( State.PLAY, Direction.SERVERBOUND, ::ConfigurationAck, mapOf( ProtocolVersion.v1_20_2..ProtocolVersion.v1_20_3 to ServerboundPackets1_20_2.CONFIGURATION_ACKNOWLEDGED.id, - ProtocolVersion.v1_20_5.singleton to ServerboundPackets1_20_5.CONFIGURATION_ACKNOWLEDGED.id + ProtocolVersion.v1_20_5..ProtocolVersion.v1_21 to ServerboundPackets1_20_5.CONFIGURATION_ACKNOWLEDGED.id ) ) // todo update chat to latest version @@ -190,8 +190,8 @@ object PacketRegistry { register( State.PLAY, Direction.SERVERBOUND, ::ServerboundChatMessage, mapOf( - ProtocolVersion.v1_19.singleton to ServerboundPackets1_19.CHAT_MESSAGE.id, - ProtocolVersion.v1_19_1.singleton to ServerboundPackets1_19_1.CHAT_MESSAGE.id + ProtocolVersion.v1_19.singleton to ServerboundPackets1_19.CHAT.id, + ProtocolVersion.v1_19_1.singleton to ServerboundPackets1_19_1.CHAT.id ) ) } @@ -255,7 +255,7 @@ object PacketRegistry { } fun decode(byteBuf: ByteBuf, protocolVersion: ProtocolVersion, state: State, direction: Direction): Packet { - val packetId = Type.VAR_INT.readPrimitive(byteBuf) + val packetId = Types.VAR_INT.readPrimitive(byteBuf) val packet = getPacketConstructor(protocolVersion, state, packetId, direction)?.get() ?: UnknownPacket(packetId, ByteBufAllocator.DEFAULT.buffer()) try { @@ -275,7 +275,7 @@ object PacketRegistry { getPacketId(packet.javaClass, protocolVersion, direction) ?: throw StacklessException("Failed to get id for " + packet::class.java.simpleName) } - Type.VAR_INT.writePrimitive(byteBuf, id) + Types.VAR_INT.writePrimitive(byteBuf, id) try { packet.encode(byteBuf, protocolVersion) } catch (e: Exception) { diff --git a/src/main/kotlin/com/viaversion/aas/codec/packet/login/CryptoResponse.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/login/CryptoResponse.kt index 54253b4..589c61c 100644 --- a/src/main/kotlin/com/viaversion/aas/codec/packet/login/CryptoResponse.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/login/CryptoResponse.kt @@ -4,7 +4,7 @@ import com.viaversion.aas.codec.packet.Packet import com.viaversion.aas.protocol.sharewareVersion import com.viaversion.aas.readByteArray import com.viaversion.viaversion.api.protocol.version.ProtocolVersion -import com.viaversion.viaversion.api.type.Type +import com.viaversion.viaversion.api.type.Types import io.netty.buffer.ByteBuf class CryptoResponse : Packet { @@ -17,18 +17,18 @@ class CryptoResponse : Packet { when { protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_19) && protocolVersion.olderThan(ProtocolVersion.v1_19_3) -> { - encryptedKey = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf) + encryptedKey = Types.BYTE_ARRAY_PRIMITIVE.read(byteBuf) if (byteBuf.readBoolean()) { - encryptedNonce = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf) + encryptedNonce = Types.BYTE_ARRAY_PRIMITIVE.read(byteBuf) } else { salt = byteBuf.readLong() - signature = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf) + signature = Types.BYTE_ARRAY_PRIMITIVE.read(byteBuf) } } protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_8) || protocolVersion.equalTo(sharewareVersion) -> { - encryptedKey = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf) - encryptedNonce = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf) + encryptedKey = Types.BYTE_ARRAY_PRIMITIVE.read(byteBuf) + encryptedNonce = Types.BYTE_ARRAY_PRIMITIVE.read(byteBuf) } else -> { @@ -42,20 +42,20 @@ class CryptoResponse : Packet { when { protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_19) && protocolVersion.olderThan(ProtocolVersion.v1_19_3) -> { - Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedKey) + Types.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedKey) if (encryptedNonce != null) { byteBuf.writeBoolean(true) - Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedNonce) + Types.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedNonce) } else { byteBuf.writeBoolean(false) byteBuf.writeLong(salt!!) - Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, signature) + Types.BYTE_ARRAY_PRIMITIVE.write(byteBuf, signature) } } protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_8) || protocolVersion.equalTo(sharewareVersion) -> { - Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedKey) - Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedNonce) + Types.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedKey) + Types.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedNonce) } else -> { diff --git a/src/main/kotlin/com/viaversion/aas/codec/packet/login/LoginSuccess.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/login/LoginSuccess.kt index 6863dfc..e1c473e 100644 --- a/src/main/kotlin/com/viaversion/aas/codec/packet/login/LoginSuccess.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/login/LoginSuccess.kt @@ -5,7 +5,7 @@ import com.viaversion.aas.parseUndashedId import com.viaversion.aas.protocol.sharewareVersion import com.viaversion.aas.util.SignableProperty import com.viaversion.viaversion.api.protocol.version.ProtocolVersion -import com.viaversion.viaversion.api.type.Type +import com.viaversion.viaversion.api.type.Types import io.netty.buffer.ByteBuf import java.util.* @@ -18,20 +18,20 @@ class LoginSuccess : Packet { override fun decode(byteBuf: ByteBuf, protocolVersion: ProtocolVersion) { id = when { protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_16) -> { - Type.UUID.read(byteBuf) + Types.UUID.read(byteBuf) } protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_7_6) || protocolVersion.equalTo(sharewareVersion) -> { - UUID.fromString(Type.STRING.read(byteBuf)) + UUID.fromString(Types.STRING.read(byteBuf)) } - else -> parseUndashedId(Type.STRING.read(byteBuf)) + else -> parseUndashedId(Types.STRING.read(byteBuf)) } - username = Type.STRING.read(byteBuf) + username = Types.STRING.read(byteBuf) if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_19)) { - val properties = Type.VAR_INT.readPrimitive(byteBuf) + val properties = Types.VAR_INT.readPrimitive(byteBuf) for (i in 0 until properties) { - val name = Type.STRING.read(byteBuf) - val value = Type.STRING.read(byteBuf) - val signature = Type.OPTIONAL_STRING.read(byteBuf) + val name = Types.STRING.read(byteBuf) + val value = Types.STRING.read(byteBuf) + val signature = Types.OPTIONAL_STRING.read(byteBuf) this.properties.add(SignableProperty(name, value, signature)) } } @@ -43,20 +43,20 @@ class LoginSuccess : Packet { override fun encode(byteBuf: ByteBuf, protocolVersion: ProtocolVersion) { when { protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_16) -> { - Type.UUID.write(byteBuf, id) + Types.UUID.write(byteBuf, id) } protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_7_6) || protocolVersion.equalTo(sharewareVersion) -> { - Type.STRING.write(byteBuf, id.toString()) + Types.STRING.write(byteBuf, id.toString()) } - else -> Type.STRING.write(byteBuf, id.toString().replace("-", "")) + else -> Types.STRING.write(byteBuf, id.toString().replace("-", "")) } - Type.STRING.write(byteBuf, username) + Types.STRING.write(byteBuf, username) if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_19)) { - Type.VAR_INT.writePrimitive(byteBuf, properties.size) + Types.VAR_INT.writePrimitive(byteBuf, properties.size) for (property in properties) { - Type.STRING.write(byteBuf, property.key) - Type.STRING.write(byteBuf, property.value) - Type.OPTIONAL_STRING.write(byteBuf, property.signature) + Types.STRING.write(byteBuf, property.key) + Types.STRING.write(byteBuf, property.value) + Types.OPTIONAL_STRING.write(byteBuf, property.signature) } } if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_5)) { diff --git a/src/main/kotlin/com/viaversion/aas/command/sub/ConnectionsSubCommand.kt b/src/main/kotlin/com/viaversion/aas/command/sub/ConnectionsSubCommand.kt index 652a964..d56525a 100644 --- a/src/main/kotlin/com/viaversion/aas/command/sub/ConnectionsSubCommand.kt +++ b/src/main/kotlin/com/viaversion/aas/command/sub/ConnectionsSubCommand.kt @@ -5,7 +5,7 @@ import com.viaversion.viaversion.api.Via import com.viaversion.viaversion.api.command.ViaCommandSender import com.viaversion.viaversion.api.command.ViaSubCommand -object ConnectionsSubCommand : ViaSubCommand() { +object ConnectionsSubCommand : ViaSubCommand { override fun name(): String = "connections" override fun description(): String = "Lists VIAaaS connections" override fun execute(p0: ViaCommandSender, p1: Array): Boolean { diff --git a/src/main/kotlin/com/viaversion/aas/command/sub/StopSubCommand.kt b/src/main/kotlin/com/viaversion/aas/command/sub/StopSubCommand.kt index a949aa2..89ed704 100644 --- a/src/main/kotlin/com/viaversion/aas/command/sub/StopSubCommand.kt +++ b/src/main/kotlin/com/viaversion/aas/command/sub/StopSubCommand.kt @@ -4,7 +4,7 @@ import com.viaversion.aas.AspirinServer import com.viaversion.viaversion.api.command.ViaCommandSender import com.viaversion.viaversion.api.command.ViaSubCommand -object StopSubCommand : ViaSubCommand() { +object StopSubCommand : ViaSubCommand { override fun name() = "stop" override fun description(): String = "Stops VIAaaS" override fun execute(sender: ViaCommandSender, p1: Array): Boolean { diff --git a/src/main/kotlin/com/viaversion/aas/command/sub/VIAaaSSubCommand.kt b/src/main/kotlin/com/viaversion/aas/command/sub/VIAaaSSubCommand.kt index b8ce77c..8ee0792 100644 --- a/src/main/kotlin/com/viaversion/aas/command/sub/VIAaaSSubCommand.kt +++ b/src/main/kotlin/com/viaversion/aas/command/sub/VIAaaSSubCommand.kt @@ -7,7 +7,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.launch -object VIAaaSSubCommand : ViaSubCommand() { +object VIAaaSSubCommand : ViaSubCommand { override fun name(): String = "viaaas" override fun description(): String = "Info about VIAaaS" override fun execute(p0: ViaCommandSender, p1: Array): Boolean { diff --git a/src/main/kotlin/com/viaversion/aas/config/VIAaaSConfig.kt b/src/main/kotlin/com/viaversion/aas/config/VIAaaSConfig.kt index 3a7ee58..1c49c7c 100644 --- a/src/main/kotlin/com/viaversion/aas/config/VIAaaSConfig.kt +++ b/src/main/kotlin/com/viaversion/aas/config/VIAaaSConfig.kt @@ -3,6 +3,7 @@ package com.viaversion.aas.config import com.google.common.net.HostAndPort import com.viaversion.aas.secureRandom import com.viaversion.aas.util.AddressParser +import com.viaversion.aas.viaaasLoggerJava import com.viaversion.viaversion.util.Config import net.coobird.thumbnailator.Thumbnails import net.coobird.thumbnailator.filters.Canvas @@ -13,7 +14,7 @@ import java.net.URI import java.net.URL import java.util.* -object VIAaaSConfig : Config(File("config/viaaas.yml")), com.viaversion.viaversion.api.configuration.Config { +object VIAaaSConfig : Config(File("config/viaaas.yml"), viaaasLoggerJava), com.viaversion.viaversion.api.configuration.Config { var defaultParameters: Map = emptyMap() var bindAddresses = emptyList() var hostName: List = emptyList() diff --git a/src/main/kotlin/com/viaversion/aas/handler/HandlerUtil.kt b/src/main/kotlin/com/viaversion/aas/handler/HandlerUtil.kt index 5e9a3b5..9fe4bdb 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/HandlerUtil.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/HandlerUtil.kt @@ -6,6 +6,7 @@ import com.viaversion.aas.readRemainingBytes import com.viaversion.aas.send import com.viaversion.viaversion.api.protocol.version.ProtocolVersion import com.viaversion.viaversion.api.type.Type +import com.viaversion.viaversion.api.type.Types import io.netty.buffer.ByteBufAllocator import io.netty.buffer.Unpooled import io.netty.channel.Channel @@ -43,7 +44,7 @@ fun decodeBrand(data: ByteArray, is17: Boolean): String { String(data, Charsets.UTF_8) } else -> { - Type.STRING.read(Unpooled.wrappedBuffer(data)) + Types.STRING.read(Unpooled.wrappedBuffer(data)) } } } @@ -54,7 +55,7 @@ fun encodeBrand(string: String, is17: Boolean): ByteArray { } else { val buf = ByteBufAllocator.DEFAULT.buffer() try { - Type.STRING.write(buf, string) + Types.STRING.write(buf, string) readRemainingBytes(buf) } finally { buf.release() diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/HandlerStateUtil.kt b/src/main/kotlin/com/viaversion/aas/handler/state/HandlerStateUtil.kt index 3824414..3a6e631 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/HandlerStateUtil.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/HandlerStateUtil.kt @@ -12,6 +12,7 @@ import com.viaversion.aas.util.IntendedState import com.viaversion.aas.util.StacklessException import com.viaversion.viaversion.api.protocol.version.ProtocolVersion import com.viaversion.viaversion.api.type.Type +import com.viaversion.viaversion.api.type.Types import io.ktor.server.netty.* import io.netty.bootstrap.Bootstrap import io.netty.buffer.ByteBufAllocator @@ -161,8 +162,8 @@ val openAuthMagic = 0xfdebf3fd.toInt() fun encodeCompressionOpenAuth(channel: String, id: Int, data: ByteArray): IntArray { val buffer = ByteBufAllocator.DEFAULT.buffer() try { - Type.STRING.write(buffer, channel) - Type.VAR_INT.writePrimitive(buffer, id) + Types.STRING.write(buffer, channel) + Types.VAR_INT.writePrimitive(buffer, id) buffer.writeBytes(data) val out = IntArray(2 + ceil(buffer.readableBytes() / 3.0).toInt()) diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt b/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt index 5cdac17..312a4f1 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt @@ -16,7 +16,7 @@ import com.viaversion.aas.util.StacklessException import com.viaversion.aas.web.TempLoginInfo import com.viaversion.viaversion.api.protocol.packet.State import com.viaversion.viaversion.api.protocol.version.ProtocolVersion -import com.viaversion.viaversion.api.type.Type +import com.viaversion.viaversion.api.type.Types import io.netty.buffer.ByteBufAllocator import io.netty.buffer.Unpooled import io.netty.channel.Channel @@ -140,7 +140,7 @@ class LoginState : ConnectionState { pendingReauth = ThreadLocalRandom.current().nextInt() val buf = ByteBufAllocator.DEFAULT.buffer() try { - Type.STRING.write(buf, backHash) + Types.STRING.write(buf, backHash) sendOpenAuthRequest(handler, "oam:join", pendingReauth!!, readRemainingBytes(buf)) } finally { buf.release() @@ -222,7 +222,7 @@ class LoginState : ConnectionState { fun handleCryptoResponse(handler: MinecraftHandler, cryptoResponse: CryptoResponse) { if ("oam:data".encodeToByteArray().contentEquals(cryptoResponse.encryptedNonce)) { val buffer = Unpooled.wrappedBuffer(cryptoResponse.encryptedKey) - val id = Type.VAR_INT.readPrimitive(buffer) + val id = Types.VAR_INT.readPrimitive(buffer) val data = readRemainingBytes(buffer) if (handleReauthResponse(PluginResponse().also { it.isSuccess = true diff --git a/src/main/kotlin/com/viaversion/aas/platform/AspirinPlatform.kt b/src/main/kotlin/com/viaversion/aas/platform/AspirinPlatform.kt index ff54c0d..f3948d5 100644 --- a/src/main/kotlin/com/viaversion/aas/platform/AspirinPlatform.kt +++ b/src/main/kotlin/com/viaversion/aas/platform/AspirinPlatform.kt @@ -74,7 +74,6 @@ object AspirinPlatform : ViaPlatform { override fun getPlatformName() = "VIAaaS" override fun getPlatformVersion() = AspirinServer.version override fun getPluginVersion() = VersionInfo.VERSION - override fun isOldClientsAllowed() = true override fun hasPlugin(name: String?) = false override fun isProxy() = true