fix: skip OP sync for profiles not in cache instead of using empty username

Co-authored-by: Xujiayao <58985541+Xujiayao@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-10 12:57:34 +00:00 committed by Jason Xu
parent 461bbe8d39
commit 04874111ed
3 changed files with 7 additions and 7 deletions

View file

@ -61,8 +61,8 @@ DMCC 所有运行模式都基于一个统一的通信模型,该模型包含两
- **一个 Discord 账户可关联多个 Minecraft 账户**(方便玩家管理大号与小号)。
- **一个 Minecraft 账户只能关联一个 Discord 账户**(确保游戏内身份的绝对唯一性)。
- **数据持久化**: 绑定关系作为永久数据存储在 `Server` 端的 `linking/links.json` 中,以 Discord ID 为主键。
- **存储约束**: `links.json` 中仅存储绑定关系最小必要字段Discord ID、Minecraft UUID、添加时间**不得额外存储**
- **数据持久化**: 绑定关系作为永久数据存储在 `Server` 端的 `account_linking/linked_accounts.json` 中,以 Discord ID 为主键。
- **存储约束**: `linked_accounts.json` 中仅存储绑定关系最小必要字段Discord ID、Minecraft UUID、添加时间**不得额外存储**
Discord 用户名或 Minecraft 玩家名;显示名称在查询时实时解析。
### 4.2 安全绑定工作流 (严格的 MC 优先原则)
@ -75,7 +75,7 @@ DMCC 所有运行模式都基于一个统一的通信模型,该模型包含两
- 若该玩家存在未过期验证码,返回同一验证码并将过期时间重置为“当前时间 + 5 分钟”;
- 若验证码已过期或不存在,生成并返回新验证码(同样 5 分钟有效)。
4. **确认所有权**: 玩家前往 Discord使用斜杠命令 `/link A7X9P2`
5. **完成绑定**: Server 验证代码有效后,将该 Discord ID 与 MC UUID 写入 `links.json`,并使该验证码失效。
5. **完成绑定**: Server 验证代码有效后,将该 Discord ID 与 MC UUID 写入 `linked_accounts.json`,并使该验证码失效。
### 4.3 解绑与查询工作流
@ -138,7 +138,7 @@ Discord 用户的身份将通过以下规则在 Server 端结算为一个具体
1. **全量同步原则**: 每次同步均执行“全量重算 + 全量应用”,而非增量补丁。
2. **强制覆盖原则**: DMCC 将重置 Minecraft 服务器当前 OP 列表,并依据 DMCC 配置中的映射规则重新分配。
3. **绑定缺失回退**: 若某玩家解除绑定后在 `links.json` 中不再出现,则在下一次全量同步中该玩家 OP 等级将被重置为 0。
3. **绑定缺失回退**: 若某玩家解除绑定后在 `linked_accounts.json` 中不再出现,则在下一次全量同步中该玩家 OP 等级将被重置为 0。
4. **关闭时不干预**: 若 `sync_op_level_to_minecraft=false`,解绑不触发 OP 回收,服务器维持原样。
5. **与原生 `/op` 的关系**: 开启后,管理员在游戏内使用原生命令 `/op` 手动授予的结果会在下一次 DMCC 全量同步时被覆盖,这是预期行为。

View file

@ -127,7 +127,7 @@ public class LinkedAccountManager {
* Clears all linked accounts from memory without writing to disk.
* <p>
* This intentionally does NOT save to disk, so users can manually edit
* {@code links.json} while DMCC is running and reload to apply their changes.
* {@code linked_accounts.json} while DMCC is running and reload to apply their changes.
* Any in-memory changes that were not yet persisted via {@link #save()} will be lost.
* In practice, all mutations (link/unlink) call {@link #save()} immediately,
* so no data is lost under normal operation.

View file

@ -430,8 +430,8 @@ public class MinecraftEventHandler {
com.mojang.authlib.GameProfile profile = serverInstance.getProfileCache()
.get(uuid).orElse(null);
if (profile == null) {
// Create a minimal profile for offline players
profile = new com.mojang.authlib.GameProfile(uuid, "");
// Profile not in cache; skip this entry as we can't op without a valid profile
continue;
}
// Add the OP entry with the exact desired level
opList.add(new net.minecraft.server.players.ServerOpListEntry(