From 55ffe7219812a1d44815014095f5ccd2351f3697 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 15 Jul 2022 21:33:55 +0200 Subject: [PATCH] Fix overlay type check, update some comments --- .../protocol1_19_1to1_19/Protocol1_19_1To1_19.java | 12 ++++++------ .../protocol1_19to1_18_2/Protocol1_19To1_18_2.java | 2 +- .../com/viaversion/viaversion/util/CipherUtil.java | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java index 8a5925e83..b8b9b4705 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java @@ -94,14 +94,14 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol { - // Back to system chat - final JsonElement signedContnet = wrapper.read(Type.COMPONENT); + // Back to system chat - bye bye chat formats for 1.19.0 players + // ... not that big of a deal since the majority of modded servers only has Vanilla /say command and the alike sent as proper player chat + final JsonElement signedContent = wrapper.read(Type.COMPONENT); final JsonElement unsignedContent = wrapper.read(Type.OPTIONAL_COMPONENT); - wrapper.write(Type.COMPONENT, unsignedContent != null ? unsignedContent : signedContnet); + wrapper.write(Type.COMPONENT, unsignedContent != null ? unsignedContent : signedContent); - // Can only be 1 (chat) or 2 (game info) as per 1.18.2->1.19 transformer final int type = wrapper.read(Type.VAR_INT); - wrapper.write(Type.BOOLEAN, type == 1); // Overlay + wrapper.write(Type.BOOLEAN, type == 2); // Overlay, going by the default 1.19 chat type registry }); read(Type.UUID); // Sender uuid read(Type.COMPONENT); // Sender display name @@ -187,7 +187,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol { final byte[] publicKey = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); final byte[] nonce = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); - wrapper.user().put(new NonceStorage(CipherUtil.signNonce(publicKey, nonce))); + wrapper.user().put(new NonceStorage(CipherUtil.encryptNonce(publicKey, nonce))); }); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/util/CipherUtil.java b/common/src/main/java/com/viaversion/viaversion/util/CipherUtil.java index 93ba320c2..3ba951bf1 100644 --- a/common/src/main/java/com/viaversion/viaversion/util/CipherUtil.java +++ b/common/src/main/java/com/viaversion/viaversion/util/CipherUtil.java @@ -36,7 +36,7 @@ public final class CipherUtil { } } - public static byte[] signNonce(final byte[] publicKeyBytes, final byte[] nonceBytes) throws Exception { + public static byte[] encryptNonce(final byte[] publicKeyBytes, final byte[] nonceBytes) throws Exception { final EncodedKeySpec keySpec = new X509EncodedKeySpec(publicKeyBytes); final PublicKey key = RSA_FACTORY.generatePublic(keySpec); final Cipher cipher = Cipher.getInstance(key.getAlgorithm());