mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-01-02 18:39:16 +01:00
Updated ViaBedrock implementation
This commit is contained in:
parent
98926cb794
commit
d8c2a036e9
@ -23,7 +23,7 @@ vialoader_version=2.2.13-SNAPSHOT
|
|||||||
# RaphiMC Libraries
|
# RaphiMC Libraries
|
||||||
minecraftauth_version=4.0.0-SNAPSHOT
|
minecraftauth_version=4.0.0-SNAPSHOT
|
||||||
|
|
||||||
viabedrock_version=0.0.4-SNAPSHOT
|
viabedrock_version=0.0.5-SNAPSHOT
|
||||||
raknet_transport_version=1.0.0.CR1-SNAPSHOT
|
raknet_transport_version=1.0.0.CR1-SNAPSHOT
|
||||||
|
|
||||||
# Lenni0451 Libraries
|
# Lenni0451 Libraries
|
||||||
|
@ -22,9 +22,9 @@ package de.florianmichael.viafabricplus.protocolhack.impl.provider.viabedrock;
|
|||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.netty.ViaFabricPlusVLLegacyPipeline;
|
import de.florianmichael.viafabricplus.protocolhack.netty.ViaFabricPlusVLLegacyPipeline;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import net.raphimc.viabedrock.netty.AesEncryption;
|
import net.raphimc.viabedrock.api.io.compression.ProtocolCompression;
|
||||||
import net.raphimc.viabedrock.netty.SnappyCompression;
|
import net.raphimc.viabedrock.netty.AesEncryptionCodec;
|
||||||
import net.raphimc.viabedrock.netty.ZLibCompression;
|
import net.raphimc.viabedrock.netty.CompressionCodec;
|
||||||
import net.raphimc.viabedrock.protocol.providers.NettyPipelineProvider;
|
import net.raphimc.viabedrock.protocol.providers.NettyPipelineProvider;
|
||||||
import net.raphimc.vialoader.netty.VLPipeline;
|
import net.raphimc.vialoader.netty.VLPipeline;
|
||||||
|
|
||||||
@ -33,18 +33,14 @@ import javax.crypto.SecretKey;
|
|||||||
public class ViaFabricPlusNettyPipelineProvider extends NettyPipelineProvider {
|
public class ViaFabricPlusNettyPipelineProvider extends NettyPipelineProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enableCompression(UserConnection user, int threshold, int algorithm) {
|
public void enableCompression(UserConnection user, ProtocolCompression protocolCompression) {
|
||||||
final Channel channel = user.getChannel();
|
final Channel channel = user.getChannel();
|
||||||
|
|
||||||
if (channel.pipeline().names().contains(ViaFabricPlusVLLegacyPipeline.VIABEDROCK_COMPRESSION_HANDLER_NAME)) {
|
if (channel.pipeline().names().contains(ViaFabricPlusVLLegacyPipeline.VIABEDROCK_COMPRESSION_HANDLER_NAME)) {
|
||||||
throw new IllegalStateException("Compression already enabled");
|
throw new IllegalStateException("Compression already enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (algorithm) {
|
channel.pipeline().addBefore("splitter", ViaFabricPlusVLLegacyPipeline.VIABEDROCK_COMPRESSION_HANDLER_NAME, new CompressionCodec(protocolCompression));
|
||||||
case 0 -> channel.pipeline().addBefore("splitter", ViaFabricPlusVLLegacyPipeline.VIABEDROCK_COMPRESSION_HANDLER_NAME, new ZLibCompression());
|
|
||||||
case 1 -> channel.pipeline().addBefore("splitter", ViaFabricPlusVLLegacyPipeline.VIABEDROCK_COMPRESSION_HANDLER_NAME, new SnappyCompression());
|
|
||||||
default -> throw new IllegalStateException("Invalid compression algorithm: " + algorithm);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,7 +52,7 @@ public class ViaFabricPlusNettyPipelineProvider extends NettyPipelineProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
channel.pipeline().addAfter(VLPipeline.VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, ViaFabricPlusVLLegacyPipeline.VIABEDROCK_ENCRYPTION_HANDLER_NAME, new AesEncryption(key));
|
channel.pipeline().addAfter(VLPipeline.VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, ViaFabricPlusVLLegacyPipeline.VIABEDROCK_ENCRYPTION_HANDLER_NAME, new AesEncryptionCodec(key));
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user