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 displayName;
|
||||||
private String prefix;
|
private String prefix;
|
||||||
private String suffix;
|
private String suffix;
|
||||||
private byte friendlyMode;
|
private boolean friendlyFire;
|
||||||
private Set<String> players = new HashSet<>();
|
private Set<String> players = new HashSet<>();
|
||||||
|
|
||||||
public Collection<String> getPlayers()
|
public Collection<String> getPlayers()
|
||||||
|
@ -2,14 +2,16 @@ package net.md_5.bungee.protocol.packet;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class Packet0KeepAlive extends DefinedPacket
|
public class Packet0KeepAlive extends DefinedPacket
|
||||||
{
|
{
|
||||||
|
|
||||||
private int id;
|
private int randomId;
|
||||||
|
|
||||||
private Packet0KeepAlive()
|
private Packet0KeepAlive()
|
||||||
{
|
{
|
||||||
@ -19,13 +21,13 @@ public class Packet0KeepAlive extends DefinedPacket
|
|||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
id = buf.readInt();
|
randomId = buf.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buf)
|
public void write(ByteBuf buf)
|
||||||
{
|
{
|
||||||
buf.writeInt( id );
|
buf.writeInt( randomId );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class Packet1Login extends DefinedPacket
|
public class Packet1Login extends DefinedPacket
|
||||||
@ -22,6 +24,23 @@ public class Packet1Login extends DefinedPacket
|
|||||||
super( 0x01 );
|
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
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class Packet2Handshake extends DefinedPacket
|
public class Packet2Handshake extends DefinedPacket
|
||||||
|
@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class Packet3Chat extends DefinedPacket
|
public class Packet3Chat extends DefinedPacket
|
||||||
@ -16,6 +18,12 @@ public class Packet3Chat extends DefinedPacket
|
|||||||
super( 0x03 );
|
super( 0x03 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Packet3Chat(String message)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
|
@ -20,6 +20,16 @@ public class Packet9Respawn extends DefinedPacket
|
|||||||
super( 0x09 );
|
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
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class PacketC9PlayerListItem extends DefinedPacket
|
public class PacketC9PlayerListItem extends DefinedPacket
|
||||||
|
@ -16,6 +16,12 @@ public class PacketCDClientStatus extends DefinedPacket
|
|||||||
super( 0xCD );
|
super( 0xCD );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketCDClientStatus(byte payload)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.payload = payload;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class PacketCEScoreboardObjective extends DefinedPacket
|
public class PacketCEScoreboardObjective extends DefinedPacket
|
||||||
@ -21,6 +23,14 @@ public class PacketCEScoreboardObjective extends DefinedPacket
|
|||||||
super( 0xCE );
|
super( 0xCE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketCEScoreboardObjective(String name, String text, byte action)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.name = name;
|
||||||
|
this.text = text;
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class PacketCFScoreboardScore extends DefinedPacket
|
public class PacketCFScoreboardScore extends DefinedPacket
|
||||||
|
@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class PacketD0DisplayScoreboard extends DefinedPacket
|
public class PacketD0DisplayScoreboard extends DefinedPacket
|
||||||
|
@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class PacketD1Team extends DefinedPacket
|
public class PacketD1Team extends DefinedPacket
|
||||||
@ -26,22 +28,33 @@ public class PacketD1Team extends DefinedPacket
|
|||||||
super( 0xD1 );
|
super( 0xD1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Packet to destroy a team.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
public PacketD1Team(String name)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
mode = 1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
name = readString( buf );
|
name = readString( buf );
|
||||||
mode = buf.readByte();
|
mode = buf.readByte();
|
||||||
if ( mode == 0 || mode == 2 )
|
if ( getMode() == 0 || getMode() == 2 )
|
||||||
{
|
{
|
||||||
displayName = readString( buf );
|
displayName = readString( buf );
|
||||||
prefix = readString( buf );
|
prefix = readString( buf );
|
||||||
suffix = readString( buf );
|
suffix = readString( buf );
|
||||||
friendlyFire = buf.readBoolean();
|
friendlyFire = buf.readBoolean();
|
||||||
}
|
}
|
||||||
if ( mode == 0 || mode == 3 || mode == 4 )
|
if ( getMode() == 0 || getMode() == 3 || getMode() == 4 )
|
||||||
{
|
{
|
||||||
players = new String[ buf.readShort() ];
|
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 );
|
players[i] = readString( buf );
|
||||||
}
|
}
|
||||||
@ -51,21 +64,21 @@ public class PacketD1Team extends DefinedPacket
|
|||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buf)
|
public void write(ByteBuf buf)
|
||||||
{
|
{
|
||||||
writeString( name, buf );
|
writeString( getName(), buf );
|
||||||
buf.writeByte( mode );
|
buf.writeByte( getMode() );
|
||||||
if ( mode == 0 || mode == 2 )
|
if ( getMode() == 0 || getMode() == 2 )
|
||||||
{
|
{
|
||||||
writeString( displayName, buf );
|
writeString( getDisplayName(), buf );
|
||||||
writeString( prefix, buf );
|
writeString( getPrefix(), buf );
|
||||||
writeString( suffix, buf );
|
writeString( getSuffix(), buf );
|
||||||
buf.writeBoolean( friendlyFire );
|
buf.writeBoolean( isFriendlyFire() );
|
||||||
}
|
}
|
||||||
if ( mode == 0 || mode == 3 || mode == 4 )
|
if ( getMode() == 0 || getMode() == 3 || getMode() == 4 )
|
||||||
{
|
{
|
||||||
buf.writeShort( players.length );
|
buf.writeShort( getPlayers().length );
|
||||||
for ( int i = 0; i < players.length; i++ )
|
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 io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class PacketFAPluginMessage extends DefinedPacket
|
public class PacketFAPluginMessage extends DefinedPacket
|
||||||
@ -17,6 +19,13 @@ public class PacketFAPluginMessage extends DefinedPacket
|
|||||||
super( 0xFA );
|
super( 0xFA );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketFAPluginMessage(String tag, byte[] data)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.tag = tag;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class PacketFCEncryptionResponse extends DefinedPacket
|
public class PacketFCEncryptionResponse extends DefinedPacket
|
||||||
@ -17,6 +19,13 @@ public class PacketFCEncryptionResponse extends DefinedPacket
|
|||||||
super( 0xFC );
|
super( 0xFC );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketFCEncryptionResponse(byte[] sharedSecret, byte[] verifyToken)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.sharedSecret = sharedSecret;
|
||||||
|
this.verifyToken = verifyToken;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class PacketFDEncryptionRequest extends DefinedPacket
|
public class PacketFDEncryptionRequest extends DefinedPacket
|
||||||
@ -18,6 +20,14 @@ public class PacketFDEncryptionRequest extends DefinedPacket
|
|||||||
super( 0xFD );
|
super( 0xFD );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketFDEncryptionRequest(String serverId, byte[] publicKey, byte[] verifyToken)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.serverId = serverId;
|
||||||
|
this.publicKey = publicKey;
|
||||||
|
this.verifyToken = verifyToken;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,10 @@ package net.md_5.bungee.protocol.packet;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class PacketFFKick extends DefinedPacket
|
public class PacketFFKick extends DefinedPacket
|
||||||
@ -16,6 +18,12 @@ public class PacketFFKick extends DefinedPacket
|
|||||||
super( 0xFF );
|
super( 0xFF );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketFFKick(String message)
|
||||||
|
{
|
||||||
|
this();
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,11 @@ import lombok.ToString;
|
|||||||
public class Forge1Login extends Packet1Login
|
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
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
@ -28,7 +33,7 @@ public class Forge1Login extends Packet1Login
|
|||||||
buf.writeInt( entityId );
|
buf.writeInt( entityId );
|
||||||
writeString( levelType, buf );
|
writeString( levelType, buf );
|
||||||
buf.writeByte( gameMode );
|
buf.writeByte( gameMode );
|
||||||
buf.writeInt(dimension );
|
buf.writeInt( dimension );
|
||||||
buf.writeByte( difficulty );
|
buf.writeByte( difficulty );
|
||||||
buf.writeByte( unused );
|
buf.writeByte( unused );
|
||||||
buf.writeByte( maxPlayers );
|
buf.writeByte( maxPlayers );
|
||||||
|
@ -53,18 +53,15 @@ public class EncryptionUtil
|
|||||||
{
|
{
|
||||||
Cipher cipher = Cipher.getInstance( "RSA" );
|
Cipher cipher = Cipher.getInstance( "RSA" );
|
||||||
cipher.init( Cipher.DECRYPT_MODE, keys.getPrivate() );
|
cipher.init( Cipher.DECRYPT_MODE, keys.getPrivate() );
|
||||||
byte[] decrypted = cipher.doFinal( resp.verifyToken );
|
byte[] decrypted = cipher.doFinal( resp.getVerifyToken() );
|
||||||
|
|
||||||
if ( !Arrays.equals( request.verifyToken, decrypted ) )
|
if ( !Arrays.equals( request.getVerifyToken(), decrypted ) )
|
||||||
{
|
{
|
||||||
throw new IllegalStateException( "Key pairs do not match!" );
|
throw new IllegalStateException( "Key pairs do not match!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
cipher.init( Cipher.DECRYPT_MODE, keys.getPrivate() );
|
cipher.init( Cipher.DECRYPT_MODE, keys.getPrivate() );
|
||||||
byte[] shared = resp.sharedSecret;
|
return new SecretKeySpec( cipher.doFinal( resp.getSharedSecret() ), "AES" );
|
||||||
byte[] secret = cipher.doFinal( shared );
|
|
||||||
|
|
||||||
return new SecretKeySpec( secret, "AES" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Cipher getCipher(int opMode, Key shared) throws GeneralSecurityException
|
public static Cipher getCipher(int opMode, Key shared) throws GeneralSecurityException
|
||||||
@ -76,7 +73,7 @@ public class EncryptionUtil
|
|||||||
|
|
||||||
public static PublicKey getPubkey(PacketFDEncryptionRequest request) throws GeneralSecurityException
|
public static PublicKey getPubkey(PacketFDEncryptionRequest request) throws GeneralSecurityException
|
||||||
{
|
{
|
||||||
return KeyFactory.getInstance( "RSA" ).generatePublic( new X509EncodedKeySpec( request.publicKey ) );
|
return KeyFactory.getInstance( "RSA" ).generatePublic( new X509EncodedKeySpec( request.getPublicKey() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] encrypt(Key key, byte[] b) throws GeneralSecurityException
|
public static byte[] encrypt(Key key, byte[] b) throws GeneralSecurityException
|
||||||
|
12
proxy/src/main/java/net/md_5/bungee/PacketConstants.java
Normal file
12
proxy/src/main/java/net/md_5/bungee/PacketConstants.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package net.md_5.bungee;
|
||||||
|
|
||||||
|
import net.md_5.bungee.protocol.packet.Packet9Respawn;
|
||||||
|
import net.md_5.bungee.protocol.packet.PacketCDClientStatus;
|
||||||
|
|
||||||
|
public class PacketConstants
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final Packet9Respawn DIM1_SWITCH = new Packet9Respawn( (byte) 1, (byte) 0, (byte) 0, (short) 256, "DEFAULT" );
|
||||||
|
public static final Packet9Respawn DIM2_SWITCH = new Packet9Respawn( (byte) -1, (byte) 0, (byte) 0, (short) 256, "DEFAULT" );
|
||||||
|
public static final PacketCDClientStatus CLIENT_LOGIN = new PacketCDClientStatus( (byte) 0 );
|
||||||
|
}
|
@ -27,6 +27,7 @@ import net.md_5.bungee.netty.CipherDecoder;
|
|||||||
import net.md_5.bungee.netty.CipherEncoder;
|
import net.md_5.bungee.netty.CipherEncoder;
|
||||||
import net.md_5.bungee.netty.PacketDecoder;
|
import net.md_5.bungee.netty.PacketDecoder;
|
||||||
import net.md_5.bungee.netty.PacketHandler;
|
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.DefinedPacket;
|
||||||
import net.md_5.bungee.protocol.packet.Packet1Login;
|
import net.md_5.bungee.protocol.packet.Packet1Login;
|
||||||
import net.md_5.bungee.protocol.packet.Packet9Respawn;
|
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.PacketFDEncryptionRequest;
|
||||||
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||||
import net.md_5.bungee.protocol.Vanilla;
|
import net.md_5.bungee.protocol.Vanilla;
|
||||||
|
import net.md_5.bungee.protocol.packet.forge.Forge1Login;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ServerConnector extends PacketHandler
|
public class ServerConnector extends PacketHandler
|
||||||
@ -86,7 +88,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
// Skip encryption if we are not using Forge
|
// Skip encryption if we are not using Forge
|
||||||
if ( user.getPendingConnection().getForgeLogin() == null )
|
if ( user.getPendingConnection().getForgeLogin() == null )
|
||||||
{
|
{
|
||||||
channel.write( PacketCDClientStatus.CLIENT_LOGIN );
|
channel.write( PacketConstants.CLIENT_LOGIN );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,18 +135,20 @@ public class ServerConnector extends PacketHandler
|
|||||||
if ( user.getServer() == null )
|
if ( user.getServer() == null )
|
||||||
{
|
{
|
||||||
// Once again, first connection
|
// Once again, first connection
|
||||||
user.setClientEntityId( login.entityId );
|
user.setClientEntityId( login.getEntityId() );
|
||||||
user.setServerEntityId( login.entityId );
|
user.setServerEntityId( login.getEntityId() );
|
||||||
// Set tab list size
|
|
||||||
Packet1Login modLogin = new Packet1Login(
|
// Set tab list size, this sucks balls, TODO: what shall we do about packet mutability
|
||||||
login.entityId,
|
Packet1Login modLogin;
|
||||||
login.levelType,
|
if ( ch.getHandle().pipeline().get( PacketDecoder.class ).getProtocol() == Forge.getInstance() )
|
||||||
login.gameMode,
|
{
|
||||||
(byte) login.dimension,
|
modLogin = new Forge1Login( login.getEntityId(), login.getLevelType(), login.getGameMode(), login.getDimension(), login.getDifficulty(), login.getUnused(),
|
||||||
login.difficulty,
|
(byte) user.getPendingConnection().getListener().getTabListSize() );
|
||||||
login.unused,
|
} else
|
||||||
(byte) user.getPendingConnection().getListener().getTabListSize(),
|
{
|
||||||
ch.getHandle().pipeline().get( PacketDecoder.class ).getProtocol() == Vanilla.FORGE_PROTOCOL );
|
modLogin = new Packet1Login( login.getEntityId(), login.getLevelType(), login.getGameMode(), (byte) login.getDimension(), login.getDifficulty(), login.getUnused(),
|
||||||
|
(byte) user.getPendingConnection().getListener().getTabListSize() );
|
||||||
|
}
|
||||||
user.sendPacket( modLogin );
|
user.sendPacket( modLogin );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -157,15 +161,14 @@ public class ServerConnector extends PacketHandler
|
|||||||
}
|
}
|
||||||
for ( Team team : serverScoreboard.getTeams() )
|
for ( Team team : serverScoreboard.getTeams() )
|
||||||
{
|
{
|
||||||
user.sendPacket( PacketD1Team.destroy( team.getName() ) );
|
user.sendPacket( new PacketD1Team( team.getName() ) );
|
||||||
}
|
}
|
||||||
serverScoreboard.clear();
|
serverScoreboard.clear();
|
||||||
|
|
||||||
user.sendPacket( Packet9Respawn.DIM1_SWITCH );
|
user.sendDimensionSwitch();
|
||||||
user.sendPacket( Packet9Respawn.DIM2_SWITCH );
|
|
||||||
|
|
||||||
user.setServerEntityId( login.entityId );
|
user.setServerEntityId( login.getEntityId() );
|
||||||
user.sendPacket( new Packet9Respawn( login.dimension, login.difficulty, login.gameMode, (short) 256, login.levelType ) );
|
user.sendPacket( new Packet9Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), (short) 256, login.getLevelType() ) );
|
||||||
|
|
||||||
// Remove from old servers
|
// Remove from old servers
|
||||||
user.getServer().setObsolete( true );
|
user.getServer().setObsolete( true );
|
||||||
@ -209,7 +212,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
this.secretkey = EncryptionUtil.getSecret();
|
this.secretkey = EncryptionUtil.getSecret();
|
||||||
|
|
||||||
byte[] shared = EncryptionUtil.encrypt( publickey, secretkey.getEncoded() );
|
byte[] shared = EncryptionUtil.encrypt( publickey, secretkey.getEncoded() );
|
||||||
byte[] token = EncryptionUtil.encrypt( publickey, encryptRequest.verifyToken );
|
byte[] token = EncryptionUtil.encrypt( publickey, encryptRequest.getVerifyToken() );
|
||||||
|
|
||||||
ch.write( new PacketFCEncryptionResponse( shared, token ) );
|
ch.write( new PacketFCEncryptionResponse( shared, token ) );
|
||||||
|
|
||||||
@ -233,7 +236,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
|
|
||||||
ch.write( user.getPendingConnection().getForgeLogin() );
|
ch.write( user.getPendingConnection().getForgeLogin() );
|
||||||
|
|
||||||
ch.write( PacketCDClientStatus.CLIENT_LOGIN );
|
ch.write( PacketConstants.CLIENT_LOGIN );
|
||||||
thisState = State.LOGIN;
|
thisState = State.LOGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,14 +248,14 @@ public class ServerConnector extends PacketHandler
|
|||||||
{
|
{
|
||||||
def = null;
|
def = null;
|
||||||
}
|
}
|
||||||
ServerKickEvent event = bungee.getPluginManager().callEvent( new ServerKickEvent( user, kick.message, def ) );
|
ServerKickEvent event = bungee.getPluginManager().callEvent( new ServerKickEvent( user, kick.getMessage(), def ) );
|
||||||
if ( event.isCancelled() && event.getCancelServer() != null )
|
if ( event.isCancelled() && event.getCancelServer() != null )
|
||||||
{
|
{
|
||||||
user.connect( event.getCancelServer() );
|
user.connect( event.getCancelServer() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String message = bungee.getTranslation( "connect_kick" ) + target.getName() + ": " + kick.message;
|
String message = bungee.getTranslation( "connect_kick" ) + target.getName() + ": " + kick.getMessage();
|
||||||
if ( user.getServer() == null )
|
if ( user.getServer() == null )
|
||||||
{
|
{
|
||||||
user.disconnect( message );
|
user.disconnect( message );
|
||||||
@ -265,9 +268,9 @@ public class ServerConnector extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
||||||
{
|
{
|
||||||
if ( ( pluginMessage.data[0] & 0xFF ) == 0 && pluginMessage.tag.equals( "FML" ) )
|
if ( ( pluginMessage.getData()[0] & 0xFF ) == 0 && pluginMessage.getTag().equals( "FML" ) )
|
||||||
{
|
{
|
||||||
ByteArrayDataInput in = ByteStreams.newDataInput( pluginMessage.data );
|
ByteArrayDataInput in = ByteStreams.newDataInput( pluginMessage.getData() );
|
||||||
in.readUnsignedByte();
|
in.readUnsignedByte();
|
||||||
int count = in.readInt();
|
int count = in.readInt();
|
||||||
for ( int i = 0; i < count; i++ )
|
for ( int i = 0; i < count; i++ )
|
||||||
@ -277,7 +280,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
if ( in.readByte() != 0 )
|
if ( in.readByte() != 0 )
|
||||||
{
|
{
|
||||||
// TODO: Using forge flag
|
// TODO: Using forge flag
|
||||||
ch.getHandle().pipeline().get( PacketDecoder.class ).setProtocol( 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.netty.PipelineUtils;
|
||||||
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||||
import net.md_5.bungee.protocol.packet.Packet3Chat;
|
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.PacketCCSettings;
|
||||||
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||||
@ -133,10 +132,15 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
connect( target, false );
|
connect( target, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sendDimensionSwitch()
|
||||||
|
{
|
||||||
|
sendPacket( PacketConstants.DIM1_SWITCH );
|
||||||
|
sendPacket( PacketConstants.DIM2_SWITCH );
|
||||||
|
}
|
||||||
|
|
||||||
public void connectNow(ServerInfo target)
|
public void connectNow(ServerInfo target)
|
||||||
{
|
{
|
||||||
sendPacket( Packet9Respawn.DIM1_SWITCH );
|
sendDimensionSwitch();
|
||||||
sendPacket( Packet9Respawn.DIM2_SWITCH );
|
|
||||||
connect( target );
|
connect( target );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(Packet0KeepAlive alive) throws Exception
|
public void handle(Packet0KeepAlive alive) throws Exception
|
||||||
{
|
{
|
||||||
con.setSentPingId( alive.id );
|
con.setSentPingId( alive.getRandomId() );
|
||||||
con.setSentPingTime( System.currentTimeMillis() );
|
con.setSentPingTime( System.currentTimeMillis() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
public void handle(PacketC9PlayerListItem playerList) throws Exception
|
public void handle(PacketC9PlayerListItem playerList) throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !bungee.getTabListHandler().onListUpdate( con, playerList.username, playerList.online, playerList.ping ) )
|
if ( !bungee.getTabListHandler().onListUpdate( con, playerList.getUsername(), playerList.isOnline(), playerList.getPing() ) )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
@ -96,13 +96,13 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
public void handle(PacketCEScoreboardObjective objective) throws Exception
|
public void handle(PacketCEScoreboardObjective objective) throws Exception
|
||||||
{
|
{
|
||||||
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
||||||
switch ( objective.action )
|
switch ( objective.getAction() )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
serverScoreboard.addObjective( new Objective( objective.name, objective.text ) );
|
serverScoreboard.addObjective( new Objective( objective.getName(), objective.getText() ) );
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
serverScoreboard.removeObjective( objective.name );
|
serverScoreboard.removeObjective( objective.getName() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,15 +111,15 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
public void handle(PacketCFScoreboardScore score) throws Exception
|
public void handle(PacketCFScoreboardScore score) throws Exception
|
||||||
{
|
{
|
||||||
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
||||||
switch ( score.action )
|
switch ( score.getAction() )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
Score s = new Score( score.itemName, score.scoreName, score.value );
|
Score s = new Score( score.getItemName(), score.getScoreName(), score.getValue() );
|
||||||
serverScoreboard.removeScore( score.itemName );
|
serverScoreboard.removeScore( score.getItemName() );
|
||||||
serverScoreboard.addScore( s );
|
serverScoreboard.addScore( s );
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
serverScoreboard.removeScore( score.itemName );
|
serverScoreboard.removeScore( score.getItemName() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,8 +128,8 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
public void handle(PacketD0DisplayScoreboard displayScoreboard) throws Exception
|
public void handle(PacketD0DisplayScoreboard displayScoreboard) throws Exception
|
||||||
{
|
{
|
||||||
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
||||||
serverScoreboard.setName( displayScoreboard.name );
|
serverScoreboard.setName( displayScoreboard.getName() );
|
||||||
serverScoreboard.setPosition( Position.values()[displayScoreboard.position] );
|
serverScoreboard.setPosition( Position.values()[displayScoreboard.getPosition()] );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -137,37 +137,37 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
{
|
{
|
||||||
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
||||||
// Remove team and move on
|
// Remove team and move on
|
||||||
if ( team.mode == 1 )
|
if ( team.getMode() == 1 )
|
||||||
{
|
{
|
||||||
serverScoreboard.removeTeam( team.name );
|
serverScoreboard.removeTeam( team.getName() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create or get old team
|
// Create or get old team
|
||||||
Team t;
|
Team t;
|
||||||
if ( team.mode == 0 )
|
if ( team.getMode() == 0 )
|
||||||
{
|
{
|
||||||
t = new Team( team.name );
|
t = new Team( team.getName() );
|
||||||
serverScoreboard.addTeam( t );
|
serverScoreboard.addTeam( t );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
t = serverScoreboard.getTeam( team.name );
|
t = serverScoreboard.getTeam( team.getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( t != null )
|
if ( t != null )
|
||||||
{
|
{
|
||||||
if ( team.mode == 0 || team.mode == 2 )
|
if ( team.getMode() == 0 || team.getMode() == 2 )
|
||||||
{
|
{
|
||||||
t.setDisplayName( team.displayName );
|
t.setDisplayName( team.getDisplayName() );
|
||||||
t.setPrefix( team.prefix );
|
t.setPrefix( team.getPrefix() );
|
||||||
t.setSuffix( team.suffix );
|
t.setSuffix( team.getSuffix() );
|
||||||
t.setFriendlyMode( team.friendlyFire );
|
t.setFriendlyFire(team.isFriendlyFire() );
|
||||||
}
|
}
|
||||||
if ( team.players != null )
|
if ( team.getPlayers()!= null )
|
||||||
{
|
{
|
||||||
for ( String s : team.players )
|
for ( String s : team.getPlayers() )
|
||||||
{
|
{
|
||||||
if ( team.mode == 0 || team.mode == 3 )
|
if ( team.getMode() == 0 || team.getMode() == 3 )
|
||||||
{
|
{
|
||||||
t.addPlayer( s );
|
t.addPlayer( s );
|
||||||
} else
|
} else
|
||||||
@ -182,20 +182,20 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
||||||
{
|
{
|
||||||
ByteArrayDataInput in = ByteStreams.newDataInput( pluginMessage.data );
|
ByteArrayDataInput in = ByteStreams.newDataInput( pluginMessage.getData() );
|
||||||
PluginMessageEvent event = new PluginMessageEvent( con.getServer(), con, pluginMessage.tag, pluginMessage.data.clone() );
|
PluginMessageEvent event = new PluginMessageEvent( con.getServer(), con, pluginMessage.getTag(), pluginMessage.getData().clone() );
|
||||||
|
|
||||||
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pluginMessage.tag.equals( "MC|TPack" ) && con.getPendingConnection().getListener().getTexturePack() != null )
|
if ( pluginMessage.getTag().equals( "MC|TPack" ) && con.getPendingConnection().getListener().getTexturePack() != null )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pluginMessage.tag.equals( "BungeeCord" ) )
|
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
|
||||||
{
|
{
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
String subChannel = in.readUTF();
|
String subChannel = in.readUTF();
|
||||||
@ -325,7 +325,7 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
{
|
{
|
||||||
def = null;
|
def = null;
|
||||||
}
|
}
|
||||||
ServerKickEvent event = bungee.getPluginManager().callEvent( new ServerKickEvent( con, kick.message, def ) );
|
ServerKickEvent event = bungee.getPluginManager().callEvent( new ServerKickEvent( con, kick.getMessage(), def ) );
|
||||||
if ( event.isCancelled() && event.getCancelServer() != null )
|
if ( event.isCancelled() && event.getCancelServer() != null )
|
||||||
{
|
{
|
||||||
con.connectNow( event.getCancelServer() );
|
con.connectNow( event.getCancelServer() );
|
||||||
|
@ -35,6 +35,7 @@ import net.md_5.bungee.netty.CipherDecoder;
|
|||||||
import net.md_5.bungee.netty.CipherEncoder;
|
import net.md_5.bungee.netty.CipherEncoder;
|
||||||
import net.md_5.bungee.netty.PacketDecoder;
|
import net.md_5.bungee.netty.PacketDecoder;
|
||||||
import net.md_5.bungee.netty.PacketHandler;
|
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.Packet1Login;
|
||||||
import net.md_5.bungee.protocol.packet.Packet2Handshake;
|
import net.md_5.bungee.protocol.packet.Packet2Handshake;
|
||||||
import net.md_5.bungee.protocol.packet.PacketCDClientStatus;
|
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" );
|
Preconditions.checkState( forgeLogin == null, "Already received FORGE LOGIN" );
|
||||||
forgeLogin = login;
|
forgeLogin = login;
|
||||||
|
|
||||||
ch.getHandle().pipeline().get( PacketDecoder.class ).setProtocol( Vanilla.FORGE_PROTOCOL );
|
ch.getHandle().pipeline().get( PacketDecoder.class ).setProtocol( Forge.getInstance() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Packet2Handshake handshake) throws Exception
|
public void handle(Packet2Handshake handshake) throws Exception
|
||||||
{
|
{
|
||||||
Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" );
|
Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" );
|
||||||
if ( handshake.username.length() > 16 )
|
if ( handshake.getUsername().length() > 16 )
|
||||||
{
|
{
|
||||||
disconnect( "Cannot have username longer than 16 characters" );
|
disconnect( "Cannot have username longer than 16 characters" );
|
||||||
return;
|
return;
|
||||||
@ -136,7 +137,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If offline mode and they are already on, don't allow connect
|
// If offline mode and they are already on, don't allow connect
|
||||||
if ( !BungeeCord.getInstance().config.isOnlineMode() && bungee.getPlayer( handshake.username ) != null )
|
if ( !BungeeCord.getInstance().config.isOnlineMode() && bungee.getPlayer( handshake.getUsername() ) != null )
|
||||||
{
|
{
|
||||||
disconnect( bungee.getTranslation( "already_connected" ) );
|
disconnect( bungee.getTranslation( "already_connected" ) );
|
||||||
return;
|
return;
|
||||||
@ -164,7 +165,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
MessageDigest sha = MessageDigest.getInstance( "SHA-1" );
|
MessageDigest sha = MessageDigest.getInstance( "SHA-1" );
|
||||||
for ( byte[] bit : new byte[][]
|
for ( byte[] bit : new byte[][]
|
||||||
{
|
{
|
||||||
request.serverId.getBytes( "ISO_8859_1" ), sharedKey.getEncoded(), EncryptionUtil.keys.getPublic().getEncoded()
|
request.getServerId().getBytes( "ISO_8859_1" ), sharedKey.getEncoded(), EncryptionUtil.keys.getPublic().getEncoded()
|
||||||
} )
|
} )
|
||||||
{
|
{
|
||||||
sha.update( bit );
|
sha.update( bit );
|
||||||
@ -202,7 +203,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
private void finish() throws GeneralSecurityException
|
private void finish() throws GeneralSecurityException
|
||||||
{
|
{
|
||||||
// Check for multiple connections
|
// Check for multiple connections
|
||||||
ProxiedPlayer old = bungee.getPlayer( handshake.username );
|
ProxiedPlayer old = bungee.getPlayer( handshake.getUsername() );
|
||||||
if ( old != null )
|
if ( old != null )
|
||||||
{
|
{
|
||||||
old.disconnect( bungee.getTranslation( "already_connected" ) );
|
old.disconnect( bungee.getTranslation( "already_connected" ) );
|
||||||
@ -223,7 +224,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
thisState = InitialHandler.State.LOGIN;
|
thisState = InitialHandler.State.LOGIN;
|
||||||
ch.write( new PacketFCEncryptionResponse() );
|
ch.write( new PacketFCEncryptionResponse( new byte[ 0 ], new byte[ 0 ] ) );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Cipher encrypt = EncryptionUtil.getCipher( Cipher.ENCRYPT_MODE, sharedKey );
|
Cipher encrypt = EncryptionUtil.getCipher( Cipher.ENCRYPT_MODE, sharedKey );
|
||||||
@ -271,19 +272,19 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return ( handshake == null ) ? null : handshake.username;
|
return ( handshake == null ) ? null : handshake.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte getVersion()
|
public byte getVersion()
|
||||||
{
|
{
|
||||||
return ( handshake == null ) ? -1 : handshake.procolVersion;
|
return ( handshake == null ) ? -1 : handshake.getProcolVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InetSocketAddress getVirtualHost()
|
public InetSocketAddress getVirtualHost()
|
||||||
{
|
{
|
||||||
return ( handshake == null ) ? null : new InetSocketAddress( handshake.host, handshake.port );
|
return ( handshake == null ) ? null : new InetSocketAddress( handshake.getHost(), handshake.getPort() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,7 +34,7 @@ public class PingHandler extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketFFKick kick) throws Exception
|
public void handle(PacketFFKick kick) throws Exception
|
||||||
{
|
{
|
||||||
String[] split = kick.message.split( "\00" );
|
String[] split = kick.getMessage().split( "\00" );
|
||||||
ServerPing ping = new ServerPing( Byte.parseByte( split[1] ), split[2], split[3], Integer.parseInt( split[4] ), Integer.parseInt( split[5] ) );
|
ServerPing ping = new ServerPing( Byte.parseByte( split[1] ), split[2], split[3], Integer.parseInt( split[4] ), Integer.parseInt( split[5] ) );
|
||||||
callback.done( ping, null );
|
callback.done( ping, null );
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(Packet0KeepAlive alive) throws Exception
|
public void handle(Packet0KeepAlive alive) throws Exception
|
||||||
{
|
{
|
||||||
if ( alive.id == con.getSentPingId() )
|
if ( alive.getRandomId() == con.getSentPingId() )
|
||||||
{
|
{
|
||||||
int newPing = (int) ( System.currentTimeMillis() - con.getSentPingTime() );
|
int newPing = (int) ( System.currentTimeMillis() - con.getSentPingTime() );
|
||||||
bungee.getTabListHandler().onPingChange( con, newPing );
|
bungee.getTabListHandler().onPingChange( con, newPing );
|
||||||
@ -83,14 +83,14 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(Packet3Chat chat) throws Exception
|
public void handle(Packet3Chat chat) throws Exception
|
||||||
{
|
{
|
||||||
ChatEvent chatEvent = new ChatEvent( con, con.getServer(), chat.message );
|
ChatEvent chatEvent = new ChatEvent( con, con.getServer(), chat.getMessage() );
|
||||||
if ( bungee.getPluginManager().callEvent( chatEvent ).isCancelled() )
|
if ( bungee.getPluginManager().callEvent( chatEvent ).isCancelled() )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
if ( chatEvent.isCommand() )
|
if ( chatEvent.isCommand() )
|
||||||
{
|
{
|
||||||
if ( bungee.getPluginManager().dispatchCommand( con, chat.message.substring( 1 ) ) )
|
if ( bungee.getPluginManager().dispatchCommand( con, chat.getMessage().substring( 1 ) ) )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
@ -106,12 +106,12 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
public void handle(PacketFAPluginMessage pluginMessage) throws Exception
|
||||||
{
|
{
|
||||||
if ( pluginMessage.tag.equals( "BungeeCord" ) )
|
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginMessageEvent event = new PluginMessageEvent( con, con.getServer(), pluginMessage.tag, pluginMessage.data.clone() );
|
PluginMessageEvent event = new PluginMessageEvent( con, con.getServer(), pluginMessage.getTag(), pluginMessage.getData().clone() );
|
||||||
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
|
Loading…
Reference in New Issue
Block a user