Interface PlayerInjectionHandler
- All Known Implementing Classes:
AbstractPlayerHandler
public interface PlayerInjectionHandler
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classHow to handle a previously existing player injection. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPacketHandler(PacketType type, Set<ListenerOptions> options)Add an underlying packet handler of the given type.booleanWhether or not this player injection handler can also receive packets.voidcheckListener(PacketListener listener)Determine if a listener is valid or not.voidcheckListener(Set<PacketListener> listeners)Determine if the given listeners are valid.voidclose()Close any lingering proxy injections.io.netty.channel.ChannelgetChannel(org.bukkit.entity.Player player)org.bukkit.entity.PlayergetPlayerByConnection(DataInputStream inputStream)Retrieve a player by its DataInput connection.Retrieves how the server packets are read.getPlayerHook(GamePhase phase)Retrieves how the server packets are read.intgetProtocolVersion(org.bukkit.entity.Player player)Retrieve the protocol version of the given player.Retrieve the current list of registered sending listeners.voidhandleDisconnect(org.bukkit.entity.Player player)Invoke special routines for handling disconnect before a player is uninjected.handlePacketRecieved(PacketContainer packet, InputStream input, byte[] buffered)Invoked if this player injection handler can process received packets.booleanhasMainThreadListener(PacketType type)Determine if we have packet listeners with the given type that must be executed on the main thread.voidinjectPlayer(org.bukkit.entity.Player player, PlayerInjectionHandler.ConflictStrategy strategy)Initialize a player hook, allowing us to read server packets.voidrecieveClientPacket(org.bukkit.entity.Player player, Object mcPacket)Process a packet as if it were sent by the given player.voidremovePacketHandler(PacketType type)Remove an underlying packet handler of this type.voidsendServerPacket(org.bukkit.entity.Player receiver, PacketContainer packet, NetworkMarker marker, boolean filters)Send the given packet to the given receiver.voidsetPlayerHook(GamePhase phase, PlayerInjectHooks playerHook)Sets how the server packets are read.voidsetPlayerHook(PlayerInjectHooks playerHook)Sets how the server packets are read.booleanuninjectPlayer(InetSocketAddress address)Unregisters a player by the given address.booleanuninjectPlayer(org.bukkit.entity.Player player)Uninject the given player.voidupdatePlayer(org.bukkit.entity.Player player)Ensure that packet readers are informed of this player reference.
-
Method Details
-
getProtocolVersion
int getProtocolVersion(org.bukkit.entity.Player player)Retrieve the protocol version of the given player.- Parameters:
player- - the player.- Returns:
- The protocol version, or
Integer.MIN_VALUE.
-
getPlayerHook
PlayerInjectHooks getPlayerHook()Retrieves how the server packets are read.- Returns:
- Injection method for reading server packets.
-
getPlayerHook
Retrieves how the server packets are read.- Parameters:
phase- - the current game phase.- Returns:
- Injection method for reading server packets.
-
setPlayerHook
Sets how the server packets are read.- Parameters:
playerHook- - the new injection method for reading server packets.
-
setPlayerHook
Sets how the server packets are read.- Parameters:
phase- - the current game phase.playerHook- - the new injection method for reading server packets.
-
addPacketHandler
Add an underlying packet handler of the given type.- Parameters:
type- - packet type to register.options- - any specified listener options.
-
removePacketHandler
Remove an underlying packet handler of this type.- Parameters:
type- - packet type to unregister.
-
getPlayerByConnection
org.bukkit.entity.Player getPlayerByConnection(DataInputStream inputStream) throws InterruptedExceptionRetrieve a player by its DataInput connection.- Parameters:
inputStream- - the associated DataInput connection.- Returns:
- The player.
- Throws:
InterruptedException- If the thread was interrupted during the wait.
-
injectPlayer
void injectPlayer(org.bukkit.entity.Player player, PlayerInjectionHandler.ConflictStrategy strategy)Initialize a player hook, allowing us to read server packets.This call will be ignored if there's no listener that can receive the given events.
- Parameters:
player- - player to hook.strategy- - how to handle injection conflicts.
-
handleDisconnect
void handleDisconnect(org.bukkit.entity.Player player)Invoke special routines for handling disconnect before a player is uninjected.- Parameters:
player- - player to process.
-
uninjectPlayer
boolean uninjectPlayer(org.bukkit.entity.Player player)Uninject the given player.- Parameters:
player- - player to uninject.- Returns:
- TRUE if a player has been uninjected, FALSE otherwise.
-
uninjectPlayer
Unregisters a player by the given 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.
- Parameters:
address- - address of the player to unregister.- Returns:
- TRUE if a player has been uninjected, FALSE otherwise.
-
sendServerPacket
void sendServerPacket(org.bukkit.entity.Player receiver, PacketContainer packet, NetworkMarker marker, boolean filters) throws InvocationTargetExceptionSend the given packet to the given receiver.- Parameters:
receiver- - the player receiver.packet- - the packet to send.marker- - network marker.filters- - whether or not to invoke the packet filters.- Throws:
InvocationTargetException- If an error occurred during sending.
-
recieveClientPacket
void recieveClientPacket(org.bukkit.entity.Player player, Object mcPacket) throws IllegalAccessException, InvocationTargetExceptionProcess a packet as if it were sent by the given player.- Parameters:
player- - the sender.mcPacket- - the packet to process.- Throws:
IllegalAccessException- If the reflection machinery failed.InvocationTargetException- If the underlying method caused an error.
-
updatePlayer
void updatePlayer(org.bukkit.entity.Player player)Ensure that packet readers are informed of this player reference.- Parameters:
player- - the player to update.
-
checkListener
Determine if the given listeners are valid.- Parameters:
listeners- - listeners to check.
-
checkListener
Determine if a listener is valid or not.If not, a warning will be printed to the console.
- Parameters:
listener- - listener to check.
-
getSendingFilters
Set<PacketType> getSendingFilters()Retrieve the current list of registered sending listeners.- Returns:
- List of the sending listeners's packet IDs.
-
canRecievePackets
boolean canRecievePackets()Whether or not this player injection handler can also receive packets.- Returns:
- TRUE if it can, FALSE otherwise.
-
handlePacketRecieved
Invoked if this player injection handler can process received packets.- Parameters:
packet- - the received packet.input- - the input stream.buffered- - the buffered packet.- Returns:
- The packet event.
-
close
void close()Close any lingering proxy injections. -
hasMainThreadListener
Determine if we have packet listeners with the given type that must be executed on the main thread.This only applies for onPacketSending(), as it makes certain guarantees.
- Parameters:
type- - the packet type.- Returns:
- TRUE if we do, FALSE otherwise.
-
getChannel
io.netty.channel.Channel getChannel(org.bukkit.entity.Player player)
-