Interface PlayerInjectionHandler

All Known Implementing Classes:
AbstractPlayerHandler

public interface PlayerInjectionHandler
  • 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

      PlayerInjectHooks getPlayerHook(GamePhase phase)
      Retrieves how the server packets are read.
      Parameters:
      phase - - the current game phase.
      Returns:
      Injection method for reading server packets.
    • setPlayerHook

      void setPlayerHook(PlayerInjectHooks playerHook)
      Sets how the server packets are read.
      Parameters:
      playerHook - - the new injection method for reading server packets.
    • setPlayerHook

      void setPlayerHook(GamePhase phase, PlayerInjectHooks playerHook)
      Sets how the server packets are read.
      Parameters:
      phase - - the current game phase.
      playerHook - - the new injection method for reading server packets.
    • addPacketHandler

      void addPacketHandler(PacketType type, Set<ListenerOptions> options)
      Add an underlying packet handler of the given type.
      Parameters:
      type - - packet type to register.
      options - - any specified listener options.
    • removePacketHandler

      void removePacketHandler(PacketType type)
      Remove an underlying packet handler of this type.
      Parameters:
      type - - packet type to unregister.
    • getPlayerByConnection

      org.bukkit.entity.Player getPlayerByConnection(DataInputStream inputStream) throws InterruptedException
      Retrieve 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

      boolean uninjectPlayer(InetSocketAddress address)
      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 InvocationTargetException
      Send 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, InvocationTargetException
      Process 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

      void checkListener(Set<PacketListener> listeners)
      Determine if the given listeners are valid.
      Parameters:
      listeners - - listeners to check.
    • checkListener

      void checkListener(PacketListener listener)
      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

      PacketEvent handlePacketRecieved(PacketContainer packet, InputStream input, byte[] buffered)
      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

      boolean hasMainThreadListener(PacketType type)
      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)