Remove 1.7.x Support
This commit is contained in:
parent
219819b738
commit
dfaa687f71
@ -33,36 +33,6 @@ public abstract class DefinedPacket
|
||||
return new String( b, Charsets.UTF_8 );
|
||||
}
|
||||
|
||||
public static void writeArrayLegacy(byte[] b, ByteBuf buf, boolean allowExtended)
|
||||
{
|
||||
// (Integer.MAX_VALUE & 0x1FFF9A ) = 2097050 - Forge's current upper limit
|
||||
if ( allowExtended )
|
||||
{
|
||||
Preconditions.checkArgument( b.length <= ( Integer.MAX_VALUE & 0x1FFF9A ), "Cannot send array longer than 2097050 (got %s bytes)", b.length );
|
||||
} else
|
||||
{
|
||||
Preconditions.checkArgument( b.length <= Short.MAX_VALUE, "Cannot send array longer than Short.MAX_VALUE (got %s bytes)", b.length );
|
||||
}
|
||||
// Write a 2 or 3 byte number that represents the length of the packet. (3 byte "shorts" for Forge only)
|
||||
// No vanilla packet should give a 3 byte packet, this method will still retain vanilla behaviour.
|
||||
writeVarShort( buf, b.length );
|
||||
buf.writeBytes( b );
|
||||
}
|
||||
|
||||
public static byte[] readArrayLegacy(ByteBuf buf)
|
||||
{
|
||||
// Read in a 2 or 3 byte number that represents the length of the packet. (3 byte "shorts" for Forge only)
|
||||
// No vanilla packet should give a 3 byte packet, this method will still retain vanilla behaviour.
|
||||
int len = readVarShort( buf );
|
||||
|
||||
// (Integer.MAX_VALUE & 0x1FFF9A ) = 2097050 - Forge's current upper limit
|
||||
Preconditions.checkArgument( len <= ( Integer.MAX_VALUE & 0x1FFF9A ), "Cannot receive array longer than 2097050 (got %s bytes)", len );
|
||||
|
||||
byte[] ret = new byte[ len ];
|
||||
buf.readBytes( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void writeArray(byte[] b, ByteBuf buf)
|
||||
{
|
||||
writeVarInt( b.length, buf );
|
||||
|
@ -1,38 +0,0 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class MinecraftInput
|
||||
{
|
||||
|
||||
private final ByteBuf buf;
|
||||
|
||||
public byte readByte()
|
||||
{
|
||||
return buf.readByte();
|
||||
}
|
||||
|
||||
public short readUnsignedByte()
|
||||
{
|
||||
return buf.readUnsignedByte();
|
||||
}
|
||||
|
||||
public int readInt()
|
||||
{
|
||||
return buf.readInt();
|
||||
}
|
||||
|
||||
public String readString()
|
||||
{
|
||||
short len = buf.readShort();
|
||||
char[] c = new char[ len ];
|
||||
for ( int i = 0; i < c.length; i++ )
|
||||
{
|
||||
c[i] = buf.readChar();
|
||||
}
|
||||
|
||||
return new String( c );
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class MinecraftOutput
|
||||
{
|
||||
|
||||
private final ByteBuf buf;
|
||||
|
||||
public MinecraftOutput()
|
||||
{
|
||||
buf = Unpooled.buffer();
|
||||
}
|
||||
|
||||
public byte[] toArray()
|
||||
{
|
||||
if ( buf.hasArray() )
|
||||
{
|
||||
return Arrays.copyOfRange( buf.array(), buf.arrayOffset(), buf.arrayOffset() + buf.writerIndex() );
|
||||
} else
|
||||
{
|
||||
byte[] b = new byte[ buf.writerIndex() ];
|
||||
buf.readBytes( b );
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
public MinecraftOutput writeByte(byte b)
|
||||
{
|
||||
buf.writeByte( b );
|
||||
return this;
|
||||
}
|
||||
|
||||
public void writeInt(int i)
|
||||
{
|
||||
buf.writeInt( i );
|
||||
}
|
||||
|
||||
public void writeString(String s)
|
||||
{
|
||||
char[] cc = s.toCharArray();
|
||||
buf.writeShort( cc.length );
|
||||
for ( char c : cc )
|
||||
{
|
||||
buf.writeChar( c );
|
||||
}
|
||||
}
|
||||
|
||||
public void writeStringUTF8WithoutLengthHeaderBecauseDinnerboneStuffedUpTheMCBrandPacket(String s)
|
||||
{
|
||||
buf.writeBytes( s.getBytes( Charset.forName( "UTF-8" ) ) );
|
||||
}
|
||||
}
|
@ -102,9 +102,8 @@ public enum Protocol
|
||||
/*========================================================================*/
|
||||
public static final int MAX_PACKET_ID = 0xFF;
|
||||
public static List<Integer> supportedVersions = Arrays.asList(
|
||||
ProtocolConstants.MINECRAFT_1_7_2,
|
||||
ProtocolConstants.MINECRAFT_1_7_6,
|
||||
ProtocolConstants.MINECRAFT_1_8
|
||||
ProtocolConstants.MINECRAFT_1_8,
|
||||
ProtocolConstants.MINECRAFT_SNAPSHOT
|
||||
);
|
||||
/*========================================================================*/
|
||||
public final DirectionData TO_SERVER = new DirectionData( ProtocolConstants.Direction.TO_SERVER );
|
||||
|
@ -2,10 +2,8 @@ package net.md_5.bungee.protocol;
|
||||
|
||||
public class ProtocolConstants
|
||||
{
|
||||
|
||||
public static final int MINECRAFT_1_7_2 = 4;
|
||||
public static final int MINECRAFT_1_7_6 = 5;
|
||||
public static final int MINECRAFT_1_8 = 47;
|
||||
public static final int MINECRAFT_SNAPSHOT = 54;
|
||||
|
||||
public enum Direction
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ public class Chat extends DefinedPacket
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
message = readString( buf );
|
||||
if ( direction == ProtocolConstants.Direction.TO_CLIENT && protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
if ( direction == ProtocolConstants.Direction.TO_CLIENT )
|
||||
{
|
||||
position = buf.readByte();
|
||||
}
|
||||
@ -38,7 +38,7 @@ public class Chat extends DefinedPacket
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
writeString( message, buf );
|
||||
if ( direction == ProtocolConstants.Direction.TO_CLIENT && protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
if ( direction == ProtocolConstants.Direction.TO_CLIENT )
|
||||
{
|
||||
buf.writeByte( position );
|
||||
}
|
||||
|
@ -30,10 +30,6 @@ public class ClientSettings extends DefinedPacket
|
||||
viewDistance = buf.readByte();
|
||||
chatFlags = buf.readByte();
|
||||
chatColours = buf.readBoolean();
|
||||
if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_6 )
|
||||
{
|
||||
difficulty = buf.readByte();
|
||||
}
|
||||
skinParts = buf.readByte();
|
||||
}
|
||||
|
||||
@ -44,10 +40,6 @@ public class ClientSettings extends DefinedPacket
|
||||
buf.writeByte( viewDistance );
|
||||
buf.writeByte( chatFlags );
|
||||
buf.writeBoolean( chatColours );
|
||||
if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_6 )
|
||||
{
|
||||
buf.writeByte( difficulty );
|
||||
}
|
||||
buf.writeByte( skinParts );
|
||||
}
|
||||
|
||||
|
@ -24,30 +24,16 @@ public class EncryptionRequest extends DefinedPacket
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
serverId = readString( buf );
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
publicKey = readArrayLegacy( buf );
|
||||
verifyToken = readArrayLegacy( buf );
|
||||
} else
|
||||
{
|
||||
publicKey = readArray( buf );
|
||||
verifyToken = readArray( buf );
|
||||
}
|
||||
publicKey = readArray( buf );
|
||||
verifyToken = readArray( buf );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
writeString( serverId, buf );
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
writeArrayLegacy( publicKey, buf, false );
|
||||
writeArrayLegacy( verifyToken, buf, false );
|
||||
} else
|
||||
{
|
||||
writeArray( publicKey, buf );
|
||||
writeArray( verifyToken, buf );
|
||||
}
|
||||
writeArray( publicKey, buf );
|
||||
writeArray( verifyToken, buf );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,29 +22,15 @@ public class EncryptionResponse extends DefinedPacket
|
||||
@Override
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
sharedSecret = readArrayLegacy( buf );
|
||||
verifyToken = readArrayLegacy( buf );
|
||||
} else
|
||||
{
|
||||
sharedSecret = readArray( buf );
|
||||
verifyToken = readArray( buf );
|
||||
}
|
||||
sharedSecret = readArray( buf );
|
||||
verifyToken = readArray( buf );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
writeArrayLegacy( sharedSecret, buf, false );
|
||||
writeArrayLegacy( verifyToken, buf, false );
|
||||
} else
|
||||
{
|
||||
writeArray( sharedSecret, buf );
|
||||
writeArray( verifyToken, buf );
|
||||
}
|
||||
writeArray( sharedSecret, buf );
|
||||
writeArray( verifyToken, buf );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,25 +21,13 @@ public class KeepAlive extends DefinedPacket
|
||||
@Override
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
randomId = readVarInt( buf );
|
||||
} else
|
||||
{
|
||||
randomId = buf.readInt();
|
||||
}
|
||||
randomId = readVarInt( buf );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
writeVarInt( randomId, buf );
|
||||
} else
|
||||
{
|
||||
buf.writeInt( randomId );
|
||||
}
|
||||
writeVarInt( randomId, buf );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,63 +22,53 @@ public class PlayerListItem extends DefinedPacket
|
||||
@Override
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_8 )
|
||||
action = Action.values()[ DefinedPacket.readVarInt( buf )];
|
||||
items = new Item[ DefinedPacket.readVarInt( buf ) ];
|
||||
for ( int i = 0; i < items.length; i++ )
|
||||
{
|
||||
items = new Item[ 1 ];
|
||||
Item item = items[ 0 ] = new Item();
|
||||
item.displayName = item.username = readString( buf );
|
||||
action = !buf.readBoolean() ? Action.REMOVE_PLAYER : Action.ADD_PLAYER;
|
||||
item.ping = buf.readShort();
|
||||
} else
|
||||
{
|
||||
action = Action.values()[ DefinedPacket.readVarInt( buf )];
|
||||
items = new Item[ DefinedPacket.readVarInt( buf ) ];
|
||||
for ( int i = 0; i < items.length; i++ )
|
||||
Item item = items[ i ] = new Item();
|
||||
item.setUuid( DefinedPacket.readUUID( buf ) );
|
||||
switch ( action )
|
||||
{
|
||||
Item item = items[ i ] = new Item();
|
||||
item.setUuid( DefinedPacket.readUUID( buf ) );
|
||||
switch ( action )
|
||||
{
|
||||
case ADD_PLAYER:
|
||||
item.username = DefinedPacket.readString( buf );
|
||||
item.properties = new String[ DefinedPacket.readVarInt( buf ) ][];
|
||||
for ( int j = 0; j < item.properties.length; j++ )
|
||||
{
|
||||
String name = DefinedPacket.readString( buf );
|
||||
String value = DefinedPacket.readString( buf );
|
||||
if ( buf.readBoolean() )
|
||||
{
|
||||
item.properties[ j] = new String[]
|
||||
{
|
||||
name, value, DefinedPacket.readString( buf )
|
||||
};
|
||||
} else
|
||||
{
|
||||
item.properties[ j ] = new String[]
|
||||
{
|
||||
name, value
|
||||
};
|
||||
}
|
||||
}
|
||||
item.gamemode = DefinedPacket.readVarInt( buf );
|
||||
item.ping = DefinedPacket.readVarInt( buf );
|
||||
case ADD_PLAYER:
|
||||
item.username = DefinedPacket.readString( buf );
|
||||
item.properties = new String[ DefinedPacket.readVarInt( buf ) ][];
|
||||
for ( int j = 0; j < item.properties.length; j++ )
|
||||
{
|
||||
String name = DefinedPacket.readString( buf );
|
||||
String value = DefinedPacket.readString( buf );
|
||||
if ( buf.readBoolean() )
|
||||
{
|
||||
item.displayName = DefinedPacket.readString( buf );
|
||||
}
|
||||
break;
|
||||
case UPDATE_GAMEMODE:
|
||||
item.gamemode = DefinedPacket.readVarInt( buf );
|
||||
break;
|
||||
case UPDATE_LATENCY:
|
||||
item.ping = DefinedPacket.readVarInt( buf );
|
||||
break;
|
||||
case UPDATE_DISPLAY_NAME:
|
||||
if ( buf.readBoolean() )
|
||||
item.properties[ j] = new String[]
|
||||
{
|
||||
name, value, DefinedPacket.readString( buf )
|
||||
};
|
||||
} else
|
||||
{
|
||||
item.displayName = DefinedPacket.readString( buf );
|
||||
item.properties[ j ] = new String[]
|
||||
{
|
||||
name, value
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
item.gamemode = DefinedPacket.readVarInt( buf );
|
||||
item.ping = DefinedPacket.readVarInt( buf );
|
||||
if ( buf.readBoolean() )
|
||||
{
|
||||
item.displayName = DefinedPacket.readString( buf );
|
||||
}
|
||||
break;
|
||||
case UPDATE_GAMEMODE:
|
||||
item.gamemode = DefinedPacket.readVarInt( buf );
|
||||
break;
|
||||
case UPDATE_LATENCY:
|
||||
item.ping = DefinedPacket.readVarInt( buf );
|
||||
break;
|
||||
case UPDATE_DISPLAY_NAME:
|
||||
if ( buf.readBoolean() )
|
||||
{
|
||||
item.displayName = DefinedPacket.readString( buf );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,59 +76,50 @@ public class PlayerListItem extends DefinedPacket
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_8 )
|
||||
DefinedPacket.writeVarInt( action.ordinal(), buf );
|
||||
DefinedPacket.writeVarInt( items.length, buf );
|
||||
for ( Item item : items )
|
||||
{
|
||||
Item item = items[0]; // Only one at a time
|
||||
writeString( item.displayName, buf ); // TODO: Server unique only!
|
||||
buf.writeBoolean( action != Action.REMOVE_PLAYER );
|
||||
buf.writeShort( item.ping );
|
||||
} else
|
||||
{
|
||||
DefinedPacket.writeVarInt( action.ordinal(), buf );
|
||||
DefinedPacket.writeVarInt( items.length, buf );
|
||||
for ( Item item : items )
|
||||
DefinedPacket.writeUUID( item.uuid, buf );
|
||||
switch ( action )
|
||||
{
|
||||
DefinedPacket.writeUUID( item.uuid, buf );
|
||||
switch ( action )
|
||||
{
|
||||
case ADD_PLAYER:
|
||||
DefinedPacket.writeString( item.username, buf );
|
||||
DefinedPacket.writeVarInt( item.properties.length, buf );
|
||||
for ( String[] prop : item.properties )
|
||||
case ADD_PLAYER:
|
||||
DefinedPacket.writeString( item.username, buf );
|
||||
DefinedPacket.writeVarInt( item.properties.length, buf );
|
||||
for ( String[] prop : item.properties )
|
||||
{
|
||||
DefinedPacket.writeString( prop[ 0], buf );
|
||||
DefinedPacket.writeString( prop[ 1], buf );
|
||||
if ( prop.length >= 3 )
|
||||
{
|
||||
DefinedPacket.writeString( prop[ 0], buf );
|
||||
DefinedPacket.writeString( prop[ 1], buf );
|
||||
if ( prop.length >= 3 )
|
||||
{
|
||||
buf.writeBoolean( true );
|
||||
DefinedPacket.writeString( prop[ 2], buf );
|
||||
} else
|
||||
{
|
||||
buf.writeBoolean( false );
|
||||
}
|
||||
}
|
||||
DefinedPacket.writeVarInt( item.gamemode, buf );
|
||||
DefinedPacket.writeVarInt( item.ping, buf );
|
||||
buf.writeBoolean( item.displayName != null );
|
||||
if ( item.displayName != null )
|
||||
buf.writeBoolean( true );
|
||||
DefinedPacket.writeString( prop[ 2], buf );
|
||||
} else
|
||||
{
|
||||
DefinedPacket.writeString( item.displayName, buf );
|
||||
buf.writeBoolean( false );
|
||||
}
|
||||
break;
|
||||
case UPDATE_GAMEMODE:
|
||||
DefinedPacket.writeVarInt( item.gamemode, buf );
|
||||
break;
|
||||
case UPDATE_LATENCY:
|
||||
DefinedPacket.writeVarInt( item.ping, buf );
|
||||
break;
|
||||
case UPDATE_DISPLAY_NAME:
|
||||
buf.writeBoolean( item.displayName != null );
|
||||
if ( item.displayName != null )
|
||||
{
|
||||
DefinedPacket.writeString( item.displayName, buf );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
DefinedPacket.writeVarInt( item.gamemode, buf );
|
||||
DefinedPacket.writeVarInt( item.ping, buf );
|
||||
buf.writeBoolean( item.displayName != null );
|
||||
if ( item.displayName != null )
|
||||
{
|
||||
DefinedPacket.writeString( item.displayName, buf );
|
||||
}
|
||||
break;
|
||||
case UPDATE_GAMEMODE:
|
||||
DefinedPacket.writeVarInt( item.gamemode, buf );
|
||||
break;
|
||||
case UPDATE_LATENCY:
|
||||
DefinedPacket.writeVarInt( item.ping, buf );
|
||||
break;
|
||||
case UPDATE_DISPLAY_NAME:
|
||||
buf.writeBoolean( item.displayName != null );
|
||||
if ( item.displayName != null )
|
||||
{
|
||||
DefinedPacket.writeString( item.displayName, buf );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package net.md_5.bungee.protocol.packet;
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
@ -11,7 +10,6 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.protocol.MinecraftInput;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
|
||||
@ -34,29 +32,17 @@ public class PluginMessage extends DefinedPacket
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
tag = readString( buf );
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
data = readArrayLegacy( buf );
|
||||
} else
|
||||
{
|
||||
int maxSize = direction == ProtocolConstants.Direction.TO_SERVER ? Short.MAX_VALUE : 0x100000;
|
||||
Preconditions.checkArgument(buf.readableBytes() < maxSize);
|
||||
data = new byte[ buf.readableBytes() ];
|
||||
buf.readBytes( data );
|
||||
}
|
||||
int maxSize = direction == ProtocolConstants.Direction.TO_SERVER ? Short.MAX_VALUE : 0x100000;
|
||||
Preconditions.checkArgument(buf.readableBytes() < maxSize);
|
||||
data = new byte[ buf.readableBytes() ];
|
||||
buf.readBytes( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
writeString( tag, buf );
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
writeArrayLegacy( data, buf, allowExtendedPacket );
|
||||
} else
|
||||
{
|
||||
buf.writeBytes( data );
|
||||
}
|
||||
buf.writeBytes( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,9 +55,4 @@ public class PluginMessage extends DefinedPacket
|
||||
{
|
||||
return new DataInputStream( new ByteArrayInputStream( data ) );
|
||||
}
|
||||
|
||||
public MinecraftInput getMCStream()
|
||||
{
|
||||
return new MinecraftInput( Unpooled.wrappedBuffer( data ) );
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,8 @@ public class ScoreboardObjective extends DefinedPacket
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
name = readString( buf );
|
||||
if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_6 )
|
||||
{
|
||||
value = readString( buf );
|
||||
}
|
||||
action = buf.readByte();
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 && ( action == 0 || action == 2 ) )
|
||||
if ( action == 0 || action == 2 )
|
||||
{
|
||||
value = readString( buf );
|
||||
type = readString( buf );
|
||||
@ -44,12 +40,8 @@ public class ScoreboardObjective extends DefinedPacket
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
writeString( name, buf );
|
||||
if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_6 )
|
||||
{
|
||||
writeString( value, buf );
|
||||
}
|
||||
buf.writeByte( action );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 && ( action == 0 || action == 2 ) )
|
||||
if ( action == 0 || action == 2 )
|
||||
{
|
||||
writeString( value, buf );
|
||||
writeString( type, buf );
|
||||
|
@ -29,20 +29,10 @@ public class ScoreboardScore extends DefinedPacket
|
||||
{
|
||||
itemName = readString( buf );
|
||||
action = buf.readByte();
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
scoreName = readString( buf );
|
||||
if ( action != 1 )
|
||||
{
|
||||
scoreName = readString( buf );
|
||||
if ( action != 1 )
|
||||
{
|
||||
value = readVarInt( buf );
|
||||
}
|
||||
} else
|
||||
{
|
||||
if ( action != 1 )
|
||||
{
|
||||
scoreName = readString( buf );
|
||||
value = buf.readInt();
|
||||
}
|
||||
value = readVarInt( buf );
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,20 +41,10 @@ public class ScoreboardScore extends DefinedPacket
|
||||
{
|
||||
writeString( itemName, buf );
|
||||
buf.writeByte( action );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
writeString( scoreName, buf );
|
||||
if ( action != 1 )
|
||||
{
|
||||
writeString( scoreName, buf );
|
||||
if ( action != 1 )
|
||||
{
|
||||
writeVarInt( value, buf );
|
||||
}
|
||||
} else
|
||||
{
|
||||
if ( action != 1 )
|
||||
{
|
||||
writeString( scoreName, buf );
|
||||
buf.writeInt( value );
|
||||
}
|
||||
writeVarInt( value, buf );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,9 @@ public class TabCompleteRequest extends DefinedPacket
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
cursor = readString( buf );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
if ( hasPositon = buf.readBoolean() )
|
||||
{
|
||||
if ( hasPositon = buf.readBoolean() )
|
||||
{
|
||||
position = buf.readLong();
|
||||
}
|
||||
position = buf.readLong();
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,13 +34,10 @@ public class TabCompleteRequest extends DefinedPacket
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
writeString( cursor, buf );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
buf.writeBoolean( hasPositon );
|
||||
if ( hasPositon )
|
||||
{
|
||||
buf.writeBoolean( hasPositon );
|
||||
if ( hasPositon )
|
||||
{
|
||||
buf.writeLong( position );
|
||||
}
|
||||
buf.writeLong( position );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,15 +50,12 @@ public class Team extends DefinedPacket
|
||||
prefix = readString( buf );
|
||||
suffix = readString( buf );
|
||||
friendlyFire = buf.readByte();
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
nameTagVisibility = readString( buf );
|
||||
color = buf.readByte();
|
||||
}
|
||||
nameTagVisibility = readString( buf );
|
||||
color = buf.readByte();
|
||||
}
|
||||
if ( mode == 0 || mode == 3 || mode == 4 )
|
||||
{
|
||||
int len = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ) ? readVarInt( buf ) : buf.readShort();
|
||||
int len = readVarInt( buf );
|
||||
players = new String[ len ];
|
||||
for ( int i = 0; i < len; i++ )
|
||||
{
|
||||
@ -78,21 +75,12 @@ public class Team extends DefinedPacket
|
||||
writeString( prefix, buf );
|
||||
writeString( suffix, buf );
|
||||
buf.writeByte( friendlyFire );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
writeString( nameTagVisibility, buf );
|
||||
buf.writeByte( color );
|
||||
}
|
||||
writeString( nameTagVisibility, buf );
|
||||
buf.writeByte( color );
|
||||
}
|
||||
if ( mode == 0 || mode == 3 || mode == 4 )
|
||||
{
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
writeVarInt( players.length, buf );
|
||||
} else
|
||||
{
|
||||
buf.writeShort( players.length );
|
||||
}
|
||||
writeVarInt( players.length, buf );
|
||||
for ( String player : players )
|
||||
{
|
||||
writeString( player, buf );
|
||||
|
@ -139,10 +139,7 @@ public class BungeeCord extends ProxyServer
|
||||
@Getter
|
||||
private final Logger logger;
|
||||
public final Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer( ProtocolConstants.MINECRAFT_1_7_6 ) )
|
||||
.registerTypeAdapter( Favicon.class, Favicon.getFaviconTypeAdapter() ).create();
|
||||
public final Gson gsonLegacy = new GsonBuilder()
|
||||
.registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer( ProtocolConstants.MINECRAFT_1_7_2 ) )
|
||||
.registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer() )
|
||||
.registerTypeAdapter( Favicon.class, Favicon.getFaviconTypeAdapter() ).create();
|
||||
@Getter
|
||||
private ConnectionThrottle connectionThrottle;
|
||||
|
@ -152,16 +152,11 @@ public class BungeeTitle implements Title
|
||||
@Override
|
||||
public Title send(ProxiedPlayer player)
|
||||
{
|
||||
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
// Send the packets in the correct order
|
||||
sendPacket( player, clear );
|
||||
sendPacket( player, reset );
|
||||
sendPacket( player, times );
|
||||
sendPacket( player, subtitle );
|
||||
sendPacket( player, title );
|
||||
}
|
||||
|
||||
sendPacket( player, clear );
|
||||
sendPacket( player, reset );
|
||||
sendPacket( player, times );
|
||||
sendPacket( player, subtitle );
|
||||
sendPacket( player, title );
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -14,21 +14,13 @@ import java.util.UUID;
|
||||
|
||||
public class PlayerInfoSerializer implements JsonSerializer<ServerPing.PlayerInfo>, JsonDeserializer<ServerPing.PlayerInfo>
|
||||
{
|
||||
|
||||
private final int protocol;
|
||||
|
||||
public PlayerInfoSerializer(int protocol)
|
||||
{
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerPing.PlayerInfo deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
JsonObject js = json.getAsJsonObject();
|
||||
ServerPing.PlayerInfo info = new ServerPing.PlayerInfo( js.get( "name" ).getAsString(), (UUID) null );
|
||||
String id = js.get( "id" ).getAsString();
|
||||
if ( protocol == 4 || !id.contains( "-" ) )
|
||||
if ( !id.contains( "-" ) )
|
||||
{
|
||||
info.setId( id );
|
||||
} else
|
||||
@ -43,13 +35,7 @@ public class PlayerInfoSerializer implements JsonSerializer<ServerPing.PlayerInf
|
||||
{
|
||||
JsonObject out = new JsonObject();
|
||||
out.addProperty( "name", src.getName() );
|
||||
if ( protocol == 4 )
|
||||
{
|
||||
out.addProperty( "id", src.getId() );
|
||||
} else
|
||||
{
|
||||
out.addProperty( "id", src.getUniqueId().toString() );
|
||||
}
|
||||
out.addProperty( "id", src.getUniqueId().toString() );
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.netty.HandlerBoss;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.MinecraftOutput;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||
@ -193,18 +192,10 @@ public class ServerConnector extends PacketHandler
|
||||
|
||||
user.unsafe().sendPacket( modLogin );
|
||||
|
||||
if ( user.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
MinecraftOutput out = new MinecraftOutput();
|
||||
out.writeStringUTF8WithoutLengthHeaderBecauseDinnerboneStuffedUpTheMCBrandPacket( ProxyServer.getInstance().getName() + " (" + ProxyServer.getInstance().getVersion() + ")" );
|
||||
user.unsafe().sendPacket( new PluginMessage( "MC|Brand", out.toArray(), handshakeHandler.isServerForge() ) );
|
||||
} else
|
||||
{
|
||||
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
|
||||
user.unsafe().sendPacket( new PluginMessage( "MC|Brand", brand.array().clone(), handshakeHandler.isServerForge() ) );
|
||||
brand.release();
|
||||
}
|
||||
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
|
||||
user.unsafe().sendPacket( new PluginMessage( "MC|Brand", brand.array().clone(), handshakeHandler.isServerForge() ) );
|
||||
brand.release();
|
||||
} else
|
||||
{
|
||||
user.getServer().setObsolete( true );
|
||||
|
@ -391,7 +391,7 @@ public final class UserConnection implements ProxiedPlayer
|
||||
public void sendMessage(ChatMessageType position, BaseComponent... message)
|
||||
{
|
||||
// Action bar doesn't display the new JSON formattings, legacy works - send it using this for now
|
||||
if ( position == ChatMessageType.ACTION_BAR && pendingConnection.getVersion() >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
if ( position == ChatMessageType.ACTION_BAR )
|
||||
{
|
||||
sendMessage( position, ComponentSerializer.toString( new TextComponent( TextComponent.toLegacyText( message ) ) ) );
|
||||
} else
|
||||
@ -404,7 +404,7 @@ public final class UserConnection implements ProxiedPlayer
|
||||
public void sendMessage(ChatMessageType position, BaseComponent message)
|
||||
{
|
||||
// Action bar doesn't display the new JSON formattings, legacy works - send it using this for now
|
||||
if ( position == ChatMessageType.ACTION_BAR && pendingConnection.getVersion() >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
if ( position == ChatMessageType.ACTION_BAR )
|
||||
{
|
||||
sendMessage( position, ComponentSerializer.toString( new TextComponent( TextComponent.toLegacyText( message ) ) ) );
|
||||
} else
|
||||
@ -541,25 +541,19 @@ public final class UserConnection implements ProxiedPlayer
|
||||
@Override
|
||||
public void setTabHeader(BaseComponent header, BaseComponent footer)
|
||||
{
|
||||
if ( pendingConnection.getVersion() >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
unsafe().sendPacket( new PlayerListHeaderFooter(
|
||||
( header != null ) ? ComponentSerializer.toString( header ) : EMPTY_TEXT,
|
||||
( footer != null ) ? ComponentSerializer.toString( footer ) : EMPTY_TEXT
|
||||
) );
|
||||
}
|
||||
unsafe().sendPacket( new PlayerListHeaderFooter(
|
||||
( header != null ) ? ComponentSerializer.toString( header ) : EMPTY_TEXT,
|
||||
( footer != null ) ? ComponentSerializer.toString( footer ) : EMPTY_TEXT
|
||||
) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTabHeader(BaseComponent[] header, BaseComponent[] footer)
|
||||
{
|
||||
if ( pendingConnection.getVersion() >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
unsafe().sendPacket( new PlayerListHeaderFooter(
|
||||
( header != null ) ? ComponentSerializer.toString( header ) : EMPTY_TEXT,
|
||||
( footer != null ) ? ComponentSerializer.toString( footer ) : EMPTY_TEXT
|
||||
) );
|
||||
}
|
||||
unsafe().sendPacket( new PlayerListHeaderFooter(
|
||||
( header != null ) ? ComponentSerializer.toString( header ) : EMPTY_TEXT,
|
||||
( footer != null ) ? ComponentSerializer.toString( footer ) : EMPTY_TEXT
|
||||
) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -229,28 +229,13 @@ public class DownstreamBridge extends PacketHandler
|
||||
|
||||
if ( pluginMessage.getTag().equals( "MC|Brand" ) )
|
||||
{
|
||||
if ( con.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
try
|
||||
{
|
||||
ByteBuf brand = Unpooled.wrappedBuffer( pluginMessage.getData() );
|
||||
String serverBrand = DefinedPacket.readString( brand );
|
||||
brand.release();
|
||||
brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")" + " <- " + serverBrand, brand );
|
||||
pluginMessage.setData( brand.array().clone() );
|
||||
brand.release();
|
||||
} catch ( Exception ignored )
|
||||
{
|
||||
// TODO: Remove this
|
||||
// Older spigot protocol builds sent the brand incorrectly
|
||||
return;
|
||||
}
|
||||
} else
|
||||
{
|
||||
String serverBrand = new String( pluginMessage.getData(), "UTF-8" );
|
||||
pluginMessage.setData( ( bungee.getName() + " (" + bungee.getVersion() + ")" + " <- " + serverBrand ).getBytes( "UTF-8" ) );
|
||||
}
|
||||
ByteBuf brand = Unpooled.wrappedBuffer( pluginMessage.getData() );
|
||||
String serverBrand = DefinedPacket.readString( brand );
|
||||
brand.release();
|
||||
brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")" + " <- " + serverBrand, brand );
|
||||
pluginMessage.setData( brand.array().clone() );
|
||||
brand.release();
|
||||
// changes in the packet are ignored so we need to send it manually
|
||||
con.unsafe().sendPacket( pluginMessage );
|
||||
throw CancelSendSignal.INSTANCE;
|
||||
|
@ -213,7 +213,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
public void done(ProxyPingEvent pingResult, Throwable error)
|
||||
{
|
||||
BungeeCord.getInstance().getConnectionThrottle().unthrottle( getAddress().getAddress() );
|
||||
Gson gson = handshake.getProtocolVersion() == ProtocolConstants.MINECRAFT_1_7_2 ? BungeeCord.getInstance().gsonLegacy : BungeeCord.getInstance().gson;
|
||||
Gson gson = BungeeCord.getInstance().gson;
|
||||
unsafe.sendPacket( new StatusResponse( gson.toJson( pingResult.getResponse() ) ) );
|
||||
}
|
||||
};
|
||||
@ -478,13 +478,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
userCon.setCompressionThreshold( BungeeCord.getInstance().config.getCompressionThreshold() );
|
||||
userCon.init();
|
||||
|
||||
if ( getVersion() >= ProtocolConstants.MINECRAFT_1_7_6 )
|
||||
{
|
||||
unsafe.sendPacket( new LoginSuccess( getUniqueId().toString(), getName() ) ); // With dashes in between
|
||||
} else
|
||||
{
|
||||
unsafe.sendPacket( new LoginSuccess( getUUID(), getName() ) ); // Without dashes, for older clients.
|
||||
}
|
||||
unsafe.sendPacket( new LoginSuccess( getUniqueId().toString(), getName() ) ); // With dashes in between
|
||||
ch.setProtocol( Protocol.GAME );
|
||||
|
||||
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
|
||||
|
@ -53,7 +53,7 @@ public class PingHandler extends PacketHandler
|
||||
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
|
||||
public void handle(StatusResponse statusResponse) throws Exception
|
||||
{
|
||||
Gson gson = protocol == ProtocolConstants.MINECRAFT_1_7_2 ? BungeeCord.getInstance().gsonLegacy : BungeeCord.getInstance().gson;
|
||||
Gson gson = BungeeCord.getInstance().gson;
|
||||
callback.done( gson.fromJson( statusResponse.getResponse(), ServerPing.class ), null );
|
||||
channel.close();
|
||||
}
|
||||
|
@ -74,10 +74,7 @@ public class UpstreamBridge extends PacketHandler
|
||||
} );
|
||||
for ( ProxiedPlayer player : con.getServer().getInfo().getPlayers() )
|
||||
{
|
||||
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
player.unsafe().sendPacket( packet );
|
||||
}
|
||||
player.unsafe().sendPacket( packet );
|
||||
}
|
||||
con.getServer().disconnect( "Quitting" );
|
||||
}
|
||||
|
@ -25,10 +25,6 @@ public abstract class EntityMap
|
||||
{
|
||||
switch ( version )
|
||||
{
|
||||
case ProtocolConstants.MINECRAFT_1_7_2:
|
||||
return EntityMap_1_7_2.INSTANCE;
|
||||
case ProtocolConstants.MINECRAFT_1_7_6:
|
||||
return EntityMap_1_7_6.INSTANCE;
|
||||
case ProtocolConstants.MINECRAFT_1_8:
|
||||
return EntityMap_1_8.INSTANCE;
|
||||
}
|
||||
|
@ -87,19 +87,15 @@ enum ForgeClientHandshakeState implements IForgeClientPacketHandler<ForgeClientH
|
||||
Map<String, String> clientModList = ForgeUtils.readModList( message );
|
||||
con.getForgeClientHandler().setClientModList( clientModList );
|
||||
|
||||
// If the user is running 1.8 or above, we don't need to check the version of FML - it's always an OK version.
|
||||
if ( con.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
// Get the version from the mod list.
|
||||
int buildNumber = ForgeUtils.getFmlBuildNumber( clientModList );
|
||||
// Get the version from the mod list.
|
||||
int buildNumber = ForgeUtils.getFmlBuildNumber( clientModList );
|
||||
|
||||
// If we get 0, we're probably using a testing build, so let it though. Otherwise, check the build number.
|
||||
if ( buildNumber < ForgeConstants.FML_MIN_BUILD_VERSION && buildNumber != 0 )
|
||||
{
|
||||
// Mark the user as an old Forge user. This will then cause any Forge ServerConnectors to cancel any
|
||||
// connections to it.
|
||||
con.getForgeClientHandler().setForgeOutdated( true );
|
||||
}
|
||||
// If we get 0, we're probably using a testing build, so let it though. Otherwise, check the build number.
|
||||
if ( buildNumber < ForgeConstants.FML_MIN_BUILD_VERSION && buildNumber != 0 )
|
||||
{
|
||||
// Mark the user as an old Forge user. This will then cause any Forge ServerConnectors to cancel any
|
||||
// connections to it.
|
||||
con.getForgeClientHandler().setForgeOutdated( true );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,24 +90,7 @@ public class Global extends TabList
|
||||
item.setGamemode( ( (UserConnection) p ).getGamemode() );
|
||||
item.setPing( p.getPing() );
|
||||
}
|
||||
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
player.unsafe().sendPacket( playerListItem );
|
||||
} else
|
||||
{
|
||||
// Split up the packet
|
||||
for ( PlayerListItem.Item item : playerListItem.getItems() )
|
||||
{
|
||||
PlayerListItem packet = new PlayerListItem();
|
||||
packet.setAction( playerListItem.getAction() );
|
||||
|
||||
packet.setItems( new PlayerListItem.Item[]
|
||||
{
|
||||
item
|
||||
} );
|
||||
player.unsafe().sendPacket( packet );
|
||||
}
|
||||
}
|
||||
player.unsafe().sendPacket( playerListItem );
|
||||
PlayerListItem packet = new PlayerListItem();
|
||||
packet.setAction( PlayerListItem.Action.ADD_PLAYER );
|
||||
PlayerListItem.Item item = new PlayerListItem.Item();
|
||||
|
@ -12,7 +12,6 @@ public class ServerUnique extends TabList
|
||||
{
|
||||
|
||||
private final Collection<UUID> uuids = new HashSet<>();
|
||||
private final Collection<String> usernames = new HashSet<>(); // Support for <=1.7.9
|
||||
|
||||
public ServerUnique(ProxiedPlayer player)
|
||||
{
|
||||
@ -26,22 +25,10 @@ public class ServerUnique extends TabList
|
||||
{
|
||||
if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER )
|
||||
{
|
||||
if ( item.getUuid() != null )
|
||||
{
|
||||
uuids.add( item.getUuid() );
|
||||
} else
|
||||
{
|
||||
usernames.add( item.getUsername() );
|
||||
}
|
||||
uuids.add( item.getUuid() );
|
||||
} else if ( playerListItem.getAction() == PlayerListItem.Action.REMOVE_PLAYER )
|
||||
{
|
||||
if ( item.getUuid() != null )
|
||||
{
|
||||
uuids.remove( item.getUuid() );
|
||||
} else
|
||||
{
|
||||
usernames.remove( item.getUsername() );
|
||||
}
|
||||
uuids.remove( item.getUuid() );
|
||||
}
|
||||
}
|
||||
player.unsafe().sendPacket( playerListItem );
|
||||
@ -58,40 +45,16 @@ public class ServerUnique extends TabList
|
||||
{
|
||||
PlayerListItem packet = new PlayerListItem();
|
||||
packet.setAction( PlayerListItem.Action.REMOVE_PLAYER );
|
||||
PlayerListItem.Item[] items = new PlayerListItem.Item[ uuids.size() + usernames.size() ];
|
||||
PlayerListItem.Item[] items = new PlayerListItem.Item[ uuids.size() ];
|
||||
int i = 0;
|
||||
for ( UUID uuid : uuids )
|
||||
{
|
||||
PlayerListItem.Item item = items[i++] = new PlayerListItem.Item();
|
||||
item.setUuid( uuid );
|
||||
}
|
||||
for ( String username : usernames )
|
||||
{
|
||||
PlayerListItem.Item item = items[i++] = new PlayerListItem.Item();
|
||||
item.setUsername( username );
|
||||
item.setDisplayName( username );
|
||||
}
|
||||
packet.setItems( items );
|
||||
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_8 )
|
||||
{
|
||||
player.unsafe().sendPacket( packet );
|
||||
} else
|
||||
{
|
||||
// Split up the packet
|
||||
for ( PlayerListItem.Item item : packet.getItems() )
|
||||
{
|
||||
PlayerListItem p2 = new PlayerListItem();
|
||||
p2.setAction( packet.getAction() );
|
||||
|
||||
p2.setItems( new PlayerListItem.Item[]
|
||||
{
|
||||
item
|
||||
} );
|
||||
player.unsafe().sendPacket( p2 );
|
||||
}
|
||||
}
|
||||
player.unsafe().sendPacket( packet );
|
||||
uuids.clear();
|
||||
usernames.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user