Set VFNetworkManager in commons injector

This commit is contained in:
FlorianMichael 2023-10-25 22:46:58 +02:00
parent 76e8ec8baa
commit fd1b080728
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
2 changed files with 4 additions and 8 deletions

View File

@ -89,12 +89,14 @@ public class ViaForgeCommon {
*
* @param channel the channel to inject the pipeline into
*/
public void inject(final Channel channel) {
public void inject(final Channel channel, final VFNetworkManager networkManager) {
if (channel instanceof SocketChannel) {
final UserConnection user = new UserConnectionImpl(channel, true);
new ProtocolPipelineImpl(user);
channel.attr(LOCAL_VIA_USER).set(user);
channel.attr(VF_NETWORK_MANAGER).set(networkManager);
channel.pipeline().addLast(new ViaForgeVLLegacyPipeline(user, targetVersion));
}
}

View File

@ -35,12 +35,6 @@ public class MixinNetworkManager_5 {
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
// We need to access this class later to call the viaforge_setupPreNettyDecryption method.
// In one of the ViaLegacy's required providers, so we track this class instance as an own
// attribute in the connection and later access it from there and remove it.
// Counterpart in {@link java/de/florianmichael/viaforge/common/protocolhack/provider/ViaForgeEncryptionProvider.java}
channel.attr(ViaForgeCommon.VF_NETWORK_MANAGER).set((VFNetworkManager) val$networkmanager);
ViaForgeCommon.getManager().inject(channel);
ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$networkmanager);
}
}