SignedMessageBody.java
net.minecraft.network.chat.SignedMessageBody
信息
- 全限定名:net.minecraft.network.chat.SignedMessageBody
- 类型:public record
- 包:net.minecraft.network.chat
- 源码路径:src/main/java/net/minecraft/network/chat/SignedMessageBody.java
- 起始行号:L16
- 职责:
TODO
字段/常量
MAP_CODEC- 类型:
MapCodec<SignedMessageBody> - 修饰符:
public static final - 源码定位:
L17 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.network.chat.SignedMessageBody.Packed- 类型:
record - 修饰符:
public - 源码定位:
L44 - 说明:
TODO
- 类型:
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static SignedMessageBody unsigned(String content) @ L27
- 方法名:unsigned
- 源码定位:L27
- 返回类型:SignedMessageBody
- 修饰符:public static
参数:
- content: String
说明:
TODO
public void updateSignature(SignatureUpdater.Output output) @ L31
- 方法名:updateSignature
- 源码定位:L31
- 返回类型:void
- 修饰符:public
参数:
- output: SignatureUpdater.Output
说明:
TODO
public SignedMessageBody.Packed pack(MessageSignatureCache cache) @ L40
- 方法名:pack
- 源码定位:L40
- 返回类型:SignedMessageBody.Packed
- 修饰符:public
参数:
- cache: MessageSignatureCache
说明:
TODO
代码
public record SignedMessageBody(String content, Instant timeStamp, long salt, LastSeenMessages lastSeen) {
public static final MapCodec<SignedMessageBody> MAP_CODEC = RecordCodecBuilder.mapCodec(
i -> i.group(
Codec.STRING.fieldOf("content").forGetter(SignedMessageBody::content),
ExtraCodecs.INSTANT_ISO8601.fieldOf("time_stamp").forGetter(SignedMessageBody::timeStamp),
Codec.LONG.fieldOf("salt").forGetter(SignedMessageBody::salt),
LastSeenMessages.CODEC.optionalFieldOf("last_seen", LastSeenMessages.EMPTY).forGetter(SignedMessageBody::lastSeen)
)
.apply(i, SignedMessageBody::new)
);
public static SignedMessageBody unsigned(String content) {
return new SignedMessageBody(content, Instant.now(), 0L, LastSeenMessages.EMPTY);
}
public void updateSignature(SignatureUpdater.Output output) throws SignatureException {
output.update(Longs.toByteArray(this.salt));
output.update(Longs.toByteArray(this.timeStamp.getEpochSecond()));
byte[] contentBytes = this.content.getBytes(StandardCharsets.UTF_8);
output.update(Ints.toByteArray(contentBytes.length));
output.update(contentBytes);
this.lastSeen.updateSignature(output);
}
public SignedMessageBody.Packed pack(MessageSignatureCache cache) {
return new SignedMessageBody.Packed(this.content, this.timeStamp, this.salt, this.lastSeen.pack(cache));
}
public record Packed(String content, Instant timeStamp, long salt, LastSeenMessages.Packed lastSeen) {
public Packed(FriendlyByteBuf input) {
this(input.readUtf(256), input.readInstant(), input.readLong(), new LastSeenMessages.Packed(input));
}
public void write(FriendlyByteBuf output) {
output.writeUtf(this.content, 256);
output.writeInstant(this.timeStamp);
output.writeLong(this.salt);
this.lastSeen.write(output);
}
public Optional<SignedMessageBody> unpack(MessageSignatureCache cache) {
return this.lastSeen.unpack(cache).map(lastSeen -> new SignedMessageBody(this.content, this.timeStamp, this.salt, lastSeen));
}
}
}引用的其他类
-
- 引用位置:
方法调用/构造调用 - 关联成员:
LastSeenMessages.Packed(), Packed()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: