From e364f65f8ee34f77a85ccee3b8a8866debc4195f Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Sun, 27 Sep 2020 20:59:09 -0300 Subject: [PATCH] fixed compression in 1.7 --- .../creeper123123321/viaaas/CloudProtocol.kt | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/github/creeper123123321/viaaas/CloudProtocol.kt b/src/main/kotlin/com/github/creeper123123321/viaaas/CloudProtocol.kt index 17546c2..410c36f 100644 --- a/src/main/kotlin/com/github/creeper123123321/viaaas/CloudProtocol.kt +++ b/src/main/kotlin/com/github/creeper123123321/viaaas/CloudProtocol.kt @@ -26,15 +26,14 @@ import javax.naming.directory.InitialDirContext class CloudPipeline(userConnection: UserConnection) : ProtocolPipeline(userConnection) { override fun registerPackets() { super.registerPackets() - add(CloudHeadProtocol) - add(CloudTailProtocol) + add(CloudHeadProtocol) // add() will add tail protocol } override fun add(protocol: Protocol<*, *, *, *>?) { super.add(protocol) - pipes().remove(CloudHeadProtocol) + pipes().removeIf { it == CloudHeadProtocol } pipes().add(0, CloudHeadProtocol) - pipes().remove(CloudTailProtocol) + pipes().removeIf { it == CloudTailProtocol } pipes().add(CloudTailProtocol) } } @@ -149,13 +148,9 @@ object CloudTailProtocol : SimpleProtocol() { val pipe = it.user().channel!!.pipeline() val threshold = it.read(Type.VAR_INT) it.cancel() - try { - it.create(3) { - it.write(Type.VAR_INT, threshold) - }.send(CloudTailProtocol::class.java, true, true) // needs to be sent uncompressed - } catch (ignored: Exception) { - // ViaRewind cancels it - } + it.create(3) { + it.write(Type.VAR_INT, threshold) + }.send(CloudTailProtocol::class.java, true, true) // needs to be sent uncompressed pipe.get(CloudCompressor::class.java).threshold = threshold pipe.get(CloudDecompressor::class.java).threshold = threshold