Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-09-08 13:52:50 +02:00
Better support for ChannelInitializer detection (incase they do something funny, fixes latest PS dev)
Dieser Commit ist enthalten in:
Ursprung
55fccba711
Commit
bd11c98e45
@ -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);
|
||||
|
@ -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);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren