warn about incorrect favicon url

This commit is contained in:
creeper123123321 2021-10-16 11:11:32 -03:00
parent 068ac48e59
commit 822795639a
3 changed files with 21 additions and 18 deletions

View File

@ -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<String>) {
Thread { VIAaaSConsole.start() }.start()
AspirinServer.waitStopSignal()
} catch (e: Exception) {
} catch (e: Throwable) {
e.printStackTrace()
} finally {
AspirinServer.finish()

View File

@ -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()
}
}

View File

@ -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