From 0f96dc12bc013aa87380043f32e208d61e79d302 Mon Sep 17 00:00:00 2001 From: XiaoMoMi Date: Mon, 28 Apr 2025 23:03:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E4=BD=93=E9=98=B2=E5=91=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/translations/en.yml | 2 +- .../core/font/AbstractFontManager.java | 19 +++++++++++-------- .../core/pack/AbstractPackManager.java | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/bukkit/loader/src/main/resources/translations/en.yml b/bukkit/loader/src/main/resources/translations/en.yml index e62b421e4..6772ed8ba 100644 --- a/bukkit/loader/src/main/resources/translations/en.yml +++ b/bukkit/loader/src/main/resources/translations/en.yml @@ -68,7 +68,7 @@ warning.config.cast_float: "Issue found in file - Failed to load warning.config.cast_double: "Issue found in file - Failed to load '': Cannot cast '' to double type for option ''." warning.config.cast_quaternionf: "Issue found in file - Failed to load '': Cannot cast '' to Quaternionf type for option ''." warning.config.cast_vector3f: "Issue found in file - Failed to load '': Cannot cast '' to Vector3f type for option ''." -warning.config.not_a_section: "Issue found in file - '.' is expected to be a config section while it's actually a(n) ''." +warning.config.not_a_section: "Issue found in file - '' is expected to be a config section while it's actually a(n) ''." warning.config.image.duplicated: "Issue found in file - Duplicated image ''." warning.config.image.lack_height: "Issue found in file - The image '' is missing the required 'height' argument." warning.config.image.height_smaller_than_ascent: "Issue found in file - The image '' violates the bitmap image rule: 'height'[] should be no lower than 'ascent'[]." diff --git a/core/src/main/java/net/momirealms/craftengine/core/font/AbstractFontManager.java b/core/src/main/java/net/momirealms/craftengine/core/font/AbstractFontManager.java index 5ea86da63..d9fb200ad 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/font/AbstractFontManager.java +++ b/core/src/main/java/net/momirealms/craftengine/core/font/AbstractFontManager.java @@ -439,8 +439,15 @@ public abstract class AbstractFontManager implements FontManager { Key fontKey = Key.withDefaultNamespace(fontName, id.namespace()); Font font = getOrCreateFont(fontKey); List chars; - if (section.containsKey("chars")) { - chars = MiscUtils.getAsStringList(section.get("chars")).stream().map(it -> { + Object charsObj = section.get("chars"); + if (charsObj == null) { + charsObj = section.get("char"); + } + if (charsObj == null) { + throw new LocalizedResourceConfigException("warning.config.image.lack_char", path, id); + } + if (charsObj instanceof List list) { + chars = MiscUtils.getAsStringList(list).stream().map(it -> { if (it.startsWith("\\u")) { return CharacterUtils.decodeUnicodeToChars(it); } else { @@ -448,14 +455,10 @@ public abstract class AbstractFontManager implements FontManager { } }).toList(); } else { - Object c = section.get("char"); - if (c == null) { - throw new LocalizedResourceConfigException("warning.config.image.lack_char", path, id); - } - if (c instanceof Integer integer) { + if (charsObj instanceof Integer integer) { chars = List.of(new char[]{(char) integer.intValue()}); } else { - String character = c.toString(); + String character = charsObj.toString(); if (character.length() == 1) { chars = List.of(character.toCharArray()); } else { diff --git a/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java b/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java index 566ee6b75..62c7d97fd 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java +++ b/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java @@ -460,7 +460,7 @@ public abstract class AbstractPackManager implements PackManager { parser.parseSection(cached.pack(), cached.filePath(), id, plugin.templateManager().applyTemplates(configSection1)); } } else { - TranslationManager.instance().log("warning.config.not_a_section", cached.filePath().toString(), parser.sectionId()[0], configEntry.getKey(), configEntry.getValue().getClass().getSimpleName()); + TranslationManager.instance().log("warning.config.not_a_section", cached.filePath().toString(), cached.prefix() + "." + key, configEntry.getValue().getClass().getSimpleName()); } } } catch (LocalizedException e) {