This commit is contained in:
@@ -1762,8 +1762,12 @@ public class AIChatManager {
|
||||
// ★ 日志静默:正常触发不打印"触发自动互动",只在失败时记一条简要错误
|
||||
// 状态变化(失败→成功 或 成功→失败)时记一条恢复/告警
|
||||
|
||||
// 异步发送
|
||||
String systemPrompt = buildSystemPrompt() + "\n" + buildAgentPrompt();
|
||||
// 异步发送(自动抛题:建议模型直接抛题,仅在必要时才调用工具)
|
||||
String systemPrompt = buildSystemPrompt() + "\n" + buildAgentPrompt()
|
||||
+ "\n\n【自动抛题引导】\n"
|
||||
+ "你是主动抛话题带动气氛的角色。请优先基于你的训练知识、服务器人设和 Minecraft 主题直接抛出有趣的话题,\n"
|
||||
+ "不需要调用联网搜索工具。只有在玩家讨论的内容确实超出你的知识范围时,才考虑调用工具查询。\n"
|
||||
+ "直接抛题能节省时间和费用,让互动更自然流畅。";
|
||||
String jsonBody = buildChatRequest(defaultModelFull, systemPrompt, prompt, endpoint.maxToken);
|
||||
String requestUrl = buildRequestUrl(endpoint);
|
||||
|
||||
@@ -1837,6 +1841,7 @@ public class AIChatManager {
|
||||
|
||||
String reply = parseChatResponse(response.body());
|
||||
if (reply != null) {
|
||||
reply = sanitizeReply(reply);
|
||||
Bukkit.broadcastMessage("§d§l[AI] §f" + reply);
|
||||
recordIssue("[自动] " + prompt.substring(0, Math.min(100, prompt.length())), reply,
|
||||
"system", defaultModelFull, 200, null);
|
||||
|
||||
@@ -1651,14 +1651,10 @@ public class ConfigManager {
|
||||
com.google.gson.JsonObject root = oldEl.getAsJsonObject();
|
||||
List<String> added = new ArrayList<>();
|
||||
boolean merged = mergeJsonMissing(root, tplEl.getAsJsonObject(), "", added);
|
||||
// ★ 第77批-后续修复:清理根级多余键(如 填写规范/配置填写示例 被误加到根级)
|
||||
// 这些键在模板中存在于 配置部分.2 内,不应出现在根级
|
||||
boolean cleaned = removeRootLevelDuplicates(root);
|
||||
// ★ 第77批修复(#353):缺失键插入后按模板顺序重排,
|
||||
// 否则新键追加到末尾而非模板对应位置
|
||||
reorderToTemplateOrder(root, tplEl.getAsJsonObject());
|
||||
if (!merged && !cleaned) {
|
||||
return false; // 无缺失键且无多余键,幂等
|
||||
boolean reordered = reorderToTemplateOrder(root, tplEl.getAsJsonObject());
|
||||
if (!merged && !cleaned && !reordered) {
|
||||
return false; // 无缺失键、无多余键、顺序一致,幂等
|
||||
}
|
||||
// ① 备份原文件 → .bak 并逐字节校验(失败=取消,原文件不动)
|
||||
File bak = new File(file.getParentFile(), file.getName() + ".bak");
|
||||
@@ -1740,9 +1736,10 @@ public class ConfigManager {
|
||||
* @param target 已补入缺失键的对象(会被重建)
|
||||
* @param tpl 模板对象(提供键顺序)
|
||||
*/
|
||||
private void reorderToTemplateOrder(com.google.gson.JsonObject target,
|
||||
private boolean reorderToTemplateOrder(com.google.gson.JsonObject target,
|
||||
com.google.gson.JsonObject tpl) {
|
||||
com.google.gson.JsonObject reordered = new com.google.gson.JsonObject();
|
||||
boolean changed = false;
|
||||
// 先按模板顺序放入模板中存在的键
|
||||
for (Map.Entry<String, com.google.gson.JsonElement> en : tpl.entrySet()) {
|
||||
String k = en.getKey();
|
||||
@@ -1751,7 +1748,7 @@ public class ConfigManager {
|
||||
if (have != null) {
|
||||
// 递归重排嵌套对象
|
||||
if (have.isJsonObject() && en.getValue().isJsonObject()) {
|
||||
reorderToTemplateOrder(have.getAsJsonObject(), en.getValue().getAsJsonObject());
|
||||
changed |= reorderToTemplateOrder(have.getAsJsonObject(), en.getValue().getAsJsonObject());
|
||||
}
|
||||
reordered.add(k, have);
|
||||
}
|
||||
@@ -1767,6 +1764,20 @@ public class ConfigManager {
|
||||
reordered.add(k, en.getValue());
|
||||
}
|
||||
}
|
||||
// 检查顺序是否变化
|
||||
if (target.size() == reordered.size()) {
|
||||
boolean orderMatch = true;
|
||||
int i = 0;
|
||||
for (String k : target.keySet()) {
|
||||
if (!k.equals(reordered.keySet().toArray(new String[0])[i])) {
|
||||
orderMatch = false;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (orderMatch) return changed; // 顺序一致,未变化
|
||||
}
|
||||
changed = true;
|
||||
// 清空原 target 并写入重排后的内容
|
||||
for (String key : new java.util.ArrayList<>(target.keySet())) {
|
||||
target.remove(key);
|
||||
@@ -1774,6 +1785,7 @@ public class ConfigManager {
|
||||
for (Map.Entry<String, com.google.gson.JsonElement> en : reordered.entrySet()) {
|
||||
target.add(en.getKey(), en.getValue());
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/** 递归把模板里 target 缺失的键补进去(只插入不覆盖;# 说明键跳过) */
|
||||
@@ -1798,6 +1810,14 @@ public class ConfigManager {
|
||||
target.add(k, en.getValue().deepCopy());
|
||||
added.add(path + k + "(类型升级:数组/标量→对象)");
|
||||
changed = true;
|
||||
} else if (!have.getClass().equals(en.getValue().getClass())) {
|
||||
// ★ 第78批:类型不匹配——target 和 template 的 JSON 类型不同
|
||||
// 例:target 的 说明 是字符串,template 的 说明 是数组
|
||||
// 用 template 值覆盖,让用户看到正确的格式
|
||||
target.add(k, en.getValue().deepCopy());
|
||||
added.add(path + k + "(类型升级:" + have.getClass().getSimpleName()
|
||||
+ "→" + en.getValue().getClass().getSimpleName() + ")");
|
||||
changed = true;
|
||||
}
|
||||
// 已存在的对象/数组/标量 → 不碰,用户值原样保留
|
||||
}
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
"key请填写deepseek的apikey。",
|
||||
"deepseek的api会产生计费。一口价:1000次成功5块",
|
||||
"抓取失败/错误时暂不计费",
|
||||
"自动切换:使用内置deepseek供应商→自动使用deepseek的抓取服务",
|
||||
"使用其它供应商、自定义的则读取type值",
|
||||
"具体费用请留意deepseek官网动态",
|
||||
"此费用由deepseek公司收取,与插件无关",
|
||||
"介意者请留空type"
|
||||
|
||||
Reference in New Issue
Block a user