fix: HUD去日志+空列表return,服务端每5秒定期同步榜单数据
This commit is contained in:
1 parent
664d2a39cf
commit
4cc1b64fc3
2 files changed
+13
-2
No files matched your search
@@ -28,7 +28,6 @@ public class BoardHudElement implements HudElement {
|
||||
@Override
|
||||
public void extractRenderState(GuiGraphicsExtractor g, DeltaTracker delta) {
|
||||
String board = BoardClientState.displaying;
|
||||
com.github.zly2006.carpetslsaddition.ServerMain.LOGGER.info("[SLSA-HUD] extractRenderState board={}", board);
|
||||
if (board == null || board.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -37,6 +36,9 @@ public class BoardHudElement implements HudElement {
|
||||
return;
|
||||
}
|
||||
List<BoardClientState.Entry> list = BoardClientState.current();
|
||||
if (list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Font font = mc.font;
|
||||
|
||||
String title = BoardClientState.currentTitle();
|
||||
|
||||
@@ -85,13 +85,22 @@ public final class BoardSyncManager {
|
||||
}
|
||||
|
||||
private static volatile Boolean lastEnabled = null;
|
||||
private static long lastSyncTick = 0;
|
||||
|
||||
/** 由轮询线程每秒调用:规则值变化时同步给所有玩家。 */
|
||||
/** 由轮询线程每秒调用:规则值变化时立即同步;否则每 5 秒定期同步一次数据。 */
|
||||
public static void tick(MinecraftServer server) {
|
||||
boolean now = com.github.zly2006.carpetslsaddition.SLSCarpetSettings.slsBoardEnabled;
|
||||
if (lastEnabled == null || lastEnabled != now) {
|
||||
lastEnabled = now;
|
||||
syncToAll(server);
|
||||
return;
|
||||
}
|
||||
if (now) {
|
||||
long tick = server.getTickCount();
|
||||
if (tick - lastSyncTick >= 100) { // 每 100 tick(5秒)同步一次数据
|
||||
lastSyncTick = tick;
|
||||
syncToAll(server);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user