mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 11:07:53 +01:00
Move string length check in ClientSettingsPacket
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
f9080fa4f8
commit
fb81578028
@ -11,6 +11,11 @@ public record ClientSettingsPacket(@NotNull String locale, byte viewDistance,
|
|||||||
@NotNull ChatMessageType chatMessageType, boolean chatColors,
|
@NotNull ChatMessageType chatMessageType, boolean chatColors,
|
||||||
byte displayedSkinParts, @NotNull Player.MainHand mainHand,
|
byte displayedSkinParts, @NotNull Player.MainHand mainHand,
|
||||||
boolean disableTextFiltering, boolean allowsListing) implements ClientPacket {
|
boolean disableTextFiltering, boolean allowsListing) implements ClientPacket {
|
||||||
|
public ClientSettingsPacket {
|
||||||
|
if (locale.length() > 128)
|
||||||
|
throw new IllegalArgumentException("Locale cannot be longer than 128 characters.");
|
||||||
|
}
|
||||||
|
|
||||||
public ClientSettingsPacket(BinaryReader reader) {
|
public ClientSettingsPacket(BinaryReader reader) {
|
||||||
this(reader.readSizedString(128), reader.readByte(),
|
this(reader.readSizedString(128), reader.readByte(),
|
||||||
ChatMessageType.fromPacketID(reader.readVarInt()), reader.readBoolean(),
|
ChatMessageType.fromPacketID(reader.readVarInt()), reader.readBoolean(),
|
||||||
@ -20,8 +25,6 @@ public record ClientSettingsPacket(@NotNull String locale, byte viewDistance,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(@NotNull BinaryWriter writer) {
|
public void write(@NotNull BinaryWriter writer) {
|
||||||
if (locale.length() > 128)
|
|
||||||
throw new IllegalArgumentException("Locale cannot be longer than 128 characters.");
|
|
||||||
writer.writeSizedString(locale);
|
writer.writeSizedString(locale);
|
||||||
writer.writeByte(viewDistance);
|
writer.writeByte(viewDistance);
|
||||||
writer.writeVarInt(chatMessageType.getPacketID());
|
writer.writeVarInt(chatMessageType.getPacketID());
|
||||||
|
Loading…
Reference in New Issue
Block a user