Skip to content

Commit

Permalink
Remove 1.7.x Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Thinkofname authored and md-5 committed Feb 29, 2016
1 parent 219819b commit dfaa687
Show file tree
Hide file tree
Showing 29 changed files with 165 additions and 547 deletions.
30 changes: 0 additions & 30 deletions protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java
Expand Up @@ -33,36 +33,6 @@ public static String readString(ByteBuf buf)
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 );
Expand Down

This file was deleted.

This file was deleted.

5 changes: 2 additions & 3 deletions protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
Expand Up @@ -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 );
Expand Down
Expand Up @@ -2,10 +2,8 @@

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
{
Expand Down
Expand Up @@ -28,7 +28,7 @@ public Chat(String message)
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();
}
Expand All @@ -38,7 +38,7 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco
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 );
}
Expand Down
Expand Up @@ -30,10 +30,6 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco
viewDistance = buf.readByte();
chatFlags = buf.readByte();
chatColours = buf.readBoolean();
if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_6 )
{
difficulty = buf.readByte();
}
skinParts = buf.readByte();
}

Expand All @@ -44,10 +40,6 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc
buf.writeByte( viewDistance );
buf.writeByte( chatFlags );
buf.writeBoolean( chatColours );
if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_6 )
{
buf.writeByte( difficulty );
}
buf.writeByte( skinParts );
}

Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down

0 comments on commit dfaa687

Please sign in to comment.