Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/SpigotMC/BungeeCord into Sp…
Browse files Browse the repository at this point in the history
…igotMC-master

Conflicts:
	protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java
  • Loading branch information
Zartec committed Mar 29, 2016
2 parents 46c2cd5 + 540e924 commit 3c40db6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,21 @@ public static String readString(ByteBuf buf)

public static void writeArray(byte[] b, ByteBuf buf)
{
Preconditions.checkArgument( b.length <= Short.MAX_VALUE, "Cannot send byte array longer than Short.MAX_VALUE (got %s bytes)", b.length );
writeVarInt( b.length, buf );
buf.writeBytes( b );
}

public static byte[] readArray(ByteBuf buf)
{
byte[] ret = new byte[ readVarInt( buf ) ];
return readArray( buf, Short.MAX_VALUE );
}

public static byte[] readArray(ByteBuf buf, int limit)
{
int len = readVarInt( buf );
Preconditions.checkArgument( len <= limit, "Cannot receive byte array longer than %d (got %s bytes)", limit, len );
byte[] ret = new byte[ len ];
buf.readBytes( ret );
return ret;
}
Expand Down Expand Up @@ -78,6 +86,7 @@ public static byte[] readArrayLegacy(ByteBuf buf)

public static void writeStringArray(List<String> s, ByteBuf buf)
{
Preconditions.checkArgument( s.size() <= 64, "Cannot send string array longer than 64 (got %s strings)", s.size() );
writeVarInt( s.size(), buf );
for ( String str : s )
{
Expand All @@ -88,6 +97,7 @@ public static void writeStringArray(List<String> s, ByteBuf buf)
public static List<String> readStringArray(ByteBuf buf)
{
int len = readVarInt( buf );
Preconditions.checkArgument( len <= 64, "Cannot receive string array longer than 64 (got %s strings)", len );
List<String> ret = new ArrayList<>( len );
for ( int i = 0; i < len; i++ )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco
verifyToken = readArrayLegacy( buf );
} else
{
sharedSecret = readArray( buf );
verifyToken = readArray( buf );
sharedSecret = readArray( buf, 256 );
verifyToken = readArray( buf, 256 );
}
}

Expand Down

0 comments on commit 3c40db6

Please sign in to comment.