Finish and create passing unit tests for the integrity of all packet classes.

This commit is contained in:
md_5 2013-05-30 17:34:56 +10:00
parent 835e4e332c
commit ad4c143ce4
22 changed files with 380 additions and 274 deletions

View File

@ -3,14 +3,19 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public abstract class DefinedPacket
{
@SuppressWarnings("unchecked")
private static Class<? extends DefinedPacket>[] classes = new Class[ 256 ];
public static Class<? extends DefinedPacket>[] classes = new Class[ 256 ];
@SuppressWarnings("unchecked")
private static Constructor<? extends DefinedPacket>[] consructors = new Constructor[ 256 ];
private final int id;
public static DefinedPacket packet(ByteBuf buf)
{
@ -31,9 +36,9 @@ public abstract class DefinedPacket
if ( constructor != null )
{
ret = constructor.newInstance( buf );
ret = constructor.newInstance();
}
} catch ( IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException ex )
} catch ( NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex )
{
}
}
@ -41,6 +46,11 @@ public abstract class DefinedPacket
return ret;
}
public final int getId()
{
return id;
}
public void writeString(String s, ByteBuf buf)
{
// TODO: Check len - use Guava?

View File

@ -1,20 +1,21 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
@ToString
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class Packet0KeepAlive extends DefinedPacket
{
private int id;
Packet0KeepAlive()
{
super( 0x00 );
}
@Override
public void read(ByteBuf buf)
{

View File

@ -1,14 +1,10 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
@ToString
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class Packet1Login extends DefinedPacket
{
@ -21,6 +17,11 @@ public class Packet1Login extends DefinedPacket
private byte unused;
private byte maxPlayers;
Packet1Login()
{
super( 0x01 );
}
@Override
public void read(ByteBuf buf)
{

View File

@ -1,39 +1,40 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
public class Packet2Handshake extends DefinedPacket
{
public byte procolVersion;
public String username;
public String host;
public int port;
private byte procolVersion;
private String username;
private String host;
private int port;
public Packet2Handshake(byte protocolVersion, String username, String host, int port)
Packet2Handshake()
{
super( 0x02 );
writeByte( protocolVersion );
writeString( username );
writeString( host );
writeInt( port );
this.procolVersion = protocolVersion;
this.username = username;
this.host = host;
this.port = port;
}
Packet2Handshake(byte[] buf)
@Override
public void read(ByteBuf buf)
{
super( 0x02, buf );
this.procolVersion = readByte();
this.username = readUTF();
this.host = readUTF();
this.port = readInt();
procolVersion = buf.readByte();
username = readString( buf );
host = readString( buf );
port = buf.readInt();
}
@Override
public void write(ByteBuf buf)
{
buf.writeByte( procolVersion );
writeString( username, buf );
writeString( host, buf );
buf.writeInt( port );
}
@Override

View File

@ -1,27 +1,31 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
public class Packet3Chat extends DefinedPacket
{
public String message;
private String message;
public Packet3Chat(String message)
Packet3Chat()
{
super( 0x03 );
writeString( message );
this.message = message;
}
Packet3Chat(byte[] buf)
@Override
public void read(ByteBuf buf)
{
super( 0x03, buf );
this.message = readUTF();
message = readString( buf );
}
@Override
public void write(ByteBuf buf)
{
writeString( message, buf );
}
@Override

View File

@ -1,45 +1,43 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
public class Packet9Respawn extends DefinedPacket
{
public static final Packet9Respawn DIM1_SWITCH = new Packet9Respawn( (byte) 1, (byte) 0, (byte) 0, (short) 256, "DEFAULT" );
public static final Packet9Respawn DIM2_SWITCH = new Packet9Respawn( (byte) -1, (byte) 0, (byte) 0, (short) 256, "DEFAULT" );
public int dimension;
public byte difficulty;
public byte gameMode;
public short worldHeight;
public String levelType;
private int dimension;
private byte difficulty;
private byte gameMode;
private short worldHeight;
private String levelType;
public Packet9Respawn(int dimension, byte difficulty, byte gameMode, short worldHeight, String levelType)
Packet9Respawn()
{
super( 0x09 );
writeInt( dimension );
writeByte( difficulty );
writeByte( gameMode );
writeShort( worldHeight );
writeString( levelType );
this.dimension = dimension;
this.difficulty = difficulty;
this.gameMode = gameMode;
this.worldHeight = worldHeight;
this.levelType = levelType;
}
Packet9Respawn(byte[] buf)
@Override
public void read(ByteBuf buf)
{
super( 0x09, buf );
this.dimension = readInt();
this.difficulty = readByte();
this.gameMode = readByte();
this.worldHeight = readShort();
this.levelType = readUTF();
dimension = buf.readInt();
difficulty = buf.readByte();
gameMode = buf.readByte();
worldHeight = buf.readShort();
levelType = readString( buf );
}
@Override
public void write(ByteBuf buf)
{
buf.writeInt( dimension );
buf.writeByte( difficulty );
buf.writeByte( gameMode );
buf.writeShort( worldHeight );
writeString( levelType, buf );
}
@Override

View File

@ -1,32 +1,37 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketC9PlayerListItem extends DefinedPacket
{
public String username;
public boolean online;
public int ping;
private String username;
private boolean online;
private int ping;
PacketC9PlayerListItem(byte[] buf)
{
super( 0xC9, buf );
username = readUTF();
online = readBoolean();
ping = readShort();
}
public PacketC9PlayerListItem(String username, boolean online, int ping)
PacketC9PlayerListItem()
{
super( 0xC9 );
writeString( username );
writeBoolean( online );
writeShort( ping );
}
@Override
public void read(ByteBuf buf)
{
username = readString( buf );
online = buf.readBoolean();
ping = buf.readInt();
}
@Override
public void write(ByteBuf buf)
{
writeString( username, buf );
buf.writeBoolean( online );
buf.writeInt( ping );
}
@Override

View File

@ -1,28 +1,43 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketCCSettings extends DefinedPacket
{
public String locale;
public byte viewDistance;
public byte chatFlags;
public byte difficulty;
public boolean showCape;
private String locale;
private byte viewDistance;
private byte chatFlags;
private byte difficulty;
private boolean showCape;
public PacketCCSettings(byte[] buf)
PacketCCSettings()
{
super( 0xCC, buf );
locale = readUTF();
viewDistance = readByte();
chatFlags = readByte();
difficulty = readByte();
showCape = readBoolean();
super( 0xCC );
}
@Override
public void read(ByteBuf buf)
{
locale = readString( buf );
viewDistance = buf.readByte();
chatFlags = buf.readByte();
difficulty = buf.readByte();
showCape = buf.readBoolean();
}
@Override
public void write(ByteBuf buf)
{
locale = readString( buf );
buf.writeByte( viewDistance );
buf.writeByte( chatFlags );
buf.writeByte( difficulty );
buf.writeBoolean( showCape );
}
@Override

View File

@ -1,34 +1,31 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
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 );
private byte payload;
/**
* Sent from the client to the server upon respawn,
*
* @param payload 0 if initial spawn, 1 if respawn after death.
*/
public PacketCDClientStatus(byte payload)
PacketCDClientStatus()
{
super( 0xCD );
writeByte( payload );
}
PacketCDClientStatus(byte[] buf)
@Override
public void read(ByteBuf buf)
{
super( 0xCD, buf );
payload = buf.readByte();
}
@Override
public void write(ByteBuf buf)
{
buf.writeByte( payload );
}
@Override

View File

@ -1,38 +1,40 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketCEScoreboardObjective extends DefinedPacket
{
public String name;
public String text;
private String name;
private String text;
/**
* 0 to create, 1 to remove.
*/
public byte action;
private byte action;
public PacketCEScoreboardObjective(String name, String text, byte status)
PacketCEScoreboardObjective()
{
super( 0xCE );
writeString( name );
writeString( text );
writeByte( status );
this.name = name;
this.text = text;
this.action = status;
}
PacketCEScoreboardObjective(byte[] buf)
@Override
public void read(ByteBuf buf)
{
super( 0xCE, buf );
this.name = readUTF();
this.text = readUTF();
this.action = readByte();
name = readString( buf );
text = readString( buf );
action = buf.readByte();
}
@Override
public void write(ByteBuf buf)
{
writeString( name, buf );
writeString( text, buf );
buf.writeByte( action );
}
@Override

View File

@ -1,48 +1,49 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketCFScoreboardScore extends DefinedPacket
{
public String itemName;
private String itemName;
/**
* 0 = create / update, 1 = remove.
*/
public byte action;
public String scoreName;
public int value;
private byte action;
private String scoreName;
private int value;
public PacketCFScoreboardScore(byte[] buf)
PacketCFScoreboardScore()
{
super( 0xCF, buf );
itemName = readUTF();
action = readByte();
super( 0xCF );
}
@Override
public void read(ByteBuf buf)
{
itemName = readString( buf );
action = buf.readByte();
if ( action == 0 )
{
scoreName = readUTF();
value = readInt();
scoreName = readString( buf );
value = buf.readInt();
}
}
public PacketCFScoreboardScore(String itemName, byte action, String scoreName, int value)
@Override
public void write(ByteBuf buf)
{
super( 0xCF );
writeString( itemName );
writeByte( action );
writeString( itemName, buf );
buf.writeByte( action );
if ( action == 0 )
{
writeString( scoreName );
writeInt( value );
writeString( scoreName, buf );
buf.writeInt( value );
}
this.itemName = itemName;
this.action = action;
this.scoreName = scoreName;
this.value = value;
}
@Override

View File

@ -1,8 +1,8 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
@ -12,14 +12,26 @@ public class PacketD0DisplayScoreboard extends DefinedPacket
/**
* 0 = list, 1 = side, 2 = below.
*/
public byte position;
public String name;
private byte position;
private String name;
public PacketD0DisplayScoreboard(byte[] buf)
PacketD0DisplayScoreboard()
{
super( 0xD0, buf );
position = readByte();
name = readUTF();
super( 0xD0 );
}
@Override
public void read(ByteBuf buf)
{
position = buf.readByte();
name = readString( buf );
}
@Override
public void write(ByteBuf buf)
{
buf.writeByte( position );
writeString( name, buf );
}
@Override

View File

@ -1,59 +1,73 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketD1Team extends DefinedPacket
{
public String name;
private String name;
/**
* 0 - create, 1 remove, 2 info update, 3 player add, 4 player remove.
*/
public byte mode;
public String displayName;
public String prefix;
public String suffix;
public byte friendlyFire;
public short playerCount;
public String[] players;
private byte mode;
private String displayName;
private String prefix;
private String suffix;
private boolean friendlyFire;
private short playerCount;
private String[] players;
public PacketD1Team(byte[] buf)
{
super( 0xD1, buf );
name = readUTF();
mode = readByte();
if ( mode == 0 || mode == 2 )
{
displayName = readUTF();
prefix = readUTF();
suffix = readUTF();
friendlyFire = readByte();
}
if ( mode == 0 || mode == 3 || mode == 4 )
{
players = new String[ readShort() ];
for ( int i = 0; i < players.length; i++ )
{
players[i] = readUTF();
}
}
}
public PacketD1Team()
PacketD1Team()
{
super( 0xD1 );
}
public static PacketD1Team destroy(String name)
@Override
public void read(ByteBuf buf)
{
PacketD1Team packet = new PacketD1Team();
packet.writeString( name );
packet.writeByte( 1 );
return packet;
name = readString( buf );
mode = buf.readByte();
if ( mode == 0 || mode == 2 )
{
displayName = readString( buf );
prefix = readString( buf );
suffix = readString( buf );
friendlyFire = buf.readBoolean();
}
if ( mode == 0 || mode == 3 || mode == 4 )
{
players = new String[ buf.readShort() ];
for ( int i = 0; i < players.length; i++ )
{
players[i] = readString( buf );
}
}
}
@Override
public void write(ByteBuf buf)
{
writeString( name, buf );
buf.writeByte( mode );
if ( mode == 0 || mode == 2 )
{
writeString( displayName, buf );
writeString( prefix, buf );
writeString( suffix, buf );
buf.writeBoolean( friendlyFire );
}
if ( mode == 0 || mode == 3 || mode == 4 )
{
buf.writeShort( players.length );
for ( int i = 0; i < players.length; i++ )
{
writeString( players[i], buf );
}
}
}
@Override

View File

@ -1,31 +1,34 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketFAPluginMessage extends DefinedPacket
{
public String tag;
public byte[] data;
private String tag;
private byte[] data;
public PacketFAPluginMessage(String tag, byte[] data)
PacketFAPluginMessage()
{
super( 0xFA );
writeString( tag );
writeArray( data );
this.tag = tag;
this.data = data;
}
PacketFAPluginMessage(byte[] buf)
@Override
public void read(ByteBuf buf)
{
super( 0xFA, buf );
this.tag = readUTF();
this.data = readArray();
tag = readString( buf );
data = readArray( buf );
}
@Override
public void write(ByteBuf buf)
{
writeString( tag, buf );
writeArray( data, buf );
}
@Override

View File

@ -1,38 +1,34 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketFCEncryptionResponse extends DefinedPacket
{
public byte[] sharedSecret;
public byte[] verifyToken;
private byte[] sharedSecret;
private byte[] verifyToken;
public PacketFCEncryptionResponse()
PacketFCEncryptionResponse()
{
super( 0xFC );
writeArray( new byte[ 0 ] );
writeArray( new byte[ 0 ] );
}
public PacketFCEncryptionResponse(byte[] sharedSecret, byte[] verifyToken)
@Override
public void read(ByteBuf buf)
{
super( 0xFC );
writeArray( sharedSecret );
writeArray( verifyToken );
this.sharedSecret = sharedSecret;
this.verifyToken = verifyToken;
sharedSecret = readArray( buf );
verifyToken = readArray( buf );
}
PacketFCEncryptionResponse(byte[] buf)
@Override
public void write(ByteBuf buf)
{
super( 0xFC, buf );
this.sharedSecret = readArray();
this.verifyToken = readArray();
writeArray( sharedSecret, buf );
writeArray( verifyToken, buf );
}
@Override

View File

@ -3,34 +3,35 @@ package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketFDEncryptionRequest extends DefinedPacket
{
public String serverId;
public byte[] publicKey;
public byte[] verifyToken;
private String serverId;
private byte[] publicKey;
private byte[] verifyToken;
public PacketFDEncryptionRequest(String serverId, byte[] publicKey, byte[] verifyToken)
PacketFDEncryptionRequest()
{
super( 0xFD );
writeString( serverId );
writeArray( publicKey );
writeArray( verifyToken );
this.serverId = serverId;
this.publicKey = publicKey;
this.verifyToken = verifyToken;
}
PacketFDEncryptionRequest(byte[] buf)
@Override
public void read(ByteBuf buf)
{
super( 0xFD, buf );
serverId = readUTF();
publicKey = readArray();
verifyToken = readArray();
serverId = readString( buf );
publicKey = readArray( buf );
verifyToken = readArray( buf );
}
@Override
public void write(ByteBuf buf)
{
writeString( serverId, buf );
writeArray( publicKey, buf );
writeArray( verifyToken, buf );
}
@Override

View File

@ -1,20 +1,31 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketFEPing extends DefinedPacket
{
public byte version;
private byte version;
PacketFEPing(byte[] buffer)
PacketFEPing()
{
super( 0xFE, buffer );
version = readByte();
super( 0xFE );
}
@Override
public void read(ByteBuf buf)
{
version = buf.readByte();
}
@Override
public void write(ByteBuf buf)
{
buf.writeByte( version );
}
@Override

View File

@ -1,26 +1,31 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.packet.PacketHandler;
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketFFKick extends DefinedPacket
{
public String message;
private String message;
public PacketFFKick(String message)
PacketFFKick()
{
super( 0xFF );
writeString( message );
}
PacketFFKick(byte[] buf)
@Override
public void read(ByteBuf buf)
{
super( 0xFF, buf );
this.message = readUTF();
message = readString( buf );
}
@Override
public void write(ByteBuf buf)
{
writeString( message, buf );
}
@Override

View File

@ -1,38 +1,11 @@
package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.packet.Packet1Login;
import net.md_5.bungee.protocol.packet.Packet3Chat;
import net.md_5.bungee.protocol.packet.PacketD0DisplayScoreboard;
import net.md_5.bungee.protocol.packet.PacketFEPing;
import net.md_5.bungee.protocol.packet.PacketFFKick;
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
import net.md_5.bungee.protocol.packet.Packet2Handshake;
import net.md_5.bungee.protocol.packet.PacketFCEncryptionResponse;
import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest;
import net.md_5.bungee.protocol.packet.PacketCDClientStatus;
import net.md_5.bungee.protocol.packet.PacketCCSettings;
import net.md_5.bungee.protocol.packet.PacketCFScoreboardScore;
import net.md_5.bungee.protocol.packet.PacketCEScoreboardObjective;
import net.md_5.bungee.protocol.packet.Packet9Respawn;
import net.md_5.bungee.protocol.packet.PacketD1Team;
import net.md_5.bungee.protocol.packet.Packet0KeepAlive;
import net.md_5.bungee.netty.ChannelWrapper;
public abstract class PacketHandler
{
@Override
public abstract String toString();
public void connected(ChannelWrapper channel) throws Exception
{
}
public void disconnected(ChannelWrapper channel) throws Exception
{
}
public void exception(Throwable t) throws Exception
{
}

View File

@ -0,0 +1,42 @@
package net.md_5.bungee.protocol;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import net.md_5.bungee.protocol.packet.DefinedPacket;
import org.junit.Assert;
import org.junit.Test;
public class PacketTest
{
@Test
public void testPackets() throws NoSuchMethodException
{
for ( short i = 0; i < 256; i++ )
{
ByteBuf buf = Unpooled.wrappedBuffer( new byte[]
{
(byte) i
} );
Class<? extends DefinedPacket> clazz = DefinedPacket.classes[i];
if ( clazz != null )
{
Assert.assertTrue( "Packet " + clazz + " is not public", Modifier.isPublic( clazz.getModifiers() ) );
DefinedPacket packet = DefinedPacket.packet( buf );
Assert.assertTrue( "Could not create packet with id " + i + " and class " + clazz, packet != null );
Assert.assertTrue( "Packet with id " + i + " does not have correct class (expected " + clazz + " but got " + packet.getClass(), packet.getClass() == clazz );
Assert.assertTrue( "Packet " + clazz + " does not report correct id", packet.getId() == i );
Assert.assertTrue( "Packet " + clazz + " does not have custom hash code", packet.hashCode() != System.identityHashCode( packet ) );
Assert.assertTrue( "Packet " + clazz + " does not have custom toString", packet.toString().indexOf( '@' ) == -1 );
Assert.assertTrue( "Packet " + clazz + " does not have package private no args constructor", clazz.getDeclaredConstructor().getModifiers() == 0 );
for ( Field field : clazz.getDeclaredFields() )
{
Assert.assertTrue( "Packet " + clazz + " has non private field " + field, Modifier.isPrivate( field.getModifiers() ) );
}
}
}
}
}

View File

@ -13,6 +13,7 @@ public class DefinedPacketEncoder extends MessageToByteEncoder<DefinedPacket>
@Override
protected void encode(ChannelHandlerContext ctx, DefinedPacket msg, ByteBuf out) throws Exception
{
out.writeBytes( msg.getPacket() );
out.writeByte( msg.getId() );
msg.write( out );
}
}

View File

@ -0,0 +1,13 @@
package net.md_5.bungee.netty;
public abstract class PacketHandler extends net.md_5.bungee.protocol.packet.PacketHandler
{
public void connected(ChannelWrapper channel) throws Exception
{
}
public void disconnected(ChannelWrapper channel) throws Exception
{
}
}