the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 74 lines 1.6 kB view raw
1#pragma once 2 3#include "Packet.h" 4 5class ClientProtocolPacket : public Packet 6{ 7#if 0 8 private int protocolVersion; 9 private String userName; 10 11 // [EB]: Two fields below exist because we used to have a feature where we sent this 12 // information so people with dynamic proxies know where to connect us to. 13 private String hostName; 14 private int port; 15 16 public ClientProtocolPacket() { 17 // Needed 18 } 19 20 public ClientProtocolPacket(final int protocolVersion, final String userName, final String hostName, final int port) { 21 this.protocolVersion = protocolVersion; 22 this.userName = userName; 23 this.hostName = hostName; 24 this.port = port; 25 } 26 27 @Override 28 public void read(DataInputStream dis) throws IOException { 29 protocolVersion = dis.readByte(); 30 userName = readUtf(dis, Player.MAX_NAME_LENGTH); 31 hostName = readUtf(dis, 255); 32 port = dis.readInt(); 33 } 34 35 @Override 36 public void write(DataOutputStream dos) throws IOException { 37 dos.writeByte(protocolVersion); 38 writeUtf(userName, dos); 39 writeUtf(hostName, dos); 40 dos.writeInt(port); 41 } 42 43 @Override 44 public void handle(PacketListener listener) { 45 listener.handleClientProtocolPacket(this); 46 } 47 48 @Override 49 public int getEstimatedSize() { 50 return 1 + 2 + 2 * userName.length(); 51 } 52 53 public int getProtocolVersion() { 54 return protocolVersion; 55 } 56 57 public String getUserName() { 58 return userName; 59 } 60 61 public String getHostName() { 62 return hostName; 63 } 64 65 public int getPort() { 66 return port; 67 } 68 69 @Override 70 public String getDebugInfo() { 71 return String.format("ver=%d, name='%s'", protocolVersion, userName); 72 } 73#endif 74};