Skip to content

Commit

Permalink
🐛 修复ping不存在的服务器还会回复错误图片问题
Browse files Browse the repository at this point in the history
  • Loading branch information
limbang committed Jul 13, 2021
1 parent 7b5d097 commit 920c156
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "top.limbang"
version = "1.1.1"
version = "1.1.2"

repositories {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import top.limbang.mirai.minecraft.service.ServerService.pingServer
object MiraiConsoleMinecraftPlugin : KotlinPlugin(
JvmPluginDescription(
id = "top.limbang.mirai-console-minecraft-plugin",
version = "1.1.1",
version = "1.1.2",
) {
author("limbang")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import java.util.concurrent.TimeUnit

object ServerService {

fun pingServer(name: String): String? {
if (name.isEmpty()) return null
val serverInfo = MinecraftPluginData.serverMap[name] ?: return null
fun pingServer(name: String): Any? {
if (name.isEmpty()) return Unit
val serverInfo = MinecraftPluginData.serverMap[name] ?: return Unit
val serverListInfo = try {
val json = MinecraftClient.ping(serverInfo.address, serverInfo.port)
.get(5000, TimeUnit.MILLISECONDS) ?: return null
Expand Down

0 comments on commit 920c156

Please sign in to comment.