diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncFilterManager.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncFilterManager.java index 2fe5a601..4f4b47ed 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncFilterManager.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncFilterManager.java @@ -305,22 +305,28 @@ public class AsyncFilterManager implements AsynchronousManager { /** * Enqueue a packet for asynchronous processing. + * * @param syncPacket - synchronous packet event. * @param asyncMarker - the asynchronous marker to use. */ public synchronized void enqueueSyncPacket(PacketEvent syncPacket, AsyncMarker asyncMarker) { PacketEvent newEvent = PacketEvent.fromSynchronous(syncPacket, asyncMarker); - + if (asyncMarker.isQueued() || asyncMarker.isTransmitted()) throw new IllegalArgumentException("Cannot queue a packet that has already been queued."); - + asyncMarker.setQueuedSendingIndex(asyncMarker.getNewSendingIndex()); - - // Start the process - getSendingQueue(syncPacket).enqueue(newEvent); - - // We know this is occuring on the main thread, so pass TRUE - getProcessingQueue(syncPacket).enqueue(newEvent, true); + + // The player is only be null when they're logged out, + // so this should be a pretty safe check + Player player = newEvent.getPlayer(); + if (player != null) { + // Start the process + getSendingQueue(syncPacket).enqueue(newEvent); + + // We know this is occuring on the main thread, so pass TRUE + getProcessingQueue(syncPacket).enqueue(newEvent, true); + } } @Override diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java index 86ab87e6..11fcedb8 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java @@ -81,10 +81,10 @@ import com.comphenix.protocol.injector.player.PlayerInjectorBuilder; import com.comphenix.protocol.injector.spigot.SpigotPacketInjector; import com.comphenix.protocol.reflect.FieldAccessException; import com.comphenix.protocol.reflect.FuzzyReflection; -import com.comphenix.protocol.utility.Util; import com.comphenix.protocol.utility.EnhancerFactory; import com.comphenix.protocol.utility.MinecraftReflection; import com.comphenix.protocol.utility.MinecraftVersion; +import com.comphenix.protocol.utility.Util; import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; @@ -1008,6 +1008,7 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok /** * Register this protocol manager on Bukkit. + * * @param manager - Bukkit plugin manager that provides player join/leave events. * @param plugin - the parent plugin. */ @@ -1020,26 +1021,31 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok try { manager.registerEvents(new Listener() { + @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerLogin(PlayerLoginEvent event) { + public void onPlayerLogin(PlayerLoginEvent event) { PacketFilterManager.this.onPlayerLogin(event); } + @EventHandler(priority = EventPriority.LOWEST) - public void onPrePlayerJoin(PlayerJoinEvent event) { + public void onPrePlayerJoin(PlayerJoinEvent event) { PacketFilterManager.this.onPrePlayerJoin(event); } + @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerJoin(PlayerJoinEvent event) { + public void onPlayerJoin(PlayerJoinEvent event) { PacketFilterManager.this.onPlayerJoin(event); - } + } + @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerQuit(PlayerQuitEvent event) { + public void onPlayerQuit(PlayerQuitEvent event) { PacketFilterManager.this.onPlayerQuit(event); - } + } + @EventHandler(priority = EventPriority.MONITOR) - public void onPluginDisabled(PluginDisableEvent event) { + public void onPluginDisabled(PluginDisableEvent event) { PacketFilterManager.this.onPluginDisabled(event, plugin); - } + } }, plugin); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/NettyProtocolInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/NettyProtocolInjector.java index 82e9508b..68424f13 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/NettyProtocolInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/NettyProtocolInjector.java @@ -253,6 +253,7 @@ public class NettyProtocolInjector implements ChannelListener { PacketContainer container = new PacketContainer(PacketRegistry.getPacketType(clazz), packet); return packetQueued(container, injector.getPlayer(), marker); } + // Don't change anything return null; } @@ -265,6 +266,7 @@ public class NettyProtocolInjector implements ChannelListener { PacketContainer container = new PacketContainer(PacketRegistry.getPacketType(clazz), packet); return packetReceived(container, injector.getPlayer(), marker); } + // Don't change anything return null; } @@ -314,8 +316,8 @@ public class NettyProtocolInjector implements ChannelListener { @Override public void updatePlayer(Player player) { injectionFactory.fromPlayer(player, listener).inject(); - } + @Override public void injectPlayer(Player player, ConflictStrategy strategy) { injectionFactory.fromPlayer(player, listener).inject();