From 1bdd200794e8199a80a60e3fd9c96424a79404fa Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Sat, 16 Jul 2016 16:03:01 -0400 Subject: [PATCH] Try to fix a weird null case --- .../java/com/comphenix/protocol/utility/MinecraftFields.java | 1 + .../comphenix/protocol/injector/netty/ChannelInjector.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) 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; }