mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-29 20:09:13 +00:00
字体防呆
This commit is contained in:
@@ -68,7 +68,7 @@ warning.config.cast_float: "<yellow>Issue found in file <arg:0> - Failed to load
|
||||
warning.config.cast_double: "<yellow>Issue found in file <arg:0> - Failed to load '<arg:1>': Cannot cast '<arg:2>' to double type for option '<arg:3>'."
|
||||
warning.config.cast_quaternionf: "<yellow>Issue found in file <arg:0> - Failed to load '<arg:1>': Cannot cast '<arg:2>' to Quaternionf type for option '<arg:3>'."
|
||||
warning.config.cast_vector3f: "<yellow>Issue found in file <arg:0> - Failed to load '<arg:1>': Cannot cast '<arg:2>' to Vector3f type for option '<arg:3>'."
|
||||
warning.config.not_a_section: "<yellow>Issue found in file <arg:0> - '<arg:1>.<arg:2>' is expected to be a config section while it's actually a(n) '<arg:3>'.</yellow>"
|
||||
warning.config.not_a_section: "<yellow>Issue found in file <arg:0> - '<arg:1>' is expected to be a config section while it's actually a(n) '<arg:2>'.</yellow>"
|
||||
warning.config.image.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated image '<arg:1>'.</yellow>"
|
||||
warning.config.image.lack_height: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is missing the required 'height' argument.</yellow>"
|
||||
warning.config.image.height_smaller_than_ascent: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' violates the bitmap image rule: 'height'[<arg:2>] should be no lower than 'ascent'[<arg:3>].</yellow>"
|
||||
|
||||
@@ -439,8 +439,15 @@ public abstract class AbstractFontManager implements FontManager {
|
||||
Key fontKey = Key.withDefaultNamespace(fontName, id.namespace());
|
||||
Font font = getOrCreateFont(fontKey);
|
||||
List<char[]> 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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user