update to viaversion 5

This commit is contained in:
creeper123123321 2024-06-18 11:09:28 -03:00
parent e6676c93d9
commit 5515f507fa
39 changed files with 208 additions and 202 deletions

View File

@ -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")

View File

@ -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<ByteBuf, ByteBuf> {
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<ByteBuf, ByteBuf> {
protected void decode(ChannelHandlerContext ctx, ByteBuf input, List<Object> 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;

View File

@ -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<ByteBuf> {
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<ByteBuf> {
@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);
}
}

View File

@ -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);
}
}

View File

@ -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() {

View File

@ -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() {

View File

@ -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());
}
}
}

View File

@ -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());
}
}

View File

@ -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);
}
}

View File

@ -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() {

View File

@ -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() {

View File

@ -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);

View File

@ -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);
}
}
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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

View File

@ -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

View File

@ -13,12 +13,6 @@ public class FutureTask implements PlatformTask<Future<?>> {
this.object = object;
}
@Override
@Deprecated
public @Nullable Future<?> getObject() {
return object;
}
@Override
public void cancel() {
object.cancel(false);

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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 {

View File

@ -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

View File

@ -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 {

View File

@ -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()
}

View File

@ -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) {

View File

@ -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 -> {

View File

@ -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)) {

View File

@ -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<out String>): Boolean {

View File

@ -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<String>): Boolean {

View File

@ -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<out String>): Boolean {

View File

@ -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<Int, AddressParser> = emptyMap()
var bindAddresses = emptyList<HostAndPort>()
var hostName: List<String> = emptyList()

View File

@ -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()

View File

@ -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())

View File

@ -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

View File

@ -74,7 +74,6 @@ object AspirinPlatform : ViaPlatform<UserConnection> {
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