ServerDebugSubscribers.java
net.minecraft.util.debug.ServerDebugSubscribers
信息
- 全限定名:net.minecraft.util.debug.ServerDebugSubscribers
- 类型:public class
- 包:net.minecraft.util.debug
- 源码路径:src/main/java/net/minecraft/util/debug/ServerDebugSubscribers.java
- 起始行号:L14
- 职责:
TODO
字段/常量
-
server- 类型:
MinecraftServer - 修饰符:
private final - 源码定位:
L15 - 说明:
TODO
- 类型:
-
enabledSubscriptions- 类型:
Map<DebugSubscription<?>,List<ServerPlayer>> - 修饰符:
private final - 源码定位:
L16 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public ServerDebugSubscribers(MinecraftServer server) @ L18
- 构造器名:ServerDebugSubscribers
- 源码定位:L18
- 修饰符:public
参数:
- server: MinecraftServer
说明:
TODO
方法
下面的方法块按源码顺序生成。
private List<ServerPlayer> getSubscribersFor(DebugSubscription<?> subscription) @ L22
- 方法名:getSubscribersFor
- 源码定位:L22
- 返回类型:List
- 修饰符:private
参数:
- subscription: DebugSubscription<?>
说明:
TODO
public void tick() @ L26
- 方法名:tick
- 源码定位:L26
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void broadcastToAll(DebugSubscription<?> subscription, Packet<?> packet) @ L38
- 方法名:broadcastToAll
- 源码定位:L38
- 返回类型:void
- 修饰符:public
参数:
- subscription: DebugSubscription<?>
- packet: Packet<?>
说明:
TODO
public Set<DebugSubscription<?>> enabledSubscriptions() @ L44
- 方法名:enabledSubscriptions
- 源码定位:L44
- 返回类型:Set<DebugSubscription<?>>
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean hasAnySubscriberFor(DebugSubscription<?> subscription) @ L48
- 方法名:hasAnySubscriberFor
- 源码定位:L48
- 返回类型:boolean
- 修饰符:public
参数:
- subscription: DebugSubscription<?>
说明:
TODO
public boolean hasRequiredPermissions(ServerPlayer player) @ L52
- 方法名:hasRequiredPermissions
- 源码定位:L52
- 返回类型:boolean
- 修饰符:public
参数:
- player: ServerPlayer
说明:
TODO
代码
public class ServerDebugSubscribers {
private final MinecraftServer server;
private final Map<DebugSubscription<?>, List<ServerPlayer>> enabledSubscriptions = new HashMap<>();
public ServerDebugSubscribers(MinecraftServer server) {
this.server = server;
}
private List<ServerPlayer> getSubscribersFor(DebugSubscription<?> subscription) {
return this.enabledSubscriptions.getOrDefault(subscription, List.of());
}
public void tick() {
this.enabledSubscriptions.values().forEach(List::clear);
for (ServerPlayer player : this.server.getPlayerList().getPlayers()) {
for (DebugSubscription<?> subscription : player.debugSubscriptions()) {
this.enabledSubscriptions.computeIfAbsent(subscription, s -> new ArrayList<>()).add(player);
}
}
this.enabledSubscriptions.values().removeIf(List::isEmpty);
}
public void broadcastToAll(DebugSubscription<?> subscription, Packet<?> packet) {
for (ServerPlayer player : this.getSubscribersFor(subscription)) {
player.connection.send(packet);
}
}
public Set<DebugSubscription<?>> enabledSubscriptions() {
return Set.copyOf(this.enabledSubscriptions.keySet());
}
public boolean hasAnySubscriberFor(DebugSubscription<?> subscription) {
return !this.getSubscribersFor(subscription).isEmpty();
}
public boolean hasRequiredPermissions(ServerPlayer player) {
NameAndId nameAndId = player.nameAndId();
return SharedConstants.IS_RUNNING_IN_IDE && this.server.isSingleplayerOwner(nameAndId) ? true : this.server.getPlayerList().isOp(nameAndId);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置: