Archiviert
13
0

Made IntegerSet accessible. Encapsulating the injection handler.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-02-05 01:37:41 +01:00
Ursprung 4685a06d27
Commit e8112dba0e
7 geänderte Dateien mit 14 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -30,6 +30,11 @@ import com.comphenix.protocol.reflect.IntEnum;
*/
public final class Packets {
/**
* The highest possible packet ID. It's unlikely that this value will ever change.
*/
public static final int MAXIMUM_PACKET_ID = 255;
/**
* List of packets sent only by the server.
* @author Kristian

Datei anzeigen

@ -15,7 +15,7 @@
* 02111-1307 USA
*/
package com.comphenix.protocol.injector.player;
package com.comphenix.protocol.concurrency;
import java.util.Arrays;
import java.util.HashSet;
@ -27,7 +27,7 @@ import java.util.Set;
* This class is intentionally missing a size method.
* @author Kristian
*/
class IntegerSet {
public class IntegerSet {
private final boolean[] array;
/**

Datei anzeigen

@ -28,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.entity.Player;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.concurrency.IntegerSet;
import com.comphenix.protocol.error.ErrorReporter;
import com.comphenix.protocol.events.ListeningWhitelist;
import com.comphenix.protocol.events.PacketListener;

Datei anzeigen

@ -31,6 +31,7 @@ import java.lang.reflect.Method;
import org.bukkit.entity.Player;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.concurrency.IntegerSet;
import com.comphenix.protocol.error.ErrorReporter;
import com.comphenix.protocol.events.ListeningWhitelist;
import com.comphenix.protocol.events.PacketListener;

Datei anzeigen

@ -32,6 +32,7 @@ import net.sf.cglib.proxy.NoOp;
import org.bukkit.entity.Player;
import com.comphenix.protocol.concurrency.IntegerSet;
import com.comphenix.protocol.error.ErrorReporter;
import com.comphenix.protocol.events.PacketListener;
import com.comphenix.protocol.injector.GamePhase;

Datei anzeigen

@ -79,13 +79,6 @@ public interface PlayerInjectionHandler {
*/
public abstract void injectPlayer(Player player);
/**
* Determine if it's truly necessary to perform the given player injection.
* @param phase - current game phase.
* @return TRUE if we should perform the injection, FALSE otherwise.
*/
public abstract boolean isInjectionNecessary(GamePhase phase);
/**
* Invoke special routines for handling disconnect before a player is uninjected.
* @param player - player to process.
@ -99,14 +92,6 @@ public interface PlayerInjectionHandler {
*/
public abstract boolean uninjectPlayer(Player player);
/**
* Unregisters the given player.
* @param player - player to unregister.
* @param removeAuxiliary - TRUE to remove auxiliary information, such as input stream and address.
* @return TRUE if a player has been uninjected, FALSE otherwise.
*/
public abstract boolean uninjectPlayer(Player player, boolean removeAuxiliary);
/**
* Unregisters a player by the given address.
* <p>

Datei anzeigen

@ -29,7 +29,9 @@ import java.util.concurrent.TimeUnit;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.concurrency.BlockingHashMap;
import com.comphenix.protocol.concurrency.IntegerSet;
import com.comphenix.protocol.error.ErrorReporter;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
@ -52,12 +54,7 @@ class ProxyPlayerInjectionHandler implements PlayerInjectionHandler {
* The maximum number of milliseconds to wait until a player can be looked up by connection.
*/
private static final long TIMEOUT_PLAYER_LOOKUP = 2000; // ms
/**
* The highest possible packet ID. It's unlikely that this value will ever change.
*/
private static final int MAXIMUM_PACKET_ID = 255;
// Server connection injection
private InjectedServerConnection serverInjection;
@ -88,7 +85,7 @@ class ProxyPlayerInjectionHandler implements PlayerInjectionHandler {
private ListenerInvoker invoker;
// Enabled packet filters
private IntegerSet sendingFilters = new IntegerSet(MAXIMUM_PACKET_ID + 1);
private IntegerSet sendingFilters = new IntegerSet(Packets.MAXIMUM_PACKET_ID + 1);
// List of packet listeners
private Set<PacketListener> packetListeners;
@ -262,7 +259,6 @@ class ProxyPlayerInjectionHandler implements PlayerInjectionHandler {
* @param phase - current game phase.
* @return TRUE if we should perform the injection, FALSE otherwise.
*/
@Override
public boolean isInjectionNecessary(GamePhase phase) {
return injectionFilter.apply(phase);
}
@ -417,7 +413,6 @@ class ProxyPlayerInjectionHandler implements PlayerInjectionHandler {
* @param removeAuxiliary - TRUE to remove auxiliary information, such as input stream and address.
* @return TRUE if a player has been uninjected, FALSE otherwise.
*/
@Override
public boolean uninjectPlayer(Player player, boolean removeAuxiliary) {
return uninjectPlayer(player, removeAuxiliary, false);
}