mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2025-01-09 19:48:37 +01:00
fixed compression in PLAY state
This commit is contained in:
parent
59ee492c1b
commit
ebb2f80328
@ -28,14 +28,14 @@ public class CompressionCodec extends MessageToMessageCodec<ByteBuf, ByteBuf> {
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
public void setThreshold(int threshold) {
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
public int getThreshold() {
|
||||
return threshold;
|
||||
}
|
||||
|
||||
public void setThreshold(int threshold) {
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||
var level = VIAaaSConfig.INSTANCE.getCompressionLevel();
|
||||
@ -114,10 +114,10 @@ public class CompressionCodec extends MessageToMessageCodec<ByteBuf, ByteBuf> {
|
||||
}
|
||||
|
||||
if (claimedUncompressedSize < threshold) {
|
||||
throw new DecoderException("Badly compressed packet - size of $claimedUncompressedSize is below server threshold of $threshold");
|
||||
throw new DecoderException("Badly compressed packet - size of " + claimedUncompressedSize + " is below server threshold of " + threshold);
|
||||
}
|
||||
if (claimedUncompressedSize > UNCOMPRESSED_CAP) {
|
||||
throw new DecoderException("Badly compressed packet - size of $claimedUncompressedSize is larger than maximum of $UNCOMPRESSED_CAP");
|
||||
throw new DecoderException("Badly compressed packet - size of " + claimedUncompressedSize + " is larger than maximum of " + UNCOMPRESSED_CAP);
|
||||
}
|
||||
var compatibleIn = MoreByteBufUtils.ensureCompatible(ctx.alloc(), compressor, input);
|
||||
var decompressed = MoreByteBufUtils.preferredBuffer(ctx.alloc(), compressor, claimedUncompressedSize);
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.viaversion.aas.platform;
|
||||
|
||||
import com.viaversion.aas.provider.AspirinCompressionProvider;
|
||||
import com.viaversion.aas.provider.AspirinVersionProvider;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CompressionProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||
import com.viaversion.viaversion.velocity.providers.VelocityMovementTransmitter;
|
||||
|
||||
@ -12,6 +14,7 @@ public class AspirinLoader implements ViaPlatformLoader {
|
||||
public void load() {
|
||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new VelocityMovementTransmitter());
|
||||
Via.getManager().getProviders().use(VersionProvider.class, new AspirinVersionProvider());
|
||||
Via.getManager().getProviders().use(CompressionProvider.class, new AspirinCompressionProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.viaversion.aas.provider;
|
||||
|
||||
import com.viaversion.aas.handler.UtilKt;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CompressionProvider;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class AspirinCompressionProvider extends CompressionProvider {
|
||||
@Override
|
||||
public void handlePlayCompression(UserConnection user, int threshold) {
|
||||
UtilKt.setCompression(Objects.requireNonNull(user.getChannel()), threshold);
|
||||
}
|
||||
}
|
@ -66,7 +66,7 @@ fun encodeBrand(string: String, is17: Boolean): ByteArray {
|
||||
fun setCompression(channel: Channel, threshold: Int) {
|
||||
val pipe = channel.pipeline()
|
||||
|
||||
if (threshold == -1) {
|
||||
if (threshold <= 0) {
|
||||
if (pipe["compress"] != null) pipe.remove("compress")
|
||||
} else {
|
||||
if (pipe["compress"] != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user