3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 08:10:09 +01:00

Better support for ChannelInitializer detection (incase they do something funny, fixes latest PS dev)

Dieser Commit ist enthalten in:
Myles 2016-10-26 17:34:09 +01:00
Ursprung 55fccba711
Commit bd11c98e45
2 geänderte Dateien mit 32 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -72,7 +72,22 @@ public class BukkitViaInjector implements ViaInjector {
private void injectChannelFuture(ChannelFuture future) throws Exception {
try {
ChannelHandler bootstrapAcceptor = future.channel().pipeline().first();
List<String> names = future.channel().pipeline().names();
ChannelHandler bootstrapAcceptor = null;
// Pick best
for (String name : names) {
ChannelHandler handler = future.channel().pipeline().get(name);
try {
ReflectionUtil.get(handler, "childHandler", ChannelInitializer.class);
bootstrapAcceptor = handler;
} catch (Exception e) {
// Not this one
}
}
// Default to first (Also allows blame to work)
if (bootstrapAcceptor == null) {
bootstrapAcceptor = future.channel().pipeline().first();
}
try {
ChannelInitializer<SocketChannel> oldInit = ReflectionUtil.get(bootstrapAcceptor, "childHandler", ChannelInitializer.class);
ChannelInitializer newInit = new BukkitChannelInitializer(oldInit);

Datei anzeigen

@ -71,7 +71,22 @@ public class SpongeViaInjector implements ViaInjector {
private void injectChannelFuture(ChannelFuture future) throws Exception {
try {
ChannelHandler bootstrapAcceptor = future.channel().pipeline().first();
List<String> names = future.channel().pipeline().names();
ChannelHandler bootstrapAcceptor = null;
// Pick best
for (String name : names) {
ChannelHandler handler = future.channel().pipeline().get(name);
try {
ReflectionUtil.get(handler, "childHandler", ChannelInitializer.class);
bootstrapAcceptor = handler;
} catch (Exception e) {
// Not this one
}
}
// Default to first (Also allows blame to work)
if (bootstrapAcceptor == null) {
bootstrapAcceptor = future.channel().pipeline().first();
}
try {
ChannelInitializer<SocketChannel> oldInit = ReflectionUtil.get(bootstrapAcceptor, "childHandler", ChannelInitializer.class);
ChannelInitializer newInit = new SpongeChannelInitializer(oldInit);