DeprecatedTranslationsInfo.java
net.minecraft.locale.DeprecatedTranslationsInfo
信息
- 全限定名:net.minecraft.locale.DeprecatedTranslationsInfo
- 类型:public record
- 包:net.minecraft.locale
- 源码路径:src/main/java/net/minecraft/locale/DeprecatedTranslationsInfo.java
- 起始行号:L16
- 职责:
TODO
字段/常量
-
LOGGER- 类型:
Logger - 修饰符:
private static final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
EMPTY- 类型:
DeprecatedTranslationsInfo - 修饰符:
public static final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
CODEC- 类型:
Codec<DeprecatedTranslationsInfo> - 修饰符:
public static final - 源码定位:
L19 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static DeprecatedTranslationsInfo loadFromJson(InputStream stream) @ L27
- 方法名:loadFromJson
- 源码定位:L27
- 返回类型:DeprecatedTranslationsInfo
- 修饰符:public static
参数:
- stream: InputStream
说明:
TODO
public static DeprecatedTranslationsInfo loadFromResource(String path) @ L32
- 方法名:loadFromResource
- 源码定位:L32
- 返回类型:DeprecatedTranslationsInfo
- 修饰符:public static
参数:
- path: String
说明:
TODO
public static DeprecatedTranslationsInfo loadFromDefaultResource() @ L41
- 方法名:loadFromDefaultResource
- 源码定位:L41
- 返回类型:DeprecatedTranslationsInfo
- 修饰符:public static
参数:
- 无
说明:
TODO
public void applyToMap(Map<String,String> translations) @ L45
- 方法名:applyToMap
- 源码定位:L45
- 返回类型:void
- 修饰符:public
参数:
- translations: Map<String,String>
说明:
TODO
代码
public record DeprecatedTranslationsInfo(List<String> removed, Map<String, String> renamed) {
private static final Logger LOGGER = LogUtils.getLogger();
public static final DeprecatedTranslationsInfo EMPTY = new DeprecatedTranslationsInfo(List.of(), Map.of());
public static final Codec<DeprecatedTranslationsInfo> CODEC = RecordCodecBuilder.create(
i -> i.group(
Codec.STRING.listOf().fieldOf("removed").forGetter(DeprecatedTranslationsInfo::removed),
Codec.unboundedMap(Codec.STRING, Codec.STRING).fieldOf("renamed").forGetter(DeprecatedTranslationsInfo::renamed)
)
.apply(i, DeprecatedTranslationsInfo::new)
);
public static DeprecatedTranslationsInfo loadFromJson(InputStream stream) {
JsonElement entries = StrictJsonParser.parse(new InputStreamReader(stream, StandardCharsets.UTF_8));
return CODEC.parse(JsonOps.INSTANCE, entries).getOrThrow(msg -> new IllegalStateException("Failed to parse deprecated language data: " + msg));
}
public static DeprecatedTranslationsInfo loadFromResource(String path) {
try (InputStream stream = Language.class.getResourceAsStream(path)) {
return stream != null ? loadFromJson(stream) : EMPTY;
} catch (Exception var6) {
LOGGER.error("Failed to read {}", path, var6);
return EMPTY;
}
}
public static DeprecatedTranslationsInfo loadFromDefaultResource() {
return loadFromResource("/assets/minecraft/lang/deprecated.json");
}
public void applyToMap(Map<String, String> translations) {
for (String key : this.removed) {
translations.remove(key);
}
this.renamed.forEach((fromKey, toKey) -> {
String value = translations.remove(fromKey);
if (value == null) {
LOGGER.warn("Missing translation key for rename: {}", fromKey);
translations.remove(toKey);
} else {
translations.put(toKey, value);
}
});
}
}引用的其他类
- StrictJsonParser
- 引用位置:
方法调用 - 关联成员:
StrictJsonParser.parse()
- 引用位置: