Start work on more efficient, publically accessable packet API
This commit is contained in:
@@ -14,27 +14,11 @@ public class PacketDefinitions
|
||||
public enum OpCode
|
||||
{
|
||||
|
||||
BOOLEAN, BULK_CHUNK, BYTE, BYTE_INT, DOUBLE, FLOAT, INT, INT_3, INT_BYTE, ITEM, LONG, METADATA, OPTIONAL_MOTION, SCORE, SHORT, SHORT_BYTE, SHORT_ITEM, STRING, TEAM, USHORT_BYTE
|
||||
BOOLEAN, BULK_CHUNK, BYTE, BYTE_INT, DOUBLE, FLOAT, INT, INT_3, INT_BYTE, ITEM, LONG, METADATA, OPTIONAL_MOTION, SHORT, SHORT_BYTE, SHORT_ITEM, STRING, USHORT_BYTE
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
opCodes[0x00] = new OpCode[]
|
||||
{
|
||||
INT
|
||||
};
|
||||
opCodes[0x01] = new OpCode[]
|
||||
{
|
||||
INT, STRING, BYTE, BYTE, BYTE, BYTE, BYTE
|
||||
};
|
||||
opCodes[0x02] = new OpCode[]
|
||||
{
|
||||
BYTE, STRING, STRING, INT
|
||||
};
|
||||
opCodes[0x03] = new OpCode[]
|
||||
{
|
||||
STRING
|
||||
};
|
||||
opCodes[0x04] = new OpCode[]
|
||||
{
|
||||
LONG, LONG
|
||||
@@ -55,10 +39,6 @@ public class PacketDefinitions
|
||||
{
|
||||
SHORT, SHORT, FLOAT
|
||||
};
|
||||
opCodes[0x09] = new OpCode[]
|
||||
{
|
||||
INT, BYTE, BYTE, SHORT, STRING
|
||||
};
|
||||
opCodes[0x0A] = new OpCode[]
|
||||
{
|
||||
BOOLEAN
|
||||
@@ -283,10 +263,6 @@ public class PacketDefinitions
|
||||
{
|
||||
INT, BYTE
|
||||
};
|
||||
opCodes[0xC9] = new OpCode[]
|
||||
{
|
||||
STRING, BOOLEAN, SHORT
|
||||
};
|
||||
opCodes[0xCA] = new OpCode[]
|
||||
{
|
||||
BYTE, BYTE, BYTE
|
||||
@@ -295,54 +271,5 @@ public class PacketDefinitions
|
||||
{
|
||||
STRING
|
||||
};
|
||||
opCodes[0xCC] = new OpCode[]
|
||||
{
|
||||
STRING, BYTE, BYTE, BYTE, BOOLEAN
|
||||
};
|
||||
opCodes[0xCD] = new OpCode[]
|
||||
{
|
||||
BYTE
|
||||
};
|
||||
opCodes[0xCE] = new OpCode[]
|
||||
{
|
||||
STRING, STRING, BYTE
|
||||
};
|
||||
opCodes[0xCF] = new OpCode[]
|
||||
{
|
||||
SCORE
|
||||
};
|
||||
opCodes[0xD0] = new OpCode[]
|
||||
{
|
||||
BYTE, STRING
|
||||
};
|
||||
opCodes[0xD1] = new OpCode[]
|
||||
{
|
||||
TEAM
|
||||
};
|
||||
opCodes[0xFA] = new OpCode[]
|
||||
{
|
||||
STRING, SHORT_BYTE
|
||||
};
|
||||
opCodes[0xFC] = new OpCode[]
|
||||
{
|
||||
SHORT_BYTE, SHORT_BYTE
|
||||
};
|
||||
opCodes[0xFD] = new OpCode[]
|
||||
{
|
||||
STRING, SHORT_BYTE, SHORT_BYTE
|
||||
};
|
||||
opCodes[0xFE] = new OpCode[]
|
||||
{
|
||||
BYTE
|
||||
};
|
||||
opCodes[0xFF] = new OpCode[]
|
||||
{
|
||||
STRING
|
||||
};
|
||||
/*========================== Minecraft Forge ===========================*/
|
||||
opCodes[0x01 + FORGE_PROTOCOL] = new OpCode[]
|
||||
{
|
||||
INT, STRING, BYTE, INT, BYTE, BYTE, BYTE
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -19,12 +19,10 @@ abstract class Instruction
|
||||
static final Instruction LONG = new Jump( 8 );
|
||||
static final Instruction METADATA = new MetaData();
|
||||
static final Instruction OPTIONAL_MOTION = new OptionalMotion();
|
||||
static final Instruction SCORE = new Score();
|
||||
static final Instruction SHORT = new Jump( 2 );
|
||||
static final Instruction SHORT_BYTE = new ShortHeader( BYTE );
|
||||
static final Instruction SHORT_ITEM = new ShortHeader( ITEM );
|
||||
static final Instruction STRING = new ShortHeader( new Jump( 2 ) );
|
||||
static final Instruction TEAM = new Team();
|
||||
static final Instruction USHORT_BYTE = new UnsignedShortByte();
|
||||
// Illegal forward references below this line
|
||||
static final Instruction BYTE_INT = new ByteHeader( INT );
|
||||
|
@@ -1,19 +0,0 @@
|
||||
package net.md_5.bungee.protocol.netty;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Score extends Instruction
|
||||
{
|
||||
|
||||
@Override
|
||||
void read(ByteBuf in) throws IOException
|
||||
{
|
||||
STRING.read( in );
|
||||
if ( in.readByte() == 0 )
|
||||
{
|
||||
STRING.read( in );
|
||||
INT.read( in );
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
package net.md_5.bungee.protocol.netty;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
|
||||
class Team extends Instruction
|
||||
{
|
||||
|
||||
@Override
|
||||
void read(ByteBuf in) throws IOException
|
||||
{
|
||||
STRING.read( in );
|
||||
byte mode = in.readByte();
|
||||
if ( mode == 0 || mode == 2 )
|
||||
{
|
||||
STRING.read( in );
|
||||
STRING.read( in );
|
||||
STRING.read( in );
|
||||
BYTE.read( in );
|
||||
}
|
||||
if ( mode == 0 || mode == 3 || mode == 4 )
|
||||
{
|
||||
STRING_ARRAY.read( in );
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,117 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public abstract class DefinedPacket
|
||||
{
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Class<? extends DefinedPacket>[] classes = new Class[ 256 ];
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Constructor<? extends DefinedPacket>[] consructors = new Constructor[ 256 ];
|
||||
|
||||
public static DefinedPacket packet(ByteBuf buf)
|
||||
{
|
||||
DefinedPacket ret = null;
|
||||
int id = buf.readUnsignedByte();
|
||||
Class<? extends DefinedPacket> clazz = classes[id];
|
||||
|
||||
if ( clazz != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
Constructor<? extends DefinedPacket> constructor = consructors[id];
|
||||
if ( constructor == null )
|
||||
{
|
||||
constructor = clazz.getDeclaredConstructor();
|
||||
consructors[id] = constructor;
|
||||
}
|
||||
|
||||
if ( constructor != null )
|
||||
{
|
||||
ret = constructor.newInstance( buf );
|
||||
}
|
||||
} catch ( IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException ex )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void writeString(String s, ByteBuf buf)
|
||||
{
|
||||
// TODO: Check len - use Guava?
|
||||
buf.writeShort( s.length() );
|
||||
for ( char c : s.toCharArray() )
|
||||
{
|
||||
buf.writeChar( c );
|
||||
}
|
||||
}
|
||||
|
||||
public String readString(ByteBuf buf)
|
||||
{
|
||||
// TODO: Check len - use Guava?
|
||||
short len = buf.readShort();
|
||||
char[] chars = new char[ len ];
|
||||
for ( int i = 0; i < len; i++ )
|
||||
{
|
||||
chars[i] = buf.readChar();
|
||||
}
|
||||
return new String( chars );
|
||||
}
|
||||
|
||||
public void writeArray(byte[] b, ByteBuf buf)
|
||||
{
|
||||
// TODO: Check len - use Guava?
|
||||
buf.writeByte( b.length );
|
||||
buf.writeBytes( b );
|
||||
}
|
||||
|
||||
public byte[] readArray(ByteBuf buf)
|
||||
{
|
||||
// TODO: Check len - use Guava?
|
||||
short len = buf.readShort();
|
||||
byte[] ret = new byte[ len ];
|
||||
buf.readBytes( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
public abstract void read(ByteBuf buf);
|
||||
|
||||
public abstract void write(ByteBuf buf);
|
||||
|
||||
public abstract void handle(PacketHandler handler) throws Exception;
|
||||
|
||||
@Override
|
||||
public abstract boolean equals(Object obj);
|
||||
|
||||
@Override
|
||||
public abstract int hashCode();
|
||||
|
||||
@Override
|
||||
public abstract String toString();
|
||||
|
||||
static
|
||||
{
|
||||
classes[0x00] = Packet0KeepAlive.class;
|
||||
classes[0x01] = Packet1Login.class;
|
||||
classes[0x02] = Packet2Handshake.class;
|
||||
classes[0x03] = Packet3Chat.class;
|
||||
classes[0x09] = Packet9Respawn.class;
|
||||
classes[0xC9] = PacketC9PlayerListItem.class;
|
||||
classes[0xCC] = PacketCCSettings.class;
|
||||
classes[0xCD] = PacketCDClientStatus.class;
|
||||
classes[0xCE] = PacketCEScoreboardObjective.class;
|
||||
classes[0xCF] = PacketCFScoreboardScore.class;
|
||||
classes[0xD0] = PacketD0DisplayScoreboard.class;
|
||||
classes[0xD1] = PacketD1Team.class;
|
||||
classes[0xFA] = PacketFAPluginMessage.class;
|
||||
classes[0xFC] = PacketFCEncryptionResponse.class;
|
||||
classes[0xFD] = PacketFDEncryptionRequest.class;
|
||||
classes[0xFE] = PacketFEPing.class;
|
||||
classes[0xFF] = PacketFFKick.class;
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
{
|
||||
id = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf)
|
||||
{
|
||||
buf.writeInt( id );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
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
|
||||
{
|
||||
|
||||
private int entityId;
|
||||
private String levelType;
|
||||
private byte gameMode;
|
||||
private byte dimension;
|
||||
private byte difficulty;
|
||||
private byte unused;
|
||||
private byte maxPlayers;
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
{
|
||||
entityId = buf.readInt();
|
||||
levelType = readString( buf );
|
||||
gameMode = buf.readByte();
|
||||
dimension = buf.readByte();
|
||||
difficulty = buf.readByte();
|
||||
unused = buf.readByte();
|
||||
maxPlayers = buf.readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf)
|
||||
{
|
||||
buf.writeInt( entityId );
|
||||
writeString( levelType, buf );
|
||||
buf.writeByte( gameMode );
|
||||
buf.writeByte( dimension );
|
||||
buf.writeByte( difficulty );
|
||||
buf.writeByte( unused );
|
||||
buf.writeByte( maxPlayers );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
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;
|
||||
|
||||
public Packet2Handshake(byte protocolVersion, String username, String host, int port)
|
||||
{
|
||||
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)
|
||||
{
|
||||
super( 0x02, buf );
|
||||
this.procolVersion = readByte();
|
||||
this.username = readUTF();
|
||||
this.host = readUTF();
|
||||
this.port = readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
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;
|
||||
|
||||
public Packet3Chat(String message)
|
||||
{
|
||||
super( 0x03 );
|
||||
writeString( message );
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
Packet3Chat(byte[] buf)
|
||||
{
|
||||
super( 0x03, buf );
|
||||
this.message = readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
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;
|
||||
|
||||
public Packet9Respawn(int dimension, byte difficulty, byte gameMode, short worldHeight, String levelType)
|
||||
{
|
||||
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)
|
||||
{
|
||||
super( 0x09, buf );
|
||||
this.dimension = readInt();
|
||||
this.difficulty = readByte();
|
||||
this.gameMode = readByte();
|
||||
this.worldHeight = readShort();
|
||||
this.levelType = readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
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;
|
||||
|
||||
PacketC9PlayerListItem(byte[] buf)
|
||||
{
|
||||
super( 0xC9, buf );
|
||||
username = readUTF();
|
||||
online = readBoolean();
|
||||
ping = readShort();
|
||||
}
|
||||
|
||||
public PacketC9PlayerListItem(String username, boolean online, int ping)
|
||||
{
|
||||
super( 0xC9 );
|
||||
writeString( username );
|
||||
writeBoolean( online );
|
||||
writeShort( ping );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
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;
|
||||
|
||||
public PacketCCSettings(byte[] buf)
|
||||
{
|
||||
super( 0xCC, buf );
|
||||
locale = readUTF();
|
||||
viewDistance = readByte();
|
||||
chatFlags = readByte();
|
||||
difficulty = readByte();
|
||||
showCape = readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
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 );
|
||||
|
||||
/**
|
||||
* Sent from the client to the server upon respawn,
|
||||
*
|
||||
* @param payload 0 if initial spawn, 1 if respawn after death.
|
||||
*/
|
||||
public PacketCDClientStatus(byte payload)
|
||||
{
|
||||
super( 0xCD );
|
||||
writeByte( payload );
|
||||
}
|
||||
|
||||
PacketCDClientStatus(byte[] buf)
|
||||
{
|
||||
super( 0xCD, buf );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
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;
|
||||
/**
|
||||
* 0 to create, 1 to remove.
|
||||
*/
|
||||
public byte action;
|
||||
|
||||
public PacketCEScoreboardObjective(String name, String text, byte status)
|
||||
{
|
||||
super( 0xCE );
|
||||
writeString( name );
|
||||
writeString( text );
|
||||
writeByte( status );
|
||||
this.name = name;
|
||||
this.text = text;
|
||||
this.action = status;
|
||||
}
|
||||
|
||||
PacketCEScoreboardObjective(byte[] buf)
|
||||
{
|
||||
super( 0xCE, buf );
|
||||
this.name = readUTF();
|
||||
this.text = readUTF();
|
||||
this.action = readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
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;
|
||||
/**
|
||||
* 0 = create / update, 1 = remove.
|
||||
*/
|
||||
public byte action;
|
||||
public String scoreName;
|
||||
public int value;
|
||||
|
||||
public PacketCFScoreboardScore(byte[] buf)
|
||||
{
|
||||
super( 0xCF, buf );
|
||||
itemName = readUTF();
|
||||
action = readByte();
|
||||
if ( action == 0 )
|
||||
{
|
||||
scoreName = readUTF();
|
||||
value = readInt();
|
||||
}
|
||||
}
|
||||
|
||||
public PacketCFScoreboardScore(String itemName, byte action, String scoreName, int value)
|
||||
{
|
||||
super( 0xCF );
|
||||
writeString( itemName );
|
||||
writeByte( action );
|
||||
if ( action == 0 )
|
||||
{
|
||||
writeString( scoreName );
|
||||
writeInt( value );
|
||||
}
|
||||
this.itemName = itemName;
|
||||
this.action = action;
|
||||
this.scoreName = scoreName;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import net.md_5.bungee.packet.PacketHandler;
|
||||
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PacketD0DisplayScoreboard extends DefinedPacket
|
||||
{
|
||||
|
||||
/**
|
||||
* 0 = list, 1 = side, 2 = below.
|
||||
*/
|
||||
public byte position;
|
||||
public String name;
|
||||
|
||||
public PacketD0DisplayScoreboard(byte[] buf)
|
||||
{
|
||||
super( 0xD0, buf );
|
||||
position = readByte();
|
||||
name = readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
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;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
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()
|
||||
{
|
||||
super( 0xD1 );
|
||||
}
|
||||
|
||||
public static PacketD1Team destroy(String name)
|
||||
{
|
||||
PacketD1Team packet = new PacketD1Team();
|
||||
packet.writeString( name );
|
||||
packet.writeByte( 1 );
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
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;
|
||||
|
||||
public PacketFAPluginMessage(String tag, byte[] data)
|
||||
{
|
||||
super( 0xFA );
|
||||
writeString( tag );
|
||||
writeArray( data );
|
||||
this.tag = tag;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
PacketFAPluginMessage(byte[] buf)
|
||||
{
|
||||
super( 0xFA, buf );
|
||||
this.tag = readUTF();
|
||||
this.data = readArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
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;
|
||||
|
||||
public PacketFCEncryptionResponse()
|
||||
{
|
||||
super( 0xFC );
|
||||
writeArray( new byte[ 0 ] );
|
||||
writeArray( new byte[ 0 ] );
|
||||
}
|
||||
|
||||
public PacketFCEncryptionResponse(byte[] sharedSecret, byte[] verifyToken)
|
||||
{
|
||||
super( 0xFC );
|
||||
writeArray( sharedSecret );
|
||||
writeArray( verifyToken );
|
||||
this.sharedSecret = sharedSecret;
|
||||
this.verifyToken = verifyToken;
|
||||
}
|
||||
|
||||
PacketFCEncryptionResponse(byte[] buf)
|
||||
{
|
||||
super( 0xFC, buf );
|
||||
this.sharedSecret = readArray();
|
||||
this.verifyToken = readArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
|
||||
public PacketFDEncryptionRequest(String serverId, byte[] publicKey, byte[] verifyToken)
|
||||
{
|
||||
super( 0xFD );
|
||||
writeString( serverId );
|
||||
writeArray( publicKey );
|
||||
writeArray( verifyToken );
|
||||
this.serverId = serverId;
|
||||
this.publicKey = publicKey;
|
||||
this.verifyToken = verifyToken;
|
||||
}
|
||||
|
||||
PacketFDEncryptionRequest(byte[] buf)
|
||||
{
|
||||
super( 0xFD, buf );
|
||||
serverId = readUTF();
|
||||
publicKey = readArray();
|
||||
verifyToken = readArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
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;
|
||||
|
||||
PacketFEPing(byte[] buffer)
|
||||
{
|
||||
super( 0xFE, buffer );
|
||||
version = readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
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;
|
||||
|
||||
public PacketFFKick(String message)
|
||||
{
|
||||
super( 0xFF );
|
||||
writeString( message );
|
||||
}
|
||||
|
||||
PacketFFKick(byte[] buf)
|
||||
{
|
||||
super( 0xFF, buf );
|
||||
this.message = readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,111 @@
|
||||
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
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(byte[] buf) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(Packet0KeepAlive alive) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(Packet1Login login) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(Packet2Handshake handshake) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(Packet3Chat chat) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(Packet9Respawn respawn) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketC9PlayerListItem playerList) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketCCSettings settings) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketCDClientStatus clientStatus) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketCEScoreboardObjective objective) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketCFScoreboardScore score) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketD0DisplayScoreboard displayScoreboard) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketD1Team team) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketFCEncryptionResponse encryptResponse) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketFDEncryptionRequest encryptRequest) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketFEPing ping) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketFFKick kick) throws Exception
|
||||
{
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user