Class ChannelInjector

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
com.comphenix.protocol.injector.netty.ChannelInjector
All Implemented Interfaces:
Injector, io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

public class ChannelInjector extends io.netty.handler.codec.ByteToMessageDecoder implements Injector
Represents a channel injector.
Author:
Kristian
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Represents a socket injector that foreards to the current channel injector.

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelActive​(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    Close the current injector.
    protected void
    decode​(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf byteBuffer, List<Object> packets)
     
    void
    exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
     
    io.netty.channel.Channel
     
    Retrieve the current protocol state.
    getMarker​(Object packet)
    Retrieve the network marker associated with a given packet.
    org.bukkit.entity.Player
    Retrieve the current player or temporary player associated with the injector.
    int
    Get the version of the current protocol.
    boolean
    Inject the current channel.
    boolean
    Determine if this channel has been closed and cleaned up.
    boolean
    Determine if the channel has already been injected.
    void
    Recieve a packet on the server.
    void
    saveMarker​(Object packet, NetworkMarker marker)
    Associate a given network marker with a specific packet.
    void
    sendServerPacket​(Object packet, NetworkMarker marker, boolean filtered)
    Send a packet to a player's client.
    void
    setPlayer​(org.bukkit.entity.Player player)
    Set the player instance.
    void
    setUpdatedPlayer​(org.bukkit.entity.Player updated)
    Set the updated player instance.

    Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder

    actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setSingleDecode

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    handlerAdded, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded
  • Method Details

    • getProtocolVersion

      public int getProtocolVersion()
      Get the version of the current protocol.
      Specified by:
      getProtocolVersion in interface Injector
      Returns:
      The version.
    • inject

      public boolean inject()
      Description copied from interface: Injector
      Inject the current channel.

      Note that only active channels can be injected.

      Specified by:
      inject in interface Injector
      Returns:
      TRUE if we injected the channel, false if we could not inject or it was already injected.
    • exceptionCaught

      public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelHandler
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception
    • decode

      protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf byteBuffer, List<Object> packets) throws Exception
      Specified by:
      decode in class io.netty.handler.codec.ByteToMessageDecoder
      Throws:
      Exception
    • channelActive

      public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      channelActive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception
    • sendServerPacket

      public void sendServerPacket(Object packet, NetworkMarker marker, boolean filtered)
      Description copied from interface: Injector
      Send a packet to a player's client.
      Specified by:
      sendServerPacket in interface Injector
      Parameters:
      packet - - the packet to send.
      marker - - the network marker.
      filtered - - whether or not the packet is filtered.
    • recieveClientPacket

      public void recieveClientPacket(Object packet)
      Description copied from interface: Injector
      Recieve a packet on the server.
      Specified by:
      recieveClientPacket in interface Injector
      Parameters:
      packet - - the (NMS) packet to send.
    • getCurrentProtocol

      public PacketType.Protocol getCurrentProtocol()
      Description copied from interface: Injector
      Retrieve the current protocol state.
      Specified by:
      getCurrentProtocol in interface Injector
      Returns:
      The current protocol.
    • getMarker

      public NetworkMarker getMarker(Object packet)
      Description copied from interface: Injector
      Retrieve the network marker associated with a given packet.
      Specified by:
      getMarker in interface Injector
      Parameters:
      packet - - the packet.
      Returns:
      The network marker.
    • saveMarker

      public void saveMarker(Object packet, NetworkMarker marker)
      Description copied from interface: Injector
      Associate a given network marker with a specific packet.
      Specified by:
      saveMarker in interface Injector
      Parameters:
      packet - - the NMS packet.
      marker - - the associated marker.
    • getPlayer

      public org.bukkit.entity.Player getPlayer()
      Description copied from interface: Injector
      Retrieve the current player or temporary player associated with the injector.
      Specified by:
      getPlayer in interface Injector
      Returns:
      The current player.
    • setPlayer

      public void setPlayer(org.bukkit.entity.Player player)
      Set the player instance.
      Specified by:
      setPlayer in interface Injector
      Parameters:
      player - - current instance.
    • setUpdatedPlayer

      public void setUpdatedPlayer(org.bukkit.entity.Player updated)
      Set the updated player instance.
      Specified by:
      setUpdatedPlayer in interface Injector
      Parameters:
      updated - - updated instance.
    • isInjected

      public boolean isInjected()
      Description copied from interface: Injector
      Determine if the channel has already been injected.
      Specified by:
      isInjected in interface Injector
      Returns:
      TRUE if it has, FALSE otherwise.
    • isClosed

      public boolean isClosed()
      Determine if this channel has been closed and cleaned up.
      Specified by:
      isClosed in interface Injector
      Returns:
      TRUE if it has, FALSE otherwise.
    • close

      public void close()
      Description copied from interface: Injector
      Close the current injector.
      Specified by:
      close in interface Injector
    • getChannel

      public io.netty.channel.Channel getChannel()