第123批:修 tab 补全丢失 + password+custom 接 CLI 菜单 + custom 房间类型语义
Auto Release / build (push) Successful in 2m27s

问题1 tab补全丢失(根因实锤):
- 顶层 switch 根本没有 custom case,菜单按钮 /pvp custom set/reset/start
  全部落进 default 帮助页 = 点了没反应(补全丢了只是表象)
- Main.onTabComplete 的 pvp 分支补齐:第1层 password/ps、
  join 后第3层 custom 房间类型、第3/4层 password 密码/model、
  custom set 的 room 选项与 shield 三态/room 公开/私人专用值

问题2 password+custom 接 CLI 菜单:
- joinPasswordArena 拆分:model=custom → openCustomMenuForPassword
  (挂起密码+强制私人),不直接开房
- 新增 createPasswordRoom(owner,pwd,cfg):菜单 [开始游戏] 回调此时
  才生成房码/登记/建世界,cfg 写入 customCfg 并认定开局房主
- PVPCustomModeManager 新增 passwordPendingPwd 挂接表,
  start() 检出挂接则转 createPasswordRoom;cancel/drop 同步清理

问题3 custom 房间类型语义:
- /pvp join custom [type]:传参即定初始类型(private/pre/私人→私人),
  不传默认公开;菜单 [公开]/[私人] 按钮单值切换天然可逆

Co-Authored-By: WorkBuddy <noreply@workbuddy.cn>
This commit is contained in:
youpaishidifu
2026-11-15 12:24:40 +08:00
co-authored by WorkBuddy
parent 41155c67ce
commit 1a3b6b5dec
4 changed files with 132 additions and 12 deletions
+33 -4
View File
@@ -11772,7 +11772,7 @@ public class Main extends JavaPlugin
if (cmd.getName().equalsIgnoreCase("pvp")) { if (cmd.getName().equalsIgnoreCase("pvp")) {
if (args.length == 1) { if (args.length == 1) {
return filterTab(Arrays.asList( return filterTab(Arrays.asList(
"join", "arena", "j", "custom", "c", "join", "arena", "j", "custom", "c", "password", "ps",
"create", "stats", "list", "delete", "create", "stats", "list", "delete",
"tool", "on", "off", "tempban", "tool", "on", "off", "tempban",
"leave", "exit", "test", "equip", "leave", "exit", "test", "equip",
@@ -11783,16 +11783,45 @@ public class Main extends JavaPlugin
|| sub0.equals("j"))) { || sub0.equals("j"))) {
return filterTab(Arrays.asList( return filterTab(Arrays.asList(
"custom", "c", "default", "d", "private", "pre", "custom", "c", "default", "d", "private", "pre",
"public", "pub"), args[1]); "public", "pub", "password", "ps"), args[1]);
}
// ★ 第123批问题1:/pvp join custom <房间类型>(传参即定初始类型,默认公开)
if (args.length == 3 && (sub0.equals("join") || sub0.equals("arena")
|| sub0.equals("j"))
&& (args[1].equalsIgnoreCase("custom") || args[1].equalsIgnoreCase("c"))) {
return filterTab(Arrays.asList("public", "pub", "private", "pre"), args[2]);
}
// ★ 第123批问题1:/pvp join password <密码> [model]
if ((sub0.equals("join") || sub0.equals("arena") || sub0.equals("j"))
&& (args[1].equalsIgnoreCase("password") || args[1].equalsIgnoreCase("ps"))) {
if (args.length == 3) {
// 密码为自由文本,空串时给个占位提示即可(非空前缀不匹配时自然无补全)
return args[2].isEmpty()
? Arrays.asList("<密码>") : list;
}
if (args.length == 4) {
return filterTab(Arrays.asList("default", "d", "custom", "c"), args[3]);
}
} }
// /pvp custom <子命令>:菜单按钮命令的补全 // /pvp custom <子命令>:菜单按钮命令的补全
if (sub0.equals("custom")) { if (sub0.equals("custom") || sub0.equals("c")) {
if (args.length == 2) { if (args.length == 2) {
return filterTab(Arrays.asList("set", "reset", "start"), args[1]); return filterTab(Arrays.asList("set", "reset", "start"), args[1]);
} }
if (args.length == 3 && args[1].equalsIgnoreCase("set")) { if (args.length == 3 && args[1].equalsIgnoreCase("set")) {
// ★ 第123批问题1:补上 room(房间类型)选项
return filterTab(Arrays.asList( return filterTab(Arrays.asList(
"force", "items", "kills", "build", "shield", "bare"), args[2]); "force", "items", "kills", "build", "shield", "bare", "room"), args[2]);
}
// ★ 第123批问题1:shield 三态专用值
if (args.length == 4 && args[1].equalsIgnoreCase("set")
&& args[2].equalsIgnoreCase("shield")) {
return filterTab(Arrays.asList("关", "自由", "开"), args[3]);
}
// ★ 第123批问题1:room 房间类型专用值
if (args.length == 4 && args[1].equalsIgnoreCase("set")
&& args[2].equalsIgnoreCase("room")) {
return filterTab(Arrays.asList("公开", "私人"), args[3]);
} }
if (args.length == 4 && args[1].equalsIgnoreCase("set") if (args.length == 4 && args[1].equalsIgnoreCase("set")
&& !args[2].equalsIgnoreCase("kills")) { && !args[2].equalsIgnoreCase("kills")) {
+35 -4
View File
@@ -4552,7 +4552,8 @@ public class PVPArenaManager implements Listener {
/** /**
* 第122批:房主 `/pvp join password [password] (model)` —— 创建 password 私人陪练房间。 * 第122批:房主 `/pvp join password [password] (model)` —— 创建 password 私人陪练房间。
* 复用私人房体系(独立世界 + 5分钟清场 + /tpahere 邀请),额外生成3位数字房码。 * 复用私人房体系(独立世界 + 5分钟清场 + /tpahere 邀请),额外生成3位数字房码。
* model 不填默认 default;填 custom 走自定义 CLI 菜单(第一板块)。 * model 不填默认 default;★ 第123批问题2:填 custom 先开自定义 CLI 菜单,
* 配置完成点[开始游戏]后由 createPasswordRoom 真正开房(配置应用到私人房世界)。
*/ */
public void joinPasswordArena(Player owner, String pwd, String model) { public void joinPasswordArena(Player owner, String pwd, String model) {
String name = owner.getName(); String name = owner.getName();
@@ -4560,11 +4561,41 @@ public class PVPArenaManager implements Listener {
owner.sendMessage("§c你已创建私人房间,请勿重复创建"); owner.sendMessage("§c你已创建私人房间,请勿重复创建");
return; return;
} }
String worldName = PRIVATE_WORLD_PREFIX + name;
// 模型参数归一:不填/model=default → default;custom → 走自定义菜单 // 模型参数归一:不填/model=default → default;custom → 走自定义菜单
String m = (model == null || model.trim().isEmpty() boolean isDefault = (model == null || model.trim().isEmpty()
|| model.equalsIgnoreCase("default") || model.equalsIgnoreCase("default")
|| model.equalsIgnoreCase("d")) ? "default" : "custom"; || model.equalsIgnoreCase("d"));
if (!isDefault) {
// ★ 第123批问题2:model=custom → 先开 CLI 菜单(挂起 password),
// 配置完成由 PVPCustomModeManager.start() 回调 createPasswordRoom。
plugin.getCustomModeManager().openCustomMenuForPassword(owner, pwd);
return;
}
createPasswordRoom(owner, pwd, null);
}
/**
* 第123批问题2:真正创建 password 私人陪练房间。
* default 模式由 joinPasswordArena 直接调用(cfg=null);
* custom 模式由 PVPCustomModeManager.start() 在菜单配置完成后回调(cfg 非空,应用到私人房)。
*/
public void createPasswordRoom(Player owner, String pwd,
PVPCustomModeManager.CustomConfig cfg) {
String name = owner.getName();
if (privateRooms.containsKey(name)) {
owner.sendMessage("§c你已创建私人房间,请勿重复创建");
return;
}
String worldName = PRIVATE_WORLD_PREFIX + name;
String m = (cfg == null) ? "default" : "custom";
// 自定义配置:写入 customCfg(私人房世界内生效)+ 认定开局房主(拥有选装权限)
if (cfg != null) {
customCfg.put(name, cfg);
if (customModeOwner == null) {
customModeOwner = name;
}
plugin.getLogger().info("[PVP私人陪练] " + name + " 自定义配置: " + cfg.describe());
}
// 生成3位数字房码(避免与既有房码冲突) // 生成3位数字房码(避免与既有房码冲突)
String code; String code;
do { do {
@@ -95,6 +95,11 @@ public class PVPCustomModeManager {
private final Map<String, CustomConfig> configs = new HashMap<>(); private final Map<String, CustomConfig> configs = new HashMap<>();
// ===== 第123批问题2:password 房挂接模式 =====
/** 玩家名 → 该玩家 custom 菜单配置完成后应创建的 password 房密码;
* null/不含 = 普通 /pvp join custom(菜单 start 走 joinArena 通用链)。 */
private final Map<String, String> passwordPendingPwd = new HashMap<>();
public PVPCustomModeManager(Main plugin) { public PVPCustomModeManager(Main plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
@@ -106,6 +111,23 @@ public class PVPCustomModeManager {
renderMenu(p); renderMenu(p);
} }
/**
* 第123批问题2:password 房挂接模式入口。
* 房主 `/pvp join password <pwd> custom` 时调用:挂起 password 密码,
* 开 custom 菜单强制房间类型=私人;配置完成点 [开始游戏] 后由 start()
* 转出 createPasswordRoom 真正开房(此时才把配置应用到私人房世界)。
*/
public void openCustomMenuForPassword(Player p, String pwd) {
String name = p.getName();
passwordPendingPwd.put(name, pwd == null ? "" : pwd);
CustomConfig cfg = new CustomConfig();
cfg.roomType = RoomType.PRIVATE; // password 房强制私人
configs.put(name, cfg);
renderMenu(p);
p.sendMessage(Component.text("§7提示: 此菜单为私人陪练(password)房配置,"
+ "房间类型已锁定为§b私人§7,配置完成点[开始游戏]将创建带密码的私人房间。"));
}
/** 渲染整个 CLI 菜单(领地 showConfigPage 风格:一页全列 + 底部俩按钮) */ /** 渲染整个 CLI 菜单(领地 showConfigPage 风格:一页全列 + 底部俩按钮) */
private void renderMenu(Player p) { private void renderMenu(Player p) {
String name = p.getName(); String name = p.getName();
@@ -214,6 +236,7 @@ public class PVPCustomModeManager {
/** 取消整个流程(不进入PVP) */ /** 取消整个流程(不进入PVP) */
public void cancel(Player p) { public void cancel(Player p) {
configs.remove(p.getName()); configs.remove(p.getName());
passwordPendingPwd.remove(p.getName()); // ★ 第123批:清掉 password 挂接,避免残留
p.sendMessage(Component.text("§c已取消自定义模式配置,未进入PVP")); p.sendMessage(Component.text("§c已取消自定义模式配置,未进入PVP"));
} }
@@ -323,7 +346,8 @@ public class PVPCustomModeManager {
/** 开始游戏:校验+收尾(徒手与强制装备必须全开)+ 进入竞技场 */ /** 开始游戏:校验+收尾(徒手与强制装备必须全开)+ 进入竞技场 */
public void start(Player p) { public void start(Player p) {
CustomConfig cfg = configs.remove(p.getName()); String name = p.getName();
CustomConfig cfg = configs.remove(name);
if (cfg == null) { if (cfg == null) {
p.sendMessage(Component.text("§c当前没有进行中的自定义配置(先 /pvp join custom)")); p.sendMessage(Component.text("§c当前没有进行中的自定义配置(先 /pvp join custom)"));
return; return;
@@ -334,6 +358,13 @@ public class PVPCustomModeManager {
cfg.forceEquip = true; cfg.forceEquip = true;
} }
p.sendMessage(Component.text("§a§l配置完成: " + cfg.describe())); p.sendMessage(Component.text("§a§l配置完成: " + cfg.describe()));
// ★ 第123批问题2:password 挂接模式 → 配置完成后创建带密码的私人房
// (强制私人:password 房语义就是私人陪练,忽略菜单里被改回公开的情况)
String pwd = passwordPendingPwd.remove(name);
if (pwd != null) {
plugin.getPVPArenaManager().createPasswordRoom(p, pwd, cfg);
return;
}
plugin.getPVPArenaManager().joinArena(p, cfg); plugin.getPVPArenaManager().joinArena(p, cfg);
} }
@@ -372,5 +403,6 @@ public class PVPCustomModeManager {
/** 清空某玩家流程(掉线/离场兜底) */ /** 清空某玩家流程(掉线/离场兜底) */
public void drop(String playerName) { public void drop(String playerName) {
configs.remove(playerName); configs.remove(playerName);
passwordPendingPwd.remove(playerName); // ★ 第123批:同步清 password 挂接
} }
} }
+31 -3
View File
@@ -1236,10 +1236,15 @@ public class PVPManager implements Listener {
// 「同时支持public和private参数,/pvp join [model] [type]」)。 // 「同时支持public和private参数,/pvp join [model] [type]」)。
// 不穿 type 时默认公开;进菜单后仍可点 [私人] 按钮切换。 // 不穿 type 时默认公开;进菜单后仍可点 [私人] 按钮切换。
if (args.length >= 2 && args[1].equalsIgnoreCase("custom")) { if (args.length >= 2 && args[1].equalsIgnoreCase("custom")) {
// ★ 第123批问题3:传参即定初始房间类型(pre/private→私人),不传默认公开;
// 即便一开始传了 private,也能通过菜单 [公开] 按钮改回公开(setOption 单值切换天然可逆)。
// 仅 private/pre 设为私人,其余(含 public/公开)与不传都让 openCustomMenu 的默认公开生效。
boolean wantPrivate = args.length >= 3
&& (args[2].equalsIgnoreCase("private")
|| args[2].equalsIgnoreCase("pre")
|| args[2].equals("私人"));
plugin.getCustomModeManager().openCustomMenu(p); plugin.getCustomModeManager().openCustomMenu(p);
// 把命令行穿的房间类型写进刚创建的配置(openCustomMenu 会覆盖默认值,故放后面) if (wantPrivate) {
if (args.length >= 3 && (args[2].equalsIgnoreCase("private")
|| args[2].equalsIgnoreCase("pre"))) {
plugin.getCustomModeManager().setOption(p, "room", "私人"); plugin.getCustomModeManager().setOption(p, "room", "私人");
} }
return true; return true;
@@ -1252,6 +1257,29 @@ public class PVPManager implements Listener {
} }
plugin.getPVPArenaManager().joinArena(p); plugin.getPVPArenaManager().joinArena(p);
return true; return true;
// ★ 第123批问题1:/pvp custom <set|reset|start> 顶层分发。
// CLI 菜单按钮(ClickEvent.runCommand("/pvp custom set/reset/start"))全靠这里落;
// 原先顶层 switch 无 custom case → 按钮全落 default 帮助页 = 点了没反应。
// 无参 /pvp custom 直接开菜单(与 /pvp join custom 同口径;配置全走 CLI 菜单)。
case "custom":
if (args.length >= 2 && args[1].equalsIgnoreCase("set")) {
if (args.length < 4) {
p.sendMessage("§c用法: /pvp custom set <项> <值>(项: force/items/kills/build/shield/bare/room)");
return true;
}
plugin.getCustomModeManager().setOption(p, args[2], args[3]);
return true;
}
if (args.length >= 2 && args[1].equalsIgnoreCase("reset")) {
plugin.getCustomModeManager().reset(p);
return true;
}
if (args.length >= 2 && args[1].equalsIgnoreCase("start")) {
plugin.getCustomModeManager().start(p);
return true;
}
plugin.getCustomModeManager().openCustomMenu(p);
return true;
case "equip": case "equip":
case "adjust": case "adjust":
if (!plugin.getPVPArenaManager().isInPVPArena(p.getName())) { if (!plugin.getPVPArenaManager().isInPVPArena(p.getName())) {