mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2025-01-23 21:52:35 +01:00
parent
2f4616f38e
commit
3f3a8de294
@ -72,6 +72,7 @@ dependencies {
|
||||
|
||||
implementation("com.google.guava:guava:30.1.1-jre")
|
||||
implementation("com.velocitypowered:velocity-native:3.0.0")
|
||||
implementation("net.coobird:thumbnailator:0.4.14")
|
||||
implementation("org.powernukkit.fastutil:fastutil-lite:8.1.1")
|
||||
implementation("org.yaml:snakeyaml:1.29")
|
||||
|
||||
|
@ -2,8 +2,11 @@ package com.viaversion.aas.config
|
||||
|
||||
import com.viaversion.aas.secureRandom
|
||||
import com.viaversion.viaversion.util.Config
|
||||
import net.coobird.thumbnailator.Thumbnails
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
import java.net.URL
|
||||
import java.util.*
|
||||
|
||||
object VIAaaSConfig : Config(File("config/viaaas.yml")) {
|
||||
@ -11,6 +14,26 @@ object VIAaaSConfig : Config(File("config/viaaas.yml")) {
|
||||
reloadConfig()
|
||||
}
|
||||
|
||||
override fun reloadConfig() {
|
||||
super.reloadConfig()
|
||||
reloadIcon()
|
||||
}
|
||||
|
||||
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)
|
||||
.outputFormat("png").toOutputStream(it)
|
||||
}.toByteArray()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getUnsupportedOptions() = emptyList<String>()
|
||||
override fun getDefaultConfigURL() = VIAaaSConfig::class.java.classLoader.getResource("viaaas.yml")!!
|
||||
override fun handleConfig(map: MutableMap<String, Any>) {
|
||||
@ -63,8 +86,7 @@ object VIAaaSConfig : Config(File("config/viaaas.yml")) {
|
||||
if (it.isNullOrBlank()) throw IllegalStateException("invalid jwt-secret") else it
|
||||
}
|
||||
val rateLimitLoginMc: Double get() = this.getDouble("rate-limit-login-mc", 0.2)
|
||||
val faviconUrl: String?
|
||||
get() = this.getString("favicon-url", "")!!.filter { !it.isWhitespace() }.ifEmpty { null }
|
||||
var faviconUrl: String? = null
|
||||
val maxPlayers: Int? get() = this.getInt("max-players", 20).let { if (it == -1) null else it }
|
||||
val backendProxy: URI?
|
||||
get() = this.getString("backend-proxy", "").let { if (it.isNullOrEmpty()) null else URI.create(it) }
|
||||
|
@ -75,8 +75,8 @@ listening-ws-limit: 10
|
||||
#####
|
||||
# Misc
|
||||
#####
|
||||
# Favicon URL to use in disconnection messages. Should use "data:image/png;base64," and be a 64x64 PNG
|
||||
favicon-url: ''
|
||||
# Favicon URL to use in disconnection messages.
|
||||
favicon-url: https://cdn.discordapp.com/attachments/316218802155028482/850014925622476820/unknown.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
|
||||
|
Loading…
Reference in New Issue
Block a user