update via platform

This commit is contained in:
creeper123123321 2021-03-26 17:19:24 -03:00
parent 01c5c1a324
commit 6ff3b1e5e0
5 changed files with 29 additions and 24 deletions

View File

@ -36,12 +36,11 @@ import io.netty.channel.socket.nio.NioSocketChannel
import io.netty.util.concurrent.Future
import org.apache.logging.log4j.Level
import org.apache.logging.log4j.io.IoBuilder
import us.myles.ViaVersion.ViaManager
import us.myles.ViaVersion.ViaManagerImpl
import us.myles.ViaVersion.api.Via
import us.myles.ViaVersion.api.data.MappingDataLoader
import us.myles.ViaVersion.api.protocol.ProtocolVersion
import java.io.File
import java.lang.Thread
import java.net.InetAddress
import java.security.KeyPairGenerator
import java.util.concurrent.CompletableFuture
@ -103,11 +102,13 @@ fun main(args: Array<String>) {
System.setOut(IoBuilder.forLogger("STDOUT").setLevel(Level.INFO).buildPrintStream());
System.setErr(IoBuilder.forLogger("STDERR").setLevel(Level.ERROR).buildPrintStream());
println("""\\ // // //\\ => //|| //|| /=====/ PROXY
println(
"""\\ // // //\\ => //|| //|| /=====/ PROXY
| \\ // // // \\ // || // || //
| \\ // // //====\\ //==|| //==|| \====\ $viaaasVer
| \\ // // // \\ // || // || //
|<= \\// // // \\ // || // || /====/""".trimMargin())
|<= \\// // // \\ // || // || /====/""".trimMargin()
)
File("config/https.jks").apply {
parentFile.mkdirs()
@ -115,14 +116,14 @@ fun main(args: Array<String>) {
}
Via.init(
ViaManager.builder()
ViaManagerImpl.builder()
.injector(AspirinInjector)
.loader(AspirinLoader)
.commandHandler(AspirinCommands)
.platform(AspirinPlatform).build()
)
MappingDataLoader.enableMappingsCache()
Via.getManager().init()
(Via.getManager() as ViaManagerImpl).init()
ProtocolVersion.register(-2, "AUTO")
AspirinRewind.init(ViaRewindConfigImpl(File("config/viarewind.yml")))
AspirinBackwards.init(File("config/viabackwards"))
@ -147,14 +148,16 @@ fun main(args: Array<String>) {
initFuture.complete(Unit)
VIAaaSConsole.start()
while(runningServer) { Thread.sleep(1000L) }
while (runningServer) {
Thread.sleep(1000L)
}
ktorServer?.stop(1000, 1000)
httpClient.close()
listOf<Future<*>>(future.channel().close(), parentLoop.shutdownGracefully(), childLoop.shutdownGracefully())
.forEach { it.sync() }
Via.getManager().destroy()
(Via.getManager() as ViaManagerImpl).destroy()
}
fun Application.mainWeb() {

View File

@ -1,13 +1,20 @@
package com.github.creeper123123321.viaaas.platform
import us.myles.ViaVersion.api.platform.ViaInjector
import us.myles.ViaVersion.api.protocol.ProtocolVersion
import us.myles.viaversion.libs.fastutil.ints.IntLinkedOpenHashSet
import us.myles.viaversion.libs.fastutil.ints.IntSortedSet
import us.myles.viaversion.libs.gson.JsonObject
object AspirinInjector : ViaInjector {
override fun getEncoderName(): String = "via-codec"
override fun getDecoderName() = "via-codec"
override fun getDump(): JsonObject = JsonObject()
override fun getServerProtocolVersion() = 47 // Dummy
override fun getServerProtocolVersions(): IntSortedSet = IntLinkedOpenHashSet(
sortedSetOf(ProtocolVersion.v1_16_4.version, ProtocolVersion.v1_7_1.version)
)
override fun getServerProtocolVersion(): Int = ProtocolVersion.v1_7_1.version
override fun uninject() {
}

View File

@ -23,7 +23,7 @@ import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import java.util.logging.Logger
object AspirinPlatform : ViaPlatform<Unit> {
object AspirinPlatform : ViaPlatform<UUID> {
val connMan = ViaConnectionManager()
val executor = Executors.newCachedThreadPool(ThreadFactoryBuilder().setNameFormat("Via-%d").setDaemon(true).build())
val eventLoop = DefaultEventLoop(executor)
@ -52,7 +52,7 @@ object AspirinPlatform : ViaPlatform<Unit> {
override fun getDump(): JsonObject = JsonObject()
override fun kickPlayer(p0: UUID, p1: String): Boolean = false
override fun getApi(): ViaAPI<Unit> = AspirinViaAPI
override fun getApi(): ViaAPI<UUID> = AspirinViaAPI
override fun getDataFolder(): File = File("viaversion")
override fun getConf(): ViaVersionConfig = AspirinViaConfig
override fun runAsync(p0: Runnable): TaskId = AspirinTask(CompletableFuture.runAsync(p0, executor))

View File

@ -1,22 +1,17 @@
package com.github.creeper123123321.viaaas.platform
import io.netty.buffer.ByteBuf
import us.myles.ViaVersion.api.ViaAPI
import us.myles.ViaVersion.api.ViaAPIBase
import us.myles.ViaVersion.api.boss.BossBar
import us.myles.ViaVersion.api.boss.BossColor
import us.myles.ViaVersion.api.boss.BossStyle
import us.myles.ViaVersion.api.protocol.ProtocolRegistry
import java.util.*
import kotlin.UnsupportedOperationException
object AspirinViaAPI : ViaAPI<Unit> {
override fun isInjected(p0: UUID): Boolean = false
object AspirinViaAPI : ViaAPIBase<UUID>() {
override fun createBossBar(p0: String, p1: BossColor, p2: BossStyle): BossBar<*> = AspirinBossBar(p0, 0f, p2, p1)
override fun createBossBar(p0: String, p1: Float, p2: BossColor, p3: BossStyle): BossBar<*> = AspirinBossBar(p0, p1, p3, p2)
override fun sendRawPacket(p0: Unit?, p1: ByteBuf?) = throw UnsupportedOperationException()
override fun sendRawPacket(p0: UUID?, p1: ByteBuf?) = throw UnsupportedOperationException()
override fun getPlayerVersion(p0: Unit?): Int = throw UnsupportedOperationException()
override fun createBossBar(p0: String, p1: Float, p2: BossColor, p3: BossStyle): BossBar<*> =
AspirinBossBar(p0, p1, p3, p2)
override fun sendRawPacket(p0: UUID, p1: ByteBuf) = super.sendRawPacket(p0, p1)
override fun getPlayerVersion(p0: UUID?): Int = throw UnsupportedOperationException()
override fun getVersion(): String = AspirinPlatform.pluginVersion
override fun getSupportedVersions(): SortedSet<Int> = ProtocolRegistry.getSupportedVersions()
}

View File

@ -2,9 +2,9 @@ package com.github.creeper123123321.viaaas.provider
import com.github.creeper123123321.viaaas.handler.MinecraftHandler
import us.myles.ViaVersion.api.data.UserConnection
import us.myles.ViaVersion.protocols.base.VersionProvider
import us.myles.ViaVersion.protocols.base.BaseVersionProvider
object AspirinVersionProvider : VersionProvider() {
object AspirinVersionProvider : BaseVersionProvider() {
override fun getServerProtocol(connection: UserConnection): Int {
val ver = connection.channel!!.pipeline().get(MinecraftHandler::class.java).data.viaBackServerVer
if (ver != null) return ver