入门指南
本教程将详细介绍如何创建和使用 CustomScreenMenu 插件的全息光标菜单系统。通过本教程,您将学会如何从零开始创建功能丰富的交互式菜单。
基础菜单创建
学习如何创建简单的菜单,包括基本配置和布局设置
高级功能
掌握菜单的高级功能,如权限控制、命令执行和菜单跳转
交互设计
了解如何设计用户友好的菜单交互体验
基础菜单创建
在本节中,我们将创建一个简单的菜单,展示菜单的基本结构和配置选项。
创建菜单文件
首先,在 plugins/CustomScreenMenu/menu/ 目录下创建一个新的 YAML 文件,例如 example_menu.yml。
基础配置结构
以下是一个最简单的菜单配置示例:
example_menu:
permission: cursormenu.menu.example_menu
camera-position:
world: world
x: 0
y: 64
z: 0
yaw: 0
pitch: 0
layout:
button1:
name: "欢迎使用菜单系统"
x: 0
y: 1
z: 3
command:
- "[player] say 我正在使用 CustomScreenMenu!"
高级功能
权限控制
您可以为整个菜单或单个按钮设置权限节点:
example_menu:
permission: cursormenu.menu.example_menu # 菜单整体权限
camera-position:
world: world
x: 0
y: 64
z: 0
yaw: 0
pitch: 0
layout:
button1:
permission: cursormenu.button.example_button1 # 按钮权限
name: "受限按钮"
x: 0
y: 1
z: 3
command:
- "[player] say 我有权限使用这个按钮!"
命令执行
菜单按钮可以执行多种类型的命令:
layout:
player_command:
name: "玩家命令"
x: -1
y: 1
z: 3
command:
- "[player] say 这是玩家命令"
console_command:
name: "控制台命令"
x: 0
y: 1
z: 3
command:
- "[console] say 这是控制台命令"
op_command:
name: "OP命令"
x: 1
y: 1
z: 3
command:
- "[op] gamemode creative"
菜单跳转
您可以设置按钮跳转到其他菜单:
layout:
next_menu_button:
name: "下一个菜单"
x: 0
y: 1
z: 3
next-menu:
enabled: true
menu: another_menu
设计原则
布局规划
在设计菜单时,需要考虑以下坐标系统:
- X轴:水平方向,负值向左,正值向右
- Y轴:垂直方向,负值向下,正值向上
- Z轴:深度方向,数值越大离玩家越远
用户体验
创建菜单时应考虑以下因素:
- 按钮之间保持适当间距,避免误触
- 重要功能放置在易于点击的位置
- 使用清晰明确的按钮标签
- 合理组织菜单结构,避免过于复杂
实践示例
玩家主菜单
一个完整的玩家主菜单示例:
main_menu:
permission: cursormenu.menu.main
camera-position:
world: world
x: 0
y: 64
z: 0
yaw: 0
pitch: 0
layout:
teleport_menu:
name: "传送菜单"
x: -1
y: 1
z: 3
next-menu:
enabled: true
menu: teleport_menu
kit_menu:
name: "礼包菜单"
x: 1
y: 1
z: 3
next-menu:
enabled: true
menu: kit_menu
close:
name: "关闭菜单"
x: 0
y: 0
z: 3
command:
- "[console] cursormenu stop"
传送菜单
一个传送功能菜单示例:
teleport_menu:
permission: cursormenu.menu.teleport
camera-position:
world: world
x: 0
y: 64
z: 0
yaw: 0
pitch: 0
layout:
spawn:
name: "返回主城"
x: -1
y: 1
z: 3
command:
- "[player] spawn"
world_nether:
name: "前往下界"
x: 0
y: 1
z: 3
command:
- "[player] tp world_nether 0 64 0"
world_the_end:
name: "前往末地"
x: 1
y: 1
z: 3
command:
- "[player] tp world_the_end 0 64 0"
back:
name: "返回主菜单"
x: 0
y: 0
z: 3
next-menu:
enabled: true
menu: main_menu
故障排除
- 菜单无法打开:检查权限节点是否正确设置
- 按钮无响应:确认命令格式是否正确
- 菜单显示错位:检查坐标设置是否合理
- 跳转失败:确认目标菜单文件是否存在且配置正确
常见问题解答
Q: 如何测试菜单是否正常工作?
A: 给自己分配相应的权限节点,然后使用 /cursormenu run 菜单名 命令打开菜单进行测试。
Q: 可以在一个菜单中添加多少个按钮?
A: 理论上没有限制,但建议保持在合理数量以确保良好的用户体验。
Q: 如何实现复杂的交互逻辑?
A: 可以通过组合使用命令执行、菜单跳转和权限控制来实现复杂的交互逻辑。
Getting Started
This tutorial will详细介绍 how to create and use the holographic cursor menu system of the CustomScreenMenu plugin. Through this tutorial, you will learn how to create feature-rich interactive menus from scratch.
Basic Menu Creation
Learn how to create simple menus, including basic configuration and layout settings
Advanced Features
Master advanced menu features such as permission control, command execution, and menu navigation
Interaction Design
Learn how to design user-friendly menu interaction experiences
Basic Menu Creation
In this section, we'll create a simple menu to demonstrate the basic structure and configuration options of menus.
Creating a Menu File
First, create a new YAML file in the plugins/CustomScreenMenu/menu/ directory, for example, example_menu.yml.
Basic Configuration Structure
Here is a simple menu configuration example:
example_menu:
permission: cursormenu.menu.example_menu
camera-position:
world: world
x: 0
y: 64
z: 0
yaw: 0
pitch: 0
layout:
button1:
name: "Welcome to the Menu System"
x: 0
y: 1
z: 3
command:
- "[player] say I'm using CustomScreenMenu!"
Advanced Features
Permission Control
You can set permission nodes for the entire menu or individual buttons:
example_menu:
permission: cursormenu.menu.example_menu # Menu-wide permission
camera-position:
world: world
x: 0
y: 64
z: 0
yaw: 0
pitch: 0
layout:
button1:
permission: cursormenu.button.example_button1 # Button permission
name: "Restricted Button"
x: 0
y: 1
z: 3
command:
- "[player] say I have permission to use this button!"
Command Execution
Menu buttons can execute various types of commands:
layout:
player_command:
name: "Player Command"
x: -1
y: 1
z: 3
command:
- "[player] say This is a player command"
console_command:
name: "Console Command"
x: 0
y: 1
z: 3
command:
- "[console] say This is a console command"
op_command:
name: "OP Command"
x: 1
y: 1
z: 3
command:
- "[op] gamemode creative"
Menu Navigation
You can set buttons to navigate to other menus:
layout:
next_menu_button:
name: "Next Menu"
x: 0
y: 1
z: 3
next-menu:
enabled: true
menu: another_menu
Design Principles
Layout Planning
When designing menus, consider the following coordinate system:
- X-axis: Horizontal direction, negative values to the left, positive values to the right
- Y-axis: Vertical direction, negative values down, positive values up
- Z-axis: Depth direction, larger values are farther from the player
User Experience
Consider the following factors when creating menus:
- Maintain appropriate spacing between buttons to avoid mis-clicks
- Place important functions in easily clickable positions
- Use clear and explicit button labels
- Organize menu structure reasonably to avoid excessive complexity
Practical Examples
Player Main Menu
A complete player main menu example:
main_menu:
permission: cursormenu.menu.main
camera-position:
world: world
x: 0
y: 64
z: 0
yaw: 0
pitch: 0
layout:
teleport_menu:
name: "Teleport Menu"
x: -1
y: 1
z: 3
next-menu:
enabled: true
menu: teleport_menu
kit_menu:
name: "Kit Menu"
x: 1
y: 1
z: 3
next-menu:
enabled: true
menu: kit_menu
close:
name: "Close Menu"
x: 0
y: 0
z: 3
command:
- "[console] cursormenu stop"
Teleport Menu
A teleport function menu example:
teleport_menu:
permission: cursormenu.menu.teleport
camera-position:
world: world
x: 0
y: 64
z: 0
yaw: 0
pitch: 0
layout:
spawn:
name: "Return to Spawn"
x: -1
y: 1
z: 3
command:
- "[player] spawn"
world_nether:
name: "Go to Nether"
x: 0
y: 1
z: 3
command:
- "[player] tp world_nether 0 64 0"
world_the_end:
name: "Go to The End"
x: 1
y: 1
z: 3
command:
- "[player] tp world_the_end 0 64 0"
back:
name: "Back to Main Menu"
x: 0
y: 0
z: 3
next-menu:
enabled: true
menu: main_menu
Troubleshooting
- Menu won't open: Check if permission nodes are set correctly
- Button unresponsive: Confirm command format is correct
- Menu display misaligned: Check if coordinate settings are reasonable
- Navigation failure: Confirm target menu file exists and is configured correctly
FAQ
Q: How to test if a menu works properly?
A: Assign yourself the appropriate permission nodes, then use the /cursormenu run menu_name command to open the menu for testing.
Q: How many buttons can be added to a menu?
A: There is theoretically no limit, but it's recommended to keep a reasonable number for good user experience.
Q: How to implement complex interaction logic?
A: Complex interaction logic can be implemented by combining command execution, menu navigation, and permission control.