第120批:PVP自定义模式CLI是/否按钮改用ASCII on/off(修复中文参数点击失效)+诊断日志
Auto Release / build (push) Successful in 2m29s
Auto Release / build (push) Successful in 2m29s
This commit is contained in:
@@ -125,13 +125,17 @@ public class PVPCustomModeManager {
|
||||
.hoverEvent(HoverEvent.showText(Component.text("§e点击-1"))));
|
||||
} else {
|
||||
// 是/否项:按钮点击即执行 /pvp custom set <项> <值>,直接切换(不拉起聊天栏)
|
||||
// ★ 第120批:点击执行参数一律用 ASCII on/off(不用中文「是/否」)。
|
||||
// 中文参数经 ClickEvent.runCommand 在客户端→服务器往返时不可靠,
|
||||
// 玩家点「是」实际到达服务器的是「否」→ parseBool 判否 → 渲染回「否」。
|
||||
// 改 ASCII 后彻底绕开非 ASCII 传输;parseBool 本就接受 on/off。
|
||||
line = line.append(Component.text("§a[是] ")
|
||||
.clickEvent(ClickEvent.runCommand(
|
||||
"/pvp custom set " + OPTION_KEYS[step] + " 是"))
|
||||
"/pvp custom set " + OPTION_KEYS[step] + " on"))
|
||||
.hoverEvent(HoverEvent.showText(Component.text("§e点击切换为「是」")))
|
||||
.append(Component.text("§c[否] "))
|
||||
.clickEvent(ClickEvent.runCommand(
|
||||
"/pvp custom set " + OPTION_KEYS[step] + " 否"))
|
||||
"/pvp custom set " + OPTION_KEYS[step] + " off"))
|
||||
.hoverEvent(HoverEvent.showText(Component.text("§e点击切换为「否」"))));
|
||||
}
|
||||
p.sendMessage(line);
|
||||
@@ -160,6 +164,16 @@ public class PVPCustomModeManager {
|
||||
}
|
||||
int idx = keyIndex(key);
|
||||
if (idx < 0) return false;
|
||||
// ★ 第120批诊断日志:把到达的原始参数 hex 出来,若再点「是」却收到「否」,
|
||||
// 一眼看出是编码问题还是命令本身问题(on/off ASCII 不应有编码歧义)。
|
||||
if (plugin != null && plugin.getLogger() != null) {
|
||||
StringBuilder hex = new StringBuilder();
|
||||
for (byte b : val.getBytes(java.nio.charset.StandardCharsets.UTF_8)) {
|
||||
hex.append(String.format("%02x ", b));
|
||||
}
|
||||
plugin.getLogger().info("[PVP自定义] setOption 收到 key=" + key
|
||||
+ " val='" + val + "' (UTF8: " + hex.toString().trim() + ") -> " + OPTION_NAMES[idx]);
|
||||
}
|
||||
switch (idx) {
|
||||
case 0: cfg.forceEquip = parseBool(val); break;
|
||||
case 1: cfg.itemsOn = parseBool(val); break;
|
||||
|
||||
Reference in New Issue
Block a user