You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

mcmmo插件.yml文件报错:紧凑映射不允许嵌套映射问题排查

MCMMO插件模组物品YAML配置报错问题

我在给MCMMO插件添加模组物品时遇到问题,插件通过.yml文件读取物品配置。我的配置代码如下:

Boots:    
    Travelers Boots: tconstruct:travelers_boots
        Repairable: true
        Repair_Material: minecraft:copper_ingot
        Repair_Material_Data_Value: 0
        Repair_Material_Quantity: 1
        Repair_Material_Pretty_Name: Copper Ingot
        Repair_MinimumLevel: 80
        Repair_XpMultiplier: 1.0
        Durability: 130
    Plate Boots: tconstruct:plate_boots
        Repairable: true
        Repair_Material: tconstruct:cobalt_ingot
        Repair_Material_Data_Value: 0
        Repair_Material_Quantity: 1
        Repair_Material_Pretty_Name: Cobalt Ingot
        Repair_MinimumLevel: 150
        Repair_XpMultiplier: 1.2
        Durability: 390
    Slimeboots: tconstruct:slime_boots
        Repairable: true
        Repair_Material: minecraft:slime_ball
        Repair_Material_Data_Value: 0
        Repair_Material_Quantity: 5
        Repair_Material_Pretty_Name: Slimeball
        Repair_MinimumLevel: 250
        Repair_XpMultiplier: 1.5
        Durability: 546
    Chocodisguise Boots: chococraft:choco_disguise_boots
        Repairable: true
        Repair_Material: chococraft:chocobo_feather
        Repair_Material_Data_Value: 0
        Repair_Material_Quantity: 1
        Repair_Material_Pretty_Name: Chocobo Feather
        Repair_MinimumLevel: 75
        Repair_XpMultiplier: 1.0
        Durability: 2600    

服务器启动时反复抛出Nested mappings are not allowed in compact mappings in line x column y的报错信息。我使用Notepad++编辑该文件,已开启自动将制表符转换为空格的选项,经YAMLlint验证工具检测,得到以下错误提示:

Nested mappings are not allowed in compact mappings at line 2, column 22
Implicit keys need to be on a single line at line 2, column 22
Nested mappings are not allowed in compact mappings at line 3, column 21
Implicit keys need to be on a single line at line 3, column 21
Nested mappings are not allowed in compact mappings at line 4, column 26
Implicit keys need to be on a single line at line 4, column 26


问题原因及修复方案

问题出在YAML语法错误:你将物品名称与ID写在同一行的紧凑映射(如Travelers Boots: tconstruct:travelers_boots)后,直接嵌套了子属性,这违反了YAML的规则——紧凑映射(单行键值对)不能包含后续的嵌套映射。

正确的写法是将每个物品的ID作为子属性放在嵌套结构里,修正后的配置如下:

Boots:    
    Travelers Boots:
        Item: tconstruct:travelers_boots
        Repairable: true
        Repair_Material: minecraft:copper_ingot
        Repair_Material_Data_Value: 0
        Repair_Material_Quantity: 1
        Repair_Material_Pretty_Name: Copper Ingot
        Repair_MinimumLevel: 80
        Repair_XpMultiplier: 1.0
        Durability: 130
    Plate Boots:
        Item: tconstruct:plate_boots
        Repairable: true
        Repair_Material: tconstruct:cobalt_ingot
        Repair_Material_Data_Value: 0
        Repair_Material_Quantity: 1
        Repair_Material_Pretty_Name: Cobalt Ingot
        Repair_MinimumLevel: 150
        Repair_XpMultiplier: 1.2
        Durability: 390
    Slimeboots:
        Item: tconstruct:slime_boots
        Repairable: true
        Repair_Material: minecraft:slime_ball
        Repair_Material_Data_Value: 0
        Repair_Material_Quantity: 5
        Repair_Material_Pretty_Name: Slimeball
        Repair_MinimumLevel: 250
        Repair_XpMultiplier: 1.5
        Durability: 546
    Chocodisguise Boots:
        Item: chococraft:choco_disguise_boots
        Repairable: true
        Repair_Material: chococraft:chocobo_feather
        Repair_Material_Data_Value: 0
        Repair_Material_Quantity: 1
        Repair_Material_Pretty_Name: Chocobo Feather
        Repair_MinimumLevel: 75
        Repair_XpMultiplier: 1.0
        Durability: 2600    

修正说明

  • 每个物品名称(如Travelers Boots)后仅保留冒号,换行缩进后添加子属性
  • 将原单行的物品ID移至Item子键下,明确属性层级
  • 保持所有子属性的缩进一致(确保用空格而非制表符,你已开启转换选项,这部分没问题)

内容的提问来源于stack exchange,提问作者Xcillid Bang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 17:34:55