UserWhiteList.java
net.minecraft.server.players.UserWhiteList
信息
- 全限定名:net.minecraft.server.players.UserWhiteList
- 类型:public class
- 包:net.minecraft.server.players
- 源码路径:src/main/java/net/minecraft/server/players/UserWhiteList.java
- 起始行号:L8
- 继承:StoredUserList<NameAndId,UserWhiteListEntry>
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
- 无
构造器
public UserWhiteList(File file, NotificationService notificationService) @ L9
- 构造器名:UserWhiteList
- 源码定位:L9
- 修饰符:public
参数:
- file: File
- notificationService: NotificationService
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected StoredUserEntry<NameAndId> createEntry(JsonObject object) @ L13
- 方法名:createEntry
- 源码定位:L13
- 返回类型:StoredUserEntry
- 修饰符:protected
参数:
- object: JsonObject
说明:
TODO
public boolean isWhiteListed(NameAndId user) @ L18
- 方法名:isWhiteListed
- 源码定位:L18
- 返回类型:boolean
- 修饰符:public
参数:
- user: NameAndId
说明:
TODO
public boolean add(UserWhiteListEntry infos) @ L22
- 方法名:add
- 源码定位:L22
- 返回类型:boolean
- 修饰符:public
参数:
- infos: UserWhiteListEntry
说明:
TODO
public boolean remove(NameAndId user) @ L34
- 方法名:remove
- 源码定位:L34
- 返回类型:boolean
- 修饰符:public
参数:
- user: NameAndId
说明:
TODO
public void clear() @ L43
- 方法名:clear
- 源码定位:L43
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public String[] getUserList() @ L54
- 方法名:getUserList
- 源码定位:L54
- 返回类型:String[]
- 修饰符:public
参数:
- 无
说明:
TODO
protected String getKeyForUser(NameAndId user) @ L59
- 方法名:getKeyForUser
- 源码定位:L59
- 返回类型:String
- 修饰符:protected
参数:
- user: NameAndId
说明:
TODO
代码
public class UserWhiteList extends StoredUserList<NameAndId, UserWhiteListEntry> {
public UserWhiteList(File file, NotificationService notificationService) {
super(file, notificationService);
}
@Override
protected StoredUserEntry<NameAndId> createEntry(JsonObject object) {
return new UserWhiteListEntry(object);
}
public boolean isWhiteListed(NameAndId user) {
return this.contains(user);
}
public boolean add(UserWhiteListEntry infos) {
if (super.add(infos)) {
if (infos.getUser() != null) {
this.notificationService.playerAddedToAllowlist(infos.getUser());
}
return true;
} else {
return false;
}
}
public boolean remove(NameAndId user) {
if (super.remove(user)) {
this.notificationService.playerRemovedFromAllowlist(user);
return true;
} else {
return false;
}
}
@Override
public void clear() {
for (UserWhiteListEntry user : this.getEntries()) {
if (user.getUser() != null) {
this.notificationService.playerRemovedFromAllowlist(user.getUser());
}
}
super.clear();
}
@Override
public String[] getUserList() {
return this.getEntries().stream().map(StoredUserEntry::getUser).filter(Objects::nonNull).map(NameAndId::name).toArray(String[]::new);
}
protected String getKeyForUser(NameAndId user) {
return user.id().toString();
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
参数/构造调用 - 关联成员:
UserWhiteListEntry()
- 引用位置:
-
- 引用位置:
参数
- 引用位置: