ServerOpList.java

net.minecraft.server.players.ServerOpList

信息

  • 全限定名:net.minecraft.server.players.ServerOpList
  • 类型:public class
  • 包:net.minecraft.server.players
  • 源码路径:src/main/java/net/minecraft/server/players/ServerOpList.java
  • 起始行号:L8
  • 继承:StoredUserList<NameAndId,ServerOpListEntry>
  • 职责:

    TODO

字段/常量

内部类/嵌套类型

构造器

public ServerOpList(File file, NotificationService notificationService) @ L9

  • 构造器名:ServerOpList
  • 源码定位:L9
  • 修饰符:public

参数:

  • file: File
  • notificationService: NotificationService

说明:

TODO

方法

下面的方法块按源码顺序生成。

protected StoredUserEntry<NameAndId> createEntry(JsonObject object) @ L13

  • 方法名:createEntry
  • 源码定位:L13
  • 返回类型:StoredUserEntry
  • 修饰符:protected

参数:

  • object: JsonObject

说明:

TODO

public String[] getUserList() @ L18

  • 方法名:getUserList
  • 源码定位:L18
  • 返回类型:String[]
  • 修饰符:public

参数:

说明:

TODO

public boolean add(ServerOpListEntry infos) @ L23

  • 方法名:add
  • 源码定位:L23
  • 返回类型:boolean
  • 修饰符:public

参数:

  • infos: ServerOpListEntry

说明:

TODO

public boolean remove(NameAndId user) @ L35

  • 方法名:remove
  • 源码定位:L35
  • 返回类型:boolean
  • 修饰符:public

参数:

  • user: NameAndId

说明:

TODO

public void clear() @ L48

  • 方法名:clear
  • 源码定位:L48
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

public boolean canBypassPlayerLimit(NameAndId user) @ L59

  • 方法名:canBypassPlayerLimit
  • 源码定位:L59
  • 返回类型:boolean
  • 修饰符:public

参数:

  • user: NameAndId

说明:

TODO

protected String getKeyForUser(NameAndId user) @ L64

  • 方法名:getKeyForUser
  • 源码定位:L64
  • 返回类型:String
  • 修饰符:protected

参数:

  • user: NameAndId

说明:

TODO

代码

public class ServerOpList extends StoredUserList<NameAndId, ServerOpListEntry> {
    public ServerOpList(File file, NotificationService notificationService) {
        super(file, notificationService);
    }
 
    @Override
    protected StoredUserEntry<NameAndId> createEntry(JsonObject object) {
        return new ServerOpListEntry(object);
    }
 
    @Override
    public String[] getUserList() {
        return this.getEntries().stream().map(StoredUserEntry::getUser).filter(Objects::nonNull).map(NameAndId::name).toArray(String[]::new);
    }
 
    public boolean add(ServerOpListEntry infos) {
        if (super.add(infos)) {
            if (infos.getUser() != null) {
                this.notificationService.playerOped(infos);
            }
 
            return true;
        } else {
            return false;
        }
    }
 
    public boolean remove(NameAndId user) {
        ServerOpListEntry entry = this.get(user);
        if (super.remove(user)) {
            if (entry != null) {
                this.notificationService.playerDeoped(entry);
            }
 
            return true;
        } else {
            return false;
        }
    }
 
    @Override
    public void clear() {
        for (ServerOpListEntry user : this.getEntries()) {
            if (user.getUser() != null) {
                this.notificationService.playerDeoped(user);
            }
        }
 
        super.clear();
    }
 
    public boolean canBypassPlayerLimit(NameAndId user) {
        ServerOpListEntry entry = this.get(user);
        return entry != null ? entry.getBypassesPlayerLimit() : false;
    }
 
    protected String getKeyForUser(NameAndId user) {
        return user.id().toString();
    }
}

引用的其他类