public interface PlayerInjectionHandler
Modifier and Type | Method and Description |
---|---|
void |
addPacketHandler(int packetID)
Add an underlying packet handler of the given ID.
|
void |
checkListener(PacketListener listener)
Determine if a listener is valid or not.
|
void |
checkListener(java.util.Set<PacketListener> listeners)
Determine if the given listeners are valid.
|
void |
close()
Close any lingering proxy injections.
|
Player |
getPlayerByConnection(java.io.DataInputStream inputStream)
Retrieve a player by its DataInput connection.
|
Player |
getPlayerByConnection(java.io.DataInputStream inputStream,
long playerTimeout,
java.util.concurrent.TimeUnit unit)
Retrieve a player by its DataInput connection.
|
PacketFilterManager.PlayerInjectHooks |
getPlayerHook()
Retrieves how the server packets are read.
|
PacketFilterManager.PlayerInjectHooks |
getPlayerHook(GamePhase phase)
Retrieves how the server packets are read.
|
java.util.Set<java.lang.Integer> |
getSendingFilters()
Retrieve the current list of registered sending listeners.
|
void |
handleDisconnect(Player player)
Invoke special routines for handling disconnect before a player is uninjected.
|
void |
injectPlayer(Player player)
Initialize a player hook, allowing us to read server packets.
|
void |
processPacket(Player player,
java.lang.Object mcPacket)
Process a packet as if it were sent by the given player.
|
void |
removePacketHandler(int packetID)
Remove an underlying packet handler of ths ID.
|
void |
scheduleDataInputRefresh(Player player)
Inform the current PlayerInjector that it should update the DataInputStream next.
|
void |
sendServerPacket(Player reciever,
PacketContainer packet,
boolean filters)
Send the given packet to the given reciever.
|
void |
setPlayerHook(GamePhase phase,
PacketFilterManager.PlayerInjectHooks playerHook)
Sets how the server packets are read.
|
void |
setPlayerHook(PacketFilterManager.PlayerInjectHooks playerHook)
Sets how the server packets are read.
|
boolean |
uninjectPlayer(java.net.InetSocketAddress address)
Unregisters a player by the given address.
|
boolean |
uninjectPlayer(Player player)
Unregisters the given player.
|
PacketFilterManager.PlayerInjectHooks getPlayerHook()
PacketFilterManager.PlayerInjectHooks getPlayerHook(GamePhase phase)
phase
- - the current game phase.void setPlayerHook(PacketFilterManager.PlayerInjectHooks playerHook)
playerHook
- - the new injection method for reading server packets.void setPlayerHook(GamePhase phase, PacketFilterManager.PlayerInjectHooks playerHook)
phase
- - the current game phase.playerHook
- - the new injection method for reading server packets.void addPacketHandler(int packetID)
packetID
- - packet ID to register.void removePacketHandler(int packetID)
packetID
- - packet ID to unregister.Player getPlayerByConnection(java.io.DataInputStream inputStream) throws java.lang.InterruptedException
inputStream
- - the associated DataInput connection.java.lang.InterruptedException
- If the thread was interrupted during the wait.Player getPlayerByConnection(java.io.DataInputStream inputStream, long playerTimeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
inputStream
- - the associated DataInput connection.playerTimeout
- - the amount of time to wait for a result.unit
- - unit of playerTimeout.java.lang.InterruptedException
- If the thread was interrupted during the wait.void injectPlayer(Player player)
This call will be ignored if there's no listener that can receive the given events.
player
- - player to hook.void handleDisconnect(Player player)
player
- - player to process.boolean uninjectPlayer(Player player)
player
- - player to unregister.boolean uninjectPlayer(java.net.InetSocketAddress address)
If the server handler has been created before we've gotten a chance to unject the player, the method will try a workaround to remove the injected hook in the NetServerHandler.
address
- - address of the player to unregister.void sendServerPacket(Player reciever, PacketContainer packet, boolean filters) throws java.lang.reflect.InvocationTargetException
reciever
- - the player receiver.packet
- - the packet to send.filters
- - whether or not to invoke the packet filters.java.lang.reflect.InvocationTargetException
- If an error occured during sending.void processPacket(Player player, java.lang.Object mcPacket) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
player
- - the sender.mcPacket
- - the packet to process.java.lang.IllegalAccessException
- If the reflection machinery failed.java.lang.reflect.InvocationTargetException
- If the underlying method caused an error.void checkListener(java.util.Set<PacketListener> listeners)
listeners
- - listeners to check.void checkListener(PacketListener listener)
If not, a warning will be printed to the console.
listener
- - listener to check.java.util.Set<java.lang.Integer> getSendingFilters()
void close()
void scheduleDataInputRefresh(Player player)
player
- - the player to update.