| 中文名: | 自定义指令 |
|---|---|
| 外语名: | custom-commands |
| 支持版本: | 1.16.x 1.17.x 1.18.x 1.19.x 1.20.x 1.21.x |
| 适用服务端: | Spigot |
| 插件属性: | 本体插件 |
| 插件类型: | 管理 安全 编程 娱乐 综合 信息 |
| 前置插件: | 无前置 |
| 来源: | 原创 |
| 原帖地址: | https://www.minebbs.com/resources/custom-commands-papi.11962/ |
| 下载地址: | https://www.minebbs.com/resources/custom-commands-papi.11962/ |
| 最后更新: | 2025-07-06 |
|
[MD] # CustomCommands - Minecraft 自定义命令插件 一个强大的 Minecraft Paper/Spigot 插件,允许服务器管理员在配置文件中创建自定义命令,将多个指令整合成一条指令执行。支持热重载、参数传递、权限控制等高级功能。 ## - - - - - - - - - ## - **Minecraft版本**: 1.16.5+ - **服务端**: Paper/Spigot - **Java版本**: 8+ - **可选依赖**: PlaceholderAPI(用于高级变量支持) ## 1. 下载插件 jar 文件 2. 将文件放入服务器的 `plugins` 文件夹 3. **(可选)** 安装 PlaceholderAPI 插件以启用高级变量支持 4. 重启服务器或使用 `/reload` 命令 5. 插件会自动生成默认配置文件 6. 编辑 `plugins/CustomCommands/config.yml` 配置你的自定义命令 ### PlaceholderAPI 安装(可选) 如果你想使用 PlaceholderAPI 变量(如 `%player_level%`、`%server_online%` 等),请按以下步骤安装: 1. 下载 [PlaceholderAPI](https://www.spigotmc.org/resources/placeholderapi.6245/) 插件 2. 将 PlaceholderAPI.jar 放入 `plugins` 文件夹 3. 重启服务器 4. 使用 `/papi ecloud download <扩展名>` 下载所需的扩展 5. 使用 `/papi reload` 重新加载扩展 > ## 配置文件位置:`plugins/CustomCommands/config.yml` ### 基础配置格式 ```yaml custom-commands: 命令名称: enabled: true/false # 是否启用此命令 commands: # 要执行的命令列表 - "命令1" - "命令2" - "命令3" ``` ### 占位符说明 #### 基础占位符 - `{player}` - 执行命令的玩家名称 - `{args}` - 所有参数(用空格连接) - `{arg0}`, `{arg1}`, `{arg2}...` - 第0、1、2...个参数 #### PlaceholderAPI变量 本插件完全支持PlaceholderAPI变量,使用 `%变量名%` 格式: **玩家信息变量:** - `%player_name%` - 玩家名称 - `%player_displayname%` - 玩家显示名 - `%player_level%` - 玩家等级 - `%player_exp%` - 玩家经验值 - `%player_health%` - 玩家当前生命值 - `%player_max_health%` - 玩家最大生命值 - `%player_food_level%` - 玩家饥饿值 - `%player_gamemode%` - 玩家游戏模式 - `%player_world%` - 玩家所在世界 - `%player_x%`, `%player_y%`, `%player_z%` - 玩家坐标 **服务器信息变量:** - `%server_online%` - 在线玩家数量 - `%server_max_players%` - 最大玩家数量 - `%server_time_24%` - 服务器时间(24小时制) **世界信息变量:** - `%world_time%` - 世界游戏时间 - `%world_weather%` - 世界天气状态 - `%world_is_raining%` - 是否正在下雨 **经济变量(需要Vault插件):** - `%vault_eco_balance%` - 玩家余额 - `%vault_eco_balance_formatted%` - 格式化的玩家余额 > ### 配置示例 #### 示例1:新手礼包命令 ```yaml kit: enabled: true commands: - "give {player} minecraft:iron_sword 1" - "give {player} minecraft:bread 16" - "tell {player} §a欢迎来到服务器!这是你的新手礼包!" ``` #### 示例2:带参数的命令 ```yaml giveitem: enabled: true commands: - "give {player} {arg0} {arg1}" - "tell {player} §a已给予你 {arg1} 个 {arg0}!" ``` 使用方法:`/giveitem diamond 64` #### 示例3:传送到出生点 ```yaml spawn: enabled: true commands: - "tp {player} 0 64 0" - "tell {player} §b已将你传送到出生点!" - "playsound minecraft:entity.enderman.teleport player {player}" ``` #### 示例4:玩家状态查询(使用PAPI变量) ```yaml status: enabled: true commands: - "tell {player} §6=== 你的状态 ===" - "tell {player} §e等级: §f%player_level% (经验: %player_exp%)" - "tell {player} §e生命值: §f%player_health%/%player_max_health%" - "tell {player} §e坐标: §f%player_x%, %player_y%, %player_z%" - "tell {player} §e世界: §f%player_world%" - "tell {player} §6==================" ``` #### 示例5:服务器信息(使用PAPI变量) ```yaml serverinfo: enabled: true commands: - "tell {player} §6=== 服务器信息 ===" - "tell {player} §e在线玩家: §f%server_online%/%server_max_players%" - "tell {player} §e当前时间: §f%server_time_24%" - "tell {player} §e世界天气: §f%world_weather%" - "tell {player} §6==================" ``` ## ### 管理员命令 - `/customcommands` 或 `/cc` - 显示插件信息 - `/customcommands reload` - 重新加载配置文件 - `/customcommands list` - 查看所有自定义命令列表 ### 自定义命令 根据配置文件中定义的命令名称使用,例如: - `/kit` - 获取新手礼包 - `/spawn` - 传送到出生点 - `/heal` - 完全治疗 - `/giveitem diamond 64` - 给予64个钻石 ## ### 管理权限 - `customcommands.admin` - 插件管理权限(默认:OP) - `customcommands.reload` - 重新加载配置权限(默认:OP) - `customcommands.list` - 查看命令列表权限(默认:OP) ### 使用权限 - `customcommands.use.*` - 使用所有自定义命令(默认:所有玩家) - `customcommands.use.<命令名>` - 使用特定自定义命令 ### 权限配置示例 ```yaml # 给予玩家使用特定命令的权限 permissions: - customcommands.use.kit - customcommands.use.spawn - customcommands.use.heal ``` ## ### 1. 条件执行 可以在命令中使用条件判断(需要配合其他插件): ```yaml conditional_heal: enabled: true commands: - "execute if entity {player}[nbt={Health:1.0f..10.0f}] run effect give {player} minecraft:instant_health 1 10" - "tell {player} §c你的生命值太低了,已为你治疗!" ``` ### 2. 延迟执行 ```yaml delayed_command: enabled: true commands: - "tell {player} §e3秒后将传送你到出生点..." - "schedule function mypack:teleport_player 60t" ``` ### 3. 多玩家命令 ```yaml broadcast: enabled: true commands: - "say §c[公告] §f{player} 说: {args}" - "playsound minecraft:block.note_block.pling master @a" ``` ## - **开发者**: 9C2211D - **版本**: 1.0-SNAPSHOT - **API 版本**: 1.16+ - **构建工具**: Gradle - **依赖**: Paper API 1.16.5 ## ```bash # 克隆项目 git clone <repository-url> cd custom-commands # 构建插件 ./gradlew build # 运行测试服务器 ./gradlew runServer ``` ## ### 常见问题 **Q: 自定义命令不工作?** A: 检查以下几点: 1. 确保命令在配置文件中 `enabled: true` 2. 检查玩家是否有相应权限 3. 查看控制台是否有错误信息 4. 使用 `/customcommands list` 确认命令已加载 **Q: 配置文件修改后不生效?** A: 使用 `/customcommands reload` 重新加载配置文件 **Q: 权限设置不正确?** A: 确保权限插件正确配置了 `customcommands.use.*` 或具体的命令权限 ### 调试模式 在配置文件中添加以下内容启用调试: ```yaml debug: true ``` ## ### v1.0.0 - - - - - - ## 欢迎提交 Issue 和 Pull Request! 1. Fork 本项目 2. 创建功能分支 (`git checkout -b feature/AmazingFeature`) 3. 提交更改 (`git commit -m 'Add some AmazingFeature'`) 4. 推送到分支 (`git push origin feature/AmazingFeature`) 5. 创建 Pull Request ## 本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情 ## - [ ] 支持命令冷却时间 - [ ] 支持命令使用次数限制 - [ ] 添加 GUI 配置界面 - [ ] 支持数据库存储 - [ ] 添加命令执行统计 - [ ] 支持条件执行 - [ ] 添加命令别名系统 --- **如果这个插件对你有帮助,请给个 下载地址: ## - GitHub Issues: [提交问题](https://github.com/9C2211D/custom-commands/issues) - QQ群: 159998932 [/MD] |
提升卡
观察者