mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-27 20:59:12 +01:00
Start work on more efficient, publically accessable packet API
This commit is contained in:
parent
0578f94522
commit
835e4e332c
@ -14,27 +14,11 @@ public class PacketDefinitions
|
|||||||
public enum OpCode
|
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
|
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[]
|
opCodes[0x04] = new OpCode[]
|
||||||
{
|
{
|
||||||
LONG, LONG
|
LONG, LONG
|
||||||
@ -55,10 +39,6 @@ public class PacketDefinitions
|
|||||||
{
|
{
|
||||||
SHORT, SHORT, FLOAT
|
SHORT, SHORT, FLOAT
|
||||||
};
|
};
|
||||||
opCodes[0x09] = new OpCode[]
|
|
||||||
{
|
|
||||||
INT, BYTE, BYTE, SHORT, STRING
|
|
||||||
};
|
|
||||||
opCodes[0x0A] = new OpCode[]
|
opCodes[0x0A] = new OpCode[]
|
||||||
{
|
{
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
@ -283,10 +263,6 @@ public class PacketDefinitions
|
|||||||
{
|
{
|
||||||
INT, BYTE
|
INT, BYTE
|
||||||
};
|
};
|
||||||
opCodes[0xC9] = new OpCode[]
|
|
||||||
{
|
|
||||||
STRING, BOOLEAN, SHORT
|
|
||||||
};
|
|
||||||
opCodes[0xCA] = new OpCode[]
|
opCodes[0xCA] = new OpCode[]
|
||||||
{
|
{
|
||||||
BYTE, BYTE, BYTE
|
BYTE, BYTE, BYTE
|
||||||
@ -295,54 +271,5 @@ public class PacketDefinitions
|
|||||||
{
|
{
|
||||||
STRING
|
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 LONG = new Jump( 8 );
|
||||||
static final Instruction METADATA = new MetaData();
|
static final Instruction METADATA = new MetaData();
|
||||||
static final Instruction OPTIONAL_MOTION = new OptionalMotion();
|
static final Instruction OPTIONAL_MOTION = new OptionalMotion();
|
||||||
static final Instruction SCORE = new Score();
|
|
||||||
static final Instruction SHORT = new Jump( 2 );
|
static final Instruction SHORT = new Jump( 2 );
|
||||||
static final Instruction SHORT_BYTE = new ShortHeader( BYTE );
|
static final Instruction SHORT_BYTE = new ShortHeader( BYTE );
|
||||||
static final Instruction SHORT_ITEM = new ShortHeader( ITEM );
|
static final Instruction SHORT_ITEM = new ShortHeader( ITEM );
|
||||||
static final Instruction STRING = new ShortHeader( new Jump( 2 ) );
|
static final Instruction STRING = new ShortHeader( new Jump( 2 ) );
|
||||||
static final Instruction TEAM = new Team();
|
|
||||||
static final Instruction USHORT_BYTE = new UnsignedShortByte();
|
static final Instruction USHORT_BYTE = new UnsignedShortByte();
|
||||||
// Illegal forward references below this line
|
// Illegal forward references below this line
|
||||||
static final Instruction BYTE_INT = new ByteHeader( INT );
|
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 );
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -17,8 +18,8 @@ public class Packet2Handshake extends DefinedPacket
|
|||||||
{
|
{
|
||||||
super( 0x02 );
|
super( 0x02 );
|
||||||
writeByte( protocolVersion );
|
writeByte( protocolVersion );
|
||||||
writeUTF( username );
|
writeString( username );
|
||||||
writeUTF( host );
|
writeString( host );
|
||||||
writeInt( port );
|
writeInt( port );
|
||||||
this.procolVersion = protocolVersion;
|
this.procolVersion = protocolVersion;
|
||||||
this.username = username;
|
this.username = username;
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -13,7 +14,7 @@ public class Packet3Chat extends DefinedPacket
|
|||||||
public Packet3Chat(String message)
|
public Packet3Chat(String message)
|
||||||
{
|
{
|
||||||
super( 0x03 );
|
super( 0x03 );
|
||||||
writeUTF( message );
|
writeString( message );
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -23,7 +24,7 @@ public class Packet9Respawn extends DefinedPacket
|
|||||||
writeByte( difficulty );
|
writeByte( difficulty );
|
||||||
writeByte( gameMode );
|
writeByte( gameMode );
|
||||||
writeShort( worldHeight );
|
writeShort( worldHeight );
|
||||||
writeUTF( levelType );
|
writeString( levelType );
|
||||||
this.dimension = dimension;
|
this.dimension = dimension;
|
||||||
this.difficulty = difficulty;
|
this.difficulty = difficulty;
|
||||||
this.gameMode = gameMode;
|
this.gameMode = gameMode;
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -23,7 +24,7 @@ public class PacketC9PlayerListItem extends DefinedPacket
|
|||||||
public PacketC9PlayerListItem(String username, boolean online, int ping)
|
public PacketC9PlayerListItem(String username, boolean online, int ping)
|
||||||
{
|
{
|
||||||
super( 0xC9 );
|
super( 0xC9 );
|
||||||
writeUTF( username );
|
writeString( username );
|
||||||
writeBoolean( online );
|
writeBoolean( online );
|
||||||
writeShort( ping );
|
writeShort( ping );
|
||||||
}
|
}
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -18,8 +19,8 @@ public class PacketCEScoreboardObjective extends DefinedPacket
|
|||||||
public PacketCEScoreboardObjective(String name, String text, byte status)
|
public PacketCEScoreboardObjective(String name, String text, byte status)
|
||||||
{
|
{
|
||||||
super( 0xCE );
|
super( 0xCE );
|
||||||
writeUTF( name );
|
writeString( name );
|
||||||
writeUTF( text );
|
writeString( text );
|
||||||
writeByte( status );
|
writeByte( status );
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.text = text;
|
this.text = text;
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -31,11 +32,11 @@ public class PacketCFScoreboardScore extends DefinedPacket
|
|||||||
public PacketCFScoreboardScore(String itemName, byte action, String scoreName, int value)
|
public PacketCFScoreboardScore(String itemName, byte action, String scoreName, int value)
|
||||||
{
|
{
|
||||||
super( 0xCF );
|
super( 0xCF );
|
||||||
writeUTF( itemName );
|
writeString( itemName );
|
||||||
writeByte( action );
|
writeByte( action );
|
||||||
if ( action == 0 )
|
if ( action == 0 )
|
||||||
{
|
{
|
||||||
writeUTF( scoreName );
|
writeString( scoreName );
|
||||||
writeInt( value );
|
writeInt( value );
|
||||||
}
|
}
|
||||||
this.itemName = itemName;
|
this.itemName = itemName;
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -50,7 +51,7 @@ public class PacketD1Team extends DefinedPacket
|
|||||||
public static PacketD1Team destroy(String name)
|
public static PacketD1Team destroy(String name)
|
||||||
{
|
{
|
||||||
PacketD1Team packet = new PacketD1Team();
|
PacketD1Team packet = new PacketD1Team();
|
||||||
packet.writeUTF( name );
|
packet.writeString( name );
|
||||||
packet.writeByte( 1 );
|
packet.writeByte( 1 );
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -14,7 +15,7 @@ public class PacketFAPluginMessage extends DefinedPacket
|
|||||||
public PacketFAPluginMessage(String tag, byte[] data)
|
public PacketFAPluginMessage(String tag, byte[] data)
|
||||||
{
|
{
|
||||||
super( 0xFA );
|
super( 0xFA );
|
||||||
writeUTF( tag );
|
writeString( tag );
|
||||||
writeArray( data );
|
writeArray( data );
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.data = data;
|
this.data = data;
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
@ -1,8 +1,9 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -16,7 +17,7 @@ public class PacketFDEncryptionRequest extends DefinedPacket
|
|||||||
public PacketFDEncryptionRequest(String serverId, byte[] publicKey, byte[] verifyToken)
|
public PacketFDEncryptionRequest(String serverId, byte[] publicKey, byte[] verifyToken)
|
||||||
{
|
{
|
||||||
super( 0xFD );
|
super( 0xFD );
|
||||||
writeUTF( serverId );
|
writeString( serverId );
|
||||||
writeArray( publicKey );
|
writeArray( publicKey );
|
||||||
writeArray( verifyToken );
|
writeArray( verifyToken );
|
||||||
this.serverId = serverId;
|
this.serverId = serverId;
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
@ -1,7 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.md_5.bungee.packet.PacketHandler;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -13,7 +14,7 @@ public class PacketFFKick extends DefinedPacket
|
|||||||
public PacketFFKick(String message)
|
public PacketFFKick(String message)
|
||||||
{
|
{
|
||||||
super( 0xFF );
|
super( 0xFF );
|
||||||
writeUTF( message );
|
writeString( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketFFKick(byte[] buf)
|
PacketFFKick(byte[] buf)
|
@ -1,5 +1,22 @@
|
|||||||
package net.md_5.bungee.packet;
|
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;
|
import net.md_5.bungee.netty.ChannelWrapper;
|
||||||
|
|
||||||
public abstract class PacketHandler
|
public abstract class PacketHandler
|
@ -51,9 +51,9 @@ import net.md_5.bungee.api.scheduler.TaskScheduler;
|
|||||||
import net.md_5.bungee.command.*;
|
import net.md_5.bungee.command.*;
|
||||||
import net.md_5.bungee.config.YamlConfig;
|
import net.md_5.bungee.config.YamlConfig;
|
||||||
import net.md_5.bungee.netty.PipelineUtils;
|
import net.md_5.bungee.netty.PipelineUtils;
|
||||||
import net.md_5.bungee.packet.DefinedPacket;
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
import net.md_5.bungee.packet.Packet3Chat;
|
import net.md_5.bungee.protocol.packet.Packet3Chat;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.protocol.PacketDefinitions;
|
import net.md_5.bungee.protocol.PacketDefinitions;
|
||||||
import net.md_5.bungee.scheduler.BungeeThreadPool;
|
import net.md_5.bungee.scheduler.BungeeThreadPool;
|
||||||
import net.md_5.bungee.util.CaseInsensitiveMap;
|
import net.md_5.bungee.util.CaseInsensitiveMap;
|
||||||
|
@ -25,8 +25,8 @@ import net.md_5.bungee.api.connection.Server;
|
|||||||
import net.md_5.bungee.connection.PingHandler;
|
import net.md_5.bungee.connection.PingHandler;
|
||||||
import net.md_5.bungee.netty.HandlerBoss;
|
import net.md_5.bungee.netty.HandlerBoss;
|
||||||
import net.md_5.bungee.netty.PipelineUtils;
|
import net.md_5.bungee.netty.PipelineUtils;
|
||||||
import net.md_5.bungee.packet.DefinedPacket;
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class BungeeServerInfo implements ServerInfo
|
public class BungeeServerInfo implements ServerInfo
|
||||||
|
@ -15,8 +15,8 @@ import javax.crypto.SecretKey;
|
|||||||
import javax.crypto.spec.IvParameterSpec;
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.md_5.bungee.packet.PacketFCEncryptionResponse;
|
import net.md_5.bungee.protocol.packet.PacketFCEncryptionResponse;
|
||||||
import net.md_5.bungee.packet.PacketFDEncryptionRequest;
|
import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class containing all encryption related methods for the proxy.
|
* Class containing all encryption related methods for the proxy.
|
||||||
|
@ -7,8 +7,8 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.md_5.bungee.api.connection.Server;
|
import net.md_5.bungee.api.connection.Server;
|
||||||
import net.md_5.bungee.netty.ChannelWrapper;
|
import net.md_5.bungee.netty.ChannelWrapper;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.packet.PacketFFKick;
|
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ServerConnection implements Server
|
public class ServerConnection implements Server
|
||||||
|
@ -26,17 +26,17 @@ import net.md_5.bungee.netty.ChannelWrapper;
|
|||||||
import net.md_5.bungee.netty.CipherDecoder;
|
import net.md_5.bungee.netty.CipherDecoder;
|
||||||
import net.md_5.bungee.netty.CipherEncoder;
|
import net.md_5.bungee.netty.CipherEncoder;
|
||||||
import net.md_5.bungee.netty.PacketDecoder;
|
import net.md_5.bungee.netty.PacketDecoder;
|
||||||
import net.md_5.bungee.packet.DefinedPacket;
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
import net.md_5.bungee.packet.Packet1Login;
|
import net.md_5.bungee.protocol.packet.Packet1Login;
|
||||||
import net.md_5.bungee.packet.Packet9Respawn;
|
import net.md_5.bungee.protocol.packet.Packet9Respawn;
|
||||||
import net.md_5.bungee.packet.PacketCDClientStatus;
|
import net.md_5.bungee.protocol.packet.PacketCDClientStatus;
|
||||||
import net.md_5.bungee.packet.PacketCEScoreboardObjective;
|
import net.md_5.bungee.protocol.packet.PacketCEScoreboardObjective;
|
||||||
import net.md_5.bungee.packet.PacketD1Team;
|
import net.md_5.bungee.protocol.packet.PacketD1Team;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.packet.PacketFCEncryptionResponse;
|
import net.md_5.bungee.protocol.packet.PacketFCEncryptionResponse;
|
||||||
import net.md_5.bungee.packet.PacketFDEncryptionRequest;
|
import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest;
|
||||||
import net.md_5.bungee.packet.PacketFFKick;
|
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||||
import net.md_5.bungee.packet.PacketHandler;
|
import net.md_5.bungee.protocol.packet.PacketHandler;
|
||||||
import net.md_5.bungee.protocol.PacketDefinitions;
|
import net.md_5.bungee.protocol.PacketDefinitions;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@ -30,12 +30,12 @@ import net.md_5.bungee.connection.InitialHandler;
|
|||||||
import net.md_5.bungee.netty.ChannelWrapper;
|
import net.md_5.bungee.netty.ChannelWrapper;
|
||||||
import net.md_5.bungee.netty.HandlerBoss;
|
import net.md_5.bungee.netty.HandlerBoss;
|
||||||
import net.md_5.bungee.netty.PipelineUtils;
|
import net.md_5.bungee.netty.PipelineUtils;
|
||||||
import net.md_5.bungee.packet.DefinedPacket;
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
import net.md_5.bungee.packet.Packet3Chat;
|
import net.md_5.bungee.protocol.packet.Packet3Chat;
|
||||||
import net.md_5.bungee.packet.Packet9Respawn;
|
import net.md_5.bungee.protocol.packet.Packet9Respawn;
|
||||||
import net.md_5.bungee.packet.PacketCCSettings;
|
import net.md_5.bungee.protocol.packet.PacketCCSettings;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.packet.PacketFFKick;
|
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||||
import net.md_5.bungee.util.CaseInsensitiveSet;
|
import net.md_5.bungee.util.CaseInsensitiveSet;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@ -22,16 +22,16 @@ import net.md_5.bungee.api.scoreboard.Score;
|
|||||||
import net.md_5.bungee.api.scoreboard.Scoreboard;
|
import net.md_5.bungee.api.scoreboard.Scoreboard;
|
||||||
import net.md_5.bungee.api.scoreboard.Team;
|
import net.md_5.bungee.api.scoreboard.Team;
|
||||||
import net.md_5.bungee.netty.ChannelWrapper;
|
import net.md_5.bungee.netty.ChannelWrapper;
|
||||||
import net.md_5.bungee.packet.Packet0KeepAlive;
|
import net.md_5.bungee.protocol.packet.Packet0KeepAlive;
|
||||||
import net.md_5.bungee.packet.Packet3Chat;
|
import net.md_5.bungee.protocol.packet.Packet3Chat;
|
||||||
import net.md_5.bungee.packet.PacketC9PlayerListItem;
|
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
|
||||||
import net.md_5.bungee.packet.PacketCEScoreboardObjective;
|
import net.md_5.bungee.protocol.packet.PacketCEScoreboardObjective;
|
||||||
import net.md_5.bungee.packet.PacketCFScoreboardScore;
|
import net.md_5.bungee.protocol.packet.PacketCFScoreboardScore;
|
||||||
import net.md_5.bungee.packet.PacketD0DisplayScoreboard;
|
import net.md_5.bungee.protocol.packet.PacketD0DisplayScoreboard;
|
||||||
import net.md_5.bungee.packet.PacketD1Team;
|
import net.md_5.bungee.protocol.packet.PacketD1Team;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.packet.PacketFFKick;
|
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||||
import net.md_5.bungee.packet.PacketHandler;
|
import net.md_5.bungee.protocol.packet.PacketHandler;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class DownstreamBridge extends PacketHandler
|
public class DownstreamBridge extends PacketHandler
|
||||||
|
@ -34,15 +34,15 @@ import net.md_5.bungee.netty.ChannelWrapper;
|
|||||||
import net.md_5.bungee.netty.CipherDecoder;
|
import net.md_5.bungee.netty.CipherDecoder;
|
||||||
import net.md_5.bungee.netty.CipherEncoder;
|
import net.md_5.bungee.netty.CipherEncoder;
|
||||||
import net.md_5.bungee.netty.PacketDecoder;
|
import net.md_5.bungee.netty.PacketDecoder;
|
||||||
import net.md_5.bungee.packet.Packet1Login;
|
import net.md_5.bungee.protocol.packet.Packet1Login;
|
||||||
import net.md_5.bungee.packet.Packet2Handshake;
|
import net.md_5.bungee.protocol.packet.Packet2Handshake;
|
||||||
import net.md_5.bungee.packet.PacketCDClientStatus;
|
import net.md_5.bungee.protocol.packet.PacketCDClientStatus;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.packet.PacketFCEncryptionResponse;
|
import net.md_5.bungee.protocol.packet.PacketFCEncryptionResponse;
|
||||||
import net.md_5.bungee.packet.PacketFDEncryptionRequest;
|
import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest;
|
||||||
import net.md_5.bungee.packet.PacketFEPing;
|
import net.md_5.bungee.protocol.packet.PacketFEPing;
|
||||||
import net.md_5.bungee.packet.PacketFFKick;
|
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||||
import net.md_5.bungee.packet.PacketHandler;
|
import net.md_5.bungee.protocol.packet.PacketHandler;
|
||||||
import net.md_5.bungee.protocol.PacketDefinitions;
|
import net.md_5.bungee.protocol.PacketDefinitions;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@ -5,8 +5,8 @@ import net.md_5.bungee.api.Callback;
|
|||||||
import net.md_5.bungee.api.ServerPing;
|
import net.md_5.bungee.api.ServerPing;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.netty.ChannelWrapper;
|
import net.md_5.bungee.netty.ChannelWrapper;
|
||||||
import net.md_5.bungee.packet.PacketFFKick;
|
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||||
import net.md_5.bungee.packet.PacketHandler;
|
import net.md_5.bungee.protocol.packet.PacketHandler;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PingHandler extends PacketHandler
|
public class PingHandler extends PacketHandler
|
||||||
|
@ -10,11 +10,11 @@ import net.md_5.bungee.api.event.ChatEvent;
|
|||||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
import net.md_5.bungee.netty.ChannelWrapper;
|
import net.md_5.bungee.netty.ChannelWrapper;
|
||||||
import net.md_5.bungee.packet.Packet0KeepAlive;
|
import net.md_5.bungee.protocol.packet.Packet0KeepAlive;
|
||||||
import net.md_5.bungee.packet.Packet3Chat;
|
import net.md_5.bungee.protocol.packet.Packet3Chat;
|
||||||
import net.md_5.bungee.packet.PacketCCSettings;
|
import net.md_5.bungee.protocol.packet.PacketCCSettings;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.packet.PacketHandler;
|
import net.md_5.bungee.protocol.packet.PacketHandler;
|
||||||
|
|
||||||
public class UpstreamBridge extends PacketHandler
|
public class UpstreamBridge extends PacketHandler
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.MessageToByteEncoder;
|
import io.netty.handler.codec.MessageToByteEncoder;
|
||||||
import net.md_5.bungee.packet.DefinedPacket;
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
|
|
||||||
@ChannelHandler.Sharable
|
@ChannelHandler.Sharable
|
||||||
public class DefinedPacketEncoder extends MessageToByteEncoder<DefinedPacket>
|
public class DefinedPacketEncoder extends MessageToByteEncoder<DefinedPacket>
|
||||||
|
@ -8,8 +8,8 @@ import java.io.IOException;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.connection.CancelSendSignal;
|
import net.md_5.bungee.connection.CancelSendSignal;
|
||||||
import net.md_5.bungee.packet.DefinedPacket;
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
import net.md_5.bungee.packet.PacketHandler;
|
import net.md_5.bungee.protocol.packet.PacketHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is a primitive wrapper for {@link PacketHandler} instances tied to
|
* This class is a primitive wrapper for {@link PacketHandler} instances tied to
|
||||||
|
@ -1,240 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
|
||||||
import com.google.common.io.ByteStreams;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import lombok.Delegate;
|
|
||||||
import net.md_5.bungee.Util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class represents a packet which has been given a special definition. All
|
|
||||||
* subclasses can read and write to the backing byte array which can be
|
|
||||||
* retrieved via the {@link #getPacket()} method.
|
|
||||||
*/
|
|
||||||
public abstract class DefinedPacket implements DataOutput
|
|
||||||
{
|
|
||||||
|
|
||||||
private static interface Overriden
|
|
||||||
{
|
|
||||||
|
|
||||||
void readUTF();
|
|
||||||
|
|
||||||
void writeUTF(String s);
|
|
||||||
}
|
|
||||||
private ByteArrayInputStream byteStream;
|
|
||||||
private DataInputStream in;
|
|
||||||
@Delegate(excludes = Overriden.class)
|
|
||||||
private ByteArrayDataOutput out;
|
|
||||||
private byte[] buf;
|
|
||||||
|
|
||||||
public DefinedPacket(int id, byte[] buf)
|
|
||||||
{
|
|
||||||
byteStream = new ByteArrayInputStream( buf );
|
|
||||||
in = new DataInputStream( byteStream );
|
|
||||||
if ( readUnsignedByte() != id )
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException( "Wasn't expecting packet id " + Util.hex( id ) );
|
|
||||||
}
|
|
||||||
this.buf = buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DefinedPacket(int id)
|
|
||||||
{
|
|
||||||
out = ByteStreams.newDataOutput();
|
|
||||||
writeByte( id );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the bytes that make up this packet.
|
|
||||||
*
|
|
||||||
* @return the bytes which make up this packet, either the original byte
|
|
||||||
* array or the newly written one.
|
|
||||||
*/
|
|
||||||
public byte[] getPacket()
|
|
||||||
{
|
|
||||||
return buf == null ? buf = out.toByteArray() : buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeUTF(String s)
|
|
||||||
{
|
|
||||||
writeShort( s.length() );
|
|
||||||
writeChars( s );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String readUTF()
|
|
||||||
{
|
|
||||||
short len = readShort();
|
|
||||||
char[] chars = new char[ len ];
|
|
||||||
for ( int i = 0; i < len; i++ )
|
|
||||||
{
|
|
||||||
chars[i] = this.readChar();
|
|
||||||
}
|
|
||||||
return new String( chars );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeArray(byte[] b)
|
|
||||||
{
|
|
||||||
writeShort( b.length );
|
|
||||||
write( b );
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] readArray()
|
|
||||||
{
|
|
||||||
short len = readShort();
|
|
||||||
byte[] ret = new byte[ len ];
|
|
||||||
readFully( ret );
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int available()
|
|
||||||
{
|
|
||||||
return byteStream.available();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void readFully(byte b[])
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
in.readFully( b );
|
|
||||||
} catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean readBoolean()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return in.readBoolean();
|
|
||||||
} catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final byte readByte()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return in.readByte();
|
|
||||||
} catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int readUnsignedByte()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return in.readUnsignedByte();
|
|
||||||
} catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final short readShort()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return in.readShort();
|
|
||||||
} catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final char readChar()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return in.readChar();
|
|
||||||
} catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int readInt()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return in.readInt();
|
|
||||||
} catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract boolean equals(Object obj);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract int hashCode();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract String toString();
|
|
||||||
|
|
||||||
public abstract void handle(PacketHandler handler) throws Exception;
|
|
||||||
@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(byte[] buf)
|
|
||||||
{
|
|
||||||
int id = buf[0] & 0xFF;
|
|
||||||
Class<? extends DefinedPacket> clazz = classes[id];
|
|
||||||
DefinedPacket ret = null;
|
|
||||||
if ( clazz != null )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Constructor<? extends DefinedPacket> constructor = consructors[id];
|
|
||||||
if ( constructor == null )
|
|
||||||
{
|
|
||||||
constructor = clazz.getDeclaredConstructor( byte[].class );
|
|
||||||
consructors[id] = constructor;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( constructor != null )
|
|
||||||
{
|
|
||||||
ret = constructor.newInstance( buf );
|
|
||||||
}
|
|
||||||
} catch ( IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException ex )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class Packet0KeepAlive extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
public int id;
|
|
||||||
|
|
||||||
Packet0KeepAlive(byte[] buf)
|
|
||||||
{
|
|
||||||
super( 0x00, buf );
|
|
||||||
id = readInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class Packet1Login extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
public int entityId;
|
|
||||||
public String levelType;
|
|
||||||
public byte gameMode;
|
|
||||||
public int dimension;
|
|
||||||
public byte difficulty;
|
|
||||||
public byte unused;
|
|
||||||
public byte maxPlayers;
|
|
||||||
|
|
||||||
public Packet1Login(int entityId, String levelType, byte gameMode, byte dimension, byte difficulty, byte unused, byte maxPlayers, boolean forge)
|
|
||||||
{
|
|
||||||
super( 0x01 );
|
|
||||||
writeInt( entityId );
|
|
||||||
writeUTF( levelType );
|
|
||||||
writeByte( gameMode );
|
|
||||||
if ( forge )
|
|
||||||
{
|
|
||||||
writeInt( dimension );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
writeByte( dimension );
|
|
||||||
}
|
|
||||||
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(byte[] buf)
|
|
||||||
{
|
|
||||||
super( 0x01, buf );
|
|
||||||
this.entityId = readInt();
|
|
||||||
this.levelType = readUTF();
|
|
||||||
this.gameMode = readByte();
|
|
||||||
if ( available() == 4 )
|
|
||||||
{
|
|
||||||
this.dimension = readByte();
|
|
||||||
} else if ( available() == 7 )
|
|
||||||
{
|
|
||||||
this.dimension = readInt();
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
this.difficulty = readByte();
|
|
||||||
this.unused = readByte();
|
|
||||||
this.maxPlayers = readByte();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,7 @@ import net.md_5.bungee.UserConnection;
|
|||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.TabListHandler;
|
import net.md_5.bungee.api.TabListHandler;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.packet.PacketC9PlayerListItem;
|
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
|
||||||
|
|
||||||
public class Global implements TabListHandler
|
public class Global implements TabListHandler
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ import gnu.trove.map.TObjectIntMap;
|
|||||||
import gnu.trove.map.hash.TObjectIntHashMap;
|
import gnu.trove.map.hash.TObjectIntHashMap;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.packet.PacketC9PlayerListItem;
|
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
|
||||||
|
|
||||||
public class GlobalPing extends Global
|
public class GlobalPing extends Global
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@ import java.util.Collection;
|
|||||||
import net.md_5.bungee.UserConnection;
|
import net.md_5.bungee.UserConnection;
|
||||||
import net.md_5.bungee.api.TabListHandler;
|
import net.md_5.bungee.api.TabListHandler;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.packet.PacketC9PlayerListItem;
|
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
|
||||||
|
|
||||||
public class ServerUnique implements TabListHandler
|
public class ServerUnique implements TabListHandler
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user