mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-27 03:27:56 +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;
|
||||
|
||||
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) {
|
||||
this(reader.readSizedString(256));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
if (message.length() > 256) {
|
||||
throw new IllegalArgumentException("Message cannot be more than 256 characters long.");
|
||||
}
|
||||
writer.writeSizedString(message);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user