diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java index e0259b033..7da858d9f 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java @@ -97,22 +97,6 @@ public enum ProtocolUtils { } } - public static String readString(ByteBuf buf) { - return readString(buf, DEFAULT_MAX_STRING_SIZE); - } - - /** - * Reads a VarInt length-prefixed UTF-8 string from the {@code buf}, making sure to not go over - * {@code cap} size. - * @param buf the buffer to read from - * @param cap the maximum size of the string, in UTF-8 character length - * @return the decoded string - */ - public static String readString(ByteBuf buf, int cap) { - int length = readVarInt(buf); - return readString(buf, cap, length); - } - /** * Reads a VarInt length-prefixed ASCII string from the {@code buf}, making sure to not go over * {@code cap} size. This method is specialized for select parts of the Minecraft protocol where @@ -131,6 +115,22 @@ public enum ProtocolUtils { return str; } + public static String readString(ByteBuf buf) { + return readString(buf, DEFAULT_MAX_STRING_SIZE); + } + + /** + * Reads a VarInt length-prefixed UTF-8 string from the {@code buf}, making sure to not go over + * {@code cap} size. + * @param buf the buffer to read from + * @param cap the maximum size of the string, in UTF-8 character length + * @return the decoded string + */ + public static String readString(ByteBuf buf, int cap) { + int length = readVarInt(buf); + return readString(buf, cap, length); + } + private static String readString(ByteBuf buf, int cap, int length) { checkFrame(length >= 0, "Got a negative-length string (%s)", length); // `cap` is interpreted as a UTF-8 character length. To cover the full Unicode plane, we must