diff --git a/src/integration-test/java/com/replaymod/extra/DownloadOpenEye.java b/src/integration-test/java/com/replaymod/extra/DownloadOpenEye.java index 753090c0..257a56fd 100644 --- a/src/integration-test/java/com/replaymod/extra/DownloadOpenEye.java +++ b/src/integration-test/java/com/replaymod/extra/DownloadOpenEye.java @@ -10,6 +10,10 @@ import java.nio.file.NoSuchFileException; public class DownloadOpenEye extends AbstractTask { @Override protected void init() { + if ("1".equals(System.getenv("RM_INTEGRATION_TEST_NO_OPENEYE"))) { + runLater(() -> future.set(null)); + return; + } expectGui(OpenEyeExtra.OfferGui.class, offerGui -> { click(offerGui.yesButton); expectGuiClosed(20 * 1000, () -> { diff --git a/src/main/java/com/replaymod/extras/OpenEyeExtra.java b/src/main/java/com/replaymod/extras/OpenEyeExtra.java index ba0575fb..bc13e23d 100644 --- a/src/main/java/com/replaymod/extras/OpenEyeExtra.java +++ b/src/main/java/com/replaymod/extras/OpenEyeExtra.java @@ -26,6 +26,7 @@ import java.nio.channels.FileChannel; import java.nio.channels.ReadableByteChannel; import static com.replaymod.core.utils.Utils.SSL_SOCKET_FACTORY; +import static com.replaymod.extras.ReplayModExtras.LOGGER; public class OpenEyeExtra implements Extra { private static final String DOWNLOAD_URL = "https://www.replaymod.com/dl/openeye/" + Loader.MC_VERSION; @@ -39,7 +40,25 @@ public class OpenEyeExtra implements Extra { mod.getSettingsRegistry().register(ASK_FOR_OPEN_EYE); if (!Loader.isModLoaded("OpenEye") && mod.getSettingsRegistry().get(ASK_FOR_OPEN_EYE)) { - mod.runLater(() -> new OfferGui(GuiScreen.wrap(mod.getMinecraft().currentScreen)).display()); + new Thread(() -> { + try { + LOGGER.trace("Checking for OpenEye availability"); + HttpsURLConnection connection = (HttpsURLConnection) new URL(DOWNLOAD_URL).openConnection(); + connection.setSSLSocketFactory(SSL_SOCKET_FACTORY); + connection.setRequestMethod("HEAD"); + connection.connect(); + LOGGER.trace("Got response code: {}", connection.getResponseCode()); + if (connection.getResponseCode() == 200) { + mod.runLater(() -> new OfferGui(GuiScreen.wrap(mod.getMinecraft().currentScreen)).display()); + } else { + LOGGER.info("Cannot offer OpenEye, server returned: {} {}", + connection.getResponseCode(), connection.getResponseMessage()); + } + connection.disconnect(); + } catch (Throwable e) { + LOGGER.error("Failed to check for OpenEye availability:", e); + } + }).start(); } }