ServerLinks.java
net.minecraft.server.ServerLinks
信息
- 全限定名:net.minecraft.server.ServerLinks
- 类型:public record
- 包:net.minecraft.server
- 源码路径:src/main/java/net/minecraft/server/ServerLinks.java
- 起始行号:L15
- 职责:
TODO
字段/常量
-
EMPTY- 类型:
ServerLinks - 修饰符:
public static final - 源码定位:
L16 - 说明:
TODO
- 类型:
-
TYPE_STREAM_CODEC- 类型:
StreamCodec<ByteBuf,Either<ServerLinks.KnownLinkType,Component>> - 修饰符:
public static final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
UNTRUSTED_LINKS_STREAM_CODEC- 类型:
StreamCodec<ByteBuf,List<ServerLinks.UntrustedEntry>> - 修饰符:
public static final - 源码定位:
L20 - 说明:
TODO
- 类型:
内部类/嵌套类型
-
net.minecraft.server.ServerLinks.Entry- 类型:
record - 修饰符:
public - 源码定位:
L35 - 说明:
TODO
- 类型:
-
net.minecraft.server.ServerLinks.KnownLinkType- 类型:
enum - 修饰符:
public static - 源码定位:
L49 - 说明:
TODO
- 类型:
-
net.minecraft.server.ServerLinks.UntrustedEntry- 类型:
record - 修饰符:
public - 源码定位:
L80 - 说明:
TODO
- 类型:
构造器
- 无
方法
下面的方法块按源码顺序生成。
public boolean isEmpty() @ L23
- 方法名:isEmpty
- 源码定位:L23
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public Optional<ServerLinks.Entry> findKnownType(ServerLinks.KnownLinkType type) @ L27
- 方法名:findKnownType
- 源码定位:L27
- 返回类型:Optional<ServerLinks.Entry>
- 修饰符:public
参数:
- type: ServerLinks.KnownLinkType
说明:
TODO
public List<ServerLinks.UntrustedEntry> untrust() @ L31
- 方法名:untrust
- 源码定位:L31
- 返回类型:List<ServerLinks.UntrustedEntry>
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public record ServerLinks(List<ServerLinks.Entry> entries) {
public static final ServerLinks EMPTY = new ServerLinks(List.of());
public static final StreamCodec<ByteBuf, Either<ServerLinks.KnownLinkType, Component>> TYPE_STREAM_CODEC = ByteBufCodecs.either(
ServerLinks.KnownLinkType.STREAM_CODEC, ComponentSerialization.TRUSTED_CONTEXT_FREE_STREAM_CODEC
);
public static final StreamCodec<ByteBuf, List<ServerLinks.UntrustedEntry>> UNTRUSTED_LINKS_STREAM_CODEC = ServerLinks.UntrustedEntry.STREAM_CODEC
.apply(ByteBufCodecs.list());
public boolean isEmpty() {
return this.entries.isEmpty();
}
public Optional<ServerLinks.Entry> findKnownType(ServerLinks.KnownLinkType type) {
return this.entries.stream().filter(e -> e.type.map(l -> l == type, r -> false)).findFirst();
}
public List<ServerLinks.UntrustedEntry> untrust() {
return this.entries.stream().map(e -> new ServerLinks.UntrustedEntry(e.type, e.link.toString())).toList();
}
public record Entry(Either<ServerLinks.KnownLinkType, Component> type, URI link) {
public static ServerLinks.Entry knownType(ServerLinks.KnownLinkType type, URI link) {
return new ServerLinks.Entry(Either.left(type), link);
}
public static ServerLinks.Entry custom(Component displayName, URI link) {
return new ServerLinks.Entry(Either.right(displayName), link);
}
public Component displayName() {
return this.type.map(ServerLinks.KnownLinkType::displayName, r -> (Component)r);
}
}
public static enum KnownLinkType {
BUG_REPORT(0, "report_bug"),
COMMUNITY_GUIDELINES(1, "community_guidelines"),
SUPPORT(2, "support"),
STATUS(3, "status"),
FEEDBACK(4, "feedback"),
COMMUNITY(5, "community"),
WEBSITE(6, "website"),
FORUMS(7, "forums"),
NEWS(8, "news"),
ANNOUNCEMENTS(9, "announcements");
private static final IntFunction<ServerLinks.KnownLinkType> BY_ID = ByIdMap.continuous(e -> e.id, values(), ByIdMap.OutOfBoundsStrategy.ZERO);
public static final StreamCodec<ByteBuf, ServerLinks.KnownLinkType> STREAM_CODEC = ByteBufCodecs.idMapper(BY_ID, e -> e.id);
private final int id;
private final String name;
private KnownLinkType(int id, String name) {
this.id = id;
this.name = name;
}
private Component displayName() {
return Component.translatable("known_server_link." + this.name);
}
public ServerLinks.Entry create(URI link) {
return ServerLinks.Entry.knownType(this, link);
}
}
public record UntrustedEntry(Either<ServerLinks.KnownLinkType, Component> type, String link) {
public static final StreamCodec<ByteBuf, ServerLinks.UntrustedEntry> STREAM_CODEC = StreamCodec.composite(
ServerLinks.TYPE_STREAM_CODEC,
ServerLinks.UntrustedEntry::type,
ByteBufCodecs.STRING_UTF8,
ServerLinks.UntrustedEntry::link,
ServerLinks.UntrustedEntry::new
);
}
}引用的其他类
-
- 引用位置:
字段/方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ByteBufCodecs.either(), ByteBufCodecs.idMapper(), ByteBufCodecs.list()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
StreamCodec.composite()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ByIdMap.continuous()
- 引用位置: