RealmsDataFetcher.java

com.mojang.realmsclient.gui.RealmsDataFetcher

信息

  • 全限定名:com.mojang.realmsclient.gui.RealmsDataFetcher
  • 类型:public class
  • 包:com.mojang.realmsclient.gui
  • 源码路径:src/main/java/com/mojang/realmsclient/gui/RealmsDataFetcher.java
  • 起始行号:L20
  • 职责:

    TODO

字段/常量

  • dataFetcher

    • 类型: DataFetcher
    • 修饰符: public final
    • 源码定位: L21
    • 说明:

      TODO

  • tasks

    • 类型: List<DataFetcher.Task<?>>
    • 修饰符: private final
    • 源码定位: L22
    • 说明:

      TODO

  • notificationsTask

    • 类型: DataFetcher.Task<List<RealmsNotification>>
    • 修饰符: public final
    • 源码定位: L23
    • 说明:

      TODO

  • serverListUpdateTask

    • 类型: DataFetcher.Task<RealmsDataFetcher.ServerListData>
    • 修饰符: public final
    • 源码定位: L24
    • 说明:

      TODO

  • pendingInvitesTask

    • 类型: DataFetcher.Task<Integer>
    • 修饰符: public final
    • 源码定位: L25
    • 说明:

      TODO

  • trialAvailabilityTask

    • 类型: DataFetcher.Task<Boolean>
    • 修饰符: public final
    • 源码定位: L26
    • 说明:

      TODO

  • newsTask

    • 类型: DataFetcher.Task<RealmsNews>
    • 修饰符: public final
    • 源码定位: L27
    • 说明:

      TODO

  • onlinePlayersTask

    • 类型: DataFetcher.Task<RealmsServerPlayerLists>
    • 修饰符: public final
    • 源码定位: L28
    • 说明:

      TODO

  • newsManager

    • 类型: RealmsNewsManager
    • 修饰符: public final
    • 源码定位: L29
    • 说明:

      TODO

内部类/嵌套类型

  • com.mojang.realmsclient.gui.RealmsDataFetcher.ServerListData
    • 类型: record
    • 修饰符: public
    • 源码定位: L63
    • 说明:

      TODO

构造器

public RealmsDataFetcher(RealmsClient realmsClient) @ L31

  • 构造器名:RealmsDataFetcher
  • 源码定位:L31
  • 修饰符:public

参数:

  • realmsClient: RealmsClient

说明:

TODO

方法

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

public List<DataFetcher.Task<?>> getTasks() @ L58

  • 方法名:getTasks
  • 源码定位:L58
  • 返回类型:List<DataFetcher.Task<?>>
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class RealmsDataFetcher {
    public final DataFetcher dataFetcher = new DataFetcher(Util.ioPool(), TimeUnit.MILLISECONDS, Util.timeSource);
    private final List<DataFetcher.Task<?>> tasks;
    public final DataFetcher.Task<List<RealmsNotification>> notificationsTask;
    public final DataFetcher.Task<RealmsDataFetcher.ServerListData> serverListUpdateTask;
    public final DataFetcher.Task<Integer> pendingInvitesTask;
    public final DataFetcher.Task<Boolean> trialAvailabilityTask;
    public final DataFetcher.Task<RealmsNews> newsTask;
    public final DataFetcher.Task<RealmsServerPlayerLists> onlinePlayersTask;
    public final RealmsNewsManager newsManager = new RealmsNewsManager(new RealmsPersistence());
 
    public RealmsDataFetcher(RealmsClient realmsClient) {
        this.serverListUpdateTask = this.dataFetcher
            .createTask(
                "server list",
                () -> {
                    com.mojang.realmsclient.dto.RealmsServerList realmsServerList = realmsClient.listRealms();
                    return RealmsMainScreen.isSnapshot()
                        ? new RealmsDataFetcher.ServerListData(realmsServerList.servers(), realmsClient.listSnapshotEligibleRealms())
                        : new RealmsDataFetcher.ServerListData(realmsServerList.servers(), List.of());
                },
                Duration.ofSeconds(60L),
                RepeatedDelayStrategy.CONSTANT
            );
        this.pendingInvitesTask = this.dataFetcher
            .createTask("pending invite count", realmsClient::pendingInvitesCount, Duration.ofSeconds(10L), RepeatedDelayStrategy.exponentialBackoff(360));
        this.trialAvailabilityTask = this.dataFetcher
            .createTask("trial availablity", realmsClient::trialAvailable, Duration.ofSeconds(60L), RepeatedDelayStrategy.exponentialBackoff(60));
        this.newsTask = this.dataFetcher.createTask("unread news", realmsClient::getNews, Duration.ofMinutes(5L), RepeatedDelayStrategy.CONSTANT);
        this.notificationsTask = this.dataFetcher
            .createTask("notifications", realmsClient::getNotifications, Duration.ofMinutes(5L), RepeatedDelayStrategy.CONSTANT);
        this.onlinePlayersTask = this.dataFetcher
            .createTask("online players", realmsClient::getLiveStats, Duration.ofSeconds(10L), RepeatedDelayStrategy.CONSTANT);
        this.tasks = List.of(
            this.notificationsTask, this.serverListUpdateTask, this.pendingInvitesTask, this.trialAvailabilityTask, this.newsTask, this.onlinePlayersTask
        );
    }
 
    public List<DataFetcher.Task<?>> getTasks() {
        return this.tasks;
    }
 
    @OnlyIn(Dist.CLIENT)
    public record ServerListData(List<RealmsServer> serverList, List<RealmsServer> availableSnapshotServers) {
    }
}

引用的其他类