ReportingContext .java

net.minecraft.client.multiplayer.chat.report.ReportingContext (class, 84 lines): members: draftReportHandled, hasDraftReportFor, setReportDraft, chatLog.

net.minecraft.client.multiplayer.chat.reportclass84 linesclient2.7 KB

API Surface (8)

ReportingContext create(final ReportEnvironment environment, final UserApiService userApiService)
void draftReportHandled(final Minecraft minecraft, final Screen lastScreen, final Runnable onDiscard, final boolean quitToTitle)
AbuseReportSender sender()
ChatLog chatLog()
boolean matches(final ReportEnvironment environment)
void setReportDraft(final @Nullable Report draftReport)
boolean hasDraftReport()
boolean hasDraftReportFor(final UUID playerId)

Fields & Constants (5)

LOG_CAPACITY
sender
environment
chatLog
draftReport

String literals (6)

"gui.abuseReport.draft.quittotitle.title"
"gui.abuseReport.draft.title"
"gui.abuseReport.draft.quittotitle.content"
"gui.abuseReport.draft.content"
"gui.abuseReport.draft.edit"
"gui.abuseReport.draft.discard"

Full Source

ReportingContext.java84 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.multiplayer.chat.report;
2
3
import com.mojang.authlib.minecraft.UserApiService;
4
import java.util.Objects;
5
import java.util.UUID;
6
import net.fabricmc.api.EnvType;
7
import net.fabricmc.api.Environment;
8
import net.minecraft.client.Minecraft;
9
import net.minecraft.client.gui.screens.ConfirmScreen;
10
import net.minecraft.client.gui.screens.Screen;
11
import net.minecraft.client.multiplayer.chat.ChatLog;
12
import net.minecraft.network.chat.Component;
13
import org.jspecify.annotations.Nullable;
14
15
@Environment(EnvType.CLIENT)
16
public final class ReportingContext {
17
	private static final int LOG_CAPACITY = 1024;
18
	private final AbuseReportSender sender;
19
	private final ReportEnvironment environment;
20
	private final ChatLog chatLog;
21
	private @Nullable Report draftReport;
22
23
	public ReportingContext(final AbuseReportSender sender, final ReportEnvironment environment, final ChatLog chatLog) {
24
		this.sender = sender;
25
		this.environment = environment;
26
		this.chatLog = chatLog;
27
	}
28
29
	public static ReportingContext create(final ReportEnvironment environment, final UserApiService userApiService) {
30
		ChatLog chatLog = new ChatLog(1024);
31
		AbuseReportSender sender = AbuseReportSender.create(environment, userApiService);
32
		return new ReportingContext(sender, environment, chatLog);
33
	}
34
35
	public void draftReportHandled(final Minecraft minecraft, final Screen lastScreen, final Runnable onDiscard, final boolean quitToTitle) {
36
		if (this.draftReport != null) {
37
			Report report = this.draftReport.copy();
38
			minecraft.gui
39
				.setScreen(
40
					new ConfirmScreen(
41
						response -> {
42
							this.setReportDraft(null);
43
							if (response) {
44
								minecraft.gui.setScreen(report.createScreen(lastScreen, this));
45
							} else {
46
								onDiscard.run();
47
							}
48
						},
49
						Component.translatable(quitToTitle ? "gui.abuseReport.draft.quittotitle.title" : "gui.abuseReport.draft.title"),
50
						Component.translatable(quitToTitle ? "gui.abuseReport.draft.quittotitle.content" : "gui.abuseReport.draft.content"),
51
						Component.translatable("gui.abuseReport.draft.edit"),
52
						Component.translatable("gui.abuseReport.draft.discard")
53
					)
54
				);
55
		} else {
56
			onDiscard.run();
57
		}
58
	}
59
60
	public AbuseReportSender sender() {
61
		return this.sender;
62
	}
63
64
	public ChatLog chatLog() {
65
		return this.chatLog;
66
	}
67
68
	public boolean matches(final ReportEnvironment environment) {
69
		return Objects.equals(this.environment, environment);
70
	}
71
72
	public void setReportDraft(final @Nullable Report draftReport) {
73
		this.draftReport = draftReport;
74
	}
75
76
	public boolean hasDraftReport() {
77
		return this.draftReport != null;
78
	}
79
80
	public boolean hasDraftReportFor(final UUID playerId) {
81
		return this.hasDraftReport() && this.draftReport.isReportedPlayer(playerId);
82
	}
83
}
84

Decompiled Minecraft 26.3 source of ReportingContext (net/minecraft/client/multiplayer/chat/report/ReportingContext.java) with Mojang official mappings, stored verbatim on the site.