fix: rconPlayerListModule的Fallback修复
This commit is contained in:
parent
aa65f3fea8
commit
ba46c18fc1
|
|
@ -1,5 +1,5 @@
|
||||||
# 基于NapCat Http/Websocket Server API开发
|
# 基于NapCat Http/Websocket Server API开发
|
||||||
## 目标1:实现白名单申请通过后加群自动通过
|
## 目标1:实现白名单申请通过后加群自动通过 (模块)
|
||||||
### 拆分目标:
|
### 拆分目标:
|
||||||
轮询
|
轮询
|
||||||
1. 获取指定加群请求
|
1. 获取指定加群请求
|
||||||
|
|
|
||||||
|
|
@ -111,16 +111,18 @@ class RconPlayerListModule(
|
||||||
CmdUtil.runExeCommand(rconPath, "-c", rconConfigPath, "-T", (timeout / 1000).toString() + "s", "forge tps")
|
CmdUtil.runExeCommand(rconPath, "-c", rconConfigPath, "-T", (timeout / 1000).toString() + "s", "forge tps")
|
||||||
}.getOrElse { ex ->
|
}.getOrElse { ex ->
|
||||||
LoggerUtil.logger.warn("[$name] 执行 forge tps 失败: ${ex.message}")
|
LoggerUtil.logger.warn("[$name] 执行 forge tps 失败: ${ex.message}")
|
||||||
""
|
throw ex
|
||||||
}
|
}
|
||||||
|
|
||||||
val listOutput = runCatching {
|
val listOutput = runCatching {
|
||||||
CmdUtil.runExeCommand(rconPath, "-c", rconConfigPath, "-T", (timeout / 1000).toString() + "s", "list")
|
CmdUtil.runExeCommand(rconPath, "-c", rconConfigPath, "-T", (timeout / 1000).toString() + "s", "list")
|
||||||
}.getOrElse { ex ->
|
}.getOrElse { ex ->
|
||||||
LoggerUtil.logger.warn("[$name] 执行 list 失败: ${ex.message}")
|
LoggerUtil.logger.warn("[$name] 执行 list 失败: ${ex.message}")
|
||||||
""
|
throw ex
|
||||||
|
}
|
||||||
|
if (tpsOutput.contains("i/o timeout") || listOutput.contains("i/o timeout")) {
|
||||||
|
throw TimeoutException()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 合并输出,再解析
|
// 合并输出,再解析
|
||||||
buildString {
|
buildString {
|
||||||
appendLine(tpsOutput.trim())
|
appendLine(tpsOutput.trim())
|
||||||
|
|
@ -129,9 +131,11 @@ class RconPlayerListModule(
|
||||||
}
|
}
|
||||||
} .onFailure { ex ->
|
} .onFailure { ex ->
|
||||||
if (ex is TimeoutException) {
|
if (ex is TimeoutException) {
|
||||||
|
lastSuccessTime = now // ✅ 成功后记录冷却开始时间
|
||||||
LoggerUtil.logger.warn("[$name] RCON 连接超时: ${ex.message}")
|
LoggerUtil.logger.warn("[$name] RCON 连接超时: ${ex.message}")
|
||||||
sendFailedMessage(napCatClient, triggerMsg.realId, triggerMsg.time)
|
sendFailedMessage(napCatClient, triggerMsg.realId, triggerMsg.time)
|
||||||
} else {
|
} else {
|
||||||
|
lastSuccessTime = now // ✅ 成功后记录冷却开始时间
|
||||||
LoggerUtil.logger.error("[$name] RCON 命令执行失败", ex)
|
LoggerUtil.logger.error("[$name] RCON 命令执行失败", ex)
|
||||||
sendFailedMessage(
|
sendFailedMessage(
|
||||||
napCatClient,
|
napCatClient,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package top.r3944realms.ltdmanager
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import top.r3944realms.ltdmanager.module.GroupRequestHandlerModule
|
import top.r3944realms.ltdmanager.module.GroupRequestHandlerModule
|
||||||
import top.r3944realms.ltdmanager.module.RconPlayerListModule
|
|
||||||
import top.r3944realms.ltdmanager.utils.LoggerUtil
|
import top.r3944realms.ltdmanager.utils.LoggerUtil
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user