# 8.x 版本

自定义附魔配置可以在 `plugins/EcoEnchants/customenchants.yml` 中找到，它的一般配置如下：

```
enchants:
  - <第一个自定义附魔>
  - <第二个自定义附魔>
```

其中，`enchants` 为一个 **List** 类型的自定义附魔的键，所有自定义附魔的一半配置如下：

```
- id: escape
  type: normal
  name: "逃避"
  description: 在受到伤害后获得短时间的加速效果

  obtaining:
    table: true
    villager: true
    loot: true
    rarity: epic

  general-config:
    flags: [ ]
    targets:
      - boots
    grindstoneable: true
    disabled-in-worlds: [ ]
    requirements:
      list: [ ]
      not-met-lore: [ ]
    conflicts: [ ]

  levels:
    - effects:
        - id: potion_effect
          args:
            effect: speed
            level: 1
            duration: 30
            apply_to_player: true
          triggers:
            - take_damage
      conditions: [ ]
    - effects:
        - id: potion_effect
          args:
            effect: speed
            level: 2
            duration: 30
            apply_to_player: true
          triggers:
            - take_damage
      conditions: [ ]
```

我们可以看出它由以下部分组成：

* **id**：自定义附魔的 ID，只能由小写字母组成，如果有下划线在游戏中会被自动省略。
* **type**：附魔的类型，在正常情况下我们直接填写 **normal** 即可。

另有：**curse**（负面附魔，插件内的作用是无论该负面附魔是什么稀有度，其自定义颜色都将会是红色）、**special**（特殊附魔，插件内的作用是每个物品最多只能有一个特殊附魔）。

* **name**：附魔的名称，玩家能够看到的。
* **description**: 附魔的描述，玩家可以通过 **/enchantinfo** 指令查询到，也可以通过开启 `plugins/EcoEnchants/config.yml` 中的 `describe.enabled` 选项，将其修改为 `true` 即可。

{% hint style="info" %}
本教程将引用一种新的描述格式，以上文的 `describe.enabled` 为例，它在配置中实际显示如下：
{% endhint %}

```
  describe:
    before-lines: 5
    at-bottom: false
    only-on-books: false
    wrap: 30
    enabled: true # <----- enabled 为 describe 下的子选项
```

* **obtaining.table**
* **obtaining.villager**
* **obtaining.loot**

获得该附魔的方式，从上到下分别是：附魔台、村民、宝箱

{% hint style="info" %}
如果您的服务器还使用了其他自定义村民交易插件、自定义宝箱战利品插件等，我们建议您花费一些时间自行地为这些附魔加入到这些插件的配置中，并关闭这里的获得方法，以减少插件冲突的可能性，这会导致实质生成概率与所配置的理想状态严重不符，严重的还会进一步导致其他问题！

同时，笔者也非常建议你参照原版附魔的获得方式，而不是一股脑地所有方式都可以获得，你应该保留一些特别稀有的附魔，只能通过村民交易，并设置较低的概率，以增加游戏趣味性。
{% endhint %}

* **obtaining.rarity：**&#x83B7;得该附魔的稀有度。

请打开 `plugins/EcoEnchants/rarity.yml` 文件，该选项与该文件有直接关联。

打开后我们可以看到如下内容：

```
rarities:
  common:
    table-probability: 30
    minimum-level: 1
    villager-probability: 10.5
    loot-probability: 12
    custom-color:
      enabled: false
      color: "&7"
  uncommon:
    table-probability: 20
    minimum-level: 5
    villager-probability: 9
    loot-probability: 16
    custom-color:
      enabled: false
      color: "&a"
  rare:
    table-probability: 20
    minimum-level: 15
    villager-probability: 7.5
    loot-probability: 18
    custom-color:
      enabled: false
      color: "&9"
  epic:
    table-probability: 10
    minimum-level: 16
    villager-probability: 6
    loot-probability: 20
    custom-color:
      enabled: false
      color: "&5"
  legendary:
    table-probability: 8
    minimum-level: 20
    villager-probability: 4.5
    loot-probability: 15
    custom-color:
      enabled: false
      color: "&6"
  special:
    table-probability: 2
    minimum-level: 30
    villager-probability: 3
    loot-probability: 5
    custom-color:
      enabled: false
      color: "&d"
  veryspecial:
    table-probability: 1
    minimum-level: 30
    villager-probability: 1.5
    loot-probability: 2
    custom-color:
      enabled: false
      color: "&4"
  artifact:
    table-probability: 5
    minimum-level: 1
    villager-probability: 9
    loot-probability: 5
    custom-color:
      enabled: false
      color: "&8"

```

按照 **Yaml 语法学习** 一节的内容，我们可知 `common、 uncommon、rare、epic、legendary、special、veryspecial、artifact` 均为 `rarities` 下的子键（子选项），这也是我们需要在 `obtaining.raitiy` 中将会填写的内容，如所给示例即为 `epic`。

稀有度不仅可以显示在附魔上，它更重要功能是决定玩家能够获得这个附魔的概率。

各个稀有度下又有以下子选项：

* **table-probability：**&#x9644;魔台获得此稀有度附魔的概率。
* **minimum-level：**&#x9644;魔台获得此稀有度附魔的最低等级。
* **villager-probability：**&#x6751;民交易中含有此稀有度附魔的概率。
* **loot-probability：**&#x5B9D;箱中含有此稀有度附魔书的概率。
* **custom-color.enabled：**&#x662F;否开启稀有度附魔自定义颜色。
* **custom-color.color：**&#x81EA;定义颜色的代码。

我们继续挖掘一般自定义附魔配置：

* **general-config.targets：**&#x53EF;以拥有该附魔的物品，如何填写请见下一节。
* **general-config.flags：**&#x9644;魔的标签，值按 **List** 格式填写。

有如下几个标签可以设置：

* **hard-cap-ignore：**&#x65E0;视附魔上限。
* **no-cooldown-message：**&#x4E0D;显示附魔冷却提示。（仅限卷轴类型附魔）
* **no-use-message：**&#x4E0D;显示附魔使用提示。（仅限卷轴类型附魔）

继续一般自定义附魔配置：

* **general-config.grindstoneable：**&#x662F;否可以使用砂轮将该附魔祛除并获得经验值。
* **general-config.disabled-in-worlds：**&#x9644;魔禁用的世界，值按 **List** 格式填写。
* **general-config.requirements：**&#x9644;魔的使用条件，具体如下：

```
general-config:
  requirements:
    list:
      - 'placeholder-greater-than:%ecoskills_enchanting%:20'
    not-met-lore: 
      - ""
      - "&c你必须达到 &e附魔 XX"
      - "&c才能使用 &d狂怒&c 附魔" 
```

其中：

* **general-config.requirements.list：**&#x5177;体的条件列表，以 **List** 格式填写，其中各个值中又按照 `'条件类型:条件内容'` 填写。

{% hint style="info" %}
想一想，为什么前后要加 **'** 符号，如果你不知道，请再次阅读 **Yaml 语法格式** 一节。
{% endhint %}

* **general-config.requirements.not-met-lore：**&#x6761;件未满足时给附魔物品自动加的 **Lore**。

{% hint style="info" %}
如果你不需要这个选项，还记得我们在 **Yaml 语法学习** 所讲的吗，试试填写 **not-met-lore: \[]**，这样无论条件是否满足，附魔物品都不会被自动加上 **Lore**。
{% endhint %}

条件类型有如下几种：

* **has-permission：**&#x662F;否拥有条件内容的权限节点，条件内容填写权限节点即可。
* **placeholder-equals：**&#x53D8;量符（Placeholders）是否等于某个值，条件内容按照 `变量符:要求的值` 格式填写。例如 `%ecoskills_enchanting%:20` 即代表 `%ecoskills_enchanting%` 变量符的值必须为 **20** 时条件才会被满足。
* **placeholder-greater-than：**&#x5927;于等于，详见上。
* **placeholder-less-than：**&#x5C0F;于等于，详见上。

继续一般自定义附魔配置：

* **levels：**&#x5404;个等级的附魔的效果，以 **List** 格式填写。

我们再次阅读开头所给的示例：

```
  levels:
    - effects:
        - id: potion_effect
          args:
            effect: speed
            level: 1
            duration: 30
            apply_to_player: true
          triggers:
            - take_damage
      conditions: [ ]
    - effects:
        - id: potion_effect
          args:
            effect: speed
            level: 2
            duration: 30
            apply_to_player: true
          triggers:
            - take_damage
      conditions: [ ]
```

{% hint style="info" %}
想一想，为什么各个 **effect** 前会有一个 **-** 符号，如果你不知道，请再次阅读 **Yaml 语法学习** 一节。
{% endhint %}

以上铺垫了这么多，这里才是这个关卡最终 **Boss** 的存在，我们在 简绍  一节已经提及，所有 **EcoX** 都是围绕自定义技能（The Effect System）的，这里就是设置拥有该附魔的物品将会触发的技能了，我们这里暂时不揭露这个神秘的内容，阅读第二章，我们将会一一揭晓它神秘的面纱。
