Add a config option for leaderboard refresh time

This commit is contained in:
Melledy
2025-11-13 09:01:58 -08:00
parent b9e34301b9
commit 4cdfd7f9c2
2 changed files with 6 additions and 1 deletions

View File

@@ -101,6 +101,7 @@ public class Config {
public boolean skipIntro = false; public boolean skipIntro = false;
public boolean unlockInstances = true; public boolean unlockInstances = true;
public int dailyResetHour = 0; public int dailyResetHour = 0;
public int leaderboardRefreshTime = 60;
public WelcomeMail welcomeMail = new WelcomeMail(); public WelcomeMail welcomeMail = new WelcomeMail();
} }

View File

@@ -21,6 +21,10 @@ public class ScoreBossModule extends GameContextModule {
this.ranking = new ArrayList<>(); this.ranking = new ArrayList<>();
} }
private long getRefreshTime() {
return Nebula.getConfig().getServerOptions().leaderboardRefreshTime * 1000;
}
public synchronized List<ScoreBossRankData> getRanking() { public synchronized List<ScoreBossRankData> getRanking() {
if (System.currentTimeMillis() > this.nextUpdate) { if (System.currentTimeMillis() > this.nextUpdate) {
this.updateRanking(); this.updateRanking();
@@ -46,7 +50,7 @@ public class ScoreBossModule extends GameContextModule {
this.ranking.add(entry.toProto()); this.ranking.add(entry.toProto());
} }
this.nextUpdate = System.currentTimeMillis() + 1000; this.nextUpdate = System.currentTimeMillis() + this.getRefreshTime();
this.lastUpdate = Nebula.getCurrentTime(); this.lastUpdate = Nebula.getCurrentTime();
} }
} }