Finish up protocol API - we now compile again. Extensive testing is required, but that is for another day.

This commit is contained in:
md_5
2013-05-30 19:11:05 +10:00
parent 9b0c827c37
commit d82b29e15a
25 changed files with 232 additions and 98 deletions

View File

@@ -2,14 +2,16 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class Packet0KeepAlive extends DefinedPacket
{
private int id;
private int randomId;
private Packet0KeepAlive()
{
@@ -19,13 +21,13 @@ public class Packet0KeepAlive extends DefinedPacket
@Override
public void read(ByteBuf buf)
{
id = buf.readInt();
randomId = buf.readInt();
}
@Override
public void write(ByteBuf buf)
{
buf.writeInt( id );
buf.writeInt( randomId );
}
@Override

View File

@@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class Packet1Login extends DefinedPacket
@@ -22,6 +24,23 @@ public class Packet1Login extends DefinedPacket
super( 0x01 );
}
public Packet1Login(int entityId, String levelType, byte gameMode, byte dimension, byte difficulty, byte unused, byte maxPlayers)
{
this( entityId, levelType, gameMode, entityId, difficulty, unused, maxPlayers );
}
public Packet1Login(int entityId, String levelType, byte gameMode, int dimension, byte difficulty, byte unused, byte maxPlayers)
{
this();
this.entityId = entityId;
this.levelType = levelType;
this.gameMode = gameMode;
this.dimension = dimension;
this.difficulty = difficulty;
this.unused = unused;
this.maxPlayers = maxPlayers;
}
@Override
public void read(ByteBuf buf)
{

View File

@@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class Packet2Handshake extends DefinedPacket

View File

@@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class Packet3Chat extends DefinedPacket
@@ -16,6 +18,12 @@ public class Packet3Chat extends DefinedPacket
super( 0x03 );
}
public Packet3Chat(String message)
{
this();
this.message = message;
}
@Override
public void read(ByteBuf buf)
{

View File

@@ -20,6 +20,16 @@ public class Packet9Respawn extends DefinedPacket
super( 0x09 );
}
public Packet9Respawn(int dimension, byte difficulty, byte gameMode, short worldHeight, String levelType)
{
this();
this.dimension = dimension;
this.difficulty = difficulty;
this.gameMode = gameMode;
this.worldHeight = worldHeight;
this.levelType = levelType;
}
@Override
public void read(ByteBuf buf)
{

View File

@@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketC9PlayerListItem extends DefinedPacket

View File

@@ -16,6 +16,12 @@ public class PacketCDClientStatus extends DefinedPacket
super( 0xCD );
}
public PacketCDClientStatus(byte payload)
{
this();
this.payload = payload;
}
@Override
public void read(ByteBuf buf)
{

View File

@@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketCEScoreboardObjective extends DefinedPacket
@@ -21,6 +23,14 @@ public class PacketCEScoreboardObjective extends DefinedPacket
super( 0xCE );
}
public PacketCEScoreboardObjective(String name, String text, byte action)
{
this();
this.name = name;
this.text = text;
this.action = action;
}
@Override
public void read(ByteBuf buf)
{

View File

@@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketCFScoreboardScore extends DefinedPacket

View File

@@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketD0DisplayScoreboard extends DefinedPacket

View File

@@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketD1Team extends DefinedPacket
@@ -26,22 +28,33 @@ public class PacketD1Team extends DefinedPacket
super( 0xD1 );
}
/**
* Packet to destroy a team.
*
* @param name
*/
public PacketD1Team(String name)
{
this();
mode = 1;
}
@Override
public void read(ByteBuf buf)
{
name = readString( buf );
mode = buf.readByte();
if ( mode == 0 || mode == 2 )
if ( getMode() == 0 || getMode() == 2 )
{
displayName = readString( buf );
prefix = readString( buf );
suffix = readString( buf );
friendlyFire = buf.readBoolean();
}
if ( mode == 0 || mode == 3 || mode == 4 )
if ( getMode() == 0 || getMode() == 3 || getMode() == 4 )
{
players = new String[ buf.readShort() ];
for ( int i = 0; i < players.length; i++ )
for ( int i = 0; i < getPlayers().length; i++ )
{
players[i] = readString( buf );
}
@@ -51,21 +64,21 @@ public class PacketD1Team extends DefinedPacket
@Override
public void write(ByteBuf buf)
{
writeString( name, buf );
buf.writeByte( mode );
if ( mode == 0 || mode == 2 )
writeString( getName(), buf );
buf.writeByte( getMode() );
if ( getMode() == 0 || getMode() == 2 )
{
writeString( displayName, buf );
writeString( prefix, buf );
writeString( suffix, buf );
buf.writeBoolean( friendlyFire );
writeString( getDisplayName(), buf );
writeString( getPrefix(), buf );
writeString( getSuffix(), buf );
buf.writeBoolean( isFriendlyFire() );
}
if ( mode == 0 || mode == 3 || mode == 4 )
if ( getMode() == 0 || getMode() == 3 || getMode() == 4 )
{
buf.writeShort( players.length );
for ( int i = 0; i < players.length; i++ )
buf.writeShort( getPlayers().length );
for ( int i = 0; i < getPlayers().length; i++ )
{
writeString( players[i], buf );
writeString( getPlayers()[i], buf );
}
}
}

View File

@@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketFAPluginMessage extends DefinedPacket
@@ -17,6 +19,13 @@ public class PacketFAPluginMessage extends DefinedPacket
super( 0xFA );
}
public PacketFAPluginMessage(String tag, byte[] data)
{
this();
this.tag = tag;
this.data = data;
}
@Override
public void read(ByteBuf buf)
{

View File

@@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketFCEncryptionResponse extends DefinedPacket
@@ -17,6 +19,13 @@ public class PacketFCEncryptionResponse extends DefinedPacket
super( 0xFC );
}
public PacketFCEncryptionResponse(byte[] sharedSecret, byte[] verifyToken)
{
this();
this.sharedSecret = sharedSecret;
this.verifyToken = verifyToken;
}
@Override
public void read(ByteBuf buf)
{

View File

@@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketFDEncryptionRequest extends DefinedPacket
@@ -18,6 +20,14 @@ public class PacketFDEncryptionRequest extends DefinedPacket
super( 0xFD );
}
public PacketFDEncryptionRequest(String serverId, byte[] publicKey, byte[] verifyToken)
{
this();
this.serverId = serverId;
this.publicKey = publicKey;
this.verifyToken = verifyToken;
}
@Override
public void read(ByteBuf buf)
{

View File

@@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketFFKick extends DefinedPacket
@@ -16,6 +18,12 @@ public class PacketFFKick extends DefinedPacket
super( 0xFF );
}
public PacketFFKick(String message)
{
this();
this.message = message;
}
@Override
public void read(ByteBuf buf)
{

View File

@@ -10,6 +10,11 @@ import lombok.ToString;
public class Forge1Login extends Packet1Login
{
public Forge1Login(int entityId, String levelType, byte gameMode, int dimension, byte difficulty, byte unused, byte maxPlayers)
{
super( entityId, levelType, gameMode, dimension, difficulty, unused, maxPlayers );
}
@Override
public void read(ByteBuf buf)
{
@@ -28,7 +33,7 @@ public class Forge1Login extends Packet1Login
buf.writeInt( entityId );
writeString( levelType, buf );
buf.writeByte( gameMode );
buf.writeInt(dimension );
buf.writeInt( dimension );
buf.writeByte( difficulty );
buf.writeByte( unused );
buf.writeByte( maxPlayers );