Fill out all handlers for packets just in case they are needed.

This commit is contained in:
md_5 2013-02-09 18:06:15 +11:00
parent 23582a635b
commit b946e376c7
8 changed files with 64 additions and 6 deletions

View File

@ -109,10 +109,7 @@ public abstract class DefinedPacket implements DataInput, DataOutput
@Override
public abstract String toString();
public void handle(PacketHandler handler) throws Exception
{
handler.handle( this );
}
public abstract void handle(PacketHandler handler) throws Exception;
private static Class<? extends DefinedPacket>[] classes = new Class[ 256 ];
public static DefinedPacket packet(byte[] buf)

View File

@ -15,4 +15,10 @@ public class Packet0KeepAlive extends DefinedPacket
super( 0x00, buffer );
id = readInt();
}
@Override
public void handle(PacketHandler handler) throws Exception
{
handler.handle( this );
}
}

View File

@ -21,4 +21,10 @@ public class Packet3Chat extends DefinedPacket
super( 0x03, buf );
this.message = readUTF();
}
@Override
public void handle(PacketHandler handler) throws Exception
{
handler.handle( this );
}
}

View File

@ -33,4 +33,10 @@ public class Packet9Respawn extends DefinedPacket
this.worldHeight = readShort();
this.levelType = readUTF();
}
@Override
public void handle(PacketHandler handler) throws Exception
{
handler.handle( this );
}
}

View File

@ -27,4 +27,10 @@ public class PacketC9PlayerListItem extends DefinedPacket
writeBoolean( online );
writeShort( ping );
}
@Override
public void handle(PacketHandler handler) throws Exception
{
handler.handle( this );
}
}

View File

@ -21,4 +21,10 @@ public class PacketFFKick extends DefinedPacket
super( 0xFF, buf );
this.message = readUTF();
}
@Override
public void handle(PacketHandler handler) throws Exception
{
handler.handle( this );
}
}

View File

@ -3,36 +3,68 @@ package net.md_5.bungee.packet;
public abstract class PacketHandler
{
public void handle(DefinedPacket packet) throws Exception
private void nop(DefinedPacket packet)
{
throw new UnsupportedOperationException( "No handler defined for packet " + packet.getClass() );
}
public void handle(Packet0KeepAlive alive) throws Exception
{
nop( alive );
}
public void handle(Packet1Login login) throws Exception
{
nop( login );
}
public void handle(Packet2Handshake handshake) throws Exception
{
nop( handshake );
}
public void handle(Packet3Chat chat) throws Exception
{
nop( chat );
}
public void handle(Packet9Respawn respawn) throws Exception
{
nop( respawn );
}
public void handle(PacketC9PlayerListItem playerList) throws Exception
{
nop( playerList );
}
public void handle(PacketCDClientStatus clientStatus) throws Exception
{
nop( clientStatus );
}
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
{
nop( pluginMessage );
}
public void handle(PacketFCEncryptionResponse encryptResponse) throws Exception
{
nop( encryptResponse );
}
public void handle(PacketFDEncryptionRequest encryptRequest) throws Exception
{
nop( encryptRequest );
}
public void handle(PacketFEPing ping) throws Exception
{
nop( ping );
}
public void handle(PacketFFKick kick) throws Exception
{
nop( kick );
}
}

View File

@ -7,7 +7,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import lombok.Getter;
import lombok.Setter;
import net.md_5.mendax.datainput.DataInputPacketReader;
/**