diff --git a/paper-server/src/test/java/org/bukkit/support/condition/EnableIfMojangServerAvailableCondition.java b/paper-server/src/test/java/org/bukkit/support/condition/EnableIfMojangServerAvailableCondition.java index d88cc6cea8..ea9048fb1b 100644 --- a/paper-server/src/test/java/org/bukkit/support/condition/EnableIfMojangServerAvailableCondition.java +++ b/paper-server/src/test/java/org/bukkit/support/condition/EnableIfMojangServerAvailableCondition.java @@ -1,7 +1,7 @@ package org.bukkit.support.condition; import com.mojang.authlib.yggdrasil.YggdrasilEnvironment; -import java.net.InetAddress; +import java.net.HttpURLConnection; import java.net.URI; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.extension.ConditionEvaluationResult; @@ -12,17 +12,19 @@ public class EnableIfMojangServerAvailableCondition implements ExecutionConditio @Override public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext extensionContext) { + HttpURLConnection url = null; try { - URI url = new URI(YggdrasilEnvironment.PROD.getEnvironment().servicesHost()); - InetAddress address = InetAddress.getByName(url.getHost()); - - if (!address.isReachable((int) TimeUnit.SECONDS.toMillis(1))) { - return ConditionEvaluationResult.disabled("Mojang server is not available"); - } + url = (HttpURLConnection) new URI(YggdrasilEnvironment.PROD.getEnvironment().servicesHost()).toURL().openConnection(); + url.setConnectTimeout((int) TimeUnit.SECONDS.toMillis(1)); + url.connect(); return ConditionEvaluationResult.enabled("Mojang server available"); } catch (Exception e) { return ConditionEvaluationResult.disabled(e.getMessage()); + } finally { + if (url != null) { + url.disconnect(); + } } } }