[+] Allow disable music rank for own machine (#110)

* [+] Allow disable music rank for own machine

* fix
This commit is contained in:
凌莞~(=^▽^=)
2025-01-19 01:43:58 +08:00
committed by GitHub
parent dfee2cd71f
commit 151535139f
6 changed files with 19 additions and 1 deletions

View File

@@ -43,6 +43,9 @@ class AquaGameOptions(
@SettingField("chu3-matching")
var chusanMatchingReflector: String = "",
@SettingField("mai2")
var enableMusicRank: Boolean = true,
)
interface AquaGameOptionsRepo : JpaRepository<AquaGameOptions, Long>

View File

@@ -3,6 +3,7 @@ package icu.samnyan.aqua.sega.maimai2.handler
import com.querydsl.jpa.impl.JPAQueryFactory
import ext.logger
import ext.thread
import icu.samnyan.aqua.sega.allnet.TokenChecker
import icu.samnyan.aqua.sega.general.BaseHandler
import icu.samnyan.aqua.sega.maimai2.model.userdata.QMai2UserPlaylog
import org.springframework.scheduling.annotation.Scheduled
@@ -55,7 +56,14 @@ class GetGameRankingHandler(
override fun handle(request: Map<String, Any>): Any = mapOf(
"type" to request["type"],
"gameRankingList" to when(request["type"]) {
1 -> musicRankingCache.map { mapOf("id" to it.musicId, "point" to it.weight, "userName" to "") }
1 -> {
val opts = TokenChecker.getCurrentSession()?.user?.gameOptions
// If is null or true, return the ranking list
if (opts?.enableMusicRank == false)
emptyList()
else
musicRankingCache.map { mapOf("id" to it.musicId, "point" to it.weight, "userName" to "") }
}
else -> emptyList()
}
)