修复CLI创建领地跳转 + 无参数快速创建

1. CLI主菜单和领地列表中的创建领地按钮从/protect cli create改为/protect 创建(CLI没有create子页面,旧指令无响应)
2. /protect 创建无参数时自动快速创建3x3领地,不要求先选点
3. /protect 创建有参数时自动选名然后走confirm_create流程
This commit is contained in:
2026-06-29 18:42:30 +08:00
parent fa9be74e1f
commit fe4bee53de
2 changed files with 25 additions and 10 deletions
+2 -2
View File
@@ -98,7 +98,7 @@ public class AreaCLIManager {
p.sendMessage(clickableAction("⛏", "获取圈地工具",
"/protect 工具"));
p.sendMessage(clickableAction("⚔", "创建领地",
"/protect cli create"));
"/protect 创建"));
p.sendMessage(clickableAction("📋", "领地列表",
"/protect cli lands 1"));
p.sendMessage(clickableAction("🏪", "权限商店",
@@ -222,7 +222,7 @@ public class AreaCLIManager {
if (allLands.isEmpty()) {
p.sendMessage(Component.text("§7暂无领地,点击创建:"));
p.sendMessage(clickableAction("⚔", "创建领地",
"/protect cli create"));
"/protect 创建"));
p.sendMessage(Component.text("§7§l───────────────────────────────"));
return;
}
+23 -8
View File
@@ -5535,18 +5535,33 @@ public class AreaProtection implements Listener {
sender.sendMessage("§c仅玩家可用");
return true;
}
if (args.length < 2) {
sender.sendMessage(
"§e用法: /protect 创建 <名>");
return true;
}
Player p = (Player) sender;
UUID u = p.getUniqueId();
if (!pos1.containsKey(u)
|| !pos2.containsKey(u)) {
p.sendMessage("§c请先用工具选点");
// ★ 无参数 → 快速创建(3×3以自身为中心)
if (args.length < 2) {
if (!pos1.containsKey(u) || !pos2.containsKey(u)) {
// 无选点:快速创建3×3
if (quickCreateLand(p)) {
p.sendMessage("§7领地创建成功,如需精细控制请使用圈地工具选点后再次使用");
}
} else {
// 有选点但没有名字:用默认名创建
String autoName = p.getName();
if (areas.containsKey(autoName)) {
for (int i = 0; i <= 999; i++) {
String c = autoName + i;
if (!areas.containsKey(c)) { autoName = c; break; }
}
}
p.sendMessage("§e用法: /protect 创建 <自定义名>");
p.sendMessage("§7自动创建领地名: §e" + autoName);
// 通过confirm_create走标准流程
p.performCommand("protect confirm_create " + autoName);
}
return true;
}
String areaName = args[1];
// 检查重名(数据库+txt)
if (areas.containsKey(areaName)) {