mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 12:07:42 +01:00
Move warning to constructor
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
8f8ee4f7d2
commit
9a90018a8b
@ -6,15 +6,18 @@ import net.minestom.server.utils.binary.BinaryWriter;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public record ClientChatMessagePacket(@NotNull String message) implements ClientPacket {
|
public record ClientChatMessagePacket(@NotNull String message) implements ClientPacket {
|
||||||
|
public ClientChatMessagePacket {
|
||||||
|
if (message.length() > 256) {
|
||||||
|
throw new IllegalArgumentException("Message cannot be more than 256 characters long.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ClientChatMessagePacket(BinaryReader reader) {
|
public ClientChatMessagePacket(BinaryReader reader) {
|
||||||
this(reader.readSizedString(256));
|
this(reader.readSizedString(256));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(@NotNull BinaryWriter writer) {
|
public void write(@NotNull BinaryWriter writer) {
|
||||||
if (message.length() > 256) {
|
|
||||||
throw new IllegalArgumentException("Message cannot be more than 256 characters long.");
|
|
||||||
}
|
|
||||||
writer.writeSizedString(message);
|
writer.writeSizedString(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user