Refactor packet string charset

This commit is contained in:
P0nk
2021-06-21 22:03:20 +02:00
parent c4c5700d32
commit 72ff8d563b
4 changed files with 9 additions and 12 deletions

View File

@@ -47,12 +47,9 @@ public class ByteBufInPacket implements InPacket {
@Override
public String readString() {
short length = readShort();
char[] characters = new char[length];
for(int i = 0; i < length; i++) {
characters[i] = (char) readByte();
}
return String.valueOf(characters);
byte[] stringBytes = new byte[length];
byteBuf.readBytes(stringBytes);
return new String(stringBytes, STRING_CHARSET);
}
@Override