Class Connector<P extends ConnectorPlugin,​R>

java.lang.Object
de.themoep.connectorplugin.connector.Connector<P,​R>
Direct Known Subclasses:
BukkitConnector, BungeeConnector, VelocityConnector

public abstract class Connector<P extends ConnectorPlugin,​R> extends Object
  • Field Details

  • Constructor Details

    • Connector

      public Connector(P plugin, boolean requiresPlayer)
  • Method Details

    • handle

      protected void handle(String receiver, Message message)
    • handle

      protected void handle(R receiver, Message message)
    • sendData

      public void sendData(ConnectingPlugin sender, String action, MessageTarget target, byte[] data)
      Send data to a specific target
      Parameters:
      sender - The plugin which sends the data
      action - The action for which data is sent
      target - Where to send data to
      data - The data
    • sendData

      public void sendData(ConnectingPlugin sender, String action, MessageTarget target, R player, byte[] data)
      Send data to a specific target
      Parameters:
      sender - The plugin which sends the data
      action - The action for which data is sent
      target - Where to send data to
      player - Additional player data to use for sending (required in case the target is MessageTarget.SERVER or MessageTarget.PROXY)
      data - The data
    • sendData

      public void sendData(ConnectingPlugin sender, String action, MessageTarget target, String targetData, byte[] data)
      Send data to a specific target
      Parameters:
      sender - The plugin which sends the data
      action - The action for which data is sent
      target - Where to send data to
      targetData - Additional data to use for sending (required in case the target is MessageTarget.SERVER)
      data - The data
    • sendDataInternal

      public void sendDataInternal(ConnectingPlugin sender, String action, MessageTarget target, Object targetData, byte[] data)
    • sendDataImplementation

      protected abstract void sendDataImplementation(Object targetData, Message message)
    • hasPrefix

      protected boolean hasPrefix(String target)
    • getReceiver

      protected R getReceiver(String name)
    • getReceiverImplementation

      protected abstract R getReceiverImplementation(String name)
    • isThis

      protected boolean isThis(String receiver)
    • registerHandler

      public BiConsumer<R,​byte[]> registerHandler(ConnectingPlugin plugin, String action, BiConsumer<R,​byte[]> handler)
      Register a handler for a certain action
      Parameters:
      plugin - The plugin to register the handler for
      action - The action to register (case sensitive)
      handler - A BiConsumer which takes the receiving player and the data
      Returns:
      The previously registered handler if there was one
    • unregisterHandler

      public BiConsumer<R,​byte[]> unregisterHandler(ConnectingPlugin plugin, String action)
      Unregister a handler from a certain action
      Parameters:
      plugin - The plugin to unregister the handler of
      action - The action to unregister (case sensitive)
      Returns:
      The previously registered handler if there was one or null
    • unregisterHandlers

      public Map<String,​BiConsumer<R,​byte[]>> unregisterHandlers(ConnectingPlugin plugin)
      Unregister a all handlers of a certain plugin
      Parameters:
      plugin - The plugin to unregister the handlers of
      Returns:
      The previously registered handlers if there were some or null
    • requiresPlayer

      public boolean requiresPlayer()
      Whether this connector requires a player on the target server. (Mostly for plugin message usage)
      Returns:
      Whether this connector requires at least one player on the target server
    • close

      public void close()