From 9603e3ee3199c4c240e5288f2b3f75a350845282 Mon Sep 17 00:00:00 2001 From: SantioMC Date: Wed, 24 Apr 2024 22:43:56 -0400 Subject: [PATCH] fix: Servers (ex warzone) not working --- src/main/kotlin/me/santio/minehututils/minehut/Minehut.kt | 5 ++++- .../kotlin/me/santio/minehututils/minehut/api/ServerModel.kt | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/me/santio/minehututils/minehut/Minehut.kt b/src/main/kotlin/me/santio/minehututils/minehut/Minehut.kt index f531717..d886e1e 100644 --- a/src/main/kotlin/me/santio/minehututils/minehut/Minehut.kt +++ b/src/main/kotlin/me/santio/minehututils/minehut/Minehut.kt @@ -1,5 +1,6 @@ package me.santio.minehututils.minehut +import com.google.gson.Gson import kong.unirest.core.Unirest import me.santio.minehututils.minehut.api.* import java.time.Duration @@ -91,7 +92,9 @@ object Minehut { * @return The server model, or null if the server does not exist */ fun server(name: String): ServerModel? { - val response = client.get("https://api.minehut.com/server/${name}?byName=true").asObject(ServerResponseModel::class.java) + val response = client.get("https://api.minehut.com/server/${name}?byName=true") + .asObject(ServerResponseModel::class.java) + return if (response.isSuccess && response.body.ok != false) { response.body.server } else null } diff --git a/src/main/kotlin/me/santio/minehututils/minehut/api/ServerModel.kt b/src/main/kotlin/me/santio/minehututils/minehut/api/ServerModel.kt index 2f4f8d6..a932bcd 100644 --- a/src/main/kotlin/me/santio/minehututils/minehut/api/ServerModel.kt +++ b/src/main/kotlin/me/santio/minehututils/minehut/api/ServerModel.kt @@ -49,7 +49,7 @@ data class ServerModel( @SerializedName("using_cosmetics") val usingCosmetics: Boolean, @SerializedName("daily_online_time") - private val dailyUptime: Map? = null, + private val dailyUptime: Map? = null, val joins: Int, val icon: String, val online: Boolean,