use Aspirin prefix instead of Cloud, use subcommand, add force online mode

This commit is contained in:
creeper123123321 2021-02-12 17:47:15 -03:00
parent 58e8f689d9
commit 428d47a9b9
32 changed files with 167 additions and 122 deletions

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -1,6 +1,6 @@
package com.github.creeper123123321.viaaas
import com.github.creeper123123321.viaaas.command.CloudCommands
import com.github.creeper123123321.viaaas.command.AspirinCommands
import com.github.creeper123123321.viaaas.command.VIAaaSConsole
import com.github.creeper123123321.viaaas.config.VIAaaSConfig
import com.github.creeper123123321.viaaas.handler.FrontEndInit
@ -12,7 +12,6 @@ import io.ktor.application.*
import io.ktor.client.*
import io.ktor.client.features.*
import io.ktor.client.features.json.*
import io.ktor.client.request.*
import io.ktor.network.tls.certificates.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
@ -45,7 +44,7 @@ import java.security.KeyPairGenerator
import java.util.concurrent.CompletableFuture
val viaaasVer = GsonUtil.getGson().fromJson(
CloudPlatform::class.java.classLoader.getResourceAsStream("viaaas_info.json")!!.reader(Charsets.UTF_8).readText(),
AspirinPlatform::class.java.classLoader.getResourceAsStream("viaaas_info.json")!!.reader(Charsets.UTF_8).readText(),
JsonObject::class.java
).get("version").asString
val viaWebServer = WebDashboardServer()
@ -103,15 +102,15 @@ fun main(args: Array<String>) {
Via.init(
ViaManager.builder()
.injector(CloudInjector)
.loader(CloudLoader)
.commandHandler(CloudCommands)
.platform(CloudPlatform).build()
.injector(AspirinInjector)
.loader(AspirinLoader)
.commandHandler(AspirinCommands)
.platform(AspirinPlatform).build()
)
MappingDataLoader.enableMappingsCache()
Via.getManager().init()
CloudRewind.init(ViaRewindConfigImpl(File("config/viarewind.yml")))
CloudBackwards.init(File("config/viabackwards"))
AspirinRewind.init(ViaRewindConfigImpl(File("config/viarewind.yml")))
AspirinBackwards.init(File("config/viabackwards"))
val parent = eventLoopGroup()
val child = eventLoopGroup()
@ -135,7 +134,7 @@ fun main(args: Array<String>) {
initFuture.complete(Unit)
VIAaaSConsole().start()
VIAaaSConsole.start()
ktorServer?.stop(1000, 1000)
httpClient.close()

View File

@ -1,6 +1,6 @@
package com.github.creeper123123321.viaaas.codec
import com.github.creeper123123321.viaaas.handler.CloudMinecraftHandler
import com.github.creeper123123321.viaaas.handler.MinecraftHandler
import com.github.creeper123123321.viaaas.packet.Packet
import com.github.creeper123123321.viaaas.packet.PacketRegistry
import io.netty.buffer.ByteBuf
@ -13,7 +13,7 @@ class MinecraftCodec : MessageToMessageCodec<ByteBuf, Packet>() {
if (!ctx.channel().isActive) return
val buf = ByteBufAllocator.DEFAULT.buffer()
try {
val handler = ctx.pipeline().get(CloudMinecraftHandler::class.java)
val handler = ctx.pipeline().get(MinecraftHandler::class.java)
PacketRegistry.encode(msg, buf, handler.data.frontVer!!)
out.add(buf.retain())
} finally {
@ -23,7 +23,7 @@ class MinecraftCodec : MessageToMessageCodec<ByteBuf, Packet>() {
override fun decode(ctx: ChannelHandlerContext, msg: ByteBuf, out: MutableList<Any>) {
if (!ctx.channel().isActive || !msg.isReadable) return
val handler = ctx.pipeline().get(CloudMinecraftHandler::class.java)
val handler = ctx.pipeline().get(MinecraftHandler::class.java)
out.add(
PacketRegistry.decode(
msg,

View File

@ -0,0 +1,14 @@
package com.github.creeper123123321.viaaas.command
import com.github.creeper123123321.viaaas.command.sub.ConnectionsSubCommand
import com.github.creeper123123321.viaaas.command.sub.EndSubCommand
import com.github.creeper123123321.viaaas.command.sub.VIAaaSSubCommand
import us.myles.ViaVersion.commands.ViaCommandHandler
object AspirinCommands : ViaCommandHandler() {
init {
registerSubCommand(EndSubCommand)
registerSubCommand(VIAaaSSubCommand)
registerSubCommand(ConnectionsSubCommand)
}
}

View File

@ -1,5 +0,0 @@
package com.github.creeper123123321.viaaas.command
import us.myles.ViaVersion.commands.ViaCommandHandler
object CloudCommands : ViaCommandHandler()

View File

@ -1,9 +1,7 @@
package com.github.creeper123123321.viaaas.command
import com.github.creeper123123321.viaaas.handler.CloudMinecraftHandler
import com.github.creeper123123321.viaaas.runningServer
import com.github.creeper123123321.viaaas.viaaasLogger
import com.github.creeper123123321.viaaas.viaaasVer
import net.minecrell.terminalconsole.SimpleTerminalConsole
import org.jline.reader.Candidate
import org.jline.reader.LineReader
@ -11,16 +9,13 @@ import org.jline.reader.LineReaderBuilder
import org.slf4j.LoggerFactory
import us.myles.ViaVersion.api.Via
import us.myles.ViaVersion.api.command.ViaCommandSender
import us.myles.ViaVersion.api.protocol.ProtocolVersion
import java.util.*
class VIAaaSConsole : SimpleTerminalConsole(), ViaCommandSender {
object VIAaaSConsole : SimpleTerminalConsole(), ViaCommandSender {
val commands = hashMapOf<String, (MutableList<String>?, String, Array<String>) -> Unit>()
override fun isRunning(): Boolean = runningServer
init {
commands["stop"] = { suggestion, _, _ -> if (suggestion == null) this.shutdown() }
commands["end"] = commands["stop"]!!
commands["viaversion"] = { suggestion, _, args ->
if (suggestion == null) {
Via.getManager().commandHandler.onCommand(this, args)
@ -30,34 +25,15 @@ class VIAaaSConsole : SimpleTerminalConsole(), ViaCommandSender {
}
commands["viaver"] = commands["viaversion"]!!
commands["vvcloud"] = commands["viaversion"]!!
commands["vvaas"] = commands["viaversion"]!!
commands["vvaspirin"] = commands["viaversion"]!!
commands["viaaas"] = commands["viaversion"]!!
commands["help"] = { suggestion, _, _ ->
if (suggestion == null) sendMessage(commands.entries.groupBy { it.value }.entries.joinToString(", ") {
it.value.joinToString("/") { it.key }
})
}
commands["?"] = commands["help"]!!
commands["ver"] = { suggestion, _, _ ->
if (suggestion == null) sendMessage(viaaasVer)
}
commands["list"] = { suggestion, _, _ ->
if (suggestion == null) {
sendMessage("List of player connections: ")
Via.getPlatform().connectionManager.connections.forEach {
val backAddr = it.channel?.remoteAddress()
val pVer = it.protocolInfo?.protocolVersion?.let {
ProtocolVersion.getProtocol(it)
}
val backName = it.protocolInfo?.username
val backVer = it.protocolInfo?.serverProtocolVersion?.let {
ProtocolVersion.getProtocol(it)
}
val pAddr =
it.channel?.pipeline()?.get(CloudMinecraftHandler::class.java)?.other?.remoteAddress()
val pName = it.channel?.pipeline()?.get(CloudMinecraftHandler::class.java)?.data?.frontName
sendMessage("$pAddr $pVer ($pName) -> $backVer ($backName) $backAddr")
}
}
}
}
override fun buildReader(builder: LineReaderBuilder): LineReader {
@ -100,7 +76,7 @@ class VIAaaSConsole : SimpleTerminalConsole(), ViaCommandSender {
}
}
override fun shutdown() {
public override fun shutdown() {
viaaasLogger.info("Shutting down...")
runningServer = false
}

View File

@ -0,0 +1,31 @@
package com.github.creeper123123321.viaaas.command.sub
import com.github.creeper123123321.viaaas.command.VIAaaSConsole
import com.github.creeper123123321.viaaas.handler.MinecraftHandler
import us.myles.ViaVersion.api.Via
import us.myles.ViaVersion.api.command.ViaCommandSender
import us.myles.ViaVersion.api.command.ViaSubCommand
import us.myles.ViaVersion.api.protocol.ProtocolVersion
object ConnectionsSubCommand : ViaSubCommand() {
override fun name(): String = "connections"
override fun description(): String = "Lists VIAaaS connections"
override fun execute(p0: ViaCommandSender, p1: Array<out String>): Boolean {
p0.sendMessage("List of player connections: ")
Via.getPlatform().connectionManager.connections.forEach {
val backAddr = it.channel?.remoteAddress()
val pVer = it.protocolInfo?.protocolVersion?.let {
ProtocolVersion.getProtocol(it)
}
val backName = it.protocolInfo?.username
val backVer = it.protocolInfo?.serverProtocolVersion?.let {
ProtocolVersion.getProtocol(it)
}
val pAddr =
it.channel?.pipeline()?.get(MinecraftHandler::class.java)?.other?.remoteAddress()
val pName = it.channel?.pipeline()?.get(MinecraftHandler::class.java)?.data?.frontName
p0.sendMessage("$pAddr $pVer ($pName) -> $backVer ($backName) $backAddr")
}
return true
}
}

View File

@ -0,0 +1,14 @@
package com.github.creeper123123321.viaaas.command.sub
import com.github.creeper123123321.viaaas.command.VIAaaSConsole
import us.myles.ViaVersion.api.command.ViaCommandSender
import us.myles.ViaVersion.api.command.ViaSubCommand
object EndSubCommand : ViaSubCommand() {
override fun name() = "stop"
override fun description(): String = "Stops VIAaaS"
override fun execute(p0: ViaCommandSender?, p1: Array<out String>?): Boolean {
VIAaaSConsole.shutdown()
return true
}
}

View File

@ -0,0 +1,14 @@
package com.github.creeper123123321.viaaas.command.sub
import com.github.creeper123123321.viaaas.viaaasVer
import us.myles.ViaVersion.api.command.ViaCommandSender
import us.myles.ViaVersion.api.command.ViaSubCommand
object VIAaaSSubCommand : ViaSubCommand() {
override fun name(): String = "viaaas"
override fun description(): String = "Info about VIAaaS"
override fun execute(p0: ViaCommandSender, p1: Array<out String>): Boolean {
p0.sendMessage("VIAaaS version $viaaasVer")
return true
}
}

View File

@ -4,7 +4,7 @@ import us.myles.ViaVersion.AbstractViaConfig
import java.io.File
import java.net.URL
object CloudViaConfig : AbstractViaConfig(File("config/viaversion.yml")) {
object AspirinViaConfig : AbstractViaConfig(File("config/viaversion.yml")) {
// https://github.com/ViaVersion/ViaFabric/blob/mc-1.16/src/main/java/com/github/creeper123123321/viafabric/platform/VRViaConfig.java
override fun getDefaultConfigURL(): URL = javaClass.classLoader.getResource("assets/viaversion/config.yml")!!

View File

@ -34,4 +34,5 @@ object VIAaaSConfig : Config(File("config/viaaas.yml")) {
List::class.java,
emptyList<String>()
)!!.map { it as String }
val forceOnlineMode: Boolean get() = this.getBoolean("force-online-mode", false)
}

View File

@ -17,8 +17,8 @@ class BackEndInit(val connectionData: ConnectionData) : ChannelInitializer<Chann
// "crypto"
.addLast("frame", FrameCodec())
// compress
.addLast("via-codec", CloudViaCodec(user))
.addLast("via-codec", ViaCodec(user))
.addLast("mc", MinecraftCodec())
.addLast("handler", CloudMinecraftHandler(connectionData, connectionData.frontChannel, frontEnd = false))
.addLast("handler", MinecraftHandler(connectionData, connectionData.frontChannel, frontEnd = false))
}
}

View File

@ -14,6 +14,6 @@ class ConnectionData(
var frontVer: Int? = null,
var backVer: Int? = null,
) {
val frontHandler get() = frontChannel.pipeline().get(CloudMinecraftHandler::class.java)
val backHandler get() = backChannel?.pipeline()?.get(CloudMinecraftHandler::class.java)
val frontHandler get() = frontChannel.pipeline().get(MinecraftHandler::class.java)
val backHandler get() = backChannel?.pipeline()?.get(MinecraftHandler::class.java)
}

View File

@ -18,7 +18,7 @@ object FrontEndInit : ChannelInitializer<Channel>() {
.addLast("flow-handler", FlowControlHandler())
.addLast("mc", MinecraftCodec())
.addLast(
"handler", CloudMinecraftHandler(
"handler", MinecraftHandler(
ConnectionData(frontChannel = ch), other = null, frontEnd = true
)
)

View File

@ -9,7 +9,7 @@ import io.netty.channel.SimpleChannelInboundHandler
import us.myles.ViaVersion.exception.CancelCodecException
import java.net.SocketAddress
class CloudMinecraftHandler(
class MinecraftHandler(
val data: ConnectionData,
var other: Channel?,
val frontEnd: Boolean

View File

@ -4,6 +4,6 @@ import com.github.creeper123123321.viaaas.packet.Packet
import com.github.creeper123123321.viaaas.send
fun forward(handler: CloudMinecraftHandler, packet: Packet, flush: Boolean = false) {
fun forward(handler: MinecraftHandler, packet: Packet, flush: Boolean = false) {
send(handler.other!!, packet, flush)
}

View File

@ -7,7 +7,7 @@ import us.myles.ViaVersion.api.data.UserConnection
import us.myles.ViaVersion.exception.CancelDecoderException
import us.myles.ViaVersion.exception.CancelEncoderException
class CloudViaCodec(val info: UserConnection) : MessageToMessageCodec<ByteBuf, ByteBuf>() {
class ViaCodec(val info: UserConnection) : MessageToMessageCodec<ByteBuf, ByteBuf>() {
override fun decode(ctx: ChannelHandlerContext, bytebuf: ByteBuf, out: MutableList<Any>) {
if (!info.checkIncomingPacket()) throw CancelDecoderException.generate(null)
if (!info.shouldTransformPacket()) {

View File

@ -5,7 +5,7 @@ import com.github.creeper123123321.viaaas.packet.handshake.Handshake
import com.github.creeper123123321.viaaas.packet.Packet
import com.github.creeper123123321.viaaas.config.VIAaaSConfig
import com.github.creeper123123321.viaaas.handler.BackEndInit
import com.github.creeper123123321.viaaas.handler.CloudMinecraftHandler
import com.github.creeper123123321.viaaas.handler.MinecraftHandler
import com.github.creeper123123321.viaaas.handler.forward
import io.netty.bootstrap.Bootstrap
import io.netty.channel.ChannelFuture
@ -20,7 +20,7 @@ import java.net.InetAddress
import java.net.InetSocketAddress
class HandshakeState : MinecraftConnectionState {
fun connectBack(handler: CloudMinecraftHandler, socketAddr: InetSocketAddress): ChannelFuture {
fun connectBack(handler: MinecraftHandler, socketAddr: InetSocketAddress): ChannelFuture {
return Bootstrap()
.handler(BackEndInit(handler.data))
.channelFactory(channelSocketFactory())
@ -34,7 +34,7 @@ class HandshakeState : MinecraftConnectionState {
override val state: State
get() = State.HANDSHAKE
override fun handlePacket(handler: CloudMinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
override fun handlePacket(handler: MinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
if (packet !is Handshake) throw IllegalArgumentException("Invalid packet!")
handler.data.frontVer = packet.protocolId
@ -57,6 +57,7 @@ class HandshakeState : MinecraftConnectionState {
handler.data.backVer = backProto
handler.data.frontOnline = parsed.online
if (VIAaaSConfig.forceOnlineMode) handler.data.frontOnline = true
handler.data.backName = parsed.username
val playerAddr = handler.data.frontHandler.remoteAddress
@ -108,11 +109,11 @@ class HandshakeState : MinecraftConnectionState {
}
}
override fun disconnect(handler: CloudMinecraftHandler, msg: String) {
override fun disconnect(handler: MinecraftHandler, msg: String) {
handler.data.frontChannel.close() // Not worth logging
}
override fun onInactivated(handler: CloudMinecraftHandler) {
override fun onInactivated(handler: MinecraftHandler) {
// Not worth logging
}
}

View File

@ -5,7 +5,7 @@ import com.github.creeper123123321.viaaas.codec.CompressionCodec
import com.github.creeper123123321.viaaas.codec.CryptoCodec
import com.github.creeper123123321.viaaas.packet.*
import com.github.creeper123123321.viaaas.packet.login.*
import com.github.creeper123123321.viaaas.handler.CloudMinecraftHandler
import com.github.creeper123123321.viaaas.handler.MinecraftHandler
import com.github.creeper123123321.viaaas.handler.forward
import com.google.common.net.UrlEscapers
import com.google.gson.Gson
@ -27,7 +27,7 @@ class LoginState : MinecraftConnectionState {
override val state: State
get() = State.LOGIN
override fun handlePacket(handler: CloudMinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
override fun handlePacket(handler: MinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
when (packet) {
is LoginStart -> handleLoginStart(handler, packet)
is CryptoResponse -> handleCryptoResponse(handler, packet)
@ -41,16 +41,16 @@ class LoginState : MinecraftConnectionState {
}
}
private fun handleLoginSuccess(handler: CloudMinecraftHandler, loginSuccess: LoginSuccess) {
private fun handleLoginSuccess(handler: MinecraftHandler, loginSuccess: LoginSuccess) {
handler.data.state = PlayState
forward(handler, loginSuccess)
}
private fun handleCompression(handler: CloudMinecraftHandler, setCompression: SetCompression) {
private fun handleCompression(handler: MinecraftHandler, setCompression: SetCompression) {
val pipe = handler.data.frontChannel.pipeline()
val threshold = setCompression.threshold
val backPipe = pipe.get(CloudMinecraftHandler::class.java).other!!.pipeline()
val backPipe = pipe.get(MinecraftHandler::class.java).other!!.pipeline()
if (threshold != -1) {
backPipe.addAfter("frame", "compress", CompressionCodec(threshold))
} else if (backPipe.get("compress") != null) {
@ -67,7 +67,7 @@ class LoginState : MinecraftConnectionState {
}
}
fun authenticateOnlineFront(frontHandler: CloudMinecraftHandler) {
fun authenticateOnlineFront(frontHandler: MinecraftHandler) {
val id = "VIAaaS" + ByteArray(10).let {
secureRandom.nextBytes(it)
Base64.getEncoder().withoutPadding().encodeToString(it)
@ -89,7 +89,7 @@ class LoginState : MinecraftConnectionState {
send(frontHandler.data.frontChannel, cryptoRequest, true)
}
fun handleCryptoRequest(handler: CloudMinecraftHandler, cryptoRequest: CryptoRequest) {
fun handleCryptoRequest(handler: MinecraftHandler, cryptoRequest: CryptoRequest) {
val data = handler.data
val backServerId = cryptoRequest.serverId
val backPublicKey = cryptoRequest.publicKey
@ -140,7 +140,7 @@ class LoginState : MinecraftConnectionState {
}
}
fun handleCryptoResponse(handler: CloudMinecraftHandler, cryptoResponse: CryptoResponse) {
fun handleCryptoResponse(handler: MinecraftHandler, cryptoResponse: CryptoResponse) {
val frontHash = let {
val frontKey = decryptRsa(mcCryptoKey.private, cryptoResponse.encryptedKey)
// RSA token - wat??? why is it encrypted with RSA if it was sent unencrypted?
@ -175,7 +175,7 @@ class LoginState : MinecraftConnectionState {
}
}
fun handleLoginStart(handler: CloudMinecraftHandler, loginStart: LoginStart) {
fun handleLoginStart(handler: MinecraftHandler, loginStart: LoginStart) {
if (loginStart.username.length > 16) throw badLength
if (handler.data.frontName != null) throw IllegalStateException("Login already started")
@ -200,7 +200,7 @@ class LoginState : MinecraftConnectionState {
}
}
override fun disconnect(handler: CloudMinecraftHandler, msg: String) {
override fun disconnect(handler: MinecraftHandler, msg: String) {
super.disconnect(handler, msg)
val packet = LoginDisconnect()

View File

@ -1,7 +1,7 @@
package com.github.creeper123123321.viaaas.handler.state
import com.github.creeper123123321.viaaas.packet.Packet
import com.github.creeper123123321.viaaas.handler.CloudMinecraftHandler
import com.github.creeper123123321.viaaas.handler.MinecraftHandler
import com.github.creeper123123321.viaaas.mcLogger
import io.netty.channel.ChannelHandlerContext
import us.myles.ViaVersion.packets.State
@ -9,15 +9,15 @@ import us.myles.ViaVersion.packets.State
interface MinecraftConnectionState {
val state: State
fun handlePacket(
handler: CloudMinecraftHandler, ctx: ChannelHandlerContext,
handler: MinecraftHandler, ctx: ChannelHandlerContext,
packet: Packet
)
fun disconnect(handler: CloudMinecraftHandler, msg: String) {
fun disconnect(handler: MinecraftHandler, msg: String) {
mcLogger.info("Disconnected ${handler.remoteAddress}: $msg")
}
fun onInactivated(handler: CloudMinecraftHandler) {
fun onInactivated(handler: MinecraftHandler) {
mcLogger.info(handler.remoteAddress?.toString() + " inactivated")
}
}

View File

@ -2,7 +2,7 @@ package com.github.creeper123123321.viaaas.handler.state
import com.github.creeper123123321.viaaas.packet.Packet
import com.github.creeper123123321.viaaas.packet.UnknownPacket
import com.github.creeper123123321.viaaas.handler.CloudMinecraftHandler
import com.github.creeper123123321.viaaas.handler.MinecraftHandler
import com.github.creeper123123321.viaaas.handler.forward
import io.netty.channel.ChannelHandlerContext
import us.myles.ViaVersion.packets.State
@ -11,12 +11,12 @@ object PlayState : MinecraftConnectionState {
override val state: State
get() = State.PLAY
override fun handlePacket(handler: CloudMinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
override fun handlePacket(handler: MinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
if ((packet as UnknownPacket).id !in 0..127) throw IllegalArgumentException("Invalid packet id!")
forward(handler, packet)
}
override fun disconnect(handler: CloudMinecraftHandler, msg: String) {
override fun disconnect(handler: MinecraftHandler, msg: String) {
super.disconnect(handler, msg)
handler.data.frontChannel.close()
}

View File

@ -3,7 +3,7 @@ package com.github.creeper123123321.viaaas.handler.state
import com.github.creeper123123321.viaaas.packet.Packet
import com.github.creeper123123321.viaaas.packet.status.StatusResponse
import com.github.creeper123123321.viaaas.packet.UnknownPacket
import com.github.creeper123123321.viaaas.handler.CloudMinecraftHandler
import com.github.creeper123123321.viaaas.handler.MinecraftHandler
import com.github.creeper123123321.viaaas.handler.forward
import com.github.creeper123123321.viaaas.writeFlushClose
import com.google.gson.Gson
@ -14,12 +14,12 @@ object StatusState : MinecraftConnectionState {
override val state: State
get() = State.STATUS
override fun handlePacket(handler: CloudMinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
override fun handlePacket(handler: MinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
if (packet is UnknownPacket) throw IllegalArgumentException("Invalid packet")
forward(handler, packet)
}
override fun disconnect(handler: CloudMinecraftHandler, msg: String) {
override fun disconnect(handler: MinecraftHandler, msg: String) {
super.disconnect(handler, msg)
val packet = StatusResponse()

View File

@ -6,7 +6,7 @@ import us.myles.ViaVersion.sponge.util.LoggerWrapper
import java.io.File
import java.util.logging.Logger
object CloudBackwards : ViaBackwardsPlatform {
object AspirinBackwards : ViaBackwardsPlatform {
val log = LoggerWrapper(LoggerFactory.getLogger("ViaBackwards"))
override fun getDataFolder() = File("config/viabackwards")
override fun getLogger(): Logger = log

View File

@ -4,5 +4,5 @@ import us.myles.ViaVersion.api.boss.BossColor
import us.myles.ViaVersion.api.boss.BossStyle
import us.myles.ViaVersion.boss.CommonBoss
class CloudBossBar(title: String, health: Float, style: BossStyle, color: BossColor) :
class AspirinBossBar(title: String, health: Float, style: BossStyle, color: BossColor) :
CommonBoss<Unit>(title, health, color, style)

View File

@ -3,17 +3,15 @@ package com.github.creeper123123321.viaaas.platform
import us.myles.ViaVersion.api.platform.ViaInjector
import us.myles.viaversion.libs.gson.JsonObject
object CloudInjector : ViaInjector {
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 uninject() {
}
override fun inject() {
}
override fun getServerProtocolVersion() = 47 // Dummy
}

View File

@ -1,18 +1,18 @@
package com.github.creeper123123321.viaaas.platform
import com.github.creeper123123321.viaaas.provider.CloudVersionProvider
import com.github.creeper123123321.viaaas.provider.AspirinVersionProvider
import us.myles.ViaVersion.api.Via
import us.myles.ViaVersion.api.platform.ViaPlatformLoader
import us.myles.ViaVersion.bungee.providers.BungeeMovementTransmitter
import us.myles.ViaVersion.protocols.base.VersionProvider
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider
object CloudLoader : ViaPlatformLoader {
object AspirinLoader : ViaPlatformLoader {
override fun unload() {
}
override fun load() {
Via.getManager().providers.use(MovementTransmitterProvider::class.java, BungeeMovementTransmitter())
Via.getManager().providers.use(VersionProvider::class.java, CloudVersionProvider)
Via.getManager().providers.use(VersionProvider::class.java, AspirinVersionProvider)
}
}

View File

@ -1,7 +1,8 @@
package com.github.creeper123123321.viaaas.platform
import com.github.creeper123123321.viaaas.*
import com.github.creeper123123321.viaaas.config.CloudViaConfig
import com.github.creeper123123321.viaaas.config.AspirinViaConfig
import com.github.creeper123123321.viaaas.initFuture
import com.github.creeper123123321.viaaas.viaaasVer
import com.google.common.util.concurrent.ThreadFactoryBuilder
import io.netty.channel.DefaultEventLoop
import org.slf4j.LoggerFactory
@ -22,7 +23,7 @@ import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import java.util.logging.Logger
object CloudPlatform : ViaPlatform<Unit> {
object AspirinPlatform : ViaPlatform<Unit> {
val connMan = ViaConnectionManager()
val executor = Executors.newCachedThreadPool(ThreadFactoryBuilder().setNameFormat("Via-%d").setDaemon(true).build())
val eventLoop = DefaultEventLoop(executor)
@ -35,32 +36,31 @@ object CloudPlatform : ViaPlatform<Unit> {
// todo
}
override fun kickPlayer(p0: UUID, p1: String): Boolean = false // todo
override fun getApi(): ViaAPI<Unit> = CloudViaAPI
override fun getDataFolder(): File = File("viaversion")
override fun getConf(): ViaVersionConfig = CloudViaConfig
override fun onReload() {
}
override fun runSync(runnable: Runnable): TaskId = AspirinTask(eventLoop.submit(runnable))
override fun runSync(p0: Runnable, p1: Long): TaskId =
AspirinTask(eventLoop.schedule(p0, p1 * 50L, TimeUnit.MILLISECONDS))
override fun runRepeatingSync(p0: Runnable, p1: Long): TaskId =
AspirinTask(eventLoop.scheduleAtFixedRate(p0, 0, p1 * 50L, TimeUnit.MILLISECONDS))
override fun cancelTask(p0: TaskId?) {
(p0 as AspirinTask).obj.cancel(false)
}
override fun getDump(): JsonObject = JsonObject()
override fun runSync(runnable: Runnable): TaskId = CloudTask(eventLoop.submit(runnable))
override fun runSync(p0: Runnable, p1: Long): TaskId =
CloudTask(eventLoop.schedule(p0, p1 * 50L, TimeUnit.MILLISECONDS))
override fun runRepeatingSync(p0: Runnable, p1: Long): TaskId =
CloudTask(eventLoop.scheduleAtFixedRate(p0, 0, p1 * 50L, TimeUnit.MILLISECONDS))
override fun runAsync(p0: Runnable): TaskId = CloudTask(CompletableFuture.runAsync(p0, executor))
override fun kickPlayer(p0: UUID, p1: String): Boolean = false
override fun getApi(): ViaAPI<Unit> = AspirinViaAPI
override fun getDataFolder(): File = File("viaversion")
override fun getConf(): ViaVersionConfig = AspirinViaConfig
override fun runAsync(p0: Runnable): TaskId = AspirinTask(CompletableFuture.runAsync(p0, executor))
override fun getLogger(): Logger = LoggerWrapper(LoggerFactory.getLogger("ViaVersion"))
override fun getConnectionManager(): ViaConnectionManager = connMan
override fun getOnlinePlayers(): Array<ViaCommandSender> = arrayOf()
override fun cancelTask(p0: TaskId?) {
(p0 as CloudTask).obj.cancel(false)
}
override fun isPluginEnabled(): Boolean = true
override fun getConfigurationProvider(): ConfigurationProvider = CloudViaConfig
override fun getConfigurationProvider(): ConfigurationProvider = AspirinViaConfig
override fun getPlatformName(): String = "VIAaaS"
override fun getPlatformVersion(): String = viaaasVer
override fun getPluginVersion(): String = VersionInfo.VERSION

View File

@ -5,7 +5,7 @@ import org.slf4j.LoggerFactory
import us.myles.ViaVersion.sponge.util.LoggerWrapper
import java.util.logging.Logger
object CloudRewind : ViaRewindPlatform {
object AspirinRewind : ViaRewindPlatform {
val log = LoggerWrapper(LoggerFactory.getLogger("ViaRewind"))
override fun getLogger(): Logger = log
}

View File

@ -3,6 +3,6 @@ package com.github.creeper123123321.viaaas.platform
import us.myles.ViaVersion.api.platform.TaskId
import java.util.concurrent.Future
class CloudTask(val obj: Future<*>) : TaskId {
class AspirinTask(val obj: Future<*>) : TaskId {
override fun getObject(): Any = obj
}

View File

@ -9,14 +9,14 @@ import us.myles.ViaVersion.api.protocol.ProtocolRegistry
import java.util.*
import kotlin.UnsupportedOperationException
object CloudViaAPI : ViaAPI<Unit> {
object AspirinViaAPI : ViaAPI<Unit> {
override fun isInjected(p0: UUID): Boolean = false
override fun createBossBar(p0: String, p1: BossColor, p2: BossStyle): BossBar<*> = CloudBossBar(p0, 0f, p2, p1)
override fun createBossBar(p0: String, p1: Float, p2: BossColor, p3: BossStyle): BossBar<*> = CloudBossBar(p0, p1, p3, p2)
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 getPlayerVersion(p0: UUID?): Int = throw UnsupportedOperationException()
override fun getVersion(): String = CloudPlatform.pluginVersion
override fun getVersion(): String = AspirinPlatform.pluginVersion
override fun getSupportedVersions(): SortedSet<Int> = ProtocolRegistry.getSupportedVersions()
}

View File

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

View File

@ -25,4 +25,6 @@ default-backend-port: 25565
# If some server is in this list, it will be blocked. This has priority over allowed-back-addresses
blocked-back-addresses: ["*.hypixel.net", "hypixel.net"]
# VIAaaS will only allow if it matches an address in this list
allowed-back-addresses: ["*"]
allowed-back-addresses: ["*"]
# Requires online mode for front-end connections. May be useful for stopping bots.
force-online-mode: false