Bug fix in injecting players.
This commit is contained in:
1 parent
1943ba2da1
commit
13b3ac7107
6 files changed
+26
-6
No files matched your search
+5
-1
@@ -25,10 +25,12 @@ import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.utils.list.ListWrapper;
|
||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import net.minecraft.util.io.netty.channel.Channel;
|
||||
import net.minecraft.util.io.netty.channel.ChannelFuture;
|
||||
import net.minecraft.util.io.netty.channel.ChannelHandler;
|
||||
import net.minecraft.util.io.netty.channel.ChannelInitializer;
|
||||
import net.minecraft.util.io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
@@ -127,7 +129,9 @@ public class EarlyChannelInjectorLegacy implements EarlyInjector {
|
||||
for (Object networkManager : networkManagers) {
|
||||
WrappedPacket networkManagerWrapper = new WrappedPacket(new NMSPacket(networkManager), NMSUtils.networkManagerClass);
|
||||
Channel channel = (Channel) networkManagerWrapper.readObject(0, NMSUtils.nettyChannelClass);
|
||||
if (channel == null || !(channel.getClass().equals(net.minecraft.util.io.netty.channel.socket.nio.NioSocketChannel.class))) {
|
||||
if (channel == null ||
|
||||
(!(channel.getClass().equals(NioSocketChannel.class))) &&
|
||||
!(channel.getClass().equals(EpollSocketChannel.class))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -21,8 +21,10 @@ package io.github.retrooper.packetevents.injector.legacy.early;
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.injector.legacy.PlayerChannelHandlerLegacy;
|
||||
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import net.minecraft.util.io.netty.channel.Channel;
|
||||
import net.minecraft.util.io.netty.channel.ChannelInitializer;
|
||||
import net.minecraft.util.io.netty.channel.socket.nio.NioSocketChannel;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@@ -47,7 +49,8 @@ public class PEChannelInitializerLegacy extends ChannelInitializer<Channel> {
|
||||
protected void initChannel(Channel channel) throws Exception {
|
||||
initChannelMethod.invoke(oldChannelInitializer, channel);
|
||||
PlayerChannelHandlerLegacy channelHandler = new PlayerChannelHandlerLegacy();
|
||||
if (channel.getClass().equals(net.minecraft.util.io.netty.channel.socket.nio.NioSocketChannel.class)) {
|
||||
if (channel.getClass().equals(NioSocketChannel.class)
|
||||
|| channel.getClass().equals(EpollSocketChannel.class)) {
|
||||
if (channel.pipeline().get("packet_handler") != null) {
|
||||
String handlerName = PacketEvents.get().getHandlerName();
|
||||
if (channel.pipeline().get(handlerName) != null) {
|
||||
|
||||
+4
-1
@@ -21,7 +21,9 @@ package io.github.retrooper.packetevents.injector.legacy.late;
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.injector.LateInjector;
|
||||
import io.github.retrooper.packetevents.injector.legacy.PlayerChannelHandlerLegacy;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import net.minecraft.util.io.netty.channel.Channel;
|
||||
import net.minecraft.util.io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LateChannelInjectorLegacy implements LateInjector {
|
||||
@@ -40,7 +42,8 @@ public class LateChannelInjectorLegacy implements LateInjector {
|
||||
PlayerChannelHandlerLegacy playerChannelHandlerLegacy = new PlayerChannelHandlerLegacy();
|
||||
playerChannelHandlerLegacy.player = player;
|
||||
Channel channel = (Channel) PacketEvents.get().getPlayerUtils().getChannel(player);
|
||||
if (channel.getClass().equals(net.minecraft.util.io.netty.channel.socket.nio.NioSocketChannel.class)) {
|
||||
if (channel.getClass().equals(NioSocketChannel.class)
|
||||
|| channel.getClass().equals(EpollSocketChannel.class)) {
|
||||
channel.pipeline().addBefore("packet_handler", PacketEvents.get().getHandlerName(), playerChannelHandlerLegacy);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -29,6 +29,8 @@ import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
@@ -130,7 +132,9 @@ public class EarlyChannelInjectorModern implements EarlyInjector {
|
||||
for (Object networkManager : networkManagers) {
|
||||
WrappedPacket networkManagerWrapper = new WrappedPacket(new NMSPacket(networkManager), NMSUtils.networkManagerClass);
|
||||
Channel channel = (Channel) networkManagerWrapper.readObject(0, NMSUtils.nettyChannelClass);
|
||||
if (channel == null || !(channel.getClass().equals(io.netty.channel.socket.nio.NioSocketChannel.class))) {
|
||||
if (channel == null ||
|
||||
(!(channel.getClass().equals(NioSocketChannel.class))) &&
|
||||
!(channel.getClass().equals(EpollSocketChannel.class))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -23,6 +23,8 @@ import io.github.retrooper.packetevents.injector.modern.PlayerChannelHandlerMode
|
||||
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@@ -36,7 +38,8 @@ public class PEChannelInitializerModern extends ChannelInitializer<Channel> {
|
||||
}
|
||||
|
||||
public static void postInitChannel(Channel channel) {
|
||||
if (channel.getClass().equals(io.netty.channel.socket.nio.NioSocketChannel.class)) {
|
||||
if (channel.getClass().equals(NioSocketChannel.class)
|
||||
|| channel.getClass().equals(EpollSocketChannel.class)) {
|
||||
PlayerChannelHandlerModern channelHandler = new PlayerChannelHandlerModern();
|
||||
if (channel.pipeline().get("packet_handler") != null) {
|
||||
String handlerName = PacketEvents.get().getHandlerName();
|
||||
|
||||
+4
-1
@@ -22,6 +22,8 @@ import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.injector.LateInjector;
|
||||
import io.github.retrooper.packetevents.injector.modern.PlayerChannelHandlerModern;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LateChannelInjectorModern implements LateInjector {
|
||||
@@ -40,7 +42,8 @@ public class LateChannelInjectorModern implements LateInjector {
|
||||
PlayerChannelHandlerModern playerChannelHandlerModern = new PlayerChannelHandlerModern();
|
||||
playerChannelHandlerModern.player = player;
|
||||
Channel channel = (Channel) PacketEvents.get().getPlayerUtils().getChannel(player);
|
||||
if (channel.getClass().equals(io.netty.channel.socket.nio.NioSocketChannel.class)) {
|
||||
if (channel.getClass().equals(NioSocketChannel.class) ||
|
||||
channel.getClass().equals(EpollSocketChannel.class)) {
|
||||
channel.pipeline().addBefore("packet_handler", PacketEvents.get().getHandlerName(), playerChannelHandlerModern);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user