9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-25 09:59:20 +00:00

本地化json格式报错

This commit is contained in:
XiaoMoMi
2025-06-19 01:16:10 +08:00
parent 295f05762d
commit f7ca82037d
4 changed files with 26 additions and 15 deletions

View File

@@ -369,4 +369,5 @@ warning.config.resource_pack.generation.missing_font_texture: "<yellow>Font '<ar
warning.config.resource_pack.generation.missing_model_texture: "<yellow>Model '<arg:0>' is missing texture '<arg:1>'</yellow>"
warning.config.resource_pack.generation.missing_item_model: "<yellow>Item '<arg:0>' is missing model file: '<arg:1>'</yellow>"
warning.config.resource_pack.generation.missing_block_model: "<yellow>Block '<arg:0>' is missing model file: '<arg:1>'</yellow>"
warning.config.resource_pack.generation.missing_parent_model: "<yellow>Model '<arg:0>' cannot find parent model: '<arg:1>'</yellow>"
warning.config.resource_pack.generation.missing_parent_model: "<yellow>Model '<arg:0>' cannot find parent model: '<arg:1>'</yellow>"
warning.config.resource_pack.generation.malformatted_json: "<yellow>Json file '<arg:0>' is malformatted.</yellow>"

View File

@@ -369,4 +369,5 @@ warning.config.resource_pack.generation.missing_font_texture: "<yellow>字体'<a
warning.config.resource_pack.generation.missing_model_texture: "<yellow>模型'<arg:0>'缺少纹理'<arg:1>'</yellow>"
warning.config.resource_pack.generation.missing_item_model: "<yellow>物品'<arg:0>'缺少模型文件: '<arg:1>'</yellow>"
warning.config.resource_pack.generation.missing_block_model: "<yellow>方块'<arg:0>'缺少模型文件: '<arg:1>'</yellow>"
warning.config.resource_pack.generation.missing_parent_model: "<yellow>模型'<arg:0>'找不到父级模型文件: '<arg:1>'</yellow>"
warning.config.resource_pack.generation.missing_parent_model: "<yellow>模型'<arg:0>'找不到父级模型文件: '<arg:1>'</yellow>"
warning.config.resource_pack.generation.malformatted_json: "<yellow>Json文件 '<arg:0>' 格式错误.</yellow>"

View File

@@ -631,7 +631,7 @@ public abstract class AbstractPackManager implements PackManager {
try {
rootPaths = FileUtils.collectOverlays(path);
} catch (IOException e) {
plugin.logger().warn("Failed to read overlays for " + path.toAbsolutePath(), e);
plugin.logger().warn("Failed to collect overlays for " + path.toAbsolutePath(), e);
return;
}
Multimap<Key, Key> imageToFonts = ArrayListMultimap.create(); // 图片到字体的映射
@@ -647,7 +647,7 @@ public abstract class AbstractPackManager implements PackManager {
try {
namespaces = FileUtils.collectNamespaces(assetsPath);
} catch (IOException e) {
plugin.logger().warn("Failed to read namespaces for " + assetsPath.toAbsolutePath(), e);
plugin.logger().warn("Failed to collect namespaces for " + assetsPath.toAbsolutePath(), e);
return;
}
for (Path namespacePath : namespaces) {
@@ -662,7 +662,7 @@ public abstract class AbstractPackManager implements PackManager {
try {
fontJson = GsonHelper.readJsonFile(file).getAsJsonObject();
} catch (IOException | JsonSyntaxException e) {
plugin.logger().warn("Failed to read font json for " + file.toAbsolutePath(), e);
TranslationManager.instance().log("warning.config.resource_pack.generation.malformatted_json", file.toAbsolutePath().toString());
return FileVisitResult.CONTINUE;
}
JsonArray providers = fontJson.getAsJsonArray("providers");
@@ -698,7 +698,7 @@ public abstract class AbstractPackManager implements PackManager {
try {
itemJson = GsonHelper.readJsonFile(file).getAsJsonObject();
} catch (IOException | JsonSyntaxException e) {
plugin.logger().warn("Failed to read items json for " + file.toAbsolutePath(), e);
TranslationManager.instance().log("warning.config.resource_pack.generation.malformatted_json", file.toAbsolutePath().toString());
return FileVisitResult.CONTINUE;
}
Key item = Key.of(namespacePath.getFileName().toString(), FileUtils.pathWithoutExtension(file.getFileName().toString()));
@@ -716,14 +716,14 @@ public abstract class AbstractPackManager implements PackManager {
try {
Files.walkFileTree(blockStatesPath, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<>() {
@Override
public @NotNull FileVisitResult visitFile(@NotNull Path file, @NotNull BasicFileAttributes attrs) throws IOException {
public @NotNull FileVisitResult visitFile(@NotNull Path file, @NotNull BasicFileAttributes attrs) {
if (!isJsonFile(file)) return FileVisitResult.CONTINUE;
String blockId = FileUtils.pathWithoutExtension(file.getFileName().toString());
JsonObject blockStateJson;
try {
blockStateJson = GsonHelper.readJsonFile(file).getAsJsonObject();
} catch (IOException | JsonSyntaxException e) {
plugin.logger().warn("Failed to read blockstates json for " + file.toAbsolutePath(), e);
TranslationManager.instance().log("warning.config.resource_pack.generation.malformatted_json", file.toAbsolutePath().toString());
return FileVisitResult.CONTINUE;
}
if (blockStateJson.has("multipart")) {
@@ -760,11 +760,14 @@ public abstract class AbstractPackManager implements PackManager {
for (Path rootPath : rootPaths) {
Path modelJsonPath = rootPath.resolve(modelPath);
if (Files.exists(rootPath.resolve(modelPath))) {
JsonObject jsonObject;
try {
collectModels(key, GsonHelper.readJsonFile(modelJsonPath).getAsJsonObject(), rootPaths, imageToModels);
jsonObject = GsonHelper.readJsonFile(modelJsonPath).getAsJsonObject();
} catch (IOException | JsonSyntaxException e) {
plugin.logger().warn("Failed to read model " + modelJsonPath.toAbsolutePath(), e);
TranslationManager.instance().log("warning.config.resource_pack.generation.malformatted_json", modelJsonPath.toAbsolutePath().toString());
continue;
}
collectModels(key, jsonObject, rootPaths, imageToModels);
continue label;
}
}
@@ -778,11 +781,14 @@ public abstract class AbstractPackManager implements PackManager {
for (Path rootPath : rootPaths) {
Path modelJsonPath = rootPath.resolve(modelPath);
if (Files.exists(modelJsonPath)) {
JsonObject jsonObject;
try {
collectModels(key, GsonHelper.readJsonFile(modelJsonPath).getAsJsonObject(), rootPaths, imageToModels);
jsonObject = GsonHelper.readJsonFile(modelJsonPath).getAsJsonObject();
} catch (IOException | JsonSyntaxException e) {
plugin.logger().warn("Failed to read model " + modelJsonPath.toAbsolutePath(), e);
TranslationManager.instance().log("warning.config.resource_pack.generation.malformatted_json", modelJsonPath.toAbsolutePath().toString());
continue;
}
collectModels(key, jsonObject, rootPaths, imageToModels);
continue label;
}
}
@@ -811,11 +817,14 @@ public abstract class AbstractPackManager implements PackManager {
for (Path rootPath : rootPaths) {
Path modelJsonPath = rootPath.resolve(parentModelPath);
if (Files.exists(modelJsonPath)) {
JsonObject jsonObject;
try {
collectModels(parentResourceLocation, GsonHelper.readJsonFile(modelJsonPath).getAsJsonObject(), rootPaths, imageToModels);
jsonObject = GsonHelper.readJsonFile(modelJsonPath).getAsJsonObject();
} catch (IOException | JsonSyntaxException e) {
plugin.logger().warn("Failed to read model " + modelJsonPath.toAbsolutePath(), e);
TranslationManager.instance().log("warning.config.resource_pack.generation.malformatted_json", modelJsonPath.toAbsolutePath().toString());
break label;
}
collectModels(parentResourceLocation, jsonObject, rootPaths, imageToModels);
break label;
}
}

View File

@@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx1G
# Rule: [major update].[feature update].[bug fix]
project_version=0.0.57.4
config_version=37
lang_version=16
lang_version=17
project_group=net.momirealms
latest_supported_version=1.21.6