mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-28 11:29:17 +00:00
补齐注释, 添加新的语言key.
This commit is contained in:
@@ -65,6 +65,7 @@ command.send_resource_pack.success.single: "<white>发送资源包给 <arg:0></w
|
||||
command.send_resource_pack.success.multiple: "<white>发送资源包给 <arg:0> 个玩家</white>"
|
||||
warning.config.pack.duplicated_files: "</red>发现重复文件 请通过 config.yml 的 'resource-pack.duplicated-files-handler' 部分解决</red>"
|
||||
warning.config.yaml.duplicated_key: "<red>在文件 <arg:0> 发现问题 - 在第<arg:2>行发现重复的键 '<arg:1>', 这可能会导致一些意料之外的问题.</red>"
|
||||
warning.config.yaml.key_path_conflict: "<red>在文件 <arg:0> 发现问题 - 在第<arg:2>行发现重复且值类型不同的键 '<arg:1>', 这可能会导致一些意料之外的问题.</red>"
|
||||
warning.config.type.int: "<yellow>在文件 <arg:0> 发现问题 - 无法加载 '<arg:1>': 无法将 '<arg:2>' 转换为整数类型 (选项 '<arg:3>')</yellow>"
|
||||
warning.config.type.float: "<yellow>在文件 <arg:0> 发现问题 - 无法加载 '<arg:1>': 无法将 '<arg:2>' 转换为浮点数类型 (选项 '<arg:3>')</yellow>"
|
||||
warning.config.type.boolean: "<yellow>在文件 <arg:0> 发现问题 - 无法加载 '<arg:1>': 无法将 '<arg:2>' 转换为布尔类型 (选项 '<arg:3>')</yellow>"
|
||||
|
||||
@@ -102,27 +102,32 @@ public class StringKeyConstructor extends SafeConstructor {
|
||||
|
||||
// 处理深层键
|
||||
private void processDeepKey(Map<Object, Object> rootMap, String fullKey, Node valueNode, Node keyNode) {
|
||||
// 分割出不同的层级
|
||||
String[] keyParts = fullKey.split(DEEP_KEY_SEPARATOR);
|
||||
Map<Object, Object> currentMap = rootMap;
|
||||
|
||||
// 创建必要的的中间层级
|
||||
// 创建必要的的中间层级(最后一个key不应遍历, 如aa::bb::cc, 只应创建aa和bb.)
|
||||
for (int i = 0; i < keyParts.length - 1; i++) {
|
||||
String keyPart = keyParts[i];
|
||||
Object existingValue = currentMap.get(keyPart);
|
||||
|
||||
// 路径中的值
|
||||
if (existingValue instanceof Map) {
|
||||
currentMap = (Map<Object, Object>) existingValue;
|
||||
} else {
|
||||
if (existingValue != null) {
|
||||
logWarning("key_path_conflict", keyPart, keyNode);
|
||||
}
|
||||
Map<Object, Object> newMap = new LinkedHashMap<>();
|
||||
currentMap.put(keyPart, newMap);
|
||||
currentMap = newMap;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 如果路径中存在一个非map的值, 这意味着
|
||||
// 当存在了 {aa: bb}, 又想要写入 {aa::bb::c: value} 时, 会触发这个警告, 然后会覆盖之前的.
|
||||
if (existingValue != null) logWarning("key_path_conflict", keyPart, keyNode);
|
||||
|
||||
// 创建层级
|
||||
Map<Object, Object> newMap = new LinkedHashMap<>();
|
||||
currentMap.put(keyPart, newMap);
|
||||
currentMap = newMap;
|
||||
}
|
||||
|
||||
// 处理最终键
|
||||
// 这里再处理最后的 cc key.
|
||||
String finalKey = keyParts[keyParts.length - 1];
|
||||
Object newValue = constructObject(valueNode);
|
||||
String keyPath = String.join(DEEP_KEY_SEPARATOR, keyParts); // 构建完整的键路径字符串
|
||||
|
||||
Reference in New Issue
Block a user