Archiviert
13
0

Ignore offline players when sending overdue packets.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2012-10-02 23:05:31 +02:00
Ursprung 1e1875cbd8
Commit 3f1b5d49e9
6 geänderte Dateien mit 64 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -6,6 +6,8 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.PriorityBlockingQueue;
import org.bukkit.entity.Player;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.reflect.FieldAccessException;
@ -112,8 +114,11 @@ class PacketSendingQueue {
if (marker.isProcessed() || marker.hasExpired()) {
if (marker.isProcessed() && !current.isCancelled()) {
// Silently skip players that have logged out
if (isOnline(current.getPlayer())) {
sendPacket(current);
}
}
sendingQueue.poll();
continue;
@ -125,6 +130,10 @@ class PacketSendingQueue {
}
}
private boolean isOnline(Player player) {
return player != null && player.isOnline();
}
/**
* Send every packet, regardless of the processing state.
*/

Datei anzeigen

@ -13,6 +13,7 @@ import org.bukkit.Server;
import com.comphenix.protocol.reflect.FieldUtils;
import com.comphenix.protocol.reflect.FuzzyReflection;
import com.comphenix.protocol.reflect.ObjectCloner;
import com.comphenix.protocol.reflect.VolatileField;
/**

Datei anzeigen

@ -18,6 +18,7 @@ import org.bukkit.entity.Player;
import com.comphenix.protocol.events.PacketListener;
import com.comphenix.protocol.reflect.FieldUtils;
import com.comphenix.protocol.reflect.FuzzyReflection;
import com.comphenix.protocol.reflect.ObjectCloner;
import com.comphenix.protocol.reflect.instances.CollectionGenerator;
import com.comphenix.protocol.reflect.instances.DefaultInstances;
import com.comphenix.protocol.reflect.instances.ExistingGenerator;

Datei anzeigen

@ -403,6 +403,8 @@ public final class PacketFilterManager implements ProtocolManager {
if (packet == null)
throw new IllegalArgumentException("packet cannot be NULL.");
sender.is
PlayerInjector injector = getInjector(sender);
Packet mcPacket = packet.getHandle();
@ -503,10 +505,21 @@ public final class PacketFilterManager implements ProtocolManager {
try {
injector = getHookInstance(player, currentHook);
injector.injectManager();
DataInputStream inputStream = injector.getInputStream(false);
if (!player.isOnline() || inputStream == null) {
throw new PlayerLoggedOutException();
}
playerInjection.put(player, injector);
connectionLookup.put(injector.getInputStream(false), player);
connectionLookup.put(inputStream, player);
break;
} catch (PlayerLoggedOutException e) {
throw e;
} catch (Exception e) {
// Mark this injection attempt as a failure

Datei anzeigen

@ -0,0 +1,36 @@
package com.comphenix.protocol.injector;
/**
* Invoked when attempting to use a player that has already logged out.
*
* @author Kristian
*/
public class PlayerLoggedOutException extends RuntimeException {
public PlayerLoggedOutException() {
// Default error message
super("Cannot inject a player that has already logged out.");
}
public PlayerLoggedOutException(String message, Throwable cause) {
super(message, cause);
}
public PlayerLoggedOutException(String message) {
super(message);
}
public PlayerLoggedOutException(Throwable cause) {
super(cause);
}
/**
* Construct an exception from a formatted message.
* @param message - the message to format.
* @param params - parameters.
* @return The formated exception
*/
public static PlayerLoggedOutException fromFormat(String message, Object... params) {
return new PlayerLoggedOutException(String.format(message, params));
}
}

Datei anzeigen

@ -1,17 +1,15 @@
package com.comphenix.protocol.injector;
package com.comphenix.protocol.reflect;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import com.comphenix.protocol.reflect.FieldAccessException;
import com.comphenix.protocol.reflect.StructureModifier;
/**
* Can copy an object field by field.
*
* @author Kristian
*/
class ObjectCloner {
public class ObjectCloner {
// Cache structure modifiers
@SuppressWarnings("rawtypes")