Class SubChannelHandler<S>

Direct Known Subclasses:
PluginMessageListener, PluginMessageListener, ProxyPackListener

public abstract class SubChannelHandler<S> extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • registerSubChannel

      public BiConsumer<S,> registerSubChannel(String name, BiConsumer<S,> reaction)
      Register a new sub channel with this listener on the channel "rp:plugin"
      name - The name of the sub channel, case sensitive
      reaction - The reaction that should happen
      The previously registered Reaction or null
    • handleMessage

      protected boolean handleMessage(S source, byte[] message)
      Handle a message with sub channels
      source - The source of the plugin message
      message - The message that was received
      Whether the message was handled or not
    • sendKey

      protected void sendKey(S target)
    • sendMessage

      public void sendMessage(S target, String subChannel, Consumer<> out)
      Send a message to the target on the given sub channel
      target - The target to send the message to
      subChannel - The sub channel to send the message on
      out - The output to write to
    • writePack

      public void writePack( out, ResourcePack pack)
      Write a pack to the output. If the pack is null, an empty string will be written
      out - The output to write to
      pack - The pack to write
    • readPack

      protected ResourcePack readPack( in)
      Read a pack from the input
      in - The input to read from
      The pack that was read, if the name is empty then the empty pack will be returned, if the pack is unknown then null is returned
    • sendPluginMessage

      protected abstract void sendPluginMessage(S target, byte[] data)
    • reload

      public void reload()
      Reload the handler
    • generateKey

      protected String generateKey()
      Generate a new key
    • setKey

      protected void setKey(String key)
      Set the key used for authenticating communication and save it
      key - The key to set
    • acceptsNewKey

      protected boolean acceptsNewKey()
      Check if this listener accepts a new key
      Whether it accepts a new key or not
    • trustsSender

      protected boolean trustsSender()
      Check whether this implementation can trust the sender
      Whether the sender can be trusted or not
    • saveKey

      protected abstract void saveKey(String key)
      Save the key used for authenticating communication
      key - The key to set
    • loadKey

      protected abstract String loadKey()
      Load the key from the storage
      The key (or null if none is stored)
    • getTargetType

      protected abstract String getTargetType()
      Get the type that we are sending messages to
      The type