mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-22 10:05:12 +01:00
Merge branch 'master' into dev
This commit is contained in:
commit
3a5ac6f037
@ -28,6 +28,7 @@ import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@ -110,11 +111,22 @@ public abstract class LegacyViaInjector implements ViaInjector {
|
||||
public void uninject() throws ReflectiveOperationException {
|
||||
//TODO uninject connections
|
||||
for (ChannelFuture future : injectedFutures) {
|
||||
List<String> names = future.channel().pipeline().names();
|
||||
ChannelHandler bootstrapAcceptor = null;
|
||||
// Default to first
|
||||
ChannelPipeline pipeline = future.channel().pipeline();
|
||||
ChannelHandler bootstrapAcceptor = pipeline.first();
|
||||
if (bootstrapAcceptor == null) {
|
||||
Via.getPlatform().getLogger().info("Empty pipeline, nothing to uninject");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Pick best
|
||||
for (String name : names) {
|
||||
ChannelHandler handler = future.channel().pipeline().get(name);
|
||||
for (String name : pipeline.names()) {
|
||||
ChannelHandler handler = pipeline.get(name);
|
||||
if (handler == null) {
|
||||
Via.getPlatform().getLogger().warning("Could not get handler " + name);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
if (ReflectionUtil.get(handler, "childHandler", ChannelInitializer.class) instanceof WrappedChannelInitializer) {
|
||||
bootstrapAcceptor = handler;
|
||||
@ -124,11 +136,6 @@ public abstract class LegacyViaInjector implements ViaInjector {
|
||||
}
|
||||
}
|
||||
|
||||
if (bootstrapAcceptor == null) {
|
||||
// Default to first
|
||||
bootstrapAcceptor = future.channel().pipeline().first();
|
||||
}
|
||||
|
||||
try {
|
||||
ChannelInitializer<Channel> initializer = ReflectionUtil.get(bootstrapAcceptor, "childHandler", ChannelInitializer.class);
|
||||
if (initializer instanceof WrappedChannelInitializer) {
|
||||
|
Loading…
Reference in New Issue
Block a user