Small cleanup of packet classes

This commit is contained in:
md_5 2013-03-09 14:23:40 +11:00
parent 6525502836
commit f0a19e0f45
7 changed files with 23 additions and 2 deletions

View File

@ -105,10 +105,8 @@ public abstract class DefinedPacket implements ByteBuf
if ( constructor != null ) if ( constructor != null )
{ {
buf.markReaderIndex(); buf.markReaderIndex();
buf.markWriterIndex();
ret = constructor.newInstance( buf ); ret = constructor.newInstance( buf );
buf.resetReaderIndex(); buf.resetReaderIndex();
buf.resetWriterIndex();
} }
} catch ( IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException ex ) } catch ( IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException ex )
{ {

View File

@ -27,6 +27,13 @@ public class Packet1Login extends DefinedPacket
writeByte( difficulty ); writeByte( difficulty );
writeByte( unused ); writeByte( unused );
writeByte( maxPlayers ); writeByte( maxPlayers );
this.entityId = entityId;
this.levelType = levelType;
this.gameMode = gameMode;
this.dimension = dimension;
this.difficulty = difficulty;
this.unused = unused;
this.maxPlayers = maxPlayers;
} }
Packet1Login(ByteBuf buf) Packet1Login(ByteBuf buf)

View File

@ -21,6 +21,10 @@ public class Packet2Handshake extends DefinedPacket
writeString( username ); writeString( username );
writeString( host ); writeString( host );
writeInt( port ); writeInt( port );
this.procolVersion = protocolVersion;
this.username = username;
this.host = host;
this.port = port;
} }
Packet2Handshake(ByteBuf buf) Packet2Handshake(ByteBuf buf)

View File

@ -15,6 +15,7 @@ public class Packet3Chat extends DefinedPacket
{ {
super( 0x03 ); super( 0x03 );
writeString( message ); writeString( message );
this.message = message;
} }
Packet3Chat(ByteBuf buf) Packet3Chat(ByteBuf buf)

View File

@ -25,6 +25,11 @@ public class Packet9Respawn extends DefinedPacket
writeByte( gameMode ); writeByte( gameMode );
writeShort( worldHeight ); writeShort( worldHeight );
writeString( levelType ); writeString( levelType );
this.dimension = dimension;
this.difficulty = difficulty;
this.gameMode = gameMode;
this.worldHeight = worldHeight;
this.levelType = levelType;
} }
Packet9Respawn(ByteBuf buf) Packet9Respawn(ByteBuf buf)

View File

@ -9,6 +9,10 @@ import lombok.ToString;
public class PacketCDClientStatus extends DefinedPacket public class PacketCDClientStatus extends DefinedPacket
{ {
/**
* Represents the packet the client sends to the server when it is ready to
* login.
*/
public static PacketCDClientStatus CLIENT_LOGIN = new PacketCDClientStatus( (byte) 0 ); public static PacketCDClientStatus CLIENT_LOGIN = new PacketCDClientStatus( (byte) 0 );
/** /**

View File

@ -24,6 +24,8 @@ public class PacketFCEncryptionResponse extends DefinedPacket
super( 0xFC ); super( 0xFC );
writeArray( sharedSecret ); writeArray( sharedSecret );
writeArray( verifyToken ); writeArray( verifyToken );
this.sharedSecret = sharedSecret;
this.verifyToken = verifyToken;
} }
PacketFCEncryptionResponse(ByteBuf buf) PacketFCEncryptionResponse(ByteBuf buf)