mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-24 03:05:49 +01:00
Finish up protocol API - we now compile again. Extensive testing is required, but that is for another day.
This commit is contained in:
parent
9b0c827c37
commit
d82b29e15a
@ -14,7 +14,7 @@ public class Team
|
||||
private String displayName;
|
||||
private String prefix;
|
||||
private String suffix;
|
||||
private byte friendlyMode;
|
||||
private boolean friendlyFire;
|
||||
private Set<String> players = new HashSet<>();
|
||||
|
||||
public Collection<String> getPlayers()
|
||||
|
@ -2,14 +2,16 @@ 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 id;
|
||||
private int randomId;
|
||||
|
||||
private Packet0KeepAlive()
|
||||
{
|
||||
@ -19,13 +21,13 @@ public class Packet0KeepAlive extends DefinedPacket
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
{
|
||||
id = buf.readInt();
|
||||
randomId = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf)
|
||||
{
|
||||
buf.writeInt( id );
|
||||
buf.writeInt( randomId );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,8 +2,10 @@ 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
|
||||
@ -22,6 +24,23 @@ public class Packet1Login extends DefinedPacket
|
||||
super( 0x01 );
|
||||
}
|
||||
|
||||
public Packet1Login(int entityId, String levelType, byte gameMode, byte dimension, byte difficulty, byte unused, byte maxPlayers)
|
||||
{
|
||||
this( entityId, levelType, gameMode, entityId, 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)
|
||||
{
|
||||
|
@ -2,8 +2,10 @@ 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
|
||||
|
@ -2,8 +2,10 @@ 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
|
||||
@ -16,6 +18,12 @@ public class Packet3Chat extends DefinedPacket
|
||||
super( 0x03 );
|
||||
}
|
||||
|
||||
public Packet3Chat(String message)
|
||||
{
|
||||
this();
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
{
|
||||
|
@ -20,6 +20,16 @@ public class Packet9Respawn extends DefinedPacket
|
||||
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)
|
||||
{
|
||||
|
@ -2,8 +2,10 @@ 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
|
||||
|
@ -16,6 +16,12 @@ public class PacketCDClientStatus extends DefinedPacket
|
||||
super( 0xCD );
|
||||
}
|
||||
|
||||
public PacketCDClientStatus(byte payload)
|
||||
{
|
||||
this();
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
{
|
||||
|
@ -2,8 +2,10 @@ 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
|
||||
@ -21,6 +23,14 @@ public class PacketCEScoreboardObjective extends DefinedPacket
|
||||
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)
|
||||
{
|
||||
|
@ -2,8 +2,10 @@ 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
|
||||
|
@ -2,8 +2,10 @@ 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
|
||||
|
@ -2,8 +2,10 @@ 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
|
||||
@ -26,22 +28,33 @@ public class PacketD1Team extends DefinedPacket
|
||||
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 ( mode == 0 || mode == 2 )
|
||||
if ( getMode() == 0 || getMode() == 2 )
|
||||
{
|
||||
displayName = readString( buf );
|
||||
prefix = readString( buf );
|
||||
suffix = readString( buf );
|
||||
friendlyFire = buf.readBoolean();
|
||||
}
|
||||
if ( mode == 0 || mode == 3 || mode == 4 )
|
||||
if ( getMode() == 0 || getMode() == 3 || getMode() == 4 )
|
||||
{
|
||||
players = new String[ buf.readShort() ];
|
||||
for ( int i = 0; i < players.length; i++ )
|
||||
for ( int i = 0; i < getPlayers().length; i++ )
|
||||
{
|
||||
players[i] = readString( buf );
|
||||
}
|
||||
@ -51,21 +64,21 @@ public class PacketD1Team extends DefinedPacket
|
||||
@Override
|
||||
public void write(ByteBuf buf)
|
||||
{
|
||||
writeString( name, buf );
|
||||
buf.writeByte( mode );
|
||||
if ( mode == 0 || mode == 2 )
|
||||
writeString( getName(), buf );
|
||||
buf.writeByte( getMode() );
|
||||
if ( getMode() == 0 || getMode() == 2 )
|
||||
{
|
||||
writeString( displayName, buf );
|
||||
writeString( prefix, buf );
|
||||
writeString( suffix, buf );
|
||||
buf.writeBoolean( friendlyFire );
|
||||
writeString( getDisplayName(), buf );
|
||||
writeString( getPrefix(), buf );
|
||||
writeString( getSuffix(), buf );
|
||||
buf.writeBoolean( isFriendlyFire() );
|
||||
}
|
||||
if ( mode == 0 || mode == 3 || mode == 4 )
|
||||
if ( getMode() == 0 || getMode() == 3 || getMode() == 4 )
|
||||
{
|
||||
buf.writeShort( players.length );
|
||||
for ( int i = 0; i < players.length; i++ )
|
||||
buf.writeShort( getPlayers().length );
|
||||
for ( int i = 0; i < getPlayers().length; i++ )
|
||||
{
|
||||
writeString( players[i], buf );
|
||||
writeString( getPlayers()[i], buf );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,10 @@ 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
|
||||
@ -17,6 +19,13 @@ public class PacketFAPluginMessage extends DefinedPacket
|
||||
super( 0xFA );
|
||||
}
|
||||
|
||||
public PacketFAPluginMessage(String tag, byte[] data)
|
||||
{
|
||||
this();
|
||||
this.tag = tag;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
{
|
||||
|
@ -2,8 +2,10 @@ 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
|
||||
@ -17,6 +19,13 @@ public class PacketFCEncryptionResponse extends DefinedPacket
|
||||
super( 0xFC );
|
||||
}
|
||||
|
||||
public PacketFCEncryptionResponse(byte[] sharedSecret, byte[] verifyToken)
|
||||
{
|
||||
this();
|
||||
this.sharedSecret = sharedSecret;
|
||||
this.verifyToken = verifyToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
{
|
||||
|
@ -2,8 +2,10 @@ 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
|
||||
@ -18,6 +20,14 @@ public class PacketFDEncryptionRequest extends DefinedPacket
|
||||
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)
|
||||
{
|
||||
|
@ -2,8 +2,10 @@ 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
|
||||
@ -16,6 +18,12 @@ public class PacketFFKick extends DefinedPacket
|
||||
super( 0xFF );
|
||||
}
|
||||
|
||||
public PacketFFKick(String message)
|
||||
{
|
||||
this();
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
{
|
||||
|
@ -10,6 +10,11 @@ import lombok.ToString;
|
||||
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)
|
||||
{
|
||||
@ -28,7 +33,7 @@ public class Forge1Login extends Packet1Login
|
||||
buf.writeInt( entityId );
|
||||
writeString( levelType, buf );
|
||||
buf.writeByte( gameMode );
|
||||
buf.writeInt(dimension );
|
||||
buf.writeInt( dimension );
|
||||
buf.writeByte( difficulty );
|
||||
buf.writeByte( unused );
|
||||
buf.writeByte( maxPlayers );
|
||||
|
@ -53,18 +53,15 @@ public class EncryptionUtil
|
||||
{
|
||||
Cipher cipher = Cipher.getInstance( "RSA" );
|
||||
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!" );
|
||||
}
|
||||
|
||||
cipher.init( Cipher.DECRYPT_MODE, keys.getPrivate() );
|
||||
byte[] shared = resp.sharedSecret;
|
||||
byte[] secret = cipher.doFinal( shared );
|
||||
|
||||
return new SecretKeySpec( secret, "AES" );
|
||||
return new SecretKeySpec( cipher.doFinal( resp.getSharedSecret() ), "AES" );
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
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
|
||||
|
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 );
|
||||
}
|
@ -27,6 +27,7 @@ import net.md_5.bungee.netty.CipherDecoder;
|
||||
import net.md_5.bungee.netty.CipherEncoder;
|
||||
import net.md_5.bungee.netty.PacketDecoder;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.protocol.Forge;
|
||||
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.packet.Packet1Login;
|
||||
import net.md_5.bungee.protocol.packet.Packet9Respawn;
|
||||
@ -38,6 +39,7 @@ import net.md_5.bungee.protocol.packet.PacketFCEncryptionResponse;
|
||||
import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest;
|
||||
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||
import net.md_5.bungee.protocol.Vanilla;
|
||||
import net.md_5.bungee.protocol.packet.forge.Forge1Login;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class ServerConnector extends PacketHandler
|
||||
@ -86,7 +88,7 @@ public class ServerConnector extends PacketHandler
|
||||
// Skip encryption if we are not using Forge
|
||||
if ( user.getPendingConnection().getForgeLogin() == null )
|
||||
{
|
||||
channel.write( PacketCDClientStatus.CLIENT_LOGIN );
|
||||
channel.write( PacketConstants.CLIENT_LOGIN );
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,18 +135,20 @@ public class ServerConnector extends PacketHandler
|
||||
if ( user.getServer() == null )
|
||||
{
|
||||
// Once again, first connection
|
||||
user.setClientEntityId( login.entityId );
|
||||
user.setServerEntityId( login.entityId );
|
||||
// Set tab list size
|
||||
Packet1Login modLogin = new Packet1Login(
|
||||
login.entityId,
|
||||
login.levelType,
|
||||
login.gameMode,
|
||||
(byte) login.dimension,
|
||||
login.difficulty,
|
||||
login.unused,
|
||||
(byte) user.getPendingConnection().getListener().getTabListSize(),
|
||||
ch.getHandle().pipeline().get( PacketDecoder.class ).getProtocol() == Vanilla.FORGE_PROTOCOL );
|
||||
user.setClientEntityId( login.getEntityId() );
|
||||
user.setServerEntityId( login.getEntityId() );
|
||||
|
||||
// Set tab list size, this sucks balls, TODO: what shall we do about packet mutability
|
||||
Packet1Login modLogin;
|
||||
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(),
|
||||
(byte) user.getPendingConnection().getListener().getTabListSize() );
|
||||
} else
|
||||
{
|
||||
modLogin = new Packet1Login( login.getEntityId(), login.getLevelType(), login.getGameMode(), (byte) login.getDimension(), login.getDifficulty(), login.getUnused(),
|
||||
(byte) user.getPendingConnection().getListener().getTabListSize() );
|
||||
}
|
||||
user.sendPacket( modLogin );
|
||||
} else
|
||||
{
|
||||
@ -157,15 +161,14 @@ public class ServerConnector extends PacketHandler
|
||||
}
|
||||
for ( Team team : serverScoreboard.getTeams() )
|
||||
{
|
||||
user.sendPacket( PacketD1Team.destroy( team.getName() ) );
|
||||
user.sendPacket( new PacketD1Team( team.getName() ) );
|
||||
}
|
||||
serverScoreboard.clear();
|
||||
|
||||
user.sendPacket( Packet9Respawn.DIM1_SWITCH );
|
||||
user.sendPacket( Packet9Respawn.DIM2_SWITCH );
|
||||
user.sendDimensionSwitch();
|
||||
|
||||
user.setServerEntityId( login.entityId );
|
||||
user.sendPacket( new Packet9Respawn( login.dimension, login.difficulty, login.gameMode, (short) 256, login.levelType ) );
|
||||
user.setServerEntityId( login.getEntityId() );
|
||||
user.sendPacket( new Packet9Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), (short) 256, login.getLevelType() ) );
|
||||
|
||||
// Remove from old servers
|
||||
user.getServer().setObsolete( true );
|
||||
@ -209,7 +212,7 @@ public class ServerConnector extends PacketHandler
|
||||
this.secretkey = EncryptionUtil.getSecret();
|
||||
|
||||
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 ) );
|
||||
|
||||
@ -233,7 +236,7 @@ public class ServerConnector extends PacketHandler
|
||||
|
||||
ch.write( user.getPendingConnection().getForgeLogin() );
|
||||
|
||||
ch.write( PacketCDClientStatus.CLIENT_LOGIN );
|
||||
ch.write( PacketConstants.CLIENT_LOGIN );
|
||||
thisState = State.LOGIN;
|
||||
}
|
||||
|
||||
@ -245,14 +248,14 @@ public class ServerConnector extends PacketHandler
|
||||
{
|
||||
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 )
|
||||
{
|
||||
user.connect( event.getCancelServer() );
|
||||
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 )
|
||||
{
|
||||
user.disconnect( message );
|
||||
@ -265,9 +268,9 @@ public class ServerConnector extends PacketHandler
|
||||
@Override
|
||||
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();
|
||||
int count = in.readInt();
|
||||
for ( int i = 0; i < count; i++ )
|
||||
@ -277,7 +280,7 @@ public class ServerConnector extends PacketHandler
|
||||
if ( in.readByte() != 0 )
|
||||
{
|
||||
// TODO: Using forge flag
|
||||
ch.getHandle().pipeline().get( PacketDecoder.class ).setProtocol( Vanilla.FORGE_PROTOCOL );
|
||||
ch.getHandle().pipeline().get( PacketDecoder.class ).setProtocol( Forge.getInstance() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@ import net.md_5.bungee.netty.HandlerBoss;
|
||||
import net.md_5.bungee.netty.PipelineUtils;
|
||||
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.packet.Packet3Chat;
|
||||
import net.md_5.bungee.protocol.packet.Packet9Respawn;
|
||||
import net.md_5.bungee.protocol.packet.PacketCCSettings;
|
||||
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||
@ -133,10 +132,15 @@ public final class UserConnection implements ProxiedPlayer
|
||||
connect( target, false );
|
||||
}
|
||||
|
||||
void sendDimensionSwitch()
|
||||
{
|
||||
sendPacket( PacketConstants.DIM1_SWITCH );
|
||||
sendPacket( PacketConstants.DIM2_SWITCH );
|
||||
}
|
||||
|
||||
public void connectNow(ServerInfo target)
|
||||
{
|
||||
sendPacket( Packet9Respawn.DIM1_SWITCH );
|
||||
sendPacket( Packet9Respawn.DIM2_SWITCH );
|
||||
sendDimensionSwitch();
|
||||
connect( target );
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class DownstreamBridge extends PacketHandler
|
||||
@Override
|
||||
public void handle(Packet0KeepAlive alive) throws Exception
|
||||
{
|
||||
con.setSentPingId( alive.id );
|
||||
con.setSentPingId( alive.getRandomId() );
|
||||
con.setSentPingTime( System.currentTimeMillis() );
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public class DownstreamBridge extends PacketHandler
|
||||
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();
|
||||
}
|
||||
@ -96,13 +96,13 @@ public class DownstreamBridge extends PacketHandler
|
||||
public void handle(PacketCEScoreboardObjective objective) throws Exception
|
||||
{
|
||||
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
||||
switch ( objective.action )
|
||||
switch ( objective.getAction() )
|
||||
{
|
||||
case 0:
|
||||
serverScoreboard.addObjective( new Objective( objective.name, objective.text ) );
|
||||
serverScoreboard.addObjective( new Objective( objective.getName(), objective.getText() ) );
|
||||
break;
|
||||
case 1:
|
||||
serverScoreboard.removeObjective( objective.name );
|
||||
serverScoreboard.removeObjective( objective.getName() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -111,15 +111,15 @@ public class DownstreamBridge extends PacketHandler
|
||||
public void handle(PacketCFScoreboardScore score) throws Exception
|
||||
{
|
||||
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
||||
switch ( score.action )
|
||||
switch ( score.getAction() )
|
||||
{
|
||||
case 0:
|
||||
Score s = new Score( score.itemName, score.scoreName, score.value );
|
||||
serverScoreboard.removeScore( score.itemName );
|
||||
Score s = new Score( score.getItemName(), score.getScoreName(), score.getValue() );
|
||||
serverScoreboard.removeScore( score.getItemName() );
|
||||
serverScoreboard.addScore( s );
|
||||
break;
|
||||
case 1:
|
||||
serverScoreboard.removeScore( score.itemName );
|
||||
serverScoreboard.removeScore( score.getItemName() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -128,8 +128,8 @@ public class DownstreamBridge extends PacketHandler
|
||||
public void handle(PacketD0DisplayScoreboard displayScoreboard) throws Exception
|
||||
{
|
||||
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
||||
serverScoreboard.setName( displayScoreboard.name );
|
||||
serverScoreboard.setPosition( Position.values()[displayScoreboard.position] );
|
||||
serverScoreboard.setName( displayScoreboard.getName() );
|
||||
serverScoreboard.setPosition( Position.values()[displayScoreboard.getPosition()] );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,37 +137,37 @@ public class DownstreamBridge extends PacketHandler
|
||||
{
|
||||
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
||||
// Remove team and move on
|
||||
if ( team.mode == 1 )
|
||||
if ( team.getMode() == 1 )
|
||||
{
|
||||
serverScoreboard.removeTeam( team.name );
|
||||
serverScoreboard.removeTeam( team.getName() );
|
||||
return;
|
||||
}
|
||||
|
||||
// Create or get old team
|
||||
Team t;
|
||||
if ( team.mode == 0 )
|
||||
if ( team.getMode() == 0 )
|
||||
{
|
||||
t = new Team( team.name );
|
||||
t = new Team( team.getName() );
|
||||
serverScoreboard.addTeam( t );
|
||||
} else
|
||||
{
|
||||
t = serverScoreboard.getTeam( team.name );
|
||||
t = serverScoreboard.getTeam( team.getName() );
|
||||
}
|
||||
|
||||
if ( t != null )
|
||||
{
|
||||
if ( team.mode == 0 || team.mode == 2 )
|
||||
if ( team.getMode() == 0 || team.getMode() == 2 )
|
||||
{
|
||||
t.setDisplayName( team.displayName );
|
||||
t.setPrefix( team.prefix );
|
||||
t.setSuffix( team.suffix );
|
||||
t.setFriendlyMode( team.friendlyFire );
|
||||
t.setDisplayName( team.getDisplayName() );
|
||||
t.setPrefix( team.getPrefix() );
|
||||
t.setSuffix( team.getSuffix() );
|
||||
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 );
|
||||
} else
|
||||
@ -182,20 +182,20 @@ public class DownstreamBridge extends PacketHandler
|
||||
@Override
|
||||
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
||||
{
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput( pluginMessage.data );
|
||||
PluginMessageEvent event = new PluginMessageEvent( con.getServer(), con, pluginMessage.tag, pluginMessage.data.clone() );
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput( pluginMessage.getData() );
|
||||
PluginMessageEvent event = new PluginMessageEvent( con.getServer(), con, pluginMessage.getTag(), pluginMessage.getData().clone() );
|
||||
|
||||
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
if ( pluginMessage.tag.equals( "BungeeCord" ) )
|
||||
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
|
||||
{
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
String subChannel = in.readUTF();
|
||||
@ -325,7 +325,7 @@ public class DownstreamBridge extends PacketHandler
|
||||
{
|
||||
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 )
|
||||
{
|
||||
con.connectNow( event.getCancelServer() );
|
||||
|
@ -35,6 +35,7 @@ import net.md_5.bungee.netty.CipherDecoder;
|
||||
import net.md_5.bungee.netty.CipherEncoder;
|
||||
import net.md_5.bungee.netty.PacketDecoder;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.protocol.Forge;
|
||||
import net.md_5.bungee.protocol.packet.Packet1Login;
|
||||
import net.md_5.bungee.protocol.packet.Packet2Handshake;
|
||||
import net.md_5.bungee.protocol.packet.PacketCDClientStatus;
|
||||
@ -115,14 +116,14 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
Preconditions.checkState( forgeLogin == null, "Already received FORGE LOGIN" );
|
||||
forgeLogin = login;
|
||||
|
||||
ch.getHandle().pipeline().get( PacketDecoder.class ).setProtocol( Vanilla.FORGE_PROTOCOL );
|
||||
ch.getHandle().pipeline().get( PacketDecoder.class ).setProtocol( Forge.getInstance() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Packet2Handshake handshake) throws Exception
|
||||
{
|
||||
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" );
|
||||
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 ( !BungeeCord.getInstance().config.isOnlineMode() && bungee.getPlayer( handshake.username ) != null )
|
||||
if ( !BungeeCord.getInstance().config.isOnlineMode() && bungee.getPlayer( handshake.getUsername() ) != null )
|
||||
{
|
||||
disconnect( bungee.getTranslation( "already_connected" ) );
|
||||
return;
|
||||
@ -164,7 +165,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
MessageDigest sha = MessageDigest.getInstance( "SHA-1" );
|
||||
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 );
|
||||
@ -202,7 +203,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
private void finish() throws GeneralSecurityException
|
||||
{
|
||||
// Check for multiple connections
|
||||
ProxiedPlayer old = bungee.getPlayer( handshake.username );
|
||||
ProxiedPlayer old = bungee.getPlayer( handshake.getUsername() );
|
||||
if ( old != null )
|
||||
{
|
||||
old.disconnect( bungee.getTranslation( "already_connected" ) );
|
||||
@ -223,7 +224,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
}
|
||||
|
||||
thisState = InitialHandler.State.LOGIN;
|
||||
ch.write( new PacketFCEncryptionResponse() );
|
||||
ch.write( new PacketFCEncryptionResponse( new byte[ 0 ], new byte[ 0 ] ) );
|
||||
try
|
||||
{
|
||||
Cipher encrypt = EncryptionUtil.getCipher( Cipher.ENCRYPT_MODE, sharedKey );
|
||||
@ -271,19 +272,19 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return ( handshake == null ) ? null : handshake.username;
|
||||
return ( handshake == null ) ? null : handshake.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getVersion()
|
||||
{
|
||||
return ( handshake == null ) ? -1 : handshake.procolVersion;
|
||||
return ( handshake == null ) ? -1 : handshake.getProcolVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getVirtualHost()
|
||||
{
|
||||
return ( handshake == null ) ? null : new InetSocketAddress( handshake.host, handshake.port );
|
||||
return ( handshake == null ) ? null : new InetSocketAddress( handshake.getHost(), handshake.getPort() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,7 +34,7 @@ public class PingHandler extends PacketHandler
|
||||
@Override
|
||||
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] ) );
|
||||
callback.done( ping, null );
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class UpstreamBridge extends PacketHandler
|
||||
@Override
|
||||
public void handle(Packet0KeepAlive alive) throws Exception
|
||||
{
|
||||
if ( alive.id == con.getSentPingId() )
|
||||
if ( alive.getRandomId() == con.getSentPingId() )
|
||||
{
|
||||
int newPing = (int) ( System.currentTimeMillis() - con.getSentPingTime() );
|
||||
bungee.getTabListHandler().onPingChange( con, newPing );
|
||||
@ -83,14 +83,14 @@ public class UpstreamBridge extends PacketHandler
|
||||
@Override
|
||||
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() )
|
||||
{
|
||||
throw new CancelSendSignal();
|
||||
}
|
||||
if ( chatEvent.isCommand() )
|
||||
{
|
||||
if ( bungee.getPluginManager().dispatchCommand( con, chat.message.substring( 1 ) ) )
|
||||
if ( bungee.getPluginManager().dispatchCommand( con, chat.getMessage().substring( 1 ) ) )
|
||||
{
|
||||
throw new CancelSendSignal();
|
||||
}
|
||||
@ -106,12 +106,12 @@ public class UpstreamBridge extends PacketHandler
|
||||
@Override
|
||||
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
||||
{
|
||||
if ( pluginMessage.tag.equals( "BungeeCord" ) )
|
||||
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
|
||||
{
|
||||
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() )
|
||||
{
|
||||
throw new CancelSendSignal();
|
||||
|
Loading…
Reference in New Issue
Block a user