WorldSessionTelemetryManager.java

net.minecraft.client.telemetry.WorldSessionTelemetryManager

信息

  • 全限定名:net.minecraft.client.telemetry.WorldSessionTelemetryManager
  • 类型:public class
  • 包:net.minecraft.client.telemetry
  • 源码路径:src/main/java/net/minecraft/client/telemetry/WorldSessionTelemetryManager.java
  • 起始行号:L18
  • 职责:

    TODO

字段/常量

  • worldSessionId

    • 类型: UUID
    • 修饰符: private final
    • 源码定位: L19
    • 说明:

      TODO

  • eventSender

    • 类型: TelemetryEventSender
    • 修饰符: private final
    • 源码定位: L20
    • 说明:

      TODO

  • worldLoadEvent

    • 类型: WorldLoadEvent
    • 修饰符: private final
    • 源码定位: L21
    • 说明:

      TODO

  • worldUnloadEvent

    • 类型: WorldUnloadEvent
    • 修饰符: private final
    • 源码定位: L22
    • 说明:

      TODO

  • performanceMetricsEvent

    • 类型: PerformanceMetricsEvent
    • 修饰符: private final
    • 源码定位: L23
    • 说明:

      TODO

  • worldLoadTimesEvent

    • 类型: WorldLoadTimesEvent
    • 修饰符: private final
    • 源码定位: L24
    • 说明:

      TODO

内部类/嵌套类型

构造器

public WorldSessionTelemetryManager(TelemetryEventSender eventSender, boolean newWorld, Duration worldLoadDuration, String minigameName) @ L26

  • 构造器名:WorldSessionTelemetryManager
  • 源码定位:L26
  • 修饰符:public

参数:

  • eventSender: TelemetryEventSender
  • newWorld: boolean
  • worldLoadDuration: Duration
  • minigameName: String

说明:

TODO

方法

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

public void tick() @ L36

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

参数:

说明:

TODO

public void onPlayerInfoReceived(GameType type, boolean hardcore) @ L40

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

参数:

  • type: GameType
  • hardcore: boolean

说明:

TODO

public void onServerBrandReceived(String serverBrand) @ L46

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

参数:

  • serverBrand: String

说明:

TODO

public void setTime(long gameTime) @ L51

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

参数:

  • gameTime: long

说明:

TODO

public void worldSessionStart() @ L55

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

参数:

说明:

TODO

public void onDisconnect() @ L62

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

参数:

说明:

TODO

public void onAdvancementDone(Level level, AdvancementHolder holder) @ L68

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

参数:

  • level: Level
  • holder: AdvancementHolder

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class WorldSessionTelemetryManager {
    private final UUID worldSessionId = UUID.randomUUID();
    private final TelemetryEventSender eventSender;
    private final WorldLoadEvent worldLoadEvent;
    private final WorldUnloadEvent worldUnloadEvent = new WorldUnloadEvent();
    private final PerformanceMetricsEvent performanceMetricsEvent;
    private final WorldLoadTimesEvent worldLoadTimesEvent;
 
    public WorldSessionTelemetryManager(TelemetryEventSender eventSender, boolean newWorld, @Nullable Duration worldLoadDuration, @Nullable String minigameName) {
        this.worldLoadEvent = new WorldLoadEvent(minigameName);
        this.performanceMetricsEvent = new PerformanceMetricsEvent();
        this.worldLoadTimesEvent = new WorldLoadTimesEvent(newWorld, worldLoadDuration);
        this.eventSender = eventSender.decorate(properties -> {
            this.worldLoadEvent.addProperties(properties);
            properties.put(TelemetryProperty.WORLD_SESSION_ID, this.worldSessionId);
        });
    }
 
    public void tick() {
        this.performanceMetricsEvent.tick(this.eventSender);
    }
 
    public void onPlayerInfoReceived(GameType type, boolean hardcore) {
        this.worldLoadEvent.setGameMode(type, hardcore);
        this.worldUnloadEvent.onPlayerInfoReceived();
        this.worldSessionStart();
    }
 
    public void onServerBrandReceived(String serverBrand) {
        this.worldLoadEvent.setServerBrand(serverBrand);
        this.worldSessionStart();
    }
 
    public void setTime(long gameTime) {
        this.worldUnloadEvent.setTime(gameTime);
    }
 
    public void worldSessionStart() {
        if (this.worldLoadEvent.send(this.eventSender)) {
            this.worldLoadTimesEvent.send(this.eventSender);
            this.performanceMetricsEvent.start();
        }
    }
 
    public void onDisconnect() {
        this.worldLoadEvent.send(this.eventSender);
        this.performanceMetricsEvent.stop();
        this.worldUnloadEvent.send(this.eventSender);
    }
 
    public void onAdvancementDone(Level level, AdvancementHolder holder) {
        Identifier advancementId = holder.id();
        if (holder.value().sendsTelemetryEvent() && "minecraft".equals(advancementId.getNamespace())) {
            long gameTime = level.getGameTime();
            this.eventSender.send(TelemetryEventType.ADVANCEMENT_MADE, properties -> {
                properties.put(TelemetryProperty.ADVANCEMENT_ID, advancementId.toString());
                properties.put(TelemetryProperty.ADVANCEMENT_GAME_TIME, gameTime);
            });
        }
    }
}

引用的其他类