minecraft-src/net/minecraft/client/gui/screens/reporting/NameReportScreen.java
2025-07-04 02:00:41 +03:00

59 lines
2.6 KiB
Java

package net.minecraft.client.gui.screens.reporting;
import java.util.UUID;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.components.MultiLineEditBox;
import net.minecraft.client.gui.components.StringWidget;
import net.minecraft.client.gui.layouts.CommonLayouts;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.multiplayer.chat.report.NameReport;
import net.minecraft.client.multiplayer.chat.report.ReportingContext;
import net.minecraft.client.multiplayer.chat.report.NameReport.Builder;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.Nullable;
@Environment(EnvType.CLIENT)
public class NameReportScreen extends AbstractReportScreen<Builder> {
private static final Component TITLE = Component.translatable("gui.abuseReport.name.title");
private static final Component COMMENT_BOX_LABEL = Component.translatable("gui.abuseReport.name.comment_box_label");
@Nullable
private MultiLineEditBox commentBox;
private NameReportScreen(Screen lastScreen, ReportingContext reportingContext, Builder reportBuilder) {
super(TITLE, lastScreen, reportingContext, reportBuilder);
}
public NameReportScreen(Screen lastScreen, ReportingContext reportingContext, UUID reportedProfileId, String reportedName) {
this(lastScreen, reportingContext, new Builder(reportedProfileId, reportedName, reportingContext.sender().reportLimits()));
}
public NameReportScreen(Screen lastScreen, ReportingContext reportingContext, NameReport report) {
this(lastScreen, reportingContext, new Builder(report, reportingContext.sender().reportLimits()));
}
@Override
protected void addContent() {
Component component = Component.literal(this.reportBuilder.report().getReportedName()).withStyle(ChatFormatting.YELLOW);
this.layout
.addChild(
new StringWidget(Component.translatable("gui.abuseReport.name.reporting", component), this.font),
layoutSettings -> layoutSettings.alignHorizontallyCenter().padding(0, 8)
);
this.commentBox = this.createCommentBox(280, 9 * 8, string -> {
this.reportBuilder.setComments(string);
this.onReportChanged();
});
this.layout.addChild(CommonLayouts.labeledElement(this.font, this.commentBox, COMMENT_BOX_LABEL, layoutSettings -> layoutSettings.paddingBottom(12)));
}
@Override
public boolean mouseReleased(double mouseX, double mouseY, int button) {
if (super.mouseReleased(mouseX, mouseY, button)) {
return true;
} else {
return this.commentBox != null ? this.commentBox.mouseReleased(mouseX, mouseY, button) : false;
}
}
}