第120批续:parseBool 显式支持 off/no/false/0 + setOption 入口 hex 日志移到 key 判定前(on 未命中也能抓)
Auto Release / build (push) Successful in 2m47s
Auto Release / build (push) Successful in 2m47s
This commit is contained in:
@@ -163,17 +163,17 @@ public class PVPCustomModeManager {
|
||||
return true;
|
||||
}
|
||||
int idx = keyIndex(key);
|
||||
if (idx < 0) return false;
|
||||
// ★ 第120批诊断日志:把到达的原始参数 hex 出来,若再点「是」却收到「否」,
|
||||
// 一眼看出是编码问题还是命令本身问题(on/off ASCII 不应有编码歧义)。
|
||||
// ★ 第120批诊断日志:hex 打 val + key 是否命中,放在 return 前,确保 on/off 都能被抓
|
||||
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]);
|
||||
plugin.getLogger().info("[PVP自定义] setOption 收到 key='" + key
|
||||
+ "' val='" + val + "' (UTF8: " + hex.toString().trim() + ")"
|
||||
+ (idx < 0 ? " -> 项名非法(未命中)" : " -> " + OPTION_NAMES[idx]));
|
||||
}
|
||||
if (idx < 0) return false;
|
||||
switch (idx) {
|
||||
case 0: cfg.forceEquip = parseBool(val); break;
|
||||
case 1: cfg.itemsOn = parseBool(val); break;
|
||||
@@ -208,9 +208,20 @@ public class PVPCustomModeManager {
|
||||
}
|
||||
|
||||
private boolean parseBool(String val) {
|
||||
String t = val.toLowerCase();
|
||||
return t.equals("是") || t.equals("y") || t.equals("yes")
|
||||
|| t.equals("开") || t.equals("on") || t.equals("1") || t.equals("true");
|
||||
if (val == null) return false;
|
||||
String t = val.toLowerCase().trim();
|
||||
// ★ 第120批:显式列出 true/false 两侧,避免默认 false 造成「点是否定了」的假象。
|
||||
// 是侧:是/y/yes/开/on/1/true;否侧:否/n/no/关/off/0/false。
|
||||
if (t.equals("是") || t.equals("y") || t.equals("yes")
|
||||
|| t.equals("开") || t.equals("on") || t.equals("1") || t.equals("true")) {
|
||||
return true;
|
||||
}
|
||||
if (t.equals("否") || t.equals("n") || t.equals("no")
|
||||
|| t.equals("关") || t.equals("off") || t.equals("0") || t.equals("false")) {
|
||||
return false;
|
||||
}
|
||||
// 未识别值:默认 false(与旧行为一致),但日志会在 setOption 入口先抓到原始 val
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 恢复出厂默认搭配 */
|
||||
|
||||
Reference in New Issue
Block a user