> For the complete documentation index, see [llms.txt](https://simple.superiormc.cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://simple.superiormc.cn/arcmenu-wen-dang/cai-dan-shi-li/integration-menu.md).

# 插件联动菜单示例

本例通过玩家命令调用服务器已有的传送功能，演示如何将其他插件的操作放入菜单。完整示例适用于 Paper、Folia 和 Leaf；Spigot 的调整方法见下方说明。不要求图片资源。

## 前提

服务器必须已经提供 `/spawn` 命令，普通玩家能够按该命令所属插件的权限规则使用它。先直接执行命令确认传送、冷却和限制正常，再添加菜单。

示例使用 `myserver.menu.spawn` 作为菜单按钮的额外权限。它需要由服主的权限插件授予，不会代替 `/spawn` 自身的权限。

## 菜单文件

创建 `services.yml`，放入所用平台的菜单目录。本例不改变唯一主菜单设置。

```yaml
schema-version: 1
id: services
permission: arcmenu.use
canvas:
  width: 320
  height: 180
  pixels-per-block: 42.7
  distance: 3
frontend:
  service-background:
    type: rectangle
    width: 180
    height: 100
    color: '#182031'
  service-title:
    type: text
    content: '&fPlayer services'
    size: 5
    offset: {x: 0, y: 32, z: 1}
  player-label:
    type: text
    content: '&7%player_name%'
    size: 3
    offset: {x: 0, y: 15, z: 1}
  spawn-button:
    type: rectangle
    width: 100
    height: 20
    color: '#365E91'
    offset: {x: 0, y: -8, z: 1}
  spawn-label:
    type: text
    content: '&fReturn to spawn'
    size: 3
    offset: {x: 0, y: -8, z: 2}
  close-label:
    type: text
    content: '&7Close'
    size: 3
    offset: {x: 0, y: -34, z: 1}
backend:
  spawn-area:
    x: 0
    y: -8
    width: 100
    height: 20
    condition: 'perm myserver.menu.spawn'
    deny:
      - 'tell: &cYou cannot use this service.'
    actions:
      right:
        actions:
          - close
          - 'player: spawn'
  close-area:
    x: 0
    y: -34
    width: 60
    height: 16
    actions:
      right: close
```

### 关闭与执行命令的顺序

本例先关闭菜单，再执行传送命令。两项放在同一分支的 `actions` 列表中，使关闭后继续执行命令。Spigot 使用本例时，将 `spawn-area` 中的整个 `actions` 配置节替换为：

```yaml
actions:
  right: 'player: spawn'
```

Spigot 关闭动作会停止后续动作，应改为只执行 `player: spawn`，传送发生时菜单会关闭。若命令没有传送成功，则玩家可用关闭按钮退出。

## 加载与验证

执行 `/arcmenu validate`、`/arcmenu reload` 与 `/arcmenu open services`。分别检查有无按钮权限，以及有无 `/spawn` 命令权限的账号。

菜单调用命令，不保证命令执行成功，也不会忽略第三方插件的冷却、费用或传送限制。应以该插件反馈和实际传送结果为准。

## 扩展其他联动

将 `player: spawn` 替换为目标插件支持的玩家命令。控制台执行的命令使用 `console`，并明确填写所需玩家参数；不要假定控制台自动以点击者为目标。

Paper 系服务端可另加 PlaceholderAPI 信息、Vault 余额或 CraftEngine 物品展示，前提与限制见[平台与插件兼容性](/arcmenu-wen-dang/pei-zhi-yu-guan-li/compatibility.md)。付费操作应交由目标插件的完整交易命令处理，不能仅把扣款与奖励动作排列在一起。

示例配置需要按平台调整；第三方命令与实际操作必须在安装了目标插件的服务器中验证。
