125续15l-3 成书UI/CLI展示前剥离JSON动作块(split围栏段)
Auto Release / build (push) Successful in 2m35s

This commit is contained in:
youpaishidifu
2026-11-19 22:00:06 +08:00
parent 23d8694752
commit cb4f54d3cc
+15 -1
View File
@@ -313,7 +313,21 @@ public class RulesCLIManager implements Listener {
LinkedHashMap<String, String> signed = listSignedAgreements(playerName);
String path = signed.get(key);
if (path == null) return null;
return readFile(new File(path));
// ★ 125 续15l-3:成书/CLI 展示前剥离 JSON 动作配置块(```json ... ```),
// 避免 JSON 块泄漏进协议正文(与 CustomScreenManager.stripJsonBlock 同范式)。
return stripJsonBlock(readFile(new File(path)));
}
/** 删除 ``` 围栏块(json 动作配置),保留其余正文。 */
private String stripJsonBlock(String raw) {
if (raw == null) return null;
// 按 ``` 分段:奇数段是代码块(丢弃),偶数段是正文(保留)
String[] parts = raw.split("```", -1);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < parts.length; i += 2) {
sb.append(parts[i]);
}
return sb.toString().trim();
}
/** 分页:每页最多 pageSize 字,按行切分(一行不跨页) */