the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2
3#include "Packet.h"
4
5class ServerAuthDataPacket : public Packet
6{
7#if 0
8 private String serverId;
9 private PublicKey publicKey;
10 private byte[] nonce = new byte[]{};
11
12 public ServerAuthDataPacket() {
13 // Needed
14 }
15
16 public ServerAuthDataPacket(final String serverId, final PublicKey publicKey, final byte[] nonce) {
17 this.serverId = serverId;
18 this.publicKey = publicKey;
19 this.nonce = nonce;
20 }
21
22 @Override
23 public void read(DataInputStream dis) throws IOException {
24 serverId = readUtf(dis, 20);
25 publicKey = Crypt.byteToPublicKey(readBytes(dis));
26 nonce = readBytes(dis);
27 }
28
29 @Override
30 public void write(DataOutputStream dos) throws IOException {
31 writeUtf(serverId, dos);
32 writeBytes(dos, publicKey.getEncoded());
33 writeBytes(dos, nonce);
34 }
35
36 @Override
37 public void handle(PacketListener listener) {
38 listener.handleServerAuthData(this);
39 }
40
41 @Override
42 public int getEstimatedSize() {
43 return 2 + serverId.length() * 2 + 2 + publicKey.getEncoded().length + 2 + nonce.length;
44 }
45
46 public String getServerId() {
47 return serverId;
48 }
49
50 public PublicKey getPublicKey() {
51 return publicKey;
52 }
53
54 public byte[] getNonce() {
55 return nonce;
56 }
57#endif
58};