From 822795639a8c88fbd9cd85fafeef3ada16a2df9b Mon Sep 17 00:00:00 2001 From: creeper123123321 <7974274+creeper123123321@users.noreply.github.com> Date: Sat, 16 Oct 2021 11:11:32 -0300 Subject: [PATCH] warn about incorrect favicon url --- src/main/kotlin/com/viaversion/aas/VIAaaS.kt | 10 +++---- .../com/viaversion/aas/config/VIAaaSConfig.kt | 27 +++++++++++-------- src/main/resources/viaaas.yml | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/com/viaversion/aas/VIAaaS.kt b/src/main/kotlin/com/viaversion/aas/VIAaaS.kt index 6adff73..be1406f 100644 --- a/src/main/kotlin/com/viaversion/aas/VIAaaS.kt +++ b/src/main/kotlin/com/viaversion/aas/VIAaaS.kt @@ -1,13 +1,11 @@ package com.viaversion.aas import com.viaversion.aas.command.VIAaaSConsole -import com.viaversion.aas.command.ViaAspirinCommand -import com.viaversion.aas.platform.* +import com.viaversion.aas.platform.AspirinBackwards +import com.viaversion.aas.platform.AspirinPlatform +import com.viaversion.aas.platform.AspirinRewind import com.viaversion.aas.protocol.registerAspirinProtocols import com.viaversion.aas.web.ViaWebApp -import com.viaversion.viaversion.ViaManagerImpl -import com.viaversion.viaversion.api.Via -import com.viaversion.viaversion.api.data.MappingDataLoader import com.viaversion.viaversion.api.protocol.version.ProtocolVersion import de.gerrygames.viarewind.api.ViaRewindConfigImpl import io.ktor.application.* @@ -34,7 +32,7 @@ fun main(args: Array) { Thread { VIAaaSConsole.start() }.start() AspirinServer.waitStopSignal() - } catch (e: Exception) { + } catch (e: Throwable) { e.printStackTrace() } finally { AspirinServer.finish() diff --git a/src/main/kotlin/com/viaversion/aas/config/VIAaaSConfig.kt b/src/main/kotlin/com/viaversion/aas/config/VIAaaSConfig.kt index 27145b7..bc505e0 100644 --- a/src/main/kotlin/com/viaversion/aas/config/VIAaaSConfig.kt +++ b/src/main/kotlin/com/viaversion/aas/config/VIAaaSConfig.kt @@ -23,17 +23,22 @@ object VIAaaSConfig : Config(File("config/viaaas.yml")) { fun reloadIcon() { val rawUrl = this.getString("favicon-url", "")!! - faviconUrl = when { - rawUrl.isEmpty() -> null - rawUrl.startsWith("data:image/png;base64,") -> rawUrl.filter { !it.isWhitespace() } - else -> "data:image/png;base64," + Base64.getEncoder().encodeToString( - ByteArrayOutputStream().also { - Thumbnails.of(URL(rawUrl)) - .size(64, 64) - .addFilter(Canvas(64, 64, Positions.CENTER, false)) - .outputFormat("png").toOutputStream(it) - }.toByteArray() - ) + try { + faviconUrl = when { + rawUrl.isEmpty() -> null + rawUrl.startsWith("data:image/png;base64,") -> rawUrl.filter { !it.isWhitespace() } + else -> "data:image/png;base64," + Base64.getEncoder().encodeToString( + ByteArrayOutputStream().also { + Thumbnails.of(URL(rawUrl)) + .size(64, 64) + .addFilter(Canvas(64, 64, Positions.CENTER, false)) + .outputFormat("png") + .toOutputStream(it) + }.toByteArray() + ) + } + } catch (e: Exception) { + e.printStackTrace() } } diff --git a/src/main/resources/viaaas.yml b/src/main/resources/viaaas.yml index 0a46ab3..2e9107a 100644 --- a/src/main/resources/viaaas.yml +++ b/src/main/resources/viaaas.yml @@ -71,7 +71,7 @@ listening-ws-limit: 10 # Misc ##### # Favicon URL to use in disconnection messages. -favicon-url: https://viaversion.github.io/VIAaaS/src/main/resources/web/logo.png +favicon-url: https://raw.githubusercontent.com/ViaVersion/VIAaaS/396dcb40249ed0ef292e223c32e7f130699e7153/src/main/resources/web/logo.png # Requires online mode for front-end connections. May be useful for stopping bots. force-online-mode: false # Max players to allow connection. Use -1 to not limit