# 物品等级

物品等级和物品点数很相似，但是物品等级提供了一个内置的可升级方案，玩家可以通过积累经验值来提升物品的等级。

你可以创建无数多的物品等级。

## 如何创建物品等级

物品等级的配置文件都可以在 `/plugins/libreforge/levels/` 目录下找到，你也可以删除里面的配置文件以代表删除某个物品等级。

物品等级的ID就是文件名称。

以下是一个示例文件：

### `_example.yml`[​](https://plugins.auxilor.io/effects/item-levels#_exampleyml) <a href="#exampleyml" id="exampleyml"></a>

<pre class="language-yaml"><code class="lang-yaml"><strong># 有两种指定各个等级需要的经验值的方案:
</strong>#  1. 一个没有等级上限的等级计算公式
#  2. 一个指定各个等级所需经验值的列表

# 如果是第一种方案，需要使用以下两个选项。
# xp-formula: (2 ^ %level%) * 25
# 这个选项代表等级计算公式，其中 %level% 代表对应的等级。
# max-level: 10 
# 这个选项代表等级上限，可以不设置，不设置的话就是没有上限。

# 这是使用第二种方案，即自己人工设置各个等级所需经验值。
requirements:
  - 50
  - 100
  - 200
  - 400
  - 1000
  - 2000
  - 5000
  - 10000
  - 17500
  - 40000
  - 100000
  - 250000

# 每次升级时执行的效果
# %level% 代表对应等级
level-up-effects:
  - id: send_message
    args:
      message: "&#x26;f你升级到了 &#x26;a%level%&#x26;f 级!"
  - id: play_sound
    args:
      sound: entity_player_levelup
      volume: 1.0
      pitch: 1.5
</code></pre>

## 变量符

你可以通过以下变量符获取物品等级的信息：

`%libreforge_item_xp_等级ID%`: 当前经验值

`%libreforge_item_level_等级ID%`: 当前等级

`%libreforge_item_xp_required_等级ID%`: 当前等级升级需要的经验值

`%libreforge_item_progress_等级ID%`: 当前升级进度

你可以在各个变量符的末尾添加 `_numeral` 以获取对应数值的罗马数字。

## 示例 EcoItems 物品

下面是一个使用物品等级的 EcoItems 物品的示例：

```yaml
item:
  item: diamond_pickaxe hide_attributes unbreakable efficiency:5 blast_mining:3
  display-name: "&e可升级镐子 &8- &6%libreforge_item_level_example_numeral%"
  lore:
    - "&f当前等级 &a%libreforge_item_level_example%"
    - "&fXP: &a%libreforge_item_xp_example%&8/&a%libreforge_item_xp_required_example% &f(&a%libreforge_item_progress_example%%&f)"
  craftable: false
  recipe: [ ]

slot: mainhand

effects:
    - id: level_item
      args:
          id: example
          xp: "%v%"
      triggers:
          - mine_block

conditions: [ ]
```
