SignedMessageLink.java

信息

  • 全限定名:net.minecraft.network.chat.SignedMessageLink
  • 类型:public record
  • 包:net.minecraft.network.chat
  • 源码路径:src/main/java/net/minecraft/network/chat/SignedMessageLink.java
  • 起始行号:L14
  • 职责:

    TODO

字段/常量

  • CODEC
    • 类型: Codec<SignedMessageLink>
    • 修饰符: public static final
    • 源码定位: L15
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

下面的方法块按源码顺序生成。

  • 方法名:unsigned
  • 源码定位:L24
  • 返回类型:SignedMessageLink
  • 修饰符:public static

参数:

  • sender: UUID

说明:

TODO

  • 方法名:root
  • 源码定位:L28
  • 返回类型:SignedMessageLink
  • 修饰符:public static

参数:

  • sender: UUID
  • sessionId: UUID

说明:

TODO

public void updateSignature(SignatureUpdater.Output output) @ L32

  • 方法名:updateSignature
  • 源码定位:L32
  • 返回类型:void
  • 修饰符:public

参数:

  • output: SignatureUpdater.Output

说明:

TODO

  • 方法名:isDescendantOf
  • 源码定位:L38
  • 返回类型:boolean
  • 修饰符:public

参数:

  • link: SignedMessageLink

说明:

TODO

  • 方法名:advance
  • 源码定位:L42
  • 返回类型:SignedMessageLink
  • 修饰符:public

参数:

说明:

TODO

代码

public record SignedMessageLink(int index, UUID sender, UUID sessionId) {
    public static final Codec<SignedMessageLink> CODEC = RecordCodecBuilder.create(
        i -> i.group(
                ExtraCodecs.NON_NEGATIVE_INT.fieldOf("index").forGetter(SignedMessageLink::index),
                UUIDUtil.CODEC.fieldOf("sender").forGetter(SignedMessageLink::sender),
                UUIDUtil.CODEC.fieldOf("session_id").forGetter(SignedMessageLink::sessionId)
            )
            .apply(i, SignedMessageLink::new)
    );
 
    public static SignedMessageLink unsigned(UUID sender) {
        return root(sender, Util.NIL_UUID);
    }
 
    public static SignedMessageLink root(UUID sender, UUID sessionId) {
        return new SignedMessageLink(0, sender, sessionId);
    }
 
    public void updateSignature(SignatureUpdater.Output output) throws SignatureException {
        output.update(UUIDUtil.uuidToByteArray(this.sender));
        output.update(UUIDUtil.uuidToByteArray(this.sessionId));
        output.update(Ints.toByteArray(this.index));
    }
 
    public boolean isDescendantOf(SignedMessageLink link) {
        return this.index > link.index() && this.sender.equals(link.sender()) && this.sessionId.equals(link.sessionId());
    }
 
    public @Nullable SignedMessageLink advance() {
        return this.index == Integer.MAX_VALUE ? null : new SignedMessageLink(this.index + 1, this.sender, this.sessionId);
    }
}

引用的其他类