Fix overlay type check, update some comments

This commit is contained in:
Nassim Jahnke 2022-07-15 21:33:55 +02:00
parent a47dd2ecdb
commit 55ffe72198
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
3 changed files with 8 additions and 8 deletions

View File

@ -94,14 +94,14 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
@Override
public void registerMap() {
handler(wrapper -> {
// 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<ClientboundPack
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)));
});
}
});

View File

@ -240,7 +240,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
handler(wrapper -> {
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)));
});
}
});

View File

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