PlayerDto.java
net.minecraft.server.jsonrpc.api.PlayerDto
信息
- 全限定名:net.minecraft.server.jsonrpc.api.PlayerDto
- 类型:public record
- 包:net.minecraft.server.jsonrpc.api
- 源码路径:src/main/java/net/minecraft/server/jsonrpc/api/PlayerDto.java
- 起始行号:L13
- 职责:
TODO
字段/常量
CODEC- 类型:
MapCodec<PlayerDto> - 修饰符:
public static final - 源码定位:
L14 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static PlayerDto from(GameProfile gameProfile) @ L19
- 方法名:from
- 源码定位:L19
- 返回类型:PlayerDto
- 修饰符:public static
参数:
- gameProfile: GameProfile
说明:
TODO
public static PlayerDto from(NameAndId nameAndId) @ L23
- 方法名:from
- 源码定位:L23
- 返回类型:PlayerDto
- 修饰符:public static
参数:
- nameAndId: NameAndId
说明:
TODO
public static PlayerDto from(ServerPlayer player) @ L27
- 方法名:from
- 源码定位:L27
- 返回类型:PlayerDto
- 修饰符:public static
参数:
- player: ServerPlayer
说明:
TODO
代码
public record PlayerDto(Optional<UUID> id, Optional<String> name) {
public static final MapCodec<PlayerDto> CODEC = RecordCodecBuilder.mapCodec(
i -> i.group(UUIDUtil.STRING_CODEC.optionalFieldOf("id").forGetter(PlayerDto::id), Codec.STRING.optionalFieldOf("name").forGetter(PlayerDto::name))
.apply(i, PlayerDto::new)
);
public static PlayerDto from(GameProfile gameProfile) {
return new PlayerDto(Optional.of(gameProfile.id()), Optional.of(gameProfile.name()));
}
public static PlayerDto from(NameAndId nameAndId) {
return new PlayerDto(Optional.of(nameAndId.id()), Optional.of(nameAndId.name()));
}
public static PlayerDto from(ServerPlayer player) {
GameProfile gameProfile = player.getGameProfile();
return from(gameProfile);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: