fix: 调用startTrackingObjective让客户端收到objective

load进来的objective未在trackedObjectives集合,客户端收不到。SERVER_STARTED时显式startTrackingObjective。
This commit is contained in:
AxTps committed 2026-10-06 21:04:18 +08:00
1 parent d44ea0f4a7
commit d3bd73f7c5
1 file changed
+7
@@ -47,6 +47,13 @@ public final class BoardManager {
Component.literal("挖掘榜"), ObjectiveCriteria.RenderType.INTEGER, true, null); Component.literal("挖掘榜"), ObjectiveCriteria.RenderType.INTEGER, true, null);
ServerMain.LOGGER.info("[SLSA] created scoreboard objective {}", OBJ_MINED); ServerMain.LOGGER.info("[SLSA] created scoreboard objective {}", OBJ_MINED);
} }
// 让客户端能收到这两个 objective(load 进来的 objective 可能未被追踪)
if (sb instanceof net.minecraft.server.ServerScoreboard ssb) {
Objective d = sb.getObjective(OBJ_DEATHS);
if (d != null) ssb.startTrackingObjective(d);
Objective m = sb.getObjective(OBJ_MINED);
if (m != null) ssb.startTrackingObjective(m);
}
} }
/** 读取某玩家的挖掘总数(遍历 stats map 中 BLOCK_MINED 类型条目)。 */ /** 读取某玩家的挖掘总数(遍历 stats map 中 BLOCK_MINED 类型条目)。 */