ReportingContext.java

net.minecraft.client.multiplayer.chat.report.ReportingContext

信息

  • 全限定名:net.minecraft.client.multiplayer.chat.report.ReportingContext
  • 类型:public final class
  • 包:net.minecraft.client.multiplayer.chat.report
  • 源码路径:src/main/java/net/minecraft/client/multiplayer/chat/report/ReportingContext.java
  • 起始行号:L16
  • 职责:

    TODO

字段/常量

  • LOG_CAPACITY

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L17
    • 说明:

      TODO

  • sender

    • 类型: AbuseReportSender
    • 修饰符: private final
    • 源码定位: L18
    • 说明:

      TODO

  • environment

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

      TODO

  • chatLog

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

      TODO

  • draftReport

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

      TODO

内部类/嵌套类型

构造器

public ReportingContext(AbuseReportSender sender, ReportEnvironment environment, ChatLog chatLog) @ L23

  • 构造器名:ReportingContext
  • 源码定位:L23
  • 修饰符:public

参数:

  • sender: AbuseReportSender
  • environment: ReportEnvironment
  • chatLog: ChatLog

说明:

TODO

方法

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

public static ReportingContext create(ReportEnvironment environment, UserApiService userApiService) @ L29

  • 方法名:create
  • 源码定位:L29
  • 返回类型:ReportingContext
  • 修饰符:public static

参数:

  • environment: ReportEnvironment
  • userApiService: UserApiService

说明:

TODO

public void draftReportHandled(Minecraft minecraft, Screen lastScreen, Runnable onDiscard, boolean quitToTitle) @ L35

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

参数:

  • minecraft: Minecraft
  • lastScreen: Screen
  • onDiscard: Runnable
  • quitToTitle: boolean

说明:

TODO

public AbuseReportSender sender() @ L59

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

参数:

说明:

TODO

public ChatLog chatLog() @ L63

  • 方法名:chatLog
  • 源码定位:L63
  • 返回类型:ChatLog
  • 修饰符:public

参数:

说明:

TODO

public boolean matches(ReportEnvironment environment) @ L67

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

参数:

  • environment: ReportEnvironment

说明:

TODO

public void setReportDraft(Report draftReport) @ L71

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

参数:

  • draftReport: Report

说明:

TODO

public boolean hasDraftReport() @ L75

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

参数:

说明:

TODO

public boolean hasDraftReportFor(UUID playerId) @ L79

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

参数:

  • playerId: UUID

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public final class ReportingContext {
    private static final int LOG_CAPACITY = 1024;
    private final AbuseReportSender sender;
    private final ReportEnvironment environment;
    private final ChatLog chatLog;
    private @Nullable Report draftReport;
 
    public ReportingContext(AbuseReportSender sender, ReportEnvironment environment, ChatLog chatLog) {
        this.sender = sender;
        this.environment = environment;
        this.chatLog = chatLog;
    }
 
    public static ReportingContext create(ReportEnvironment environment, UserApiService userApiService) {
        ChatLog chatLog = new ChatLog(1024);
        AbuseReportSender sender = AbuseReportSender.create(environment, userApiService);
        return new ReportingContext(sender, environment, chatLog);
    }
 
    public void draftReportHandled(Minecraft minecraft, Screen lastScreen, Runnable onDiscard, boolean quitToTitle) {
        if (this.draftReport != null) {
            Report report = this.draftReport.copy();
            minecraft.setScreen(
                new ConfirmScreen(
                    response -> {
                        this.setReportDraft(null);
                        if (response) {
                            minecraft.setScreen(report.createScreen(lastScreen, this));
                        } else {
                            onDiscard.run();
                        }
                    },
                    Component.translatable(quitToTitle ? "gui.abuseReport.draft.quittotitle.title" : "gui.abuseReport.draft.title"),
                    Component.translatable(quitToTitle ? "gui.abuseReport.draft.quittotitle.content" : "gui.abuseReport.draft.content"),
                    Component.translatable("gui.abuseReport.draft.edit"),
                    Component.translatable("gui.abuseReport.draft.discard")
                )
            );
        } else {
            onDiscard.run();
        }
    }
 
    public AbuseReportSender sender() {
        return this.sender;
    }
 
    public ChatLog chatLog() {
        return this.chatLog;
    }
 
    public boolean matches(ReportEnvironment environment) {
        return Objects.equals(this.environment, environment);
    }
 
    public void setReportDraft(@Nullable Report draftReport) {
        this.draftReport = draftReport;
    }
 
    public boolean hasDraftReport() {
        return this.draftReport != null;
    }
 
    public boolean hasDraftReportFor(UUID playerId) {
        return this.hasDraftReport() && this.draftReport.isReportedPlayer(playerId);
    }
}

引用的其他类

  • Minecraft

    • 引用位置: 参数
  • ConfirmScreen

    • 引用位置: 构造调用
    • 关联成员: ConfirmScreen()
  • Screen

    • 引用位置: 参数
  • ChatLog

    • 引用位置: 参数/字段/构造调用/返回值
    • 关联成员: ChatLog()
  • AbuseReportSender

    • 引用位置: 参数/字段/方法调用/返回值
    • 关联成员: AbuseReportSender.create()
  • Report

    • 引用位置: 参数/字段
  • ReportEnvironment

    • 引用位置: 参数/字段
  • Component

    • 引用位置: 方法调用
    • 关联成员: Component.translatable()