SkinReport.java

net.minecraft.client.multiplayer.chat.report.SkinReport

信息

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

    TODO

字段/常量

  • skinGetter
    • 类型: Supplier<PlayerSkin>
    • 修饰符: private final
    • 源码定位: L22
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.client.multiplayer.chat.report.SkinReport.Builder
    • 类型: class
    • 修饰符: public static
    • 源码定位: L47
    • 说明:

      TODO

构造器

private SkinReport(UUID reportId, Instant createdAt, UUID reportedProfileId, Supplier<PlayerSkin> skinGetter) @ L24

  • 构造器名:SkinReport
  • 源码定位:L24
  • 修饰符:private

参数:

  • reportId: UUID
  • createdAt: Instant
  • reportedProfileId: UUID
  • skinGetter: Supplier

说明:

TODO

方法

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

public Supplier<PlayerSkin> getSkinGetter() @ L29

  • 方法名:getSkinGetter
  • 源码定位:L29
  • 返回类型:Supplier
  • 修饰符:public

参数:

说明:

TODO

public SkinReport copy() @ L33

  • 方法名:copy
  • 源码定位:L33
  • 返回类型:SkinReport
  • 修饰符:public

参数:

说明:

TODO

public Screen createScreen(Screen lastScreen, ReportingContext context) @ L41

  • 方法名:createScreen
  • 源码定位:L41
  • 返回类型:Screen
  • 修饰符:public

参数:

  • lastScreen: Screen
  • context: ReportingContext

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class SkinReport extends Report {
    private final Supplier<PlayerSkin> skinGetter;
 
    private SkinReport(UUID reportId, Instant createdAt, UUID reportedProfileId, Supplier<PlayerSkin> skinGetter) {
        super(reportId, createdAt, reportedProfileId);
        this.skinGetter = skinGetter;
    }
 
    public Supplier<PlayerSkin> getSkinGetter() {
        return this.skinGetter;
    }
 
    public SkinReport copy() {
        SkinReport result = new SkinReport(this.reportId, this.createdAt, this.reportedProfileId, this.skinGetter);
        result.comments = this.comments;
        result.reason = this.reason;
        result.attested = this.attested;
        return result;
    }
 
    @Override
    public Screen createScreen(Screen lastScreen, ReportingContext context) {
        return new SkinReportScreen(lastScreen, context, this);
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class Builder extends Report.Builder<SkinReport> {
        public Builder(SkinReport report, AbuseReportLimits limits) {
            super(report, limits);
        }
 
        public Builder(UUID reportedProfileId, Supplier<PlayerSkin> skin, AbuseReportLimits limits) {
            super(new SkinReport(UUID.randomUUID(), Instant.now(), reportedProfileId, skin), limits);
        }
 
        @Override
        public boolean hasContent() {
            return StringUtils.isNotEmpty(this.comments()) || this.reason() != null;
        }
 
        @Override
        public Report.@Nullable CannotBuildReason checkBuildable() {
            if (this.report.reason == null) {
                return Report.CannotBuildReason.NO_REASON;
            } else {
                return this.report.comments.length() > this.limits.maxOpinionCommentsLength()
                    ? Report.CannotBuildReason.COMMENT_TOO_LONG
                    : super.checkBuildable();
            }
        }
 
        @Override
        public Either<Report.Result, Report.CannotBuildReason> build(ReportingContext reportingContext) {
            Report.CannotBuildReason error = this.checkBuildable();
            if (error != null) {
                return Either.right(error);
            } else {
                String reason = Objects.requireNonNull(this.report.reason).backendName();
                ReportedEntity reportedEntity = new ReportedEntity(this.report.reportedProfileId);
                PlayerSkin skin = this.report.skinGetter.get();
                String skinUrl = skin.body() instanceof ClientAsset.DownloadedTexture downloadedTexture ? downloadedTexture.url() : null;
                AbuseReport abuseReport = AbuseReport.skin(this.report.comments, reason, skinUrl, reportedEntity, this.report.createdAt);
                return Either.left(new Report.Result(this.report.reportId, ReportType.SKIN, abuseReport));
            }
        }
    }
}

引用的其他类

  • Screen

    • 引用位置: 参数/返回值
  • SkinReportScreen

    • 引用位置: 构造调用
    • 关联成员: SkinReportScreen()
  • Report

    • 引用位置: 方法调用/构造调用/继承
    • 关联成员: Report.Result(), Result()
  • ReportingContext

    • 引用位置: 参数
  • PlayerSkin

    • 引用位置: 参数/字段/返回值