Archiviert
13
0

Fix an error involving async packets and logged off players

Fixes #65
Dieser Commit ist enthalten in:
Dan Mulloy 2015-03-22 21:23:59 -04:00
Ursprung ae8ba16a7e
Commit 2c743e1c89
3 geänderte Dateien mit 32 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -305,6 +305,7 @@ public class AsyncFilterManager implements AsynchronousManager {
/** /**
* Enqueue a packet for asynchronous processing. * Enqueue a packet for asynchronous processing.
*
* @param syncPacket - synchronous packet event. * @param syncPacket - synchronous packet event.
* @param asyncMarker - the asynchronous marker to use. * @param asyncMarker - the asynchronous marker to use.
*/ */
@ -316,12 +317,17 @@ public class AsyncFilterManager implements AsynchronousManager {
asyncMarker.setQueuedSendingIndex(asyncMarker.getNewSendingIndex()); asyncMarker.setQueuedSendingIndex(asyncMarker.getNewSendingIndex());
// 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 // Start the process
getSendingQueue(syncPacket).enqueue(newEvent); getSendingQueue(syncPacket).enqueue(newEvent);
// We know this is occuring on the main thread, so pass TRUE // We know this is occuring on the main thread, so pass TRUE
getProcessingQueue(syncPacket).enqueue(newEvent, true); getProcessingQueue(syncPacket).enqueue(newEvent, true);
} }
}
@Override @Override
public Set<Integer> getSendingFilters() { public Set<Integer> getSendingFilters() {

Datei anzeigen

@ -81,10 +81,10 @@ import com.comphenix.protocol.injector.player.PlayerInjectorBuilder;
import com.comphenix.protocol.injector.spigot.SpigotPacketInjector; import com.comphenix.protocol.injector.spigot.SpigotPacketInjector;
import com.comphenix.protocol.reflect.FieldAccessException; import com.comphenix.protocol.reflect.FieldAccessException;
import com.comphenix.protocol.reflect.FuzzyReflection; import com.comphenix.protocol.reflect.FuzzyReflection;
import com.comphenix.protocol.utility.Util;
import com.comphenix.protocol.utility.EnhancerFactory; import com.comphenix.protocol.utility.EnhancerFactory;
import com.comphenix.protocol.utility.MinecraftReflection; import com.comphenix.protocol.utility.MinecraftReflection;
import com.comphenix.protocol.utility.MinecraftVersion; import com.comphenix.protocol.utility.MinecraftVersion;
import com.comphenix.protocol.utility.Util;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -1008,6 +1008,7 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
/** /**
* Register this protocol manager on Bukkit. * Register this protocol manager on Bukkit.
*
* @param manager - Bukkit plugin manager that provides player join/leave events. * @param manager - Bukkit plugin manager that provides player join/leave events.
* @param plugin - the parent plugin. * @param plugin - the parent plugin.
*/ */
@ -1020,22 +1021,27 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
try { try {
manager.registerEvents(new Listener() { manager.registerEvents(new Listener() {
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLogin(PlayerLoginEvent event) { public void onPlayerLogin(PlayerLoginEvent event) {
PacketFilterManager.this.onPlayerLogin(event); PacketFilterManager.this.onPlayerLogin(event);
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onPrePlayerJoin(PlayerJoinEvent event) { public void onPrePlayerJoin(PlayerJoinEvent event) {
PacketFilterManager.this.onPrePlayerJoin(event); PacketFilterManager.this.onPrePlayerJoin(event);
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
PacketFilterManager.this.onPlayerJoin(event); PacketFilterManager.this.onPlayerJoin(event);
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
PacketFilterManager.this.onPlayerQuit(event); PacketFilterManager.this.onPlayerQuit(event);
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisabled(PluginDisableEvent event) { public void onPluginDisabled(PluginDisableEvent event) {
PacketFilterManager.this.onPluginDisabled(event, plugin); PacketFilterManager.this.onPluginDisabled(event, plugin);

Datei anzeigen

@ -253,6 +253,7 @@ public class NettyProtocolInjector implements ChannelListener {
PacketContainer container = new PacketContainer(PacketRegistry.getPacketType(clazz), packet); PacketContainer container = new PacketContainer(PacketRegistry.getPacketType(clazz), packet);
return packetQueued(container, injector.getPlayer(), marker); return packetQueued(container, injector.getPlayer(), marker);
} }
// Don't change anything // Don't change anything
return null; return null;
} }
@ -265,6 +266,7 @@ public class NettyProtocolInjector implements ChannelListener {
PacketContainer container = new PacketContainer(PacketRegistry.getPacketType(clazz), packet); PacketContainer container = new PacketContainer(PacketRegistry.getPacketType(clazz), packet);
return packetReceived(container, injector.getPlayer(), marker); return packetReceived(container, injector.getPlayer(), marker);
} }
// Don't change anything // Don't change anything
return null; return null;
} }
@ -314,8 +316,8 @@ public class NettyProtocolInjector implements ChannelListener {
@Override @Override
public void updatePlayer(Player player) { public void updatePlayer(Player player) {
injectionFactory.fromPlayer(player, listener).inject(); injectionFactory.fromPlayer(player, listener).inject();
} }
@Override @Override
public void injectPlayer(Player player, ConflictStrategy strategy) { public void injectPlayer(Player player, ConflictStrategy strategy) {
injectionFactory.fromPlayer(player, listener).inject(); injectionFactory.fromPlayer(player, listener).inject();