ModCheck.java

net.minecraft.util.ModCheck

信息

  • 全限定名:net.minecraft.util.ModCheck
  • 类型:public record
  • 包:net.minecraft.util
  • 源码路径:src/main/java/net/minecraft/util/ModCheck.java
  • 起始行号:L6
  • 职责:

    TODO

字段/常量

内部类/嵌套类型

  • net.minecraft.util.ModCheck.Confidence
    • 类型: enum
    • 修饰符: public static
    • 源码定位: L30
    • 说明:

      TODO

构造器

方法

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

public static ModCheck identify(String expectedBrand, Supplier<String> actualBrand, String component, Class<?> canaryClass) @ L7

  • 方法名:identify
  • 源码定位:L7
  • 返回类型:ModCheck
  • 修饰符:public static

参数:

  • expectedBrand: String
  • actualBrand: Supplier
  • component: String
  • canaryClass: Class<?>

说明:

TODO

public boolean shouldReportAsModified() @ L18

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

参数:

说明:

TODO

public ModCheck merge(ModCheck other) @ L22

  • 方法名:merge
  • 源码定位:L22
  • 返回类型:ModCheck
  • 修饰符:public

参数:

  • other: ModCheck

说明:

TODO

public String fullDescription() @ L26

  • 方法名:fullDescription
  • 源码定位:L26
  • 返回类型:String
  • 修饰符:public

参数:

说明:

TODO

代码

public record ModCheck(ModCheck.Confidence confidence, String description) {
    public static ModCheck identify(String expectedBrand, Supplier<String> actualBrand, String component, Class<?> canaryClass) {
        String mod = actualBrand.get();
        if (!expectedBrand.equals(mod)) {
            return new ModCheck(ModCheck.Confidence.DEFINITELY, component + " brand changed to '" + mod + "'");
        } else {
            return canaryClass.getSigners() == null
                ? new ModCheck(ModCheck.Confidence.VERY_LIKELY, component + " jar signature invalidated")
                : new ModCheck(ModCheck.Confidence.PROBABLY_NOT, component + " jar signature and brand is untouched");
        }
    }
 
    public boolean shouldReportAsModified() {
        return this.confidence.shouldReportAsModified;
    }
 
    public ModCheck merge(ModCheck other) {
        return new ModCheck(ObjectUtils.max(this.confidence, other.confidence), this.description + "; " + other.description);
    }
 
    public String fullDescription() {
        return this.confidence.description + " " + this.description;
    }
 
    public static enum Confidence {
        PROBABLY_NOT("Probably not.", false),
        VERY_LIKELY("Very likely;", true),
        DEFINITELY("Definitely;", true);
 
        private final String description;
        private final boolean shouldReportAsModified;
 
        private Confidence(String description, boolean shouldReportAsModified) {
            this.description = description;
            this.shouldReportAsModified = shouldReportAsModified;
        }
    }
}

引用的其他类