aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/ServerAuthDataPacket.h
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/ServerAuthDataPacket.h
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/ServerAuthDataPacket.h')
-rw-r--r--Minecraft.World/ServerAuthDataPacket.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/Minecraft.World/ServerAuthDataPacket.h b/Minecraft.World/ServerAuthDataPacket.h
new file mode 100644
index 00000000..c56844d1
--- /dev/null
+++ b/Minecraft.World/ServerAuthDataPacket.h
@@ -0,0 +1,58 @@
+#pragma once
+
+#include "Packet.h"
+
+class ServerAuthDataPacket : public Packet
+{
+#if 0
+ private String serverId;
+ private PublicKey publicKey;
+ private byte[] nonce = new byte[]{};
+
+ public ServerAuthDataPacket() {
+ // Needed
+ }
+
+ public ServerAuthDataPacket(final String serverId, final PublicKey publicKey, final byte[] nonce) {
+ this.serverId = serverId;
+ this.publicKey = publicKey;
+ this.nonce = nonce;
+ }
+
+ @Override
+ public void read(DataInputStream dis) throws IOException {
+ serverId = readUtf(dis, 20);
+ publicKey = Crypt.byteToPublicKey(readBytes(dis));
+ nonce = readBytes(dis);
+ }
+
+ @Override
+ public void write(DataOutputStream dos) throws IOException {
+ writeUtf(serverId, dos);
+ writeBytes(dos, publicKey.getEncoded());
+ writeBytes(dos, nonce);
+ }
+
+ @Override
+ public void handle(PacketListener listener) {
+ listener.handleServerAuthData(this);
+ }
+
+ @Override
+ public int getEstimatedSize() {
+ return 2 + serverId.length() * 2 + 2 + publicKey.getEncoded().length + 2 + nonce.length;
+ }
+
+ public String getServerId() {
+ return serverId;
+ }
+
+ public PublicKey getPublicKey() {
+ return publicKey;
+ }
+
+ public byte[] getNonce() {
+ return nonce;
+ }
+#endif
+}; \ No newline at end of file