Skip to content

Commit

Permalink
被封号不能签到
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed Jun 7, 2024
1 parent dc95c21 commit f5819ca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/kotlin/gm/Addenergy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ class Addenergy : Function<Map<String, String>, Any> {
return try {
val name = form["name"]!!
val energy = form["energy"]!!.toInt()
val result = Statistics.addEnergy(name, energy, true)
"{\"result\": $result}"
val playerInfo = Statistics.getPlayerInfo(name) ?: return "{\"error\": \"玩家不存在\"}"
val forbidLeft = playerInfo.forbidUntil - System.currentTimeMillis()
if (forbidLeft > 0) {
"{\"result\": false}"
} else {
val result = Statistics.addEnergy(name, energy, true)
"{\"result\": $result}"
}
} catch (e: NumberFormatException) {
"{\"error\": \"参数错误\"}"
} catch (e: NullPointerException) {
Expand Down

0 comments on commit f5819ca

Please sign in to comment.