Update protocol - major overhaul

This commit is contained in:
md_5 2013-10-11 19:26:40 +11:00
parent 4257b81d8c
commit 7be929bb08
39 changed files with 285 additions and 278 deletions

View File

@ -1,95 +1,96 @@
package net.md_5.bungee.protocol; package net.md_5.bungee.protocol;
import net.md_5.bungee.protocol.handshake.Packet0Handshake; import net.md_5.bungee.protocol.packet.KeepAlive;
import net.md_5.bungee.protocol.login.Packet0Kick; import net.md_5.bungee.protocol.packet.ClientSettings;
import net.md_5.bungee.protocol.login.Packet1EncryptionResponse; import net.md_5.bungee.protocol.packet.ClientStatus;
import net.md_5.bungee.protocol.login.Packet2LoginSuccess; import net.md_5.bungee.protocol.packet.Login;
import net.md_5.bungee.protocol.packet.Chat;
import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.TabComplete;
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
import net.md_5.bungee.protocol.packet.ScoreboardScore;
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
import net.md_5.bungee.protocol.packet.Team;
import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.packet.Kick;
import net.md_5.bungee.protocol.packet.Respawn;
import net.md_5.bungee.protocol.packet.Handshake;
import net.md_5.bungee.protocol.packet.EncryptionResponse;
import net.md_5.bungee.protocol.packet.LoginRequest;
import net.md_5.bungee.protocol.packet.LoginSuccess;
public abstract class AbstractPacketHandler public abstract class AbstractPacketHandler
{ {
/*========================================================================*/ public void handle(Handshake handshake) throws Exception
// Handshake Start
public void handle(Packet0Handshake handshake) throws Exception
{
}
// Handshake End
/*========================================================================*/
// Game Start
public void handle(Packet0Handshake handshake) throws Exception
{ {
} }
public void handle(Packet0Handshake handshake) throws Exception public void handle(KeepAlive keepAlive) throws Exception
{ {
} }
public void handle(Packet0Handshake handshake) throws Exception public void handle(Login login) throws Exception
{ {
} }
public void handle(Packet0Handshake handshake) throws Exception public void handle(Chat chat) throws Exception
{ {
} }
public void handle(Packet0Handshake handshake) throws Exception public void handle(Respawn respawn) throws Exception
{ {
} }
public void handle(Packet0Handshake handshake) throws Exception public void handle(LoginRequest loginRequest) throws Exception
{ {
} }
public void handle(Packet0Handshake handshake) throws Exception public void handle(ClientSettings settings) throws Exception
{ {
} }
public void handle(Packet0Handshake handshake) throws Exception public void handle(ClientStatus clientStatus) throws Exception
{ {
} }
public void handle(Packet0Handshake handshake) throws Exception public void handle(PlayerListItem playerListItem) throws Exception
{ {
} }
public void handle(Packet0Handshake handshake) throws Exception public void handle(TabComplete tabComplete) throws Exception
{ {
} }
public void handle(Packet0Handshake handshake) throws Exception public void handle(ScoreboardObjective scoreboardObjective) throws Exception
{ {
} }
public void handle(Packet0Handshake handshake) throws Exception public void handle(ScoreboardScore scoreboardScore) throws Exception
{ {
} }
public void handle(Packet0Handshake handshake) throws Exception public void handle(ScoreboardDisplay displayScoreboard) throws Exception
{ {
} }
public void handle(Packet0Handshake handshake) throws Exception public void handle(Team team) throws Exception
{
}
// Game End
/*========================================================================*/
// Ping Start
// Ping End
/*========================================================================*/
// Login Start
public void handle(Packet0Kick kick) throws Exception
{ {
} }
public void handle(Packet1EncryptionResponse encryptionResponse) throws Exception public void handle(PluginMessage pluginMessage) throws Exception
{ {
} }
public void handle(Packet2LoginSuccess loginSuccess) throws Exception public void handle(Kick kick) throws Exception
{
}
public void handle(EncryptionResponse encryptionResponse) throws Exception
{
}
public void handle(LoginSuccess loginSuccess) throws Exception
{ {
} }
// Login End
/*========================================================================*/
} }

View File

@ -3,34 +3,104 @@ package net.md_5.bungee.protocol;
import gnu.trove.map.TObjectIntMap; import gnu.trove.map.TObjectIntMap;
import gnu.trove.map.hash.TObjectIntHashMap; import gnu.trove.map.hash.TObjectIntHashMap;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import net.md_5.bungee.protocol.handshake.HandshakeProtocol; import net.md_5.bungee.protocol.packet.Chat;
import net.md_5.bungee.protocol.packet.ClientSettings;
import net.md_5.bungee.protocol.packet.EncryptionResponse;
import net.md_5.bungee.protocol.packet.Handshake;
import net.md_5.bungee.protocol.packet.KeepAlive;
import net.md_5.bungee.protocol.packet.Kick;
import net.md_5.bungee.protocol.packet.Login;
import net.md_5.bungee.protocol.packet.LoginRequest;
import net.md_5.bungee.protocol.packet.LoginSuccess;
import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.packet.Respawn;
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
import net.md_5.bungee.protocol.packet.ScoreboardScore;
import net.md_5.bungee.protocol.packet.TabComplete;
import net.md_5.bungee.protocol.packet.Team;
public class Protocol public enum Protocol
{ {
private static final int MAX_PACKET_ID = 0xFF; // Undef
private static final int MAX_PROTOCOLS = 0xF; SERVER_HANDSHAKE
{
{
registerPacket( 0x00, Handshake.class );
}
},
// 0
CLIENT_GAME
{
{
registerPacket( 0x00, KeepAlive.class );
registerPacket( 0x01, Login.class );
registerPacket( 0x02, Chat.class );
registerPacket( 0x07, Respawn.class );
registerPacket( 0x3B, PlayerListItem.class );
registerPacket( 0x3D, TabComplete.class );
registerPacket( 0x3E, ScoreboardObjective.class );
registerPacket( 0x3F, ScoreboardScore.class );
registerPacket( 0x40, ScoreboardDisplay.class );
registerPacket( 0x41, Team.class );
registerPacket( 0x42, PluginMessage.class );
registerPacket( 0x43, Kick.class );
}
},
// 0
SERVER_GAME
{
{
registerPacket( 0x00, KeepAlive.class );
registerPacket( 0x14, TabComplete.class );
registerPacket( 0x15, ClientSettings.class );
registerPacket( 0x17, PluginMessage.class );
}
},
// 1
CLIENT_STATUS
{
{
}
},
// 1
SERVER_STATUS
{
{
}
},
// 2
CLIENT_LOGIN
{
{
registerPacket( 0x00, Kick.class );
registerPacket( 0x01, EncryptionResponse.class );
registerPacket( 0x02, LoginSuccess.class );
}
},
// 2
SERVER_LOGIN
{
{
registerPacket( 0x00, LoginRequest.class );
}
};
/*========================================================================*/ /*========================================================================*/
private static final Protocol[] protocols = new Protocol[ MAX_PROTOCOLS ]; public static final int MAX_PACKET_ID = 0xFF;
/*========================================================================*/ /*========================================================================*/
private final TObjectIntMap<Class<? extends DefinedPacket>> packetMap = new TObjectIntHashMap<>( MAX_PACKET_ID ); private final TObjectIntMap<Class<? extends DefinedPacket>> packetMap = new TObjectIntHashMap<>( MAX_PACKET_ID );
private final Class<? extends DefinedPacket>[] packetClasses = new Class[ MAX_PACKET_ID ]; private final Class<? extends DefinedPacket>[] packetClasses = new Class[ MAX_PACKET_ID ];
private final Constructor<? extends DefinedPacket>[] packetConstructors = new Constructor[ MAX_PACKET_ID ]; private final Constructor<? extends DefinedPacket>[] packetConstructors = new Constructor[ MAX_PACKET_ID ];
static
{
}
public Protocol(int protocolId)
{
}
public static Protocol getProtocol(int id)
{
return protocols[id];
}
public final DefinedPacket createPacket(int id) public final DefinedPacket createPacket(int id)
{ {
if ( id > MAX_PACKET_ID ) if ( id > MAX_PACKET_ID )

View File

@ -1,16 +0,0 @@
package net.md_5.bungee.protocol.game;
import lombok.Getter;
import net.md_5.bungee.protocol.Protocol;
public class GameProtocol extends Protocol
{
@Getter
private static final GameProtocol instance = new GameProtocol();
private GameProtocol()
{
super( 0 );
}
}

View File

@ -1,17 +0,0 @@
package net.md_5.bungee.protocol.handshake;
import lombok.Getter;
import net.md_5.bungee.protocol.Protocol;
public class HandshakeProtocol extends Protocol
{
@Getter
private static final HandshakeProtocol instance = new HandshakeProtocol();
private HandshakeProtocol()
{
super( 0xF );
registerPacket( 0, Packet0Handshake.class );
}
}

View File

@ -1,17 +0,0 @@
package net.md_5.bungee.protocol.login;
import net.md_5.bungee.protocol.ping.*;
import lombok.Getter;
import net.md_5.bungee.protocol.Protocol;
public class LoginProtocol extends Protocol
{
@Getter
private static final LoginProtocol instance = new LoginProtocol();
private LoginProtocol()
{
super( 2 );
}
}

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.game; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -12,7 +12,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet2Chat extends DefinedPacket public class Chat extends DefinedPacket
{ {
private String message; private String message;

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.game; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -12,7 +12,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet15Settings extends DefinedPacket public class ClientSettings extends DefinedPacket
{ {
private String locale; private String locale;

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.game; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -12,7 +12,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet16ClientStatus extends DefinedPacket public class ClientStatus extends DefinedPacket
{ {
private byte payload; private byte payload;

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.login; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -12,7 +12,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet1EncryptionResponse extends DefinedPacket public class EncryptionResponse extends DefinedPacket
{ {
private byte[] sharedSecret; private byte[] sharedSecret;

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.handshake; package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -12,7 +12,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet0Handshake extends DefinedPacket public class Handshake extends DefinedPacket
{ {
private int protocolVersion; private int protocolVersion;

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.game; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -12,7 +12,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet0KeepAlive extends DefinedPacket public class KeepAlive extends DefinedPacket
{ {
private int randomId; private int randomId;

View File

@ -1,18 +1,18 @@
package net.md_5.bungee.protocol.login; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.AbstractPacketHandler; import net.md_5.bungee.protocol.AbstractPacketHandler;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet0Kick extends DefinedPacket public class Kick extends DefinedPacket
{ {
private String message; private String message;

View File

@ -1,20 +1,18 @@
package net.md_5.bungee.protocol.game; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.ToString;
import net.md_5.bungee.protocol.AbstractPacketHandler; import net.md_5.bungee.protocol.AbstractPacketHandler;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet1Login extends DefinedPacket public class Login extends DefinedPacket
{ {
private int entityId; private int entityId;

View File

@ -1,32 +1,36 @@
package net.md_5.bungee.protocol.game; /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import net.md_5.bungee.protocol.AbstractPacketHandler; import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.DefinedPacket;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet43Kick extends DefinedPacket public class LoginRequest extends DefinedPacket
{ {
private String message; private String data;
@Override @Override
public void read(ByteBuf buf) public void read(ByteBuf buf)
{ {
message = readString( buf ); data = readString( buf );
} }
@Override @Override
public void write(ByteBuf buf) public void write(ByteBuf buf)
{ {
writeString( message, buf ); writeString( data, buf );
} }
@Override @Override

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.login; package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -12,7 +12,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet2LoginSuccess extends DefinedPacket public class LoginSuccess extends DefinedPacket
{ {
private String data; private String data;

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.game; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -12,7 +12,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet3BPlayerListItem extends DefinedPacket public class PlayerListItem extends DefinedPacket
{ {
private String username; private String username;

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.game; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -17,7 +17,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet42PluginMessage extends DefinedPacket public class PluginMessage extends DefinedPacket
{ {
private String tag; private String tag;

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.game; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -13,7 +13,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet7Respawn extends DefinedPacket public class Respawn extends DefinedPacket
{ {
private int dimension; private int dimension;

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.game; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -12,7 +12,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet40DisplayScoreboard extends DefinedPacket public class ScoreboardDisplay extends DefinedPacket
{ {
/** /**

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.game; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -12,7 +12,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet3EScoreboardObjective extends DefinedPacket public class ScoreboardObjective extends DefinedPacket
{ {
private String name; private String name;

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.game; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -14,7 +14,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet3FScoreboardScore extends DefinedPacket public class ScoreboardScore extends DefinedPacket
{ {
private String itemName; private String itemName;

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.game; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -12,13 +12,13 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet3DTabComplete extends DefinedPacket public class TabComplete extends DefinedPacket
{ {
private String cursor; private String cursor;
private String[] commands; private String[] commands;
public Packet3DTabComplete(String[] alternatives) public TabComplete(String[] alternatives)
{ {
commands = alternatives; commands = alternatives;
} }

View File

@ -1,4 +1,4 @@
package net.md_5.bungee.protocol.game; package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -12,7 +12,7 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class Packet41Team extends DefinedPacket public class Team extends DefinedPacket
{ {
private String name; private String name;
@ -32,7 +32,7 @@ public class Packet41Team extends DefinedPacket
* *
* @param name * @param name
*/ */
public Packet41Team(String name) public Team(String name)
{ {
this(); this();
this.name = name; this.name = name;

View File

@ -1,16 +0,0 @@
package net.md_5.bungee.protocol.ping;
import lombok.Getter;
import net.md_5.bungee.protocol.Protocol;
public class PingProtocol extends Protocol
{
@Getter
private static final PingProtocol instance = new PingProtocol();
private PingProtocol()
{
super( 1 );
}
}

View File

@ -58,8 +58,8 @@ import net.md_5.bungee.config.YamlConfig;
import net.md_5.bungee.log.LoggingOutputStream; import net.md_5.bungee.log.LoggingOutputStream;
import net.md_5.bungee.netty.PipelineUtils; import net.md_5.bungee.netty.PipelineUtils;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.game.Packet2Chat; import net.md_5.bungee.protocol.packet.Chat;
import net.md_5.bungee.protocol.game.Packet42PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.Vanilla; import net.md_5.bungee.protocol.Vanilla;
import net.md_5.bungee.query.RemoteQuery; import net.md_5.bungee.query.RemoteQuery;
import net.md_5.bungee.tab.Custom; import net.md_5.bungee.tab.Custom;
@ -447,9 +447,9 @@ public class BungeeCord extends ProxyServer
return Collections.unmodifiableCollection( pluginChannels ); return Collections.unmodifiableCollection( pluginChannels );
} }
public Packet42PluginMessage registerChannels() public PluginMessage registerChannels()
{ {
return new Packet42PluginMessage( "REGISTER", Util.format( pluginChannels, "\00" ).getBytes() ); return new PluginMessage( "REGISTER", Util.format( pluginChannels, "\00" ).getBytes() );
} }
@Override @Override
@ -482,7 +482,7 @@ public class BungeeCord extends ProxyServer
getConsole().sendMessage( message ); getConsole().sendMessage( message );
// TODO: Here too // TODO: Here too
String encoded = BungeeCord.getInstance().gson.toJson( message ); String encoded = BungeeCord.getInstance().gson.toJson( message );
broadcast( new Packet2Chat( "{\"text\":" + encoded + "}" ) ); broadcast( new Chat( "{\"text\":" + encoded + "}" ) );
} }
public void addConnection(UserConnection con) public void addConnection(UserConnection con)

View File

@ -26,7 +26,7 @@ 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.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.game.Packet42PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
@RequiredArgsConstructor @RequiredArgsConstructor
public class BungeeServerInfo implements ServerInfo public class BungeeServerInfo implements ServerInfo
@ -97,7 +97,7 @@ public class BungeeServerInfo implements ServerInfo
server.sendData( channel, data ); server.sendData( channel, data );
} else } else
{ {
packetQueue.add( new Packet42PluginMessage( channel, data ) ); packetQueue.add( new PluginMessage( channel, data ) );
} }
} }
} }

View File

@ -15,7 +15,7 @@ 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.protocol.login.Packet1EncryptionResponse; import net.md_5.bungee.protocol.packet.EncryptionResponse;
import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest; import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest;
/** /**
@ -49,7 +49,7 @@ public class EncryptionUtil
return new PacketFDEncryptionRequest( hash, pubKey, verify ); return new PacketFDEncryptionRequest( hash, pubKey, verify );
} }
public static SecretKey getSecret(Packet1EncryptionResponse resp, PacketFDEncryptionRequest request) throws GeneralSecurityException public static SecretKey getSecret(EncryptionResponse resp, PacketFDEncryptionRequest request) throws GeneralSecurityException
{ {
Cipher cipher = Cipher.getInstance( "RSA" ); Cipher cipher = Cipher.getInstance( "RSA" );
cipher.init( Cipher.DECRYPT_MODE, keys.getPrivate() ); cipher.init( Cipher.DECRYPT_MODE, keys.getPrivate() );

View File

@ -1,18 +1,18 @@
package net.md_5.bungee; package net.md_5.bungee;
import net.md_5.bungee.protocol.game.Packet7Respawn; import net.md_5.bungee.protocol.packet.Respawn;
import net.md_5.bungee.protocol.game.Packet16ClientStatus; import net.md_5.bungee.protocol.packet.ClientStatus;
import net.md_5.bungee.protocol.game.Packet42PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
public class PacketConstants public class PacketConstants
{ {
public static final Packet7Respawn DIM1_SWITCH = new Packet7Respawn( (byte) 1, (byte) 0, (byte) 0, (short) 256, "DEFAULT" ); public static final Respawn DIM1_SWITCH = new Respawn( (byte) 1, (byte) 0, (byte) 0, (short) 256, "DEFAULT" );
public static final Packet7Respawn DIM2_SWITCH = new Packet7Respawn( (byte) -1, (byte) 0, (byte) 0, (short) 256, "DEFAULT" ); public static final Respawn DIM2_SWITCH = new Respawn( (byte) -1, (byte) 0, (byte) 0, (short) 256, "DEFAULT" );
public static final Packet16ClientStatus CLIENT_LOGIN = new Packet16ClientStatus( (byte) 0 ); public static final ClientStatus CLIENT_LOGIN = new ClientStatus( (byte) 0 );
public static final Packet42PluginMessage FORGE_MOD_REQUEST = new Packet42PluginMessage( "FML", new byte[] public static final PluginMessage FORGE_MOD_REQUEST = new PluginMessage( "FML", new byte[]
{ {
0, 0, 0, 0, 0, 2 0, 0, 0, 0, 0, 2
} ); } );
public static final Packet42PluginMessage I_AM_BUNGEE = new Packet42PluginMessage( "BungeeCord", new byte[ 0 ] ); public static final PluginMessage I_AM_BUNGEE = new PluginMessage( "BungeeCord", new byte[ 0 ] );
} }

View File

@ -8,8 +8,8 @@ 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.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.game.Packet42PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.game.Packet43Kick; import net.md_5.bungee.protocol.packet.Kick;
@RequiredArgsConstructor @RequiredArgsConstructor
public class ServerConnection implements Server public class ServerConnection implements Server
@ -34,7 +34,7 @@ public class ServerConnection implements Server
@Override @Override
public void sendData(String channel, byte[] data) public void sendData(String channel, byte[] data)
{ {
unsafe().sendPacket( new Packet42PluginMessage( channel, data ) ); unsafe().sendPacket( new PluginMessage( channel, data ) );
} }
@Override @Override
@ -43,7 +43,7 @@ public class ServerConnection implements Server
if ( !ch.isClosed() ) if ( !ch.isClosed() )
{ {
// TODO: Can we just use a future here? // TODO: Can we just use a future here?
unsafe().sendPacket( new Packet43Kick( reason ) ); unsafe().sendPacket( new Kick( reason ) );
ch.getHandle().eventLoop().schedule( new Runnable() ch.getHandle().eventLoop().schedule( new Runnable()
{ {
@Override @Override

View File

@ -31,14 +31,14 @@ import net.md_5.bungee.netty.PipelineUtils;
import net.md_5.bungee.protocol.Forge; import net.md_5.bungee.protocol.Forge;
import net.md_5.bungee.protocol.MinecraftOutput; import net.md_5.bungee.protocol.MinecraftOutput;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.game.Packet1Login; import net.md_5.bungee.protocol.packet.Login;
import net.md_5.bungee.protocol.game.Packet7Respawn; import net.md_5.bungee.protocol.packet.Respawn;
import net.md_5.bungee.protocol.game.Packet3EScoreboardObjective; import net.md_5.bungee.protocol.packet.ScoreboardObjective;
import net.md_5.bungee.protocol.game.Packet41Team; import net.md_5.bungee.protocol.packet.Team;
import net.md_5.bungee.protocol.game.Packet42PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.login.Packet1EncryptionResponse; import net.md_5.bungee.protocol.packet.EncryptionResponse;
import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest; import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest;
import net.md_5.bungee.protocol.game.Packet43Kick; import net.md_5.bungee.protocol.packet.Kick;
import net.md_5.bungee.protocol.packet.forge.Forge1Login; import net.md_5.bungee.protocol.packet.forge.Forge1Login;
@RequiredArgsConstructor @RequiredArgsConstructor
@ -81,7 +81,7 @@ public class ServerConnector extends PacketHandler
out.writeUTF( "Login" ); out.writeUTF( "Login" );
out.writeUTF( user.getAddress().getHostString() ); out.writeUTF( user.getAddress().getHostString() );
out.writeInt( user.getAddress().getPort() ); out.writeInt( user.getAddress().getPort() );
channel.write( new Packet42PluginMessage( "BungeeCord", out.toByteArray() ) ); channel.write( new PluginMessage( "BungeeCord", out.toByteArray() ) );
channel.write( user.getPendingConnection().getHandshake() ); channel.write( user.getPendingConnection().getHandshake() );
@ -99,7 +99,7 @@ public class ServerConnector extends PacketHandler
} }
@Override @Override
public void handle(Packet1Login login) throws Exception public void handle(Login login) throws Exception
{ {
Preconditions.checkState( thisState == State.LOGIN, "Not exepcting LOGIN" ); Preconditions.checkState( thisState == State.LOGIN, "Not exepcting LOGIN" );
@ -117,13 +117,13 @@ public class ServerConnector extends PacketHandler
} }
} }
for ( Packet42PluginMessage message : user.getPendingConnection().getRegisterMessages() ) for ( PluginMessage message : user.getPendingConnection().getRegisterMessages() )
{ {
ch.write( message ); ch.write( message );
} }
if ( !sentMessages ) if ( !sentMessages )
{ {
for ( Packet42PluginMessage message : user.getPendingConnection().getLoginMessages() ) for ( PluginMessage message : user.getPendingConnection().getLoginMessages() )
{ {
ch.write( message ); ch.write( message );
} }
@ -143,21 +143,21 @@ public class ServerConnector extends PacketHandler
user.setServerEntityId( login.getEntityId() ); user.setServerEntityId( login.getEntityId() );
// Set tab list size, this sucks balls, TODO: what shall we do about packet mutability // Set tab list size, this sucks balls, TODO: what shall we do about packet mutability
Packet1Login modLogin; Login modLogin;
if ( ch.getHandle().pipeline().get( PacketDecoder.class ).getProtocol() == Forge.getInstance() ) if ( ch.getHandle().pipeline().get( PacketDecoder.class ).getProtocol() == Forge.getInstance() )
{ {
modLogin = new Forge1Login( login.getEntityId(), login.getLevelType(), login.getGameMode(), login.getDimension(), login.getDifficulty(), login.getUnused(), modLogin = new Forge1Login( login.getEntityId(), login.getLevelType(), login.getGameMode(), login.getDimension(), login.getDifficulty(), login.getUnused(),
(byte) user.getPendingConnection().getListener().getTabListSize() ); (byte) user.getPendingConnection().getListener().getTabListSize() );
} else } else
{ {
modLogin = new Packet1Login( login.getEntityId(), login.getLevelType(), login.getGameMode(), (byte) login.getDimension(), login.getDifficulty(), login.getUnused(), modLogin = new Login( login.getEntityId(), login.getLevelType(), login.getGameMode(), (byte) login.getDimension(), login.getDifficulty(), login.getUnused(),
(byte) user.getPendingConnection().getListener().getTabListSize() ); (byte) user.getPendingConnection().getListener().getTabListSize() );
} }
user.unsafe().sendPacket( modLogin ); user.unsafe().sendPacket( modLogin );
MinecraftOutput out = new MinecraftOutput(); MinecraftOutput out = new MinecraftOutput();
out.writeStringUTF8WithoutLengthHeaderBecauseDinnerboneStuffedUpTheMCBrandPacket( ProxyServer.getInstance().getName() + " (" + ProxyServer.getInstance().getVersion() + ")" ); out.writeStringUTF8WithoutLengthHeaderBecauseDinnerboneStuffedUpTheMCBrandPacket( ProxyServer.getInstance().getName() + " (" + ProxyServer.getInstance().getVersion() + ")" );
user.unsafe().sendPacket( new Packet42PluginMessage( "MC|Brand", out.toArray() ) ); user.unsafe().sendPacket( new PluginMessage( "MC|Brand", out.toArray() ) );
} else } else
{ {
user.getTabList().onServerChange(); user.getTabList().onServerChange();
@ -165,18 +165,18 @@ public class ServerConnector extends PacketHandler
Scoreboard serverScoreboard = user.getServerSentScoreboard(); Scoreboard serverScoreboard = user.getServerSentScoreboard();
for ( Objective objective : serverScoreboard.getObjectives() ) for ( Objective objective : serverScoreboard.getObjectives() )
{ {
user.unsafe().sendPacket( new Packet3EScoreboardObjective( objective.getName(), objective.getValue(), (byte) 1 ) ); user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), (byte) 1 ) );
} }
for ( Team team : serverScoreboard.getTeams() ) for ( Team team : serverScoreboard.getTeams() )
{ {
user.unsafe().sendPacket( new Packet41Team( team.getName() ) ); user.unsafe().sendPacket( new Team( team.getName() ) );
} }
serverScoreboard.clear(); serverScoreboard.clear();
user.sendDimensionSwitch(); user.sendDimensionSwitch();
user.setServerEntityId( login.getEntityId() ); user.setServerEntityId( login.getEntityId() );
user.unsafe().sendPacket( new Packet7Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), (short) 256, login.getLevelType() ) ); user.unsafe().sendPacket( new Respawn( 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 );
@ -222,7 +222,7 @@ public class ServerConnector extends PacketHandler
byte[] shared = EncryptionUtil.encrypt( publickey, secretkey.getEncoded() ); byte[] shared = EncryptionUtil.encrypt( publickey, secretkey.getEncoded() );
byte[] token = EncryptionUtil.encrypt( publickey, encryptRequest.getVerifyToken() ); byte[] token = EncryptionUtil.encrypt( publickey, encryptRequest.getVerifyToken() );
ch.write( new Packet1EncryptionResponse( shared, token ) ); ch.write( new EncryptionResponse( shared, token ) );
Cipher encrypt = EncryptionUtil.getCipher( Cipher.ENCRYPT_MODE, secretkey ); Cipher encrypt = EncryptionUtil.getCipher( Cipher.ENCRYPT_MODE, secretkey );
ch.addBefore( PipelineUtils.PACKET_DECODE_HANDLER, PipelineUtils.ENCRYPT_HANDLER, new CipherEncoder( encrypt ) ); ch.addBefore( PipelineUtils.PACKET_DECODE_HANDLER, PipelineUtils.ENCRYPT_HANDLER, new CipherEncoder( encrypt ) );
@ -235,7 +235,7 @@ public class ServerConnector extends PacketHandler
} }
@Override @Override
public void handle(Packet1EncryptionResponse encryptResponse) throws Exception public void handle(EncryptionResponse encryptResponse) throws Exception
{ {
Preconditions.checkState( thisState == State.ENCRYPT_RESPONSE, "Not expecting ENCRYPT_RESPONSE" ); Preconditions.checkState( thisState == State.ENCRYPT_RESPONSE, "Not expecting ENCRYPT_RESPONSE" );
@ -249,7 +249,7 @@ public class ServerConnector extends PacketHandler
} }
@Override @Override
public void handle(Packet43Kick kick) throws Exception public void handle(Kick kick) throws Exception
{ {
ServerInfo def = bungee.getServerInfo( user.getPendingConnection().getListener().getFallbackServer() ); ServerInfo def = bungee.getServerInfo( user.getPendingConnection().getListener().getFallbackServer() );
if ( Objects.equals( target, def ) ) if ( Objects.equals( target, def ) )
@ -274,7 +274,7 @@ public class ServerConnector extends PacketHandler
} }
@Override @Override
public void handle(Packet42PluginMessage pluginMessage) throws Exception public void handle(PluginMessage pluginMessage) throws Exception
{ {
if ( pluginMessage.equals( PacketConstants.I_AM_BUNGEE ) ) if ( pluginMessage.equals( PacketConstants.I_AM_BUNGEE ) )
{ {
@ -299,7 +299,7 @@ public class ServerConnector extends PacketHandler
user.unsafe().sendPacket( pluginMessage ); // We have to forward these to the user, especially with Forge as stuff might break user.unsafe().sendPacket( pluginMessage ); // We have to forward these to the user, especially with Forge as stuff might break
if ( !sentMessages && user.getPendingConnection().getForgeLogin() != null ) if ( !sentMessages && user.getPendingConnection().getForgeLogin() != null )
{ {
for ( Packet42PluginMessage message : user.getPendingConnection().getLoginMessages() ) for ( PluginMessage message : user.getPendingConnection().getLoginMessages() )
{ {
ch.write( message ); ch.write( message );
} }

View File

@ -33,10 +33,10 @@ import net.md_5.bungee.netty.HandlerBoss;
import net.md_5.bungee.netty.PacketWrapper; import net.md_5.bungee.netty.PacketWrapper;
import net.md_5.bungee.netty.PipelineUtils; import net.md_5.bungee.netty.PipelineUtils;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.game.Packet2Chat; import net.md_5.bungee.protocol.packet.Chat;
import net.md_5.bungee.protocol.game.Packet15Settings; import net.md_5.bungee.protocol.packet.ClientSettings;
import net.md_5.bungee.protocol.game.Packet42PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.game.Packet43Kick; import net.md_5.bungee.protocol.packet.Kick;
import net.md_5.bungee.util.CaseInsensitiveSet; import net.md_5.bungee.util.CaseInsensitiveSet;
@RequiredArgsConstructor @RequiredArgsConstructor
@ -88,7 +88,7 @@ public final class UserConnection implements ProxiedPlayer
private int serverEntityId; private int serverEntityId;
@Getter @Getter
@Setter @Setter
private Packet15Settings settings; private ClientSettings settings;
@Getter @Getter
private final Scoreboard serverSentScoreboard = new Scoreboard(); private final Scoreboard serverSentScoreboard = new Scoreboard();
/*========================================================================*/ /*========================================================================*/
@ -251,7 +251,7 @@ public final class UserConnection implements ProxiedPlayer
if ( ch.getHandle().isActive() ) if ( ch.getHandle().isActive() )
{ {
bungee.getLogger().log( Level.INFO, "[" + getName() + "] disconnected with: " + reason ); bungee.getLogger().log( Level.INFO, "[" + getName() + "] disconnected with: " + reason );
unsafe().sendPacket( new Packet43Kick( reason ) ); unsafe().sendPacket( new Kick( reason ) );
ch.close(); ch.close();
if ( server != null ) if ( server != null )
{ {
@ -264,7 +264,7 @@ public final class UserConnection implements ProxiedPlayer
public void chat(String message) public void chat(String message)
{ {
Preconditions.checkState( server != null, "Not connected to server" ); Preconditions.checkState( server != null, "Not connected to server" );
server.getCh().write( new Packet2Chat( message ) ); server.getCh().write( new Chat( message ) );
} }
@Override @Override
@ -272,7 +272,7 @@ public final class UserConnection implements ProxiedPlayer
{ {
// TODO: Fix this // TODO: Fix this
String encoded = BungeeCord.getInstance().gson.toJson( message ); String encoded = BungeeCord.getInstance().gson.toJson( message );
unsafe().sendPacket( new Packet2Chat( "{\"text\":" + encoded + "}" ) ); unsafe().sendPacket( new Chat( "{\"text\":" + encoded + "}" ) );
} }
@Override @Override
@ -287,7 +287,7 @@ public final class UserConnection implements ProxiedPlayer
@Override @Override
public void sendData(String channel, byte[] data) public void sendData(String channel, byte[] data)
{ {
unsafe().sendPacket( new Packet42PluginMessage( channel, data ) ); unsafe().sendPacket( new PluginMessage( channel, data ) );
} }
@Override @Override

View File

@ -22,14 +22,14 @@ import net.md_5.bungee.api.score.Team;
import net.md_5.bungee.netty.ChannelWrapper; import net.md_5.bungee.netty.ChannelWrapper;
import net.md_5.bungee.netty.PacketHandler; import net.md_5.bungee.netty.PacketHandler;
import net.md_5.bungee.netty.PacketWrapper; import net.md_5.bungee.netty.PacketWrapper;
import net.md_5.bungee.protocol.game.Packet0KeepAlive; import net.md_5.bungee.protocol.packet.KeepAlive;
import net.md_5.bungee.protocol.game.Packet3BPlayerListItem; import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.game.Packet3EScoreboardObjective; import net.md_5.bungee.protocol.packet.ScoreboardObjective;
import net.md_5.bungee.protocol.game.Packet3FScoreboardScore; import net.md_5.bungee.protocol.packet.ScoreboardScore;
import net.md_5.bungee.protocol.game.Packet40DisplayScoreboard; import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
import net.md_5.bungee.protocol.game.Packet41Team; import net.md_5.bungee.protocol.packet.Team;
import net.md_5.bungee.protocol.game.Packet42PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.game.Packet43Kick; import net.md_5.bungee.protocol.packet.Kick;
@RequiredArgsConstructor @RequiredArgsConstructor
public class DownstreamBridge extends PacketHandler public class DownstreamBridge extends PacketHandler
@ -81,14 +81,14 @@ public class DownstreamBridge extends PacketHandler
} }
@Override @Override
public void handle(Packet0KeepAlive alive) throws Exception public void handle(KeepAlive alive) throws Exception
{ {
con.setSentPingId( alive.getRandomId() ); con.setSentPingId( alive.getRandomId() );
con.setSentPingTime( System.currentTimeMillis() ); con.setSentPingTime( System.currentTimeMillis() );
} }
@Override @Override
public void handle(Packet3BPlayerListItem playerList) throws Exception public void handle(PlayerListItem playerList) throws Exception
{ {
if ( !con.getTabList().onListUpdate( playerList.getUsername(), playerList.isOnline(), playerList.getPing() ) ) if ( !con.getTabList().onListUpdate( playerList.getUsername(), playerList.isOnline(), playerList.getPing() ) )
@ -98,7 +98,7 @@ public class DownstreamBridge extends PacketHandler
} }
@Override @Override
public void handle(Packet3EScoreboardObjective objective) throws Exception public void handle(ScoreboardObjective objective) throws Exception
{ {
Scoreboard serverScoreboard = con.getServerSentScoreboard(); Scoreboard serverScoreboard = con.getServerSentScoreboard();
switch ( objective.getAction() ) switch ( objective.getAction() )
@ -113,7 +113,7 @@ public class DownstreamBridge extends PacketHandler
} }
@Override @Override
public void handle(Packet3FScoreboardScore score) throws Exception public void handle(ScoreboardScore score) throws Exception
{ {
Scoreboard serverScoreboard = con.getServerSentScoreboard(); Scoreboard serverScoreboard = con.getServerSentScoreboard();
switch ( score.getAction() ) switch ( score.getAction() )
@ -130,7 +130,7 @@ public class DownstreamBridge extends PacketHandler
} }
@Override @Override
public void handle(Packet40DisplayScoreboard displayScoreboard) throws Exception public void handle(ScoreboardDisplay displayScoreboard) throws Exception
{ {
Scoreboard serverScoreboard = con.getServerSentScoreboard(); Scoreboard serverScoreboard = con.getServerSentScoreboard();
serverScoreboard.setName( displayScoreboard.getName() ); serverScoreboard.setName( displayScoreboard.getName() );
@ -138,7 +138,7 @@ public class DownstreamBridge extends PacketHandler
} }
@Override @Override
public void handle(Packet41Team team) throws Exception public void handle(Team team) throws Exception
{ {
Scoreboard serverScoreboard = con.getServerSentScoreboard(); Scoreboard serverScoreboard = con.getServerSentScoreboard();
// Remove team and move on // Remove team and move on
@ -185,7 +185,7 @@ public class DownstreamBridge extends PacketHandler
} }
@Override @Override
public void handle(Packet42PluginMessage pluginMessage) throws Exception public void handle(PluginMessage pluginMessage) throws Exception
{ {
DataInput in = pluginMessage.getStream(); DataInput in = pluginMessage.getStream();
PluginMessageEvent event = new PluginMessageEvent( con.getServer(), con, pluginMessage.getTag(), pluginMessage.getData().clone() ); PluginMessageEvent event = new PluginMessageEvent( con.getServer(), con, pluginMessage.getTag(), pluginMessage.getData().clone() );
@ -330,7 +330,7 @@ public class DownstreamBridge extends PacketHandler
} }
@Override @Override
public void handle(Packet43Kick kick) throws Exception public void handle(Kick kick) throws Exception
{ {
ServerInfo def = bungee.getServerInfo( con.getPendingConnection().getListener().getFallbackServer() ); ServerInfo def = bungee.getServerInfo( con.getPendingConnection().getListener().getFallbackServer() );
if ( Objects.equals( server.getInfo(), def ) ) if ( Objects.equals( server.getInfo(), def ) )

View File

@ -45,14 +45,14 @@ import net.md_5.bungee.protocol.Forge;
import net.md_5.bungee.protocol.MinecraftInput; import net.md_5.bungee.protocol.MinecraftInput;
import net.md_5.bungee.protocol.Vanilla; import net.md_5.bungee.protocol.Vanilla;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.game.Packet1Login; import net.md_5.bungee.protocol.packet.Login;
import net.md_5.bungee.protocol.packet.Packet2Handshake; import net.md_5.bungee.protocol.packet.Packet2Handshake;
import net.md_5.bungee.protocol.game.Packet16ClientStatus; import net.md_5.bungee.protocol.packet.ClientStatus;
import net.md_5.bungee.protocol.game.Packet42PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.login.Packet1EncryptionResponse; import net.md_5.bungee.protocol.packet.EncryptionResponse;
import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest; import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest;
import net.md_5.bungee.protocol.packet.PacketFEPing; import net.md_5.bungee.protocol.packet.PacketFEPing;
import net.md_5.bungee.protocol.game.Packet43Kick; import net.md_5.bungee.protocol.packet.Kick;
import net.md_5.bungee.api.AbstractReconnectHandler; import net.md_5.bungee.api.AbstractReconnectHandler;
import net.md_5.bungee.api.event.PlayerHandshakeEvent; import net.md_5.bungee.api.event.PlayerHandshakeEvent;
@ -65,14 +65,14 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@Getter @Getter
private final ListenerInfo listener; private final ListenerInfo listener;
@Getter @Getter
private Packet1Login forgeLogin; private Login forgeLogin;
@Getter @Getter
private Packet2Handshake handshake; private Packet2Handshake handshake;
private PacketFDEncryptionRequest request; private PacketFDEncryptionRequest request;
@Getter @Getter
private List<Packet42PluginMessage> loginMessages = new ArrayList<>(); private List<PluginMessage> loginMessages = new ArrayList<>();
@Getter @Getter
private List<Packet42PluginMessage> registerMessages = new ArrayList<>(); private List<PluginMessage> registerMessages = new ArrayList<>();
private State thisState = State.HANDSHAKE; private State thisState = State.HANDSHAKE;
private SecretKey sharedKey; private SecretKey sharedKey;
private final Unsafe unsafe = new Unsafe() private final Unsafe unsafe = new Unsafe()
@ -110,7 +110,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
} }
@Override @Override
public void handle(Packet42PluginMessage pluginMessage) throws Exception public void handle(PluginMessage pluginMessage) throws Exception
{ {
if ( pluginMessage.getTag().equals( "MC|PingHost" ) ) if ( pluginMessage.getTag().equals( "MC|PingHost" ) )
{ {
@ -188,7 +188,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
} }
@Override @Override
public void handle(Packet1Login login) throws Exception public void handle(Login login) throws Exception
{ {
Preconditions.checkState( thisState == State.LOGIN, "Not expecting FORGE LOGIN" ); Preconditions.checkState( thisState == State.LOGIN, "Not expecting FORGE LOGIN" );
Preconditions.checkState( forgeLogin == null, "Already received FORGE LOGIN" ); Preconditions.checkState( forgeLogin == null, "Already received FORGE LOGIN" );
@ -243,7 +243,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
} }
@Override @Override
public void handle(final Packet1EncryptionResponse encryptResponse) throws Exception public void handle(final EncryptionResponse encryptResponse) throws Exception
{ {
Preconditions.checkState( thisState == State.ENCRYPT, "Not expecting ENCRYPT" ); Preconditions.checkState( thisState == State.ENCRYPT, "Not expecting ENCRYPT" );
@ -323,7 +323,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{ {
if ( ch.getHandle().isActive() ) if ( ch.getHandle().isActive() )
{ {
unsafe().sendPacket( new Packet1EncryptionResponse( new byte[ 0 ], new byte[ 0 ] ) ); unsafe().sendPacket( new EncryptionResponse( new byte[ 0 ], new byte[ 0 ] ) );
try try
{ {
Cipher encrypt = EncryptionUtil.getCipher( Cipher.ENCRYPT_MODE, sharedKey ); Cipher encrypt = EncryptionUtil.getCipher( Cipher.ENCRYPT_MODE, sharedKey );
@ -343,7 +343,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
} }
@Override @Override
public void handle(Packet16ClientStatus clientStatus) throws Exception public void handle(ClientStatus clientStatus) throws Exception
{ {
Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" ); Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" );
@ -373,7 +373,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{ {
if ( !ch.isClosed() ) if ( !ch.isClosed() )
{ {
unsafe().sendPacket( new Packet43Kick( reason ) ); unsafe().sendPacket( new Kick( reason ) );
ch.close(); ch.close();
} }
} }

View File

@ -8,7 +8,7 @@ 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.netty.PacketHandler; import net.md_5.bungee.netty.PacketHandler;
import net.md_5.bungee.protocol.game.Packet43Kick; import net.md_5.bungee.protocol.packet.Kick;
@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(Packet43Kick kick) throws Exception public void handle(Kick kick) throws Exception
{ {
String[] split = kick.getMessage().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] ) );

View File

@ -11,11 +11,11 @@ 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.netty.PacketHandler; import net.md_5.bungee.netty.PacketHandler;
import net.md_5.bungee.netty.PacketWrapper; import net.md_5.bungee.netty.PacketWrapper;
import net.md_5.bungee.protocol.game.Packet0KeepAlive; import net.md_5.bungee.protocol.packet.KeepAlive;
import net.md_5.bungee.protocol.game.Packet2Chat; import net.md_5.bungee.protocol.packet.Chat;
import net.md_5.bungee.protocol.game.Packet3DTabComplete; import net.md_5.bungee.protocol.packet.TabComplete;
import net.md_5.bungee.protocol.game.Packet15Settings; import net.md_5.bungee.protocol.packet.ClientSettings;
import net.md_5.bungee.protocol.game.Packet42PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -67,7 +67,7 @@ public class UpstreamBridge extends PacketHandler
} }
@Override @Override
public void handle(Packet0KeepAlive alive) throws Exception public void handle(KeepAlive alive) throws Exception
{ {
if ( alive.getRandomId() == con.getSentPingId() ) if ( alive.getRandomId() == con.getSentPingId() )
{ {
@ -78,7 +78,7 @@ public class UpstreamBridge extends PacketHandler
} }
@Override @Override
public void handle(Packet2Chat chat) throws Exception public void handle(Chat chat) throws Exception
{ {
ChatEvent chatEvent = new ChatEvent( con, con.getServer(), chat.getMessage() ); ChatEvent chatEvent = new ChatEvent( con, con.getServer(), chat.getMessage() );
if ( !bungee.getPluginManager().callEvent( chatEvent ).isCancelled() ) if ( !bungee.getPluginManager().callEvent( chatEvent ).isCancelled() )
@ -93,7 +93,7 @@ public class UpstreamBridge extends PacketHandler
} }
@Override @Override
public void handle(Packet3DTabComplete tabComplete) throws Exception public void handle(TabComplete tabComplete) throws Exception
{ {
if ( tabComplete.getCursor().startsWith( "/" ) ) if ( tabComplete.getCursor().startsWith( "/" ) )
{ {
@ -102,20 +102,20 @@ public class UpstreamBridge extends PacketHandler
if ( !results.isEmpty() ) if ( !results.isEmpty() )
{ {
con.unsafe().sendPacket( new Packet3DTabComplete( results.toArray( new String[ results.size() ] ) ) ); con.unsafe().sendPacket( new TabComplete( results.toArray( new String[ results.size() ] ) ) );
throw new CancelSendSignal(); throw new CancelSendSignal();
} }
} }
} }
@Override @Override
public void handle(Packet15Settings settings) throws Exception public void handle(ClientSettings settings) throws Exception
{ {
con.setSettings( settings ); con.setSettings( settings );
} }
@Override @Override
public void handle(Packet42PluginMessage pluginMessage) throws Exception public void handle(PluginMessage pluginMessage) throws Exception
{ {
if ( pluginMessage.getTag().equals( "BungeeCord" ) ) if ( pluginMessage.getTag().equals( "BungeeCord" ) )
{ {

View File

@ -7,7 +7,7 @@ import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.tab.CustomTabList; import net.md_5.bungee.api.tab.CustomTabList;
import net.md_5.bungee.api.tab.TabListAdapter; import net.md_5.bungee.api.tab.TabListAdapter;
import net.md_5.bungee.protocol.game.Packet3BPlayerListItem; import net.md_5.bungee.protocol.packet.PlayerListItem;
public class Custom extends TabListAdapter implements CustomTabList public class Custom extends TabListAdapter implements CustomTabList
{ {
@ -96,7 +96,7 @@ public class Custom extends TabListAdapter implements CustomTabList
{ {
String text = ( slots[i][j] != null ) ? slots[i][j] : new StringBuilder().append( base( i ) ).append( base( j ) ).toString(); String text = ( slots[i][j] != null ) ? slots[i][j] : new StringBuilder().append( base( i ) ).append( base( j ) ).toString();
sent[i][j] = text; sent[i][j] = text;
getPlayer().unsafe().sendPacket( new Packet3BPlayerListItem( text, true, (short) 0 ) ); getPlayer().unsafe().sendPacket( new PlayerListItem( text, true, (short) 0 ) );
} }
} }
} }
@ -112,7 +112,7 @@ public class Custom extends TabListAdapter implements CustomTabList
{ {
String text = sent[i][j]; String text = sent[i][j];
sent[i][j] = null; sent[i][j] = null;
getPlayer().unsafe().sendPacket( new Packet3BPlayerListItem( text, false, (short) 9999 ) ); getPlayer().unsafe().sendPacket( new PlayerListItem( text, false, (short) 9999 ) );
} }
} }
} }

View File

@ -4,7 +4,7 @@ import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.tab.TabListAdapter; import net.md_5.bungee.api.tab.TabListAdapter;
import net.md_5.bungee.protocol.game.Packet3BPlayerListItem; import net.md_5.bungee.protocol.packet.PlayerListItem;
public class Global extends TabListAdapter public class Global extends TabListAdapter
{ {
@ -16,9 +16,9 @@ public class Global extends TabListAdapter
{ {
for ( ProxiedPlayer p : ProxyServer.getInstance().getPlayers() ) for ( ProxiedPlayer p : ProxyServer.getInstance().getPlayers() )
{ {
getPlayer().unsafe().sendPacket( new Packet3BPlayerListItem( p.getDisplayName(), true, (short) p.getPing() ) ); getPlayer().unsafe().sendPacket( new PlayerListItem( p.getDisplayName(), true, (short) p.getPing() ) );
} }
BungeeCord.getInstance().broadcast( new Packet3BPlayerListItem( getPlayer().getDisplayName(), true, (short) getPlayer().getPing() ) ); BungeeCord.getInstance().broadcast( new PlayerListItem( getPlayer().getDisplayName(), true, (short) getPlayer().getPing() ) );
} }
@Override @Override
@ -27,14 +27,14 @@ public class Global extends TabListAdapter
if ( !sentPing ) if ( !sentPing )
{ {
sentPing = true; sentPing = true;
BungeeCord.getInstance().broadcast( new Packet3BPlayerListItem( getPlayer().getDisplayName(), true, (short) getPlayer().getPing() ) ); BungeeCord.getInstance().broadcast( new PlayerListItem( getPlayer().getDisplayName(), true, (short) getPlayer().getPing() ) );
} }
} }
@Override @Override
public void onDisconnect() public void onDisconnect()
{ {
BungeeCord.getInstance().broadcast( new Packet3BPlayerListItem( getPlayer().getDisplayName(), false, (short) 9999 ) ); BungeeCord.getInstance().broadcast( new PlayerListItem( getPlayer().getDisplayName(), false, (short) 9999 ) );
} }
@Override @Override

View File

@ -2,7 +2,7 @@ package net.md_5.bungee.tab;
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.protocol.game.Packet3BPlayerListItem; import net.md_5.bungee.protocol.packet.PlayerListItem;
public class GlobalPing extends Global public class GlobalPing extends Global
{ {
@ -17,7 +17,7 @@ public class GlobalPing extends Global
if ( ping - PING_THRESHOLD > lastPing && ping + PING_THRESHOLD < lastPing ) if ( ping - PING_THRESHOLD > lastPing && ping + PING_THRESHOLD < lastPing )
{ {
lastPing = ping; lastPing = ping;
BungeeCord.getInstance().broadcast( new Packet3BPlayerListItem( getPlayer().getDisplayName(), true, (short) ping ) ); BungeeCord.getInstance().broadcast( new PlayerListItem( getPlayer().getDisplayName(), true, (short) ping ) );
} }
} }
} }

View File

@ -3,7 +3,7 @@ package net.md_5.bungee.tab;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import net.md_5.bungee.api.tab.TabListAdapter; import net.md_5.bungee.api.tab.TabListAdapter;
import net.md_5.bungee.protocol.game.Packet3BPlayerListItem; import net.md_5.bungee.protocol.packet.PlayerListItem;
public class ServerUnique extends TabListAdapter public class ServerUnique extends TabListAdapter
{ {
@ -17,7 +17,7 @@ public class ServerUnique extends TabListAdapter
{ {
for ( String username : usernames ) for ( String username : usernames )
{ {
getPlayer().unsafe().sendPacket( new Packet3BPlayerListItem( username, false, (short) 9999 ) ); getPlayer().unsafe().sendPacket( new PlayerListItem( username, false, (short) 9999 ) );
} }
usernames.clear(); usernames.clear();
} }