From 1a3b6b5deccb05004c84a8dcb833a3ff00ec4fad Mon Sep 17 00:00:00 2001 From: youpaishidifu <1@ypshidifu.cn> Date: Sun, 15 Nov 2026 12:24:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC123=E6=89=B9=EF=BC=9A=E4=BF=AE=20tab?= =?UTF-8?q?=20=E8=A1=A5=E5=85=A8=E4=B8=A2=E5=A4=B1=20+=20password+custom?= =?UTF-8?q?=20=E6=8E=A5=20CLI=20=E8=8F=9C=E5=8D=95=20+=20custom=20?= =?UTF-8?q?=E6=88=BF=E9=97=B4=E7=B1=BB=E5=9E=8B=E8=AF=AD=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题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 --- src/main/java/Sdf1_login/Main.java | 37 ++++++++++++++++-- src/main/java/Sdf1_login/PVPArenaManager.java | 39 +++++++++++++++++-- .../java/Sdf1_login/PVPCustomModeManager.java | 34 +++++++++++++++- src/main/java/Sdf1_login/PVPManager.java | 34 ++++++++++++++-- 4 files changed, 132 insertions(+), 12 deletions(-) diff --git a/src/main/java/Sdf1_login/Main.java b/src/main/java/Sdf1_login/Main.java index b35c3fe..e28277c 100644 --- a/src/main/java/Sdf1_login/Main.java +++ b/src/main/java/Sdf1_login/Main.java @@ -11772,7 +11772,7 @@ public class Main extends JavaPlugin if (cmd.getName().equalsIgnoreCase("pvp")) { if (args.length == 1) { return filterTab(Arrays.asList( - "join", "arena", "j", "custom", "c", + "join", "arena", "j", "custom", "c", "password", "ps", "create", "stats", "list", "delete", "tool", "on", "off", "tempban", "leave", "exit", "test", "equip", @@ -11783,16 +11783,45 @@ public class Main extends JavaPlugin || sub0.equals("j"))) { return filterTab(Arrays.asList( "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 <子命令>:菜单按钮命令的补全 - if (sub0.equals("custom")) { + if (sub0.equals("custom") || sub0.equals("c")) { if (args.length == 2) { return filterTab(Arrays.asList("set", "reset", "start"), args[1]); } if (args.length == 3 && args[1].equalsIgnoreCase("set")) { + // ★ 第123批问题1:补上 room(房间类型)选项 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") && !args[2].equalsIgnoreCase("kills")) { diff --git a/src/main/java/Sdf1_login/PVPArenaManager.java b/src/main/java/Sdf1_login/PVPArenaManager.java index 04bddcd..15056b2 100644 --- a/src/main/java/Sdf1_login/PVPArenaManager.java +++ b/src/main/java/Sdf1_login/PVPArenaManager.java @@ -4552,7 +4552,8 @@ public class PVPArenaManager implements Listener { /** * 第122批:房主 `/pvp join password [password] (model)` —— 创建 password 私人陪练房间。 * 复用私人房体系(独立世界 + 5分钟清场 + /tpahere 邀请),额外生成3位数字房码。 - * model 不填默认 default;填 custom 走自定义 CLI 菜单(第一板块)。 + * model 不填默认 default;★ 第123批问题2:填 custom 先开自定义 CLI 菜单, + * 配置完成点[开始游戏]后由 createPasswordRoom 真正开房(配置应用到私人房世界)。 */ public void joinPasswordArena(Player owner, String pwd, String model) { String name = owner.getName(); @@ -4560,11 +4561,41 @@ public class PVPArenaManager implements Listener { owner.sendMessage("§c你已创建私人房间,请勿重复创建"); return; } - String worldName = PRIVATE_WORLD_PREFIX + name; // 模型参数归一:不填/model=default → default;custom → 走自定义菜单 - String m = (model == null || model.trim().isEmpty() + boolean isDefault = (model == null || model.trim().isEmpty() || 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位数字房码(避免与既有房码冲突) String code; do { diff --git a/src/main/java/Sdf1_login/PVPCustomModeManager.java b/src/main/java/Sdf1_login/PVPCustomModeManager.java index ff66d51..11429d9 100644 --- a/src/main/java/Sdf1_login/PVPCustomModeManager.java +++ b/src/main/java/Sdf1_login/PVPCustomModeManager.java @@ -95,6 +95,11 @@ public class PVPCustomModeManager { private final Map configs = new HashMap<>(); + // ===== 第123批问题2:password 房挂接模式 ===== + /** 玩家名 → 该玩家 custom 菜单配置完成后应创建的 password 房密码; + * null/不含 = 普通 /pvp join custom(菜单 start 走 joinArena 通用链)。 */ + private final Map passwordPendingPwd = new HashMap<>(); + public PVPCustomModeManager(Main plugin) { this.plugin = plugin; } @@ -106,6 +111,23 @@ public class PVPCustomModeManager { renderMenu(p); } + /** + * 第123批问题2:password 房挂接模式入口。 + * 房主 `/pvp join password 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 风格:一页全列 + 底部俩按钮) */ private void renderMenu(Player p) { String name = p.getName(); @@ -214,6 +236,7 @@ public class PVPCustomModeManager { /** 取消整个流程(不进入PVP) */ public void cancel(Player p) { configs.remove(p.getName()); + passwordPendingPwd.remove(p.getName()); // ★ 第123批:清掉 password 挂接,避免残留 p.sendMessage(Component.text("§c已取消自定义模式配置,未进入PVP")); } @@ -323,7 +346,8 @@ public class PVPCustomModeManager { /** 开始游戏:校验+收尾(徒手与强制装备必须全开)+ 进入竞技场 */ public void start(Player p) { - CustomConfig cfg = configs.remove(p.getName()); + String name = p.getName(); + CustomConfig cfg = configs.remove(name); if (cfg == null) { p.sendMessage(Component.text("§c当前没有进行中的自定义配置(先 /pvp join custom)")); return; @@ -334,6 +358,13 @@ public class PVPCustomModeManager { cfg.forceEquip = true; } 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); } @@ -372,5 +403,6 @@ public class PVPCustomModeManager { /** 清空某玩家流程(掉线/离场兜底) */ public void drop(String playerName) { configs.remove(playerName); + passwordPendingPwd.remove(playerName); // ★ 第123批:同步清 password 挂接 } } diff --git a/src/main/java/Sdf1_login/PVPManager.java b/src/main/java/Sdf1_login/PVPManager.java index 1d414a1..f40403f 100644 --- a/src/main/java/Sdf1_login/PVPManager.java +++ b/src/main/java/Sdf1_login/PVPManager.java @@ -1236,10 +1236,15 @@ public class PVPManager implements Listener { // 「同时支持public和private参数,/pvp join [model] [type]」)。 // 不穿 type 时默认公开;进菜单后仍可点 [私人] 按钮切换。 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); - // 把命令行穿的房间类型写进刚创建的配置(openCustomMenu 会覆盖默认值,故放后面) - if (args.length >= 3 && (args[2].equalsIgnoreCase("private") - || args[2].equalsIgnoreCase("pre"))) { + if (wantPrivate) { plugin.getCustomModeManager().setOption(p, "room", "私人"); } return true; @@ -1252,6 +1257,29 @@ public class PVPManager implements Listener { } plugin.getPVPArenaManager().joinArena(p); return true; + // ★ 第123批问题1:/pvp custom 顶层分发。 + // 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 "adjust": if (!plugin.getPVPArenaManager().isInPVPArena(p.getName())) {