net.minestom.server.crypto.SignedMessageBody Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.crypto;
import net.minestom.server.network.NetworkBuffer;
import net.minestom.server.network.NetworkBufferTemplate;
import org.jetbrains.annotations.NotNull;
import java.time.Instant;
public final class SignedMessageBody {
public record Packed(@NotNull String content, @NotNull Instant timeStamp, long salt,
LastSeenMessages.@NotNull Packed lastSeen) {
public Packed {
if (content.length() > MessageSignature.SIGNATURE_BYTE_LENGTH) {
throw new IllegalArgumentException("Message content too long");
}
}
public static final NetworkBuffer.Type SERIALIZER = NetworkBufferTemplate.template(
NetworkBuffer.STRING, Packed::content,
NetworkBuffer.INSTANT_MS, Packed::timeStamp,
NetworkBuffer.LONG, Packed::salt,
LastSeenMessages.Packed.SERIALIZER, Packed::lastSeen,
Packed::new
);
}
}