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 )
{
buf.markReaderIndex();
buf.markWriterIndex();
ret = constructor.newInstance( buf );
buf.resetReaderIndex();
buf.resetWriterIndex();
}
} catch ( IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException ex )
{

View File

@ -27,6 +27,13 @@ public class Packet1Login extends DefinedPacket
writeByte( difficulty );
writeByte( unused );
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)

View File

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

View File

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

View File

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

View File

@ -9,6 +9,10 @@ import lombok.ToString;
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 );
/**

View File

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