AllowlistService.java
net.minecraft.server.jsonrpc.methods.AllowlistService
信息
- 全限定名:net.minecraft.server.jsonrpc.methods.AllowlistService
- 类型:public class
- 包:net.minecraft.server.jsonrpc.methods
- 源码路径:src/main/java/net/minecraft/server/jsonrpc/methods/AllowlistService.java
- 起始行号:L15
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static List<PlayerDto> get(MinecraftApi minecraftApi) @ L16
- 方法名:get
- 源码定位:L16
- 返回类型:List
- 修饰符:public static
参数:
- minecraftApi: MinecraftApi
说明:
TODO
public static List<PlayerDto> add(MinecraftApi minecraftApi, List<PlayerDto> playerDtos, ClientInfo clientInfo) @ L20
- 方法名:add
- 源码定位:L20
- 返回类型:List
- 修饰符:public static
参数:
- minecraftApi: MinecraftApi
- playerDtos: List
- clientInfo: ClientInfo
说明:
TODO
public static List<PlayerDto> clear(MinecraftApi minecraftApi, ClientInfo clientInfo) @ L32
- 方法名:clear
- 源码定位:L32
- 返回类型:List
- 修饰符:public static
参数:
- minecraftApi: MinecraftApi
- clientInfo: ClientInfo
说明:
TODO
public static List<PlayerDto> remove(MinecraftApi minecraftApi, List<PlayerDto> playerDtos, ClientInfo clientInfo) @ L37
- 方法名:remove
- 源码定位:L37
- 返回类型:List
- 修饰符:public static
参数:
- minecraftApi: MinecraftApi
- playerDtos: List
- clientInfo: ClientInfo
说明:
TODO
public static List<PlayerDto> set(MinecraftApi minecraftApi, List<PlayerDto> playerDtos, ClientInfo clientInfo) @ L50
- 方法名:set
- 源码定位:L50
- 返回类型:List
- 修饰符:public static
参数:
- minecraftApi: MinecraftApi
- playerDtos: List
- clientInfo: ClientInfo
说明:
TODO
代码
public class AllowlistService {
public static List<PlayerDto> get(MinecraftApi minecraftApi) {
return minecraftApi.allowListService().getEntries().stream().filter(p -> p.getUser() != null).map(u -> PlayerDto.from(u.getUser())).toList();
}
public static List<PlayerDto> add(MinecraftApi minecraftApi, List<PlayerDto> playerDtos, ClientInfo clientInfo) {
List<CompletableFuture<Optional<NameAndId>>> fetch = playerDtos.stream()
.map(playerDto -> minecraftApi.playerListService().getUser(playerDto.id(), playerDto.name()))
.toList();
for (Optional<NameAndId> user : Util.sequence(fetch).join()) {
user.ifPresent(nameAndId -> minecraftApi.allowListService().add(new UserWhiteListEntry(nameAndId), clientInfo));
}
return get(minecraftApi);
}
public static List<PlayerDto> clear(MinecraftApi minecraftApi, ClientInfo clientInfo) {
minecraftApi.allowListService().clear(clientInfo);
return get(minecraftApi);
}
public static List<PlayerDto> remove(MinecraftApi minecraftApi, List<PlayerDto> playerDtos, ClientInfo clientInfo) {
List<CompletableFuture<Optional<NameAndId>>> fetch = playerDtos.stream()
.map(playerDto -> minecraftApi.playerListService().getUser(playerDto.id(), playerDto.name()))
.toList();
for (Optional<NameAndId> user : Util.sequence(fetch).join()) {
user.ifPresent(nameAndId -> minecraftApi.allowListService().remove(nameAndId, clientInfo));
}
minecraftApi.allowListService().kickUnlistedPlayers(clientInfo);
return get(minecraftApi);
}
public static List<PlayerDto> set(MinecraftApi minecraftApi, List<PlayerDto> playerDtos, ClientInfo clientInfo) {
List<CompletableFuture<Optional<NameAndId>>> fetch = playerDtos.stream()
.map(playerDto -> minecraftApi.playerListService().getUser(playerDto.id(), playerDto.name()))
.toList();
Set<NameAndId> finalAllowList = Util.sequence(fetch).join().stream().flatMap(Optional::stream).collect(Collectors.toSet());
Set<NameAndId> currentAllowList = minecraftApi.allowListService().getEntries().stream().map(StoredUserEntry::getUser).collect(Collectors.toSet());
currentAllowList.stream().filter(user -> !finalAllowList.contains(user)).forEach(user -> minecraftApi.allowListService().remove(user, clientInfo));
finalAllowList.stream()
.filter(user -> !currentAllowList.contains(user))
.forEach(user -> minecraftApi.allowListService().add(new UserWhiteListEntry(user), clientInfo));
minecraftApi.allowListService().kickUnlistedPlayers(clientInfo);
return get(minecraftApi);
}
}引用的其他类
-
- 引用位置:
参数/方法调用/返回值 - 关联成员:
PlayerDto.from()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
UserWhiteListEntry()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.sequence()
- 引用位置: