Made IntegerSet accessible. Encapsulating the injection handler.
Dieser Commit ist enthalten in:
Ursprung
4685a06d27
Commit
e8112dba0e
@ -30,6 +30,11 @@ import com.comphenix.protocol.reflect.IntEnum;
|
|||||||
*/
|
*/
|
||||||
public final class Packets {
|
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.
|
* List of packets sent only by the server.
|
||||||
* @author Kristian
|
* @author Kristian
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* 02111-1307 USA
|
* 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.comphenix.protocol.injector.player;
|
package com.comphenix.protocol.concurrency;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -27,7 +27,7 @@ import java.util.Set;
|
|||||||
* This class is intentionally missing a size method.
|
* This class is intentionally missing a size method.
|
||||||
* @author Kristian
|
* @author Kristian
|
||||||
*/
|
*/
|
||||||
class IntegerSet {
|
public class IntegerSet {
|
||||||
private final boolean[] array;
|
private final boolean[] array;
|
||||||
|
|
||||||
/**
|
/**
|
@ -28,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.comphenix.protocol.Packets;
|
import com.comphenix.protocol.Packets;
|
||||||
|
import com.comphenix.protocol.concurrency.IntegerSet;
|
||||||
import com.comphenix.protocol.error.ErrorReporter;
|
import com.comphenix.protocol.error.ErrorReporter;
|
||||||
import com.comphenix.protocol.events.ListeningWhitelist;
|
import com.comphenix.protocol.events.ListeningWhitelist;
|
||||||
import com.comphenix.protocol.events.PacketListener;
|
import com.comphenix.protocol.events.PacketListener;
|
||||||
|
@ -31,6 +31,7 @@ import java.lang.reflect.Method;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.comphenix.protocol.Packets;
|
import com.comphenix.protocol.Packets;
|
||||||
|
import com.comphenix.protocol.concurrency.IntegerSet;
|
||||||
import com.comphenix.protocol.error.ErrorReporter;
|
import com.comphenix.protocol.error.ErrorReporter;
|
||||||
import com.comphenix.protocol.events.ListeningWhitelist;
|
import com.comphenix.protocol.events.ListeningWhitelist;
|
||||||
import com.comphenix.protocol.events.PacketListener;
|
import com.comphenix.protocol.events.PacketListener;
|
||||||
|
@ -32,6 +32,7 @@ import net.sf.cglib.proxy.NoOp;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.concurrency.IntegerSet;
|
||||||
import com.comphenix.protocol.error.ErrorReporter;
|
import com.comphenix.protocol.error.ErrorReporter;
|
||||||
import com.comphenix.protocol.events.PacketListener;
|
import com.comphenix.protocol.events.PacketListener;
|
||||||
import com.comphenix.protocol.injector.GamePhase;
|
import com.comphenix.protocol.injector.GamePhase;
|
||||||
|
@ -79,13 +79,6 @@ public interface PlayerInjectionHandler {
|
|||||||
*/
|
*/
|
||||||
public abstract void injectPlayer(Player player);
|
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.
|
* Invoke special routines for handling disconnect before a player is uninjected.
|
||||||
* @param player - player to process.
|
* @param player - player to process.
|
||||||
@ -99,14 +92,6 @@ public interface PlayerInjectionHandler {
|
|||||||
*/
|
*/
|
||||||
public abstract boolean uninjectPlayer(Player player);
|
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.
|
* Unregisters a player by the given address.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -29,7 +29,9 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.Packets;
|
||||||
import com.comphenix.protocol.concurrency.BlockingHashMap;
|
import com.comphenix.protocol.concurrency.BlockingHashMap;
|
||||||
|
import com.comphenix.protocol.concurrency.IntegerSet;
|
||||||
import com.comphenix.protocol.error.ErrorReporter;
|
import com.comphenix.protocol.error.ErrorReporter;
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
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.
|
* 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
|
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
|
// Server connection injection
|
||||||
private InjectedServerConnection serverInjection;
|
private InjectedServerConnection serverInjection;
|
||||||
|
|
||||||
@ -88,7 +85,7 @@ class ProxyPlayerInjectionHandler implements PlayerInjectionHandler {
|
|||||||
private ListenerInvoker invoker;
|
private ListenerInvoker invoker;
|
||||||
|
|
||||||
// Enabled packet filters
|
// 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
|
// List of packet listeners
|
||||||
private Set<PacketListener> packetListeners;
|
private Set<PacketListener> packetListeners;
|
||||||
@ -262,7 +259,6 @@ class ProxyPlayerInjectionHandler implements PlayerInjectionHandler {
|
|||||||
* @param phase - current game phase.
|
* @param phase - current game phase.
|
||||||
* @return TRUE if we should perform the injection, FALSE otherwise.
|
* @return TRUE if we should perform the injection, FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public boolean isInjectionNecessary(GamePhase phase) {
|
public boolean isInjectionNecessary(GamePhase phase) {
|
||||||
return injectionFilter.apply(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.
|
* @param removeAuxiliary - TRUE to remove auxiliary information, such as input stream and address.
|
||||||
* @return TRUE if a player has been uninjected, FALSE otherwise.
|
* @return TRUE if a player has been uninjected, FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public boolean uninjectPlayer(Player player, boolean removeAuxiliary) {
|
public boolean uninjectPlayer(Player player, boolean removeAuxiliary) {
|
||||||
return uninjectPlayer(player, removeAuxiliary, false);
|
return uninjectPlayer(player, removeAuxiliary, false);
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren