Remove 1.7.x Support
This commit is contained in:
@@ -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 );
|
||||
|
Reference in New Issue
Block a user