[TESTING] Merge protocol api into master. This should provide slightly better performance and allow more flexibility for plugin developers.
This commit is contained in:
commit
9fd69068ae
@ -14,7 +14,7 @@ public class Team
|
|||||||
private String displayName;
|
private String displayName;
|
||||||
private String prefix;
|
private String prefix;
|
||||||
private String suffix;
|
private String suffix;
|
||||||
private byte friendlyMode;
|
private boolean friendlyFire;
|
||||||
private Set<String> players = new HashSet<>();
|
private Set<String> players = new HashSet<>();
|
||||||
|
|
||||||
public Collection<String> getPlayers()
|
public Collection<String> getPlayers()
|
||||||
|
33
protocol/src/main/java/net/md_5/bungee/protocol/Forge.java
Normal file
33
protocol/src/main/java/net/md_5/bungee/protocol/Forge.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package net.md_5.bungee.protocol;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
|
import net.md_5.bungee.protocol.packet.forge.Forge1Login;
|
||||||
|
import net.md_5.bungee.protocol.skip.PacketReader;
|
||||||
|
|
||||||
|
public class Forge extends Vanilla
|
||||||
|
{
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static final Forge instance = new Forge();
|
||||||
|
|
||||||
|
public Forge()
|
||||||
|
{
|
||||||
|
classes[0x01] = Forge1Login.class;
|
||||||
|
skipper = new PacketReader( this ); // TODO: :(
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DefinedPacket read(short packetId, ByteBuf buf)
|
||||||
|
{
|
||||||
|
int start = buf.readerIndex();
|
||||||
|
DefinedPacket packet = read( packetId, buf, this );
|
||||||
|
if ( buf.readerIndex() == start )
|
||||||
|
{
|
||||||
|
packet = super.read( packetId, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package net.md_5.bungee.protocol;
|
||||||
|
|
||||||
|
public enum OpCode
|
||||||
|
{
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package net.md_5.bungee.protocol;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
|
import net.md_5.bungee.protocol.skip.PacketReader;
|
||||||
|
|
||||||
|
public interface Protocol
|
||||||
|
{
|
||||||
|
|
||||||
|
PacketReader getSkipper();
|
||||||
|
|
||||||
|
DefinedPacket read(short packetId, ByteBuf buf);
|
||||||
|
|
||||||
|
OpCode[][] getOpCodes();
|
||||||
|
|
||||||
|
Class<? extends DefinedPacket>[] getClasses();
|
||||||
|
|
||||||
|
Constructor<? extends DefinedPacket>[] getConstructors();
|
||||||
|
}
|
@ -1,40 +1,128 @@
|
|||||||
package net.md_5.bungee.protocol;
|
package net.md_5.bungee.protocol;
|
||||||
|
|
||||||
import static net.md_5.bungee.protocol.PacketDefinitions.OpCode.*;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import lombok.Getter;
|
||||||
|
import static net.md_5.bungee.protocol.OpCode.*;
|
||||||
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
|
import net.md_5.bungee.protocol.packet.Packet0KeepAlive;
|
||||||
|
import net.md_5.bungee.protocol.packet.Packet1Login;
|
||||||
|
import net.md_5.bungee.protocol.packet.Packet2Handshake;
|
||||||
|
import net.md_5.bungee.protocol.packet.Packet3Chat;
|
||||||
|
import net.md_5.bungee.protocol.packet.Packet9Respawn;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketCCSettings;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketCDClientStatus;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketCEScoreboardObjective;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketCFScoreboardScore;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketD0DisplayScoreboard;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketD1Team;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketFCEncryptionResponse;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketFEPing;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||||
|
import net.md_5.bungee.protocol.skip.PacketReader;
|
||||||
|
|
||||||
public class PacketDefinitions
|
public class Vanilla implements Protocol
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final byte PROTOCOL_VERSION = 61;
|
public static final byte PROTOCOL_VERSION = 61;
|
||||||
public static final String GAME_VERSION = "1.5.2";
|
public static final String GAME_VERSION = "1.5.2";
|
||||||
public static final OpCode[][] opCodes = new OpCode[ 512 ][];
|
@Getter
|
||||||
public static final int VANILLA_PROTOCOL = 0;
|
private static final Vanilla instance = new Vanilla();
|
||||||
public static final int FORGE_PROTOCOL = 256;
|
/*========================================================================*/
|
||||||
|
@Getter
|
||||||
|
private final OpCode[][] opCodes = new OpCode[ 256 ][];
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Getter
|
||||||
|
protected Class<? extends DefinedPacket>[] classes = new Class[ 256 ];
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Getter
|
||||||
|
private Constructor<? extends DefinedPacket>[] constructors = new Constructor[ 256 ];
|
||||||
|
@Getter
|
||||||
|
protected PacketReader skipper;
|
||||||
|
/*========================================================================*/
|
||||||
|
|
||||||
public enum OpCode
|
public Vanilla()
|
||||||
{
|
{
|
||||||
|
classes[0x00] = Packet0KeepAlive.class;
|
||||||
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
|
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;
|
||||||
|
skipper = new PacketReader( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
@Override
|
||||||
|
public DefinedPacket read(short packetId, ByteBuf buf)
|
||||||
{
|
{
|
||||||
opCodes[0x00] = new OpCode[]
|
int start = buf.readerIndex();
|
||||||
|
DefinedPacket packet = read( packetId, buf, this );
|
||||||
|
if ( buf.readerIndex() == start )
|
||||||
{
|
{
|
||||||
INT
|
throw new RuntimeException( "Unknown packet id " + packetId );
|
||||||
};
|
}
|
||||||
opCodes[0x01] = new OpCode[]
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DefinedPacket read(short id, ByteBuf buf, Protocol protocol)
|
||||||
{
|
{
|
||||||
INT, STRING, BYTE, BYTE, BYTE, BYTE, BYTE
|
DefinedPacket packet = packet( id, protocol );
|
||||||
};
|
if ( packet != null )
|
||||||
opCodes[0x02] = new OpCode[]
|
|
||||||
{
|
{
|
||||||
BYTE, STRING, STRING, INT
|
packet.read( buf );
|
||||||
};
|
return packet;
|
||||||
opCodes[0x03] = new OpCode[]
|
}
|
||||||
|
protocol.getSkipper().tryRead( id, buf );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DefinedPacket packet(short id, Protocol protocol)
|
||||||
|
{
|
||||||
|
DefinedPacket ret = null;
|
||||||
|
Class<? extends DefinedPacket> clazz = protocol.getClasses()[id];
|
||||||
|
|
||||||
|
if ( clazz != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Constructor<? extends DefinedPacket> constructor = protocol.getConstructors()[id];
|
||||||
|
if ( constructor == null )
|
||||||
|
{
|
||||||
|
constructor = clazz.getDeclaredConstructor();
|
||||||
|
constructor.setAccessible( true );
|
||||||
|
protocol.getConstructors()[id] = constructor;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( constructor != null )
|
||||||
|
{
|
||||||
|
ret = constructor.newInstance();
|
||||||
|
}
|
||||||
|
} catch ( NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
STRING
|
|
||||||
};
|
|
||||||
opCodes[0x04] = new OpCode[]
|
opCodes[0x04] = new OpCode[]
|
||||||
{
|
{
|
||||||
LONG, LONG
|
LONG, LONG
|
||||||
@ -55,10 +143,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 +367,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 +375,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
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +1,8 @@
|
|||||||
package net.md_5.bungee.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import net.md_5.bungee.netty.ChannelWrapper;
|
public abstract class AbstractPacketHandler
|
||||||
|
|
||||||
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(Packet0KeepAlive alive) throws Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public abstract class DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private final int id;
|
||||||
|
|
||||||
|
public final int getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
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.writeShort( 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(AbstractPacketHandler handler) throws Exception;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract boolean equals(Object obj);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract int hashCode();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract String toString();
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class Packet0KeepAlive extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private int randomId;
|
||||||
|
|
||||||
|
private Packet0KeepAlive()
|
||||||
|
{
|
||||||
|
super( 0x00 );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
randomId = buf.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ByteBuf buf)
|
||||||
|
{
|
||||||
|
buf.writeInt( randomId );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class Packet1Login extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
protected int entityId;
|
||||||
|
protected String levelType;
|
||||||
|
protected byte gameMode;
|
||||||
|
protected int dimension;
|
||||||
|
protected byte difficulty;
|
||||||
|
protected byte unused;
|
||||||
|
protected byte maxPlayers;
|
||||||
|
|
||||||
|
protected Packet1Login()
|
||||||
|
{
|
||||||
|
super( 0x01 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Packet1Login(int entityId, String levelType, byte gameMode, byte dimension, byte difficulty, byte unused, byte maxPlayers)
|
||||||
|
{
|
||||||
|
this( entityId, levelType, gameMode, (int) dimension, difficulty, unused, maxPlayers );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Packet1Login(int entityId, String levelType, byte gameMode, int dimension, byte difficulty, byte unused, byte maxPlayers)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.entityId = entityId;
|
||||||
|
this.levelType = levelType;
|
||||||
|
this.gameMode = gameMode;
|
||||||
|
this.dimension = dimension;
|
||||||
|
this.difficulty = difficulty;
|
||||||
|
this.unused = unused;
|
||||||
|
this.maxPlayers = maxPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
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(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class Packet2Handshake extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private byte procolVersion;
|
||||||
|
private String username;
|
||||||
|
private String host;
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
private Packet2Handshake()
|
||||||
|
{
|
||||||
|
super( 0x02 );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class Packet3Chat extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
private Packet3Chat()
|
||||||
|
{
|
||||||
|
super( 0x03 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Packet3Chat(String message)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
message = readString( buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ByteBuf buf)
|
||||||
|
{
|
||||||
|
writeString( message, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class Packet9Respawn extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private int dimension;
|
||||||
|
private byte difficulty;
|
||||||
|
private byte gameMode;
|
||||||
|
private short worldHeight;
|
||||||
|
private String levelType;
|
||||||
|
|
||||||
|
private Packet9Respawn()
|
||||||
|
{
|
||||||
|
super( 0x09 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Packet9Respawn(int dimension, byte difficulty, byte gameMode, short worldHeight, String levelType)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.dimension = dimension;
|
||||||
|
this.difficulty = difficulty;
|
||||||
|
this.gameMode = gameMode;
|
||||||
|
this.worldHeight = worldHeight;
|
||||||
|
this.levelType = levelType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class PacketC9PlayerListItem extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
private boolean online;
|
||||||
|
private short ping;
|
||||||
|
|
||||||
|
private PacketC9PlayerListItem()
|
||||||
|
{
|
||||||
|
super( 0xC9 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketC9PlayerListItem(String username, boolean online, short ping)
|
||||||
|
{
|
||||||
|
super( 0xC9 );
|
||||||
|
this.username = username;
|
||||||
|
this.online = online;
|
||||||
|
this.ping = ping;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
username = readString( buf );
|
||||||
|
online = buf.readBoolean();
|
||||||
|
ping = buf.readShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ByteBuf buf)
|
||||||
|
{
|
||||||
|
writeString( username, buf );
|
||||||
|
buf.writeBoolean( online );
|
||||||
|
buf.writeShort(ping );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class PacketCCSettings extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private String locale;
|
||||||
|
private byte viewDistance;
|
||||||
|
private byte chatFlags;
|
||||||
|
private byte difficulty;
|
||||||
|
private boolean showCape;
|
||||||
|
|
||||||
|
private PacketCCSettings()
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
writeString( locale, buf );
|
||||||
|
buf.writeByte( viewDistance );
|
||||||
|
buf.writeByte( chatFlags );
|
||||||
|
buf.writeByte( difficulty );
|
||||||
|
buf.writeBoolean( showCape );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class PacketCDClientStatus extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private byte payload;
|
||||||
|
|
||||||
|
private PacketCDClientStatus()
|
||||||
|
{
|
||||||
|
super( 0xCD );
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketCDClientStatus(byte payload)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.payload = payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
payload = buf.readByte();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ByteBuf buf)
|
||||||
|
{
|
||||||
|
buf.writeByte( payload );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class PacketCEScoreboardObjective extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String text;
|
||||||
|
/**
|
||||||
|
* 0 to create, 1 to remove.
|
||||||
|
*/
|
||||||
|
private byte action;
|
||||||
|
|
||||||
|
private PacketCEScoreboardObjective()
|
||||||
|
{
|
||||||
|
super( 0xCE );
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketCEScoreboardObjective(String name, String text, byte action)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.name = name;
|
||||||
|
this.text = text;
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class PacketCFScoreboardScore extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private String itemName;
|
||||||
|
/**
|
||||||
|
* 0 = create / update, 1 = remove.
|
||||||
|
*/
|
||||||
|
private byte action;
|
||||||
|
private String scoreName;
|
||||||
|
private int value;
|
||||||
|
|
||||||
|
private PacketCFScoreboardScore()
|
||||||
|
{
|
||||||
|
super( 0xCF );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
itemName = readString( buf );
|
||||||
|
action = buf.readByte();
|
||||||
|
if ( action == 0 )
|
||||||
|
{
|
||||||
|
scoreName = readString( buf );
|
||||||
|
value = buf.readInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ByteBuf buf)
|
||||||
|
{
|
||||||
|
writeString( itemName, buf );
|
||||||
|
buf.writeByte( action );
|
||||||
|
if ( action == 0 )
|
||||||
|
{
|
||||||
|
writeString( scoreName, buf );
|
||||||
|
buf.writeInt( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class PacketD0DisplayScoreboard extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0 = list, 1 = side, 2 = below.
|
||||||
|
*/
|
||||||
|
private byte position;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private PacketD0DisplayScoreboard()
|
||||||
|
{
|
||||||
|
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
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class PacketD1Team extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 0 - create, 1 remove, 2 info update, 3 player add, 4 player remove.
|
||||||
|
*/
|
||||||
|
private byte mode;
|
||||||
|
private String displayName;
|
||||||
|
private String prefix;
|
||||||
|
private String suffix;
|
||||||
|
private boolean friendlyFire;
|
||||||
|
private short playerCount;
|
||||||
|
private String[] players;
|
||||||
|
|
||||||
|
private PacketD1Team()
|
||||||
|
{
|
||||||
|
super( 0xD1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Packet to destroy a team.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
public PacketD1Team(String name)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
mode = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
name = readString( buf );
|
||||||
|
mode = buf.readByte();
|
||||||
|
if ( getMode() == 0 || getMode() == 2 )
|
||||||
|
{
|
||||||
|
displayName = readString( buf );
|
||||||
|
prefix = readString( buf );
|
||||||
|
suffix = readString( buf );
|
||||||
|
friendlyFire = buf.readBoolean();
|
||||||
|
}
|
||||||
|
if ( getMode() == 0 || getMode() == 3 || getMode() == 4 )
|
||||||
|
{
|
||||||
|
players = new String[ buf.readShort() ];
|
||||||
|
for ( int i = 0; i < getPlayers().length; i++ )
|
||||||
|
{
|
||||||
|
players[i] = readString( buf );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ByteBuf buf)
|
||||||
|
{
|
||||||
|
writeString( getName(), buf );
|
||||||
|
buf.writeByte( getMode() );
|
||||||
|
if ( getMode() == 0 || getMode() == 2 )
|
||||||
|
{
|
||||||
|
writeString( getDisplayName(), buf );
|
||||||
|
writeString( getPrefix(), buf );
|
||||||
|
writeString( getSuffix(), buf );
|
||||||
|
buf.writeBoolean( isFriendlyFire() );
|
||||||
|
}
|
||||||
|
if ( getMode() == 0 || getMode() == 3 || getMode() == 4 )
|
||||||
|
{
|
||||||
|
buf.writeShort( getPlayers().length );
|
||||||
|
for ( int i = 0; i < getPlayers().length; i++ )
|
||||||
|
{
|
||||||
|
writeString( getPlayers()[i], buf );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class PacketFAPluginMessage extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private String tag;
|
||||||
|
private byte[] data;
|
||||||
|
|
||||||
|
private PacketFAPluginMessage()
|
||||||
|
{
|
||||||
|
super( 0xFA );
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketFAPluginMessage(String tag, byte[] data)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.tag = tag;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
tag = readString( buf );
|
||||||
|
data = readArray( buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ByteBuf buf)
|
||||||
|
{
|
||||||
|
writeString( tag, buf );
|
||||||
|
writeArray( data, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class PacketFCEncryptionResponse extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private byte[] sharedSecret;
|
||||||
|
private byte[] verifyToken;
|
||||||
|
|
||||||
|
private PacketFCEncryptionResponse()
|
||||||
|
{
|
||||||
|
super( 0xFC );
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketFCEncryptionResponse(byte[] sharedSecret, byte[] verifyToken)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.sharedSecret = sharedSecret;
|
||||||
|
this.verifyToken = verifyToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
sharedSecret = readArray( buf );
|
||||||
|
verifyToken = readArray( buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ByteBuf buf)
|
||||||
|
{
|
||||||
|
writeArray( sharedSecret, buf );
|
||||||
|
writeArray( verifyToken, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class PacketFDEncryptionRequest extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private String serverId;
|
||||||
|
private byte[] publicKey;
|
||||||
|
private byte[] verifyToken;
|
||||||
|
|
||||||
|
private PacketFDEncryptionRequest()
|
||||||
|
{
|
||||||
|
super( 0xFD );
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketFDEncryptionRequest(String serverId, byte[] publicKey, byte[] verifyToken)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.serverId = serverId;
|
||||||
|
this.publicKey = publicKey;
|
||||||
|
this.verifyToken = verifyToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class PacketFEPing extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private byte version;
|
||||||
|
|
||||||
|
private PacketFEPing()
|
||||||
|
{
|
||||||
|
super( 0xFE );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
version = buf.readByte();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ByteBuf buf)
|
||||||
|
{
|
||||||
|
buf.writeByte( version );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class PacketFFKick extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
private PacketFFKick()
|
||||||
|
{
|
||||||
|
super( 0xFF );
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketFFKick(String message)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
message = readString( buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ByteBuf buf)
|
||||||
|
{
|
||||||
|
writeString( message, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet.forge;
|
||||||
|
|
||||||
|
import net.md_5.bungee.protocol.packet.*;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class Forge1Login extends Packet1Login
|
||||||
|
{
|
||||||
|
|
||||||
|
public Forge1Login(int entityId, String levelType, byte gameMode, int dimension, byte difficulty, byte unused, byte maxPlayers)
|
||||||
|
{
|
||||||
|
super( entityId, levelType, gameMode, dimension, difficulty, unused, maxPlayers );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
entityId = buf.readInt();
|
||||||
|
levelType = readString( buf );
|
||||||
|
gameMode = buf.readByte();
|
||||||
|
dimension = buf.readInt();
|
||||||
|
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.writeInt( dimension );
|
||||||
|
buf.writeByte( difficulty );
|
||||||
|
buf.writeByte( unused );
|
||||||
|
buf.writeByte( maxPlayers );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,12 @@
|
|||||||
package net.md_5.bungee.protocol.netty;
|
package net.md_5.bungee.protocol.skip;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class BulkChunk extends Instruction
|
public class BulkChunk extends Instruction
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void read(ByteBuf in) throws IOException
|
void read(ByteBuf in)
|
||||||
{
|
{
|
||||||
short count = in.readShort();
|
short count = in.readShort();
|
||||||
int size = in.readInt();
|
int size = in.readInt();
|
@ -1,7 +1,6 @@
|
|||||||
package net.md_5.bungee.protocol.netty;
|
package net.md_5.bungee.protocol.skip;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
class ByteHeader extends Instruction
|
class ByteHeader extends Instruction
|
||||||
{
|
{
|
||||||
@ -14,7 +13,7 @@ class ByteHeader extends Instruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void read(ByteBuf in) throws IOException
|
void read(ByteBuf in)
|
||||||
{
|
{
|
||||||
byte size = in.readByte();
|
byte size = in.readByte();
|
||||||
for ( byte b = 0; b < size; b++ )
|
for ( byte b = 0; b < size; b++ )
|
@ -1,7 +1,6 @@
|
|||||||
package net.md_5.bungee.protocol.netty;
|
package net.md_5.bungee.protocol.skip;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
abstract class Instruction
|
abstract class Instruction
|
||||||
{
|
{
|
||||||
@ -19,17 +18,15 @@ 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 );
|
||||||
// Custom instructions
|
// Custom instructions
|
||||||
static final Instruction STRING_ARRAY = new ShortHeader( STRING );
|
static final Instruction STRING_ARRAY = new ShortHeader( STRING );
|
||||||
|
|
||||||
abstract void read(ByteBuf in) throws IOException;
|
abstract void read(ByteBuf in);
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package net.md_5.bungee.protocol.netty;
|
package net.md_5.bungee.protocol.skip;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
class IntHeader extends Instruction
|
class IntHeader extends Instruction
|
||||||
{
|
{
|
||||||
@ -14,7 +13,7 @@ class IntHeader extends Instruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void read(ByteBuf in) throws IOException
|
void read(ByteBuf in)
|
||||||
{
|
{
|
||||||
int size = in.readInt();
|
int size = in.readInt();
|
||||||
for ( int i = 0; i < size; i++ )
|
for ( int i = 0; i < size; i++ )
|
@ -1,13 +1,12 @@
|
|||||||
package net.md_5.bungee.protocol.netty;
|
package net.md_5.bungee.protocol.skip;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
class Item extends Instruction
|
class Item extends Instruction
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void read(ByteBuf in) throws IOException
|
void read(ByteBuf in)
|
||||||
{
|
{
|
||||||
short type = in.readShort();
|
short type = in.readShort();
|
||||||
if ( type >= 0 )
|
if ( type >= 0 )
|
@ -1,7 +1,6 @@
|
|||||||
package net.md_5.bungee.protocol.netty;
|
package net.md_5.bungee.protocol.skip;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
class Jump extends Instruction
|
class Jump extends Instruction
|
||||||
{
|
{
|
||||||
@ -18,7 +17,7 @@ class Jump extends Instruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void read(ByteBuf in) throws IOException
|
void read(ByteBuf in)
|
||||||
{
|
{
|
||||||
in.skipBytes( len );
|
in.skipBytes( len );
|
||||||
}
|
}
|
@ -1,13 +1,12 @@
|
|||||||
package net.md_5.bungee.protocol.netty;
|
package net.md_5.bungee.protocol.skip;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
class MetaData extends Instruction
|
class MetaData extends Instruction
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void read(ByteBuf in) throws IOException
|
void read(ByteBuf in)
|
||||||
{
|
{
|
||||||
int x = in.readUnsignedByte();
|
int x = in.readUnsignedByte();
|
||||||
while ( x != 127 )
|
while ( x != 127 )
|
@ -1,13 +1,12 @@
|
|||||||
package net.md_5.bungee.protocol.netty;
|
package net.md_5.bungee.protocol.skip;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
class OptionalMotion extends Instruction
|
class OptionalMotion extends Instruction
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void read(ByteBuf in) throws IOException
|
void read(ByteBuf in)
|
||||||
{
|
{
|
||||||
int data = in.readInt();
|
int data = in.readInt();
|
||||||
if ( data > 0 )
|
if ( data > 0 )
|
@ -1,24 +1,24 @@
|
|||||||
package net.md_5.bungee.protocol.netty;
|
package net.md_5.bungee.protocol.skip;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.md_5.bungee.protocol.PacketDefinitions;
|
import net.md_5.bungee.protocol.OpCode;
|
||||||
import net.md_5.bungee.protocol.PacketDefinitions.OpCode;
|
import net.md_5.bungee.protocol.Protocol;
|
||||||
|
|
||||||
public class PacketReader
|
public class PacketReader
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final Instruction[][] instructions = new Instruction[ PacketDefinitions.opCodes.length ][];
|
private final Instruction[][] instructions;
|
||||||
|
|
||||||
static
|
public PacketReader(Protocol protocol)
|
||||||
{
|
{
|
||||||
|
instructions = new Instruction[ protocol.getOpCodes().length ][];
|
||||||
for ( int i = 0; i < instructions.length; i++ )
|
for ( int i = 0; i < instructions.length; i++ )
|
||||||
{
|
{
|
||||||
List<Instruction> output = new ArrayList<>();
|
List<Instruction> output = new ArrayList<>();
|
||||||
|
|
||||||
OpCode[] enums = PacketDefinitions.opCodes[i];
|
OpCode[] enums = protocol.getOpCodes()[i];
|
||||||
if ( enums != null )
|
if ( enums != null )
|
||||||
{
|
{
|
||||||
for ( OpCode struct : enums )
|
for ( OpCode struct : enums )
|
||||||
@ -59,35 +59,16 @@ public class PacketReader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void readPacket(int packetId, ByteBuf in, int protocol) throws IOException
|
public void tryRead(short packetId, ByteBuf in)
|
||||||
{
|
{
|
||||||
Instruction[] packetDef = null;
|
Instruction[] packetDef = instructions[packetId];
|
||||||
if ( packetId + protocol < instructions.length )
|
|
||||||
{
|
|
||||||
packetDef = instructions[packetId + protocol];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( packetDef == null )
|
if ( packetDef != null )
|
||||||
{
|
{
|
||||||
if ( protocol == PacketDefinitions.VANILLA_PROTOCOL )
|
|
||||||
{
|
|
||||||
throw new IOException( "Unknown packet id " + packetId );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
readPacket( packetId, in, PacketDefinitions.VANILLA_PROTOCOL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( Instruction instruction : packetDef )
|
for ( Instruction instruction : packetDef )
|
||||||
{
|
{
|
||||||
instruction.read( in );
|
instruction.read( in );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void readPacket(ByteBuf in, int protocol) throws IOException
|
|
||||||
{
|
|
||||||
int packetId = in.readUnsignedByte();
|
|
||||||
readPacket( packetId, in, protocol );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package net.md_5.bungee.protocol.netty;
|
package net.md_5.bungee.protocol.skip;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
class ShortHeader extends Instruction
|
class ShortHeader extends Instruction
|
||||||
{
|
{
|
||||||
@ -14,7 +13,7 @@ class ShortHeader extends Instruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void read(ByteBuf in) throws IOException
|
void read(ByteBuf in)
|
||||||
{
|
{
|
||||||
short size = in.readShort();
|
short size = in.readShort();
|
||||||
for ( short s = 0; s < size; s++ )
|
for ( short s = 0; s < size; s++ )
|
@ -1,13 +1,12 @@
|
|||||||
package net.md_5.bungee.protocol.netty;
|
package net.md_5.bungee.protocol.skip;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
class UnsignedShortByte extends Instruction
|
class UnsignedShortByte extends Instruction
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void read(ByteBuf in) throws IOException
|
void read(ByteBuf in)
|
||||||
{
|
{
|
||||||
int size = in.readUnsignedShort();
|
int size = in.readUnsignedShort();
|
||||||
in.skipBytes( size );
|
in.skipBytes( size );
|
@ -0,0 +1,45 @@
|
|||||||
|
package net.md_5.bungee.protocol;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import net.md_5.bungee.protocol.packet.AbstractPacketHandler;
|
||||||
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class PacketTest
|
||||||
|
{
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPackets() throws Exception
|
||||||
|
{
|
||||||
|
AbstractPacketHandler handler = new AbstractPacketHandler()
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
for ( short i = 0; i < 256; i++ )
|
||||||
|
{
|
||||||
|
Class<? extends DefinedPacket> clazz = Vanilla.getInstance().getClasses()[ i];
|
||||||
|
if ( clazz != null )
|
||||||
|
{
|
||||||
|
Assert.assertTrue( "Packet " + clazz + " is not public", Modifier.isPublic( clazz.getModifiers() ) );
|
||||||
|
DefinedPacket packet = Vanilla.packet( i, Vanilla.getInstance() );
|
||||||
|
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 );
|
||||||
|
// TODO: Enable this test again in v2
|
||||||
|
// Assert.assertTrue( "Packet " + clazz + " does not have private no args constructor", Modifier.isPrivate( clazz.getDeclaredConstructor().getModifiers() ) );
|
||||||
|
|
||||||
|
for ( Field field : clazz.getDeclaredFields() )
|
||||||
|
{
|
||||||
|
// TODO: Enable this test again in v2
|
||||||
|
// Assert.assertTrue( "Packet " + clazz + " has non private field " + field, Modifier.isPrivate( field.getModifiers() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
packet.handle( handler ); // Make sure there are no exceptions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package net.md_5.bungee.protocol;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class ProtocolTest
|
||||||
|
{
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProtocol()
|
||||||
|
{
|
||||||
|
Assert.assertFalse( "Protocols should have different login packet", Vanilla.getInstance().getClasses()[0x01] == Forge.getInstance().classes[0x01] );
|
||||||
|
}
|
||||||
|
}
|
@ -51,10 +51,10 @@ 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.Vanilla;
|
||||||
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;
|
||||||
|
|
||||||
@ -444,13 +444,13 @@ public class BungeeCord extends ProxyServer
|
|||||||
@Override
|
@Override
|
||||||
public byte getProtocolVersion()
|
public byte getProtocolVersion()
|
||||||
{
|
{
|
||||||
return PacketDefinitions.PROTOCOL_VERSION;
|
return Vanilla.PROTOCOL_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGameVersion()
|
public String getGameVersion()
|
||||||
{
|
{
|
||||||
return PacketDefinitions.GAME_VERSION;
|
return Vanilla.GAME_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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.
|
||||||
@ -53,18 +53,15 @@ public class EncryptionUtil
|
|||||||
{
|
{
|
||||||
Cipher cipher = Cipher.getInstance( "RSA" );
|
Cipher cipher = Cipher.getInstance( "RSA" );
|
||||||
cipher.init( Cipher.DECRYPT_MODE, keys.getPrivate() );
|
cipher.init( Cipher.DECRYPT_MODE, keys.getPrivate() );
|
||||||
byte[] decrypted = cipher.doFinal( resp.verifyToken );
|
byte[] decrypted = cipher.doFinal( resp.getVerifyToken() );
|
||||||
|
|
||||||
if ( !Arrays.equals( request.verifyToken, decrypted ) )
|
if ( !Arrays.equals( request.getVerifyToken(), decrypted ) )
|
||||||
{
|
{
|
||||||
throw new IllegalStateException( "Key pairs do not match!" );
|
throw new IllegalStateException( "Key pairs do not match!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
cipher.init( Cipher.DECRYPT_MODE, keys.getPrivate() );
|
cipher.init( Cipher.DECRYPT_MODE, keys.getPrivate() );
|
||||||
byte[] shared = resp.sharedSecret;
|
return new SecretKeySpec( cipher.doFinal( resp.getSharedSecret() ), "AES" );
|
||||||
byte[] secret = cipher.doFinal( shared );
|
|
||||||
|
|
||||||
return new SecretKeySpec( secret, "AES" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Cipher getCipher(int opMode, Key shared) throws GeneralSecurityException
|
public static Cipher getCipher(int opMode, Key shared) throws GeneralSecurityException
|
||||||
@ -76,7 +73,7 @@ public class EncryptionUtil
|
|||||||
|
|
||||||
public static PublicKey getPubkey(PacketFDEncryptionRequest request) throws GeneralSecurityException
|
public static PublicKey getPubkey(PacketFDEncryptionRequest request) throws GeneralSecurityException
|
||||||
{
|
{
|
||||||
return KeyFactory.getInstance( "RSA" ).generatePublic( new X509EncodedKeySpec( request.publicKey ) );
|
return KeyFactory.getInstance( "RSA" ).generatePublic( new X509EncodedKeySpec( request.getPublicKey() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] encrypt(Key key, byte[] b) throws GeneralSecurityException
|
public static byte[] encrypt(Key key, byte[] b) throws GeneralSecurityException
|
||||||
|
12
proxy/src/main/java/net/md_5/bungee/PacketConstants.java
Normal file
12
proxy/src/main/java/net/md_5/bungee/PacketConstants.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package net.md_5.bungee;
|
||||||
|
|
||||||
|
import net.md_5.bungee.protocol.packet.Packet9Respawn;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketCDClientStatus;
|
||||||
|
|
||||||
|
public class PacketConstants
|
||||||
|
{
|
||||||
|
|
||||||
|
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 static final PacketCDClientStatus CLIENT_LOGIN = new PacketCDClientStatus( (byte) 0 );
|
||||||
|
}
|
@ -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,18 +26,18 @@ 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.netty.PacketHandler;
|
||||||
import net.md_5.bungee.packet.Packet1Login;
|
import net.md_5.bungee.protocol.Forge;
|
||||||
import net.md_5.bungee.packet.Packet9Respawn;
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
import net.md_5.bungee.packet.PacketCDClientStatus;
|
import net.md_5.bungee.protocol.packet.Packet1Login;
|
||||||
import net.md_5.bungee.packet.PacketCEScoreboardObjective;
|
import net.md_5.bungee.protocol.packet.Packet9Respawn;
|
||||||
import net.md_5.bungee.packet.PacketD1Team;
|
import net.md_5.bungee.protocol.packet.PacketCEScoreboardObjective;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.protocol.packet.PacketD1Team;
|
||||||
import net.md_5.bungee.packet.PacketFCEncryptionResponse;
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.packet.PacketFDEncryptionRequest;
|
import net.md_5.bungee.protocol.packet.PacketFCEncryptionResponse;
|
||||||
import net.md_5.bungee.packet.PacketFFKick;
|
import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest;
|
||||||
import net.md_5.bungee.packet.PacketHandler;
|
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||||
import net.md_5.bungee.protocol.PacketDefinitions;
|
import net.md_5.bungee.protocol.packet.forge.Forge1Login;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ServerConnector extends PacketHandler
|
public class ServerConnector extends PacketHandler
|
||||||
@ -60,7 +60,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void exception(Throwable t) throws Exception
|
public void exception(Throwable t) throws Exception
|
||||||
{
|
{
|
||||||
String message = "Exception Connectiong:" + Util.exception( t );
|
String message = "Exception Connecting:" + Util.exception( t );
|
||||||
if ( user.getServer() == null )
|
if ( user.getServer() == null )
|
||||||
{
|
{
|
||||||
user.disconnect( message );
|
user.disconnect( message );
|
||||||
@ -86,7 +86,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
// Skip encryption if we are not using Forge
|
// Skip encryption if we are not using Forge
|
||||||
if ( user.getPendingConnection().getForgeLogin() == null )
|
if ( user.getPendingConnection().getForgeLogin() == null )
|
||||||
{
|
{
|
||||||
channel.write( PacketCDClientStatus.CLIENT_LOGIN );
|
channel.write( PacketConstants.CLIENT_LOGIN );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,18 +133,20 @@ public class ServerConnector extends PacketHandler
|
|||||||
if ( user.getServer() == null )
|
if ( user.getServer() == null )
|
||||||
{
|
{
|
||||||
// Once again, first connection
|
// Once again, first connection
|
||||||
user.setClientEntityId( login.entityId );
|
user.setClientEntityId( login.getEntityId() );
|
||||||
user.setServerEntityId( login.entityId );
|
user.setServerEntityId( login.getEntityId() );
|
||||||
// Set tab list size
|
|
||||||
Packet1Login modLogin = new Packet1Login(
|
// Set tab list size, this sucks balls, TODO: what shall we do about packet mutability
|
||||||
login.entityId,
|
Packet1Login modLogin;
|
||||||
login.levelType,
|
if ( ch.getHandle().pipeline().get( PacketDecoder.class ).getProtocol() == Forge.getInstance() )
|
||||||
login.gameMode,
|
{
|
||||||
(byte) login.dimension,
|
modLogin = new Forge1Login( login.getEntityId(), login.getLevelType(), login.getGameMode(), login.getDimension(), login.getDifficulty(), login.getUnused(),
|
||||||
login.difficulty,
|
(byte) user.getPendingConnection().getListener().getTabListSize() );
|
||||||
login.unused,
|
} else
|
||||||
(byte) user.getPendingConnection().getListener().getTabListSize(),
|
{
|
||||||
ch.getHandle().pipeline().get( PacketDecoder.class ).getProtocol() == PacketDefinitions.FORGE_PROTOCOL );
|
modLogin = new Packet1Login( login.getEntityId(), login.getLevelType(), login.getGameMode(), (byte) login.getDimension(), login.getDifficulty(), login.getUnused(),
|
||||||
|
(byte) user.getPendingConnection().getListener().getTabListSize() );
|
||||||
|
}
|
||||||
user.sendPacket( modLogin );
|
user.sendPacket( modLogin );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -157,15 +159,14 @@ public class ServerConnector extends PacketHandler
|
|||||||
}
|
}
|
||||||
for ( Team team : serverScoreboard.getTeams() )
|
for ( Team team : serverScoreboard.getTeams() )
|
||||||
{
|
{
|
||||||
user.sendPacket( PacketD1Team.destroy( team.getName() ) );
|
user.sendPacket( new PacketD1Team( team.getName() ) );
|
||||||
}
|
}
|
||||||
serverScoreboard.clear();
|
serverScoreboard.clear();
|
||||||
|
|
||||||
user.sendPacket( Packet9Respawn.DIM1_SWITCH );
|
user.sendDimensionSwitch();
|
||||||
user.sendPacket( Packet9Respawn.DIM2_SWITCH );
|
|
||||||
|
|
||||||
user.setServerEntityId( login.entityId );
|
user.setServerEntityId( login.getEntityId() );
|
||||||
user.sendPacket( new Packet9Respawn( login.dimension, login.difficulty, login.gameMode, (short) 256, login.levelType ) );
|
user.sendPacket( new Packet9Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), (short) 256, login.getLevelType() ) );
|
||||||
|
|
||||||
// Remove from old servers
|
// Remove from old servers
|
||||||
user.getServer().setObsolete( true );
|
user.getServer().setObsolete( true );
|
||||||
@ -209,7 +210,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
this.secretkey = EncryptionUtil.getSecret();
|
this.secretkey = EncryptionUtil.getSecret();
|
||||||
|
|
||||||
byte[] shared = EncryptionUtil.encrypt( publickey, secretkey.getEncoded() );
|
byte[] shared = EncryptionUtil.encrypt( publickey, secretkey.getEncoded() );
|
||||||
byte[] token = EncryptionUtil.encrypt( publickey, encryptRequest.verifyToken );
|
byte[] token = EncryptionUtil.encrypt( publickey, encryptRequest.getVerifyToken() );
|
||||||
|
|
||||||
ch.write( new PacketFCEncryptionResponse( shared, token ) );
|
ch.write( new PacketFCEncryptionResponse( shared, token ) );
|
||||||
|
|
||||||
@ -233,7 +234,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
|
|
||||||
ch.write( user.getPendingConnection().getForgeLogin() );
|
ch.write( user.getPendingConnection().getForgeLogin() );
|
||||||
|
|
||||||
ch.write( PacketCDClientStatus.CLIENT_LOGIN );
|
ch.write( PacketConstants.CLIENT_LOGIN );
|
||||||
thisState = State.LOGIN;
|
thisState = State.LOGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,14 +246,14 @@ public class ServerConnector extends PacketHandler
|
|||||||
{
|
{
|
||||||
def = null;
|
def = null;
|
||||||
}
|
}
|
||||||
ServerKickEvent event = bungee.getPluginManager().callEvent( new ServerKickEvent( user, kick.message, def ) );
|
ServerKickEvent event = bungee.getPluginManager().callEvent( new ServerKickEvent( user, kick.getMessage(), def ) );
|
||||||
if ( event.isCancelled() && event.getCancelServer() != null )
|
if ( event.isCancelled() && event.getCancelServer() != null )
|
||||||
{
|
{
|
||||||
user.connect( event.getCancelServer() );
|
user.connect( event.getCancelServer() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String message = bungee.getTranslation( "connect_kick" ) + target.getName() + ": " + kick.message;
|
String message = bungee.getTranslation( "connect_kick" ) + target.getName() + ": " + kick.getMessage();
|
||||||
if ( user.getServer() == null )
|
if ( user.getServer() == null )
|
||||||
{
|
{
|
||||||
user.disconnect( message );
|
user.disconnect( message );
|
||||||
@ -265,9 +266,9 @@ public class ServerConnector extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
||||||
{
|
{
|
||||||
if ( ( pluginMessage.data[0] & 0xFF ) == 0 && pluginMessage.tag.equals( "FML" ) )
|
if ( ( pluginMessage.getData()[0] & 0xFF ) == 0 && pluginMessage.getTag().equals( "FML" ) )
|
||||||
{
|
{
|
||||||
ByteArrayDataInput in = ByteStreams.newDataInput( pluginMessage.data );
|
ByteArrayDataInput in = ByteStreams.newDataInput( pluginMessage.getData() );
|
||||||
in.readUnsignedByte();
|
in.readUnsignedByte();
|
||||||
int count = in.readInt();
|
int count = in.readInt();
|
||||||
for ( int i = 0; i < count; i++ )
|
for ( int i = 0; i < count; i++ )
|
||||||
@ -277,7 +278,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
if ( in.readByte() != 0 )
|
if ( in.readByte() != 0 )
|
||||||
{
|
{
|
||||||
// TODO: Using forge flag
|
// TODO: Using forge flag
|
||||||
ch.getHandle().pipeline().get( PacketDecoder.class ).setProtocol( PacketDefinitions.FORGE_PROTOCOL );
|
ch.getHandle().pipeline().get( PacketDecoder.class ).setProtocol( Forge.getInstance() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,12 +30,11 @@ 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.PacketCCSettings;
|
||||||
import net.md_5.bungee.packet.PacketCCSettings;
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||||
import net.md_5.bungee.packet.PacketFFKick;
|
|
||||||
import net.md_5.bungee.util.CaseInsensitiveSet;
|
import net.md_5.bungee.util.CaseInsensitiveSet;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@ -133,10 +132,15 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
connect( target, false );
|
connect( target, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sendDimensionSwitch()
|
||||||
|
{
|
||||||
|
sendPacket( PacketConstants.DIM1_SWITCH );
|
||||||
|
sendPacket( PacketConstants.DIM2_SWITCH );
|
||||||
|
}
|
||||||
|
|
||||||
public void connectNow(ServerInfo target)
|
public void connectNow(ServerInfo target)
|
||||||
{
|
{
|
||||||
sendPacket( Packet9Respawn.DIM1_SWITCH );
|
sendDimensionSwitch();
|
||||||
sendPacket( Packet9Respawn.DIM2_SWITCH );
|
|
||||||
connect( target );
|
connect( target );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import net.md_5.bungee.api.ChatColor;
|
|||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.ChatEvent;
|
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
import net.md_5.bungee.api.event.ServerKickEvent;
|
import net.md_5.bungee.api.event.ServerKickEvent;
|
||||||
import net.md_5.bungee.api.scoreboard.Objective;
|
import net.md_5.bungee.api.scoreboard.Objective;
|
||||||
@ -22,16 +21,17 @@ 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.netty.PacketHandler;
|
||||||
import net.md_5.bungee.packet.Packet3Chat;
|
import net.md_5.bungee.protocol.packet.Packet0KeepAlive;
|
||||||
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;
|
|
||||||
|
;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class DownstreamBridge extends PacketHandler
|
public class DownstreamBridge extends PacketHandler
|
||||||
@ -78,7 +78,7 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(Packet0KeepAlive alive) throws Exception
|
public void handle(Packet0KeepAlive alive) throws Exception
|
||||||
{
|
{
|
||||||
con.setSentPingId( alive.id );
|
con.setSentPingId( alive.getRandomId() );
|
||||||
con.setSentPingTime( System.currentTimeMillis() );
|
con.setSentPingTime( System.currentTimeMillis() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
public void handle(PacketC9PlayerListItem playerList) throws Exception
|
public void handle(PacketC9PlayerListItem playerList) throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !bungee.getTabListHandler().onListUpdate( con, playerList.username, playerList.online, playerList.ping ) )
|
if ( !bungee.getTabListHandler().onListUpdate( con, playerList.getUsername(), playerList.isOnline(), playerList.getPing() ) )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
@ -96,13 +96,13 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
public void handle(PacketCEScoreboardObjective objective) throws Exception
|
public void handle(PacketCEScoreboardObjective objective) throws Exception
|
||||||
{
|
{
|
||||||
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
||||||
switch ( objective.action )
|
switch ( objective.getAction() )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
serverScoreboard.addObjective( new Objective( objective.name, objective.text ) );
|
serverScoreboard.addObjective( new Objective( objective.getName(), objective.getText() ) );
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
serverScoreboard.removeObjective( objective.name );
|
serverScoreboard.removeObjective( objective.getName() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,15 +111,15 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
public void handle(PacketCFScoreboardScore score) throws Exception
|
public void handle(PacketCFScoreboardScore score) throws Exception
|
||||||
{
|
{
|
||||||
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
||||||
switch ( score.action )
|
switch ( score.getAction() )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
Score s = new Score( score.itemName, score.scoreName, score.value );
|
Score s = new Score( score.getItemName(), score.getScoreName(), score.getValue() );
|
||||||
serverScoreboard.removeScore( score.itemName );
|
serverScoreboard.removeScore( score.getItemName() );
|
||||||
serverScoreboard.addScore( s );
|
serverScoreboard.addScore( s );
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
serverScoreboard.removeScore( score.itemName );
|
serverScoreboard.removeScore( score.getItemName() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,8 +128,8 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
public void handle(PacketD0DisplayScoreboard displayScoreboard) throws Exception
|
public void handle(PacketD0DisplayScoreboard displayScoreboard) throws Exception
|
||||||
{
|
{
|
||||||
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
||||||
serverScoreboard.setName( displayScoreboard.name );
|
serverScoreboard.setName( displayScoreboard.getName() );
|
||||||
serverScoreboard.setPosition( Position.values()[displayScoreboard.position] );
|
serverScoreboard.setPosition( Position.values()[displayScoreboard.getPosition()] );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -137,37 +137,37 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
{
|
{
|
||||||
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
||||||
// Remove team and move on
|
// Remove team and move on
|
||||||
if ( team.mode == 1 )
|
if ( team.getMode() == 1 )
|
||||||
{
|
{
|
||||||
serverScoreboard.removeTeam( team.name );
|
serverScoreboard.removeTeam( team.getName() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create or get old team
|
// Create or get old team
|
||||||
Team t;
|
Team t;
|
||||||
if ( team.mode == 0 )
|
if ( team.getMode() == 0 )
|
||||||
{
|
{
|
||||||
t = new Team( team.name );
|
t = new Team( team.getName() );
|
||||||
serverScoreboard.addTeam( t );
|
serverScoreboard.addTeam( t );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
t = serverScoreboard.getTeam( team.name );
|
t = serverScoreboard.getTeam( team.getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( t != null )
|
if ( t != null )
|
||||||
{
|
{
|
||||||
if ( team.mode == 0 || team.mode == 2 )
|
if ( team.getMode() == 0 || team.getMode() == 2 )
|
||||||
{
|
{
|
||||||
t.setDisplayName( team.displayName );
|
t.setDisplayName( team.getDisplayName() );
|
||||||
t.setPrefix( team.prefix );
|
t.setPrefix( team.getPrefix() );
|
||||||
t.setSuffix( team.suffix );
|
t.setSuffix( team.getSuffix() );
|
||||||
t.setFriendlyMode( team.friendlyFire );
|
t.setFriendlyFire(team.isFriendlyFire() );
|
||||||
}
|
}
|
||||||
if ( team.players != null )
|
if ( team.getPlayers()!= null )
|
||||||
{
|
{
|
||||||
for ( String s : team.players )
|
for ( String s : team.getPlayers() )
|
||||||
{
|
{
|
||||||
if ( team.mode == 0 || team.mode == 3 )
|
if ( team.getMode() == 0 || team.getMode() == 3 )
|
||||||
{
|
{
|
||||||
t.addPlayer( s );
|
t.addPlayer( s );
|
||||||
} else
|
} else
|
||||||
@ -182,20 +182,20 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
||||||
{
|
{
|
||||||
ByteArrayDataInput in = ByteStreams.newDataInput( pluginMessage.data );
|
ByteArrayDataInput in = ByteStreams.newDataInput( pluginMessage.getData() );
|
||||||
PluginMessageEvent event = new PluginMessageEvent( con.getServer(), con, pluginMessage.tag, pluginMessage.data.clone() );
|
PluginMessageEvent event = new PluginMessageEvent( con.getServer(), con, pluginMessage.getTag(), pluginMessage.getData().clone() );
|
||||||
|
|
||||||
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pluginMessage.tag.equals( "MC|TPack" ) && con.getPendingConnection().getListener().getTexturePack() != null )
|
if ( pluginMessage.getTag().equals( "MC|TPack" ) && con.getPendingConnection().getListener().getTexturePack() != null )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pluginMessage.tag.equals( "BungeeCord" ) )
|
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
|
||||||
{
|
{
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
String subChannel = in.readUTF();
|
String subChannel = in.readUTF();
|
||||||
@ -325,7 +325,7 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
{
|
{
|
||||||
def = null;
|
def = null;
|
||||||
}
|
}
|
||||||
ServerKickEvent event = bungee.getPluginManager().callEvent( new ServerKickEvent( con, kick.message, def ) );
|
ServerKickEvent event = bungee.getPluginManager().callEvent( new ServerKickEvent( con, kick.getMessage(), def ) );
|
||||||
if ( event.isCancelled() && event.getCancelServer() != null )
|
if ( event.isCancelled() && event.getCancelServer() != null )
|
||||||
{
|
{
|
||||||
con.connectNow( event.getCancelServer() );
|
con.connectNow( event.getCancelServer() );
|
||||||
|
@ -34,16 +34,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.Packet1Login;
|
import net.md_5.bungee.netty.PacketHandler;
|
||||||
import net.md_5.bungee.packet.Packet2Handshake;
|
import net.md_5.bungee.protocol.Forge;
|
||||||
import net.md_5.bungee.packet.PacketCDClientStatus;
|
import net.md_5.bungee.protocol.packet.Packet1Login;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.protocol.packet.Packet2Handshake;
|
||||||
import net.md_5.bungee.packet.PacketFCEncryptionResponse;
|
import net.md_5.bungee.protocol.packet.PacketCDClientStatus;
|
||||||
import net.md_5.bungee.packet.PacketFDEncryptionRequest;
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.packet.PacketFEPing;
|
import net.md_5.bungee.protocol.packet.PacketFCEncryptionResponse;
|
||||||
import net.md_5.bungee.packet.PacketFFKick;
|
import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest;
|
||||||
import net.md_5.bungee.packet.PacketHandler;
|
import net.md_5.bungee.protocol.packet.PacketFEPing;
|
||||||
import net.md_5.bungee.protocol.PacketDefinitions;
|
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||||
|
import net.md_5.bungee.protocol.Vanilla;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class InitialHandler extends PacketHandler implements PendingConnection
|
public class InitialHandler extends PacketHandler implements PendingConnection
|
||||||
@ -115,14 +116,14 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
Preconditions.checkState( forgeLogin == null, "Already received FORGE LOGIN" );
|
Preconditions.checkState( forgeLogin == null, "Already received FORGE LOGIN" );
|
||||||
forgeLogin = login;
|
forgeLogin = login;
|
||||||
|
|
||||||
ch.getHandle().pipeline().get( PacketDecoder.class ).setProtocol( PacketDefinitions.FORGE_PROTOCOL );
|
ch.getHandle().pipeline().get( PacketDecoder.class ).setProtocol( Forge.getInstance() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Packet2Handshake handshake) throws Exception
|
public void handle(Packet2Handshake handshake) throws Exception
|
||||||
{
|
{
|
||||||
Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" );
|
Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" );
|
||||||
if ( handshake.username.length() > 16 )
|
if ( handshake.getUsername().length() > 16 )
|
||||||
{
|
{
|
||||||
disconnect( "Cannot have username longer than 16 characters" );
|
disconnect( "Cannot have username longer than 16 characters" );
|
||||||
return;
|
return;
|
||||||
@ -136,7 +137,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If offline mode and they are already on, don't allow connect
|
// If offline mode and they are already on, don't allow connect
|
||||||
if ( !BungeeCord.getInstance().config.isOnlineMode() && bungee.getPlayer( handshake.username ) != null )
|
if ( !BungeeCord.getInstance().config.isOnlineMode() && bungee.getPlayer( handshake.getUsername() ) != null )
|
||||||
{
|
{
|
||||||
disconnect( bungee.getTranslation( "already_connected" ) );
|
disconnect( bungee.getTranslation( "already_connected" ) );
|
||||||
return;
|
return;
|
||||||
@ -164,7 +165,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
MessageDigest sha = MessageDigest.getInstance( "SHA-1" );
|
MessageDigest sha = MessageDigest.getInstance( "SHA-1" );
|
||||||
for ( byte[] bit : new byte[][]
|
for ( byte[] bit : new byte[][]
|
||||||
{
|
{
|
||||||
request.serverId.getBytes( "ISO_8859_1" ), sharedKey.getEncoded(), EncryptionUtil.keys.getPublic().getEncoded()
|
request.getServerId().getBytes( "ISO_8859_1" ), sharedKey.getEncoded(), EncryptionUtil.keys.getPublic().getEncoded()
|
||||||
} )
|
} )
|
||||||
{
|
{
|
||||||
sha.update( bit );
|
sha.update( bit );
|
||||||
@ -202,7 +203,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
private void finish() throws GeneralSecurityException
|
private void finish() throws GeneralSecurityException
|
||||||
{
|
{
|
||||||
// Check for multiple connections
|
// Check for multiple connections
|
||||||
ProxiedPlayer old = bungee.getPlayer( handshake.username );
|
ProxiedPlayer old = bungee.getPlayer( handshake.getUsername() );
|
||||||
if ( old != null )
|
if ( old != null )
|
||||||
{
|
{
|
||||||
old.disconnect( bungee.getTranslation( "already_connected" ) );
|
old.disconnect( bungee.getTranslation( "already_connected" ) );
|
||||||
@ -223,7 +224,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
thisState = InitialHandler.State.LOGIN;
|
thisState = InitialHandler.State.LOGIN;
|
||||||
ch.write( new PacketFCEncryptionResponse() );
|
ch.write( new PacketFCEncryptionResponse( new byte[ 0 ], new byte[ 0 ] ) );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Cipher encrypt = EncryptionUtil.getCipher( Cipher.ENCRYPT_MODE, sharedKey );
|
Cipher encrypt = EncryptionUtil.getCipher( Cipher.ENCRYPT_MODE, sharedKey );
|
||||||
@ -271,19 +272,19 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return ( handshake == null ) ? null : handshake.username;
|
return ( handshake == null ) ? null : handshake.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte getVersion()
|
public byte getVersion()
|
||||||
{
|
{
|
||||||
return ( handshake == null ) ? -1 : handshake.procolVersion;
|
return ( handshake == null ) ? -1 : handshake.getProcolVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InetSocketAddress getVirtualHost()
|
public InetSocketAddress getVirtualHost()
|
||||||
{
|
{
|
||||||
return ( handshake == null ) ? null : new InetSocketAddress( handshake.host, handshake.port );
|
return ( handshake == null ) ? null : new InetSocketAddress( handshake.getHost(), handshake.getPort() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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.netty.PacketHandler;
|
||||||
import net.md_5.bungee.packet.PacketHandler;
|
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PingHandler extends PacketHandler
|
public class PingHandler extends PacketHandler
|
||||||
@ -34,7 +34,7 @@ public class PingHandler extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketFFKick kick) throws Exception
|
public void handle(PacketFFKick kick) throws Exception
|
||||||
{
|
{
|
||||||
String[] split = kick.message.split( "\00" );
|
String[] split = kick.getMessage().split( "\00" );
|
||||||
ServerPing ping = new ServerPing( Byte.parseByte( split[1] ), split[2], split[3], Integer.parseInt( split[4] ), Integer.parseInt( split[5] ) );
|
ServerPing ping = new ServerPing( Byte.parseByte( split[1] ), split[2], split[3], Integer.parseInt( split[4] ), Integer.parseInt( split[5] ) );
|
||||||
callback.done( ping, null );
|
callback.done( ping, null );
|
||||||
}
|
}
|
||||||
|
@ -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.netty.PacketHandler;
|
||||||
import net.md_5.bungee.packet.Packet3Chat;
|
import net.md_5.bungee.protocol.packet.Packet0KeepAlive;
|
||||||
import net.md_5.bungee.packet.PacketCCSettings;
|
import net.md_5.bungee.protocol.packet.Packet3Chat;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.protocol.packet.PacketCCSettings;
|
||||||
import net.md_5.bungee.packet.PacketHandler;
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
|
|
||||||
public class UpstreamBridge extends PacketHandler
|
public class UpstreamBridge extends PacketHandler
|
||||||
{
|
{
|
||||||
@ -72,7 +72,7 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(Packet0KeepAlive alive) throws Exception
|
public void handle(Packet0KeepAlive alive) throws Exception
|
||||||
{
|
{
|
||||||
if ( alive.id == con.getSentPingId() )
|
if ( alive.getRandomId() == con.getSentPingId() )
|
||||||
{
|
{
|
||||||
int newPing = (int) ( System.currentTimeMillis() - con.getSentPingTime() );
|
int newPing = (int) ( System.currentTimeMillis() - con.getSentPingTime() );
|
||||||
bungee.getTabListHandler().onPingChange( con, newPing );
|
bungee.getTabListHandler().onPingChange( con, newPing );
|
||||||
@ -83,14 +83,14 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(Packet3Chat chat) throws Exception
|
public void handle(Packet3Chat chat) throws Exception
|
||||||
{
|
{
|
||||||
ChatEvent chatEvent = new ChatEvent( con, con.getServer(), chat.message );
|
ChatEvent chatEvent = new ChatEvent( con, con.getServer(), chat.getMessage() );
|
||||||
if ( bungee.getPluginManager().callEvent( chatEvent ).isCancelled() )
|
if ( bungee.getPluginManager().callEvent( chatEvent ).isCancelled() )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
if ( chatEvent.isCommand() )
|
if ( chatEvent.isCommand() )
|
||||||
{
|
{
|
||||||
if ( bungee.getPluginManager().dispatchCommand( con, chat.message.substring( 1 ) ) )
|
if ( bungee.getPluginManager().dispatchCommand( con, chat.getMessage().substring( 1 ) ) )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
@ -106,12 +106,12 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
||||||
{
|
{
|
||||||
if ( pluginMessage.tag.equals( "BungeeCord" ) )
|
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginMessageEvent event = new PluginMessageEvent( con, con.getServer(), pluginMessage.tag, pluginMessage.data.clone() );
|
PluginMessageEvent event = new PluginMessageEvent( con, con.getServer(), pluginMessage.getTag(), pluginMessage.getData().clone() );
|
||||||
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
|
@ -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>
|
||||||
@ -13,6 +13,7 @@ public class DefinedPacketEncoder extends MessageToByteEncoder<DefinedPacket>
|
|||||||
@Override
|
@Override
|
||||||
protected void encode(ChannelHandlerContext ctx, DefinedPacket msg, ByteBuf out) throws Exception
|
protected void encode(ChannelHandlerContext ctx, DefinedPacket msg, ByteBuf out) throws Exception
|
||||||
{
|
{
|
||||||
out.writeBytes( msg.getPacket() );
|
out.writeByte( msg.getId() );
|
||||||
|
msg.write( out );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,15 +8,13 @@ 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.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
|
||||||
* channels to maintain simple states, and only call the required, adapted
|
* channels to maintain simple states, and only call the required, adapted
|
||||||
* methods when the channel is connected.
|
* methods when the channel is connected.
|
||||||
*/
|
*/
|
||||||
public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<byte[]>
|
public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<Object>
|
||||||
{
|
{
|
||||||
|
|
||||||
private ChannelWrapper channel;
|
private ChannelWrapper channel;
|
||||||
@ -50,25 +48,27 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<byte[]>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageReceived(ChannelHandlerContext ctx, byte[] msg) throws Exception
|
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception
|
||||||
{
|
{
|
||||||
if ( handler != null && ctx.channel().isActive() )
|
if ( handler != null && ctx.channel().isActive() )
|
||||||
{
|
{
|
||||||
DefinedPacket packet = DefinedPacket.packet( msg );
|
if ( msg instanceof PacketWrapper )
|
||||||
boolean sendPacket = true;
|
|
||||||
if ( packet != null )
|
|
||||||
{
|
{
|
||||||
|
boolean sendPacket = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
packet.handle( handler );
|
( (PacketWrapper) msg ).packet.handle( handler );
|
||||||
} catch ( CancelSendSignal ex )
|
} catch ( CancelSendSignal ex )
|
||||||
{
|
{
|
||||||
sendPacket = false;
|
sendPacket = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ( sendPacket )
|
if ( sendPacket )
|
||||||
{
|
{
|
||||||
handler.handle( msg );
|
handler.handle( ( (PacketWrapper) msg ).buf );
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
handler.handle( (byte[]) msg );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,9 @@ import io.netty.handler.codec.ReplayingDecoder;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.md_5.bungee.protocol.netty.PacketReader;
|
import net.md_5.bungee.protocol.Protocol;
|
||||||
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
|
import net.md_5.bungee.protocol.skip.PacketReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class will attempt to read a packet from {@link PacketReader}, with the
|
* This class will attempt to read a packet from {@link PacketReader}, with the
|
||||||
@ -23,7 +25,7 @@ public class PacketDecoder extends ReplayingDecoder<Void>
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private int protocol;
|
private Protocol protocol;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, MessageBuf<Object> out) throws Exception
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, MessageBuf<Object> out) throws Exception
|
||||||
@ -34,7 +36,7 @@ public class PacketDecoder extends ReplayingDecoder<Void>
|
|||||||
// Store our start index
|
// Store our start index
|
||||||
int startIndex = in.readerIndex();
|
int startIndex = in.readerIndex();
|
||||||
// Run packet through framer
|
// Run packet through framer
|
||||||
PacketReader.readPacket( in, protocol );
|
DefinedPacket packet = protocol.read( in.readUnsignedByte(), in );
|
||||||
// If we got this far, it means we have formed a packet, so lets grab the end index
|
// If we got this far, it means we have formed a packet, so lets grab the end index
|
||||||
int endIndex = in.readerIndex();
|
int endIndex = in.readerIndex();
|
||||||
// Allocate a buffer big enough for all bytes we have read
|
// Allocate a buffer big enough for all bytes we have read
|
||||||
@ -47,8 +49,15 @@ public class PacketDecoder extends ReplayingDecoder<Void>
|
|||||||
in.readerIndex( endIndex );
|
in.readerIndex( endIndex );
|
||||||
// Checkpoint our state incase we don't have enough data for another packet
|
// Checkpoint our state incase we don't have enough data for another packet
|
||||||
checkpoint();
|
checkpoint();
|
||||||
|
|
||||||
// Store our decoded message
|
// Store our decoded message
|
||||||
|
if ( packet != null )
|
||||||
|
{
|
||||||
|
out.add( new PacketWrapper( packet, buf ) );
|
||||||
|
} else
|
||||||
|
{
|
||||||
out.add( buf );
|
out.add( buf );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
24
proxy/src/main/java/net/md_5/bungee/netty/PacketHandler.java
Normal file
24
proxy/src/main/java/net/md_5/bungee/netty/PacketHandler.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package net.md_5.bungee.netty;
|
||||||
|
|
||||||
|
public abstract class PacketHandler extends net.md_5.bungee.protocol.packet.AbstractPacketHandler
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract String toString();
|
||||||
|
|
||||||
|
public void exception(Throwable t) throws Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handle(byte[] buf) throws Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void connected(ChannelWrapper channel) throws Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disconnected(ChannelWrapper channel) throws Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
16
proxy/src/main/java/net/md_5/bungee/netty/PacketWrapper.java
Normal file
16
proxy/src/main/java/net/md_5/bungee/netty/PacketWrapper.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package net.md_5.bungee.netty;
|
||||||
|
|
||||||
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
|
|
||||||
|
public class PacketWrapper
|
||||||
|
{
|
||||||
|
|
||||||
|
DefinedPacket packet;
|
||||||
|
byte[] buf;
|
||||||
|
|
||||||
|
public PacketWrapper(DefinedPacket packet, byte[] buf)
|
||||||
|
{
|
||||||
|
this.packet = packet;
|
||||||
|
this.buf = buf;
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,7 @@ import net.md_5.bungee.UserConnection;
|
|||||||
import net.md_5.bungee.connection.InitialHandler;
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ListenerInfo;
|
import net.md_5.bungee.api.config.ListenerInfo;
|
||||||
import net.md_5.bungee.protocol.PacketDefinitions;
|
import net.md_5.bungee.protocol.Vanilla;
|
||||||
|
|
||||||
public class PipelineUtils
|
public class PipelineUtils
|
||||||
{
|
{
|
||||||
@ -61,7 +61,7 @@ public class PipelineUtils
|
|||||||
|
|
||||||
ch.pipeline().addLast( "outbound", new OutboundHandler() );
|
ch.pipeline().addLast( "outbound", new OutboundHandler() );
|
||||||
ch.pipeline().addLast( "timer", new ReadTimeoutHandler( BungeeCord.getInstance().config.getTimeout(), TimeUnit.MILLISECONDS ) );
|
ch.pipeline().addLast( "timer", new ReadTimeoutHandler( BungeeCord.getInstance().config.getTimeout(), TimeUnit.MILLISECONDS ) );
|
||||||
ch.pipeline().addLast( "decoder", new PacketDecoder( PacketDefinitions.VANILLA_PROTOCOL ) );
|
ch.pipeline().addLast( "decoder", new PacketDecoder( Vanilla.getInstance() ) );
|
||||||
ch.pipeline().addLast( "packet-encoder", packetEncoder );
|
ch.pipeline().addLast( "packet-encoder", packetEncoder );
|
||||||
ch.pipeline().addLast( "array-encoder", arrayEncoder );
|
ch.pipeline().addLast( "array-encoder", arrayEncoder );
|
||||||
ch.pipeline().addLast( "handler", new HandlerBoss() );
|
ch.pipeline().addLast( "handler", new HandlerBoss() );
|
||||||
|
@ -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 );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@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 );
|
|
||||||
writeUTF( username );
|
|
||||||
writeUTF( 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 );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class Packet3Chat extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
public String message;
|
|
||||||
|
|
||||||
public Packet3Chat(String message)
|
|
||||||
{
|
|
||||||
super( 0x03 );
|
|
||||||
writeUTF( message );
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
Packet3Chat(byte[] buf)
|
|
||||||
{
|
|
||||||
super( 0x03, buf );
|
|
||||||
this.message = readUTF();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@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 );
|
|
||||||
writeUTF( 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 );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@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 );
|
|
||||||
writeUTF( username );
|
|
||||||
writeBoolean( online );
|
|
||||||
writeShort( ping );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@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 );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@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 );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@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 );
|
|
||||||
writeUTF( name );
|
|
||||||
writeUTF( 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 );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@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 );
|
|
||||||
writeUTF( itemName );
|
|
||||||
writeByte( action );
|
|
||||||
if ( action == 0 )
|
|
||||||
{
|
|
||||||
writeUTF( 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 );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@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 );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@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.writeUTF( name );
|
|
||||||
packet.writeByte( 1 );
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class PacketFAPluginMessage extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
public String tag;
|
|
||||||
public byte[] data;
|
|
||||||
|
|
||||||
public PacketFAPluginMessage(String tag, byte[] data)
|
|
||||||
{
|
|
||||||
super( 0xFA );
|
|
||||||
writeUTF( 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 );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@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 );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@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 );
|
|
||||||
writeUTF( 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 );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@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 );
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package net.md_5.bungee.packet;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class PacketFFKick extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
public String message;
|
|
||||||
|
|
||||||
public PacketFFKick(String message)
|
|
||||||
{
|
|
||||||
super( 0xFF );
|
|
||||||
writeUTF( message );
|
|
||||||
}
|
|
||||||
|
|
||||||
PacketFFKick(byte[] buf)
|
|
||||||
{
|
|
||||||
super( 0xFF, buf );
|
|
||||||
this.message = readUTF();
|
|
||||||
}
|
|
||||||
|
|
||||||
@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
|
||||||
{
|
{
|
||||||
@ -20,9 +20,9 @@ public class Global implements TabListHandler
|
|||||||
UserConnection con = (UserConnection) player;
|
UserConnection con = (UserConnection) player;
|
||||||
for ( ProxiedPlayer p : ProxyServer.getInstance().getPlayers() )
|
for ( ProxiedPlayer p : ProxyServer.getInstance().getPlayers() )
|
||||||
{
|
{
|
||||||
con.sendPacket( new PacketC9PlayerListItem( p.getDisplayName(), true, p.getPing() ) );
|
con.sendPacket( new PacketC9PlayerListItem( p.getDisplayName(), true, (short) p.getPing() ) );
|
||||||
}
|
}
|
||||||
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), true, player.getPing() ) );
|
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), true, (short) player.getPing() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -30,7 +30,7 @@ public class Global implements TabListHandler
|
|||||||
{
|
{
|
||||||
if ( !sentPings.contains( player ) )
|
if ( !sentPings.contains( player ) )
|
||||||
{
|
{
|
||||||
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), true, player.getPing() ) );
|
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), true, (short) player.getPing() ) );
|
||||||
sentPings.add( player );
|
sentPings.add( player );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ public class Global implements TabListHandler
|
|||||||
@Override
|
@Override
|
||||||
public void onDisconnect(ProxiedPlayer player)
|
public void onDisconnect(ProxiedPlayer player)
|
||||||
{
|
{
|
||||||
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), false, 9999 ) );
|
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), false, (short) 9999 ) );
|
||||||
sentPings.remove( player );
|
sentPings.remove( player );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
@ -25,7 +25,7 @@ public class GlobalPing extends Global
|
|||||||
int lastPing = lastPings.get( player );
|
int lastPing = lastPings.get( player );
|
||||||
if ( ping - PING_THRESHOLD > lastPing && ping + PING_THRESHOLD < lastPing )
|
if ( ping - PING_THRESHOLD > lastPing && ping + PING_THRESHOLD < lastPing )
|
||||||
{
|
{
|
||||||
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), true, ping ) );
|
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), true, (short) ping ) );
|
||||||
lastPings.put( player, ping );
|
lastPings.put( player, ping );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
@ -38,7 +38,7 @@ public class ServerUnique implements TabListHandler
|
|||||||
{
|
{
|
||||||
for ( String username : usernames )
|
for ( String username : usernames )
|
||||||
{
|
{
|
||||||
( (UserConnection) player ).sendPacket( new PacketC9PlayerListItem( username, false, 9999 ) );
|
( (UserConnection) player ).sendPacket( new PacketC9PlayerListItem( username, false, (short) 9999 ) );
|
||||||
}
|
}
|
||||||
usernames.clear();
|
usernames.clear();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user