diff --git a/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftFields.java b/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftFields.java index 88353730..0c4378c0 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftFields.java +++ b/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftFields.java @@ -47,6 +47,7 @@ public class MinecraftFields { * @return The player connection. */ public static Object getPlayerConnection(Player player) { + Preconditions.checkNotNull(player, "player cannot be null!"); return getPlayerConnection(BukkitUnwrapper.getInstance().unwrapItem(player)); } diff --git a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java index 526376fa..5d268bbc 100644 --- a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java +++ b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java @@ -671,7 +671,7 @@ public class ChannelInjector extends ByteToMessageDecoder implements Injector { MinecraftMethods.getSendPacketMethod().invoke(getPlayerConnection(), packet); } } catch (Throwable ex) { - ProtocolLibrary.getErrorReporter().reportWarning(factory.getPlugin(), + ProtocolLibrary.getErrorReporter().reportWarning(this, Report.newBuilder(REPORT_CANNOT_SEND_PACKET).messageParam(packet, playerName).error(ex).build()); } } @@ -716,7 +716,7 @@ public class ChannelInjector extends ByteToMessageDecoder implements Injector { */ private Object getPlayerConnection() { if (playerConnection == null) { - playerConnection = MinecraftFields.getPlayerConnection(player); + playerConnection = MinecraftFields.getPlayerConnection(getPlayer()); } return playerConnection; }