Class BridgeCommon<P extends ConnectorPlugin<R>,R>

java.lang.Object
de.themoep.connectorplugin.BridgeCommon<P,R>
Direct Known Subclasses:
Bridge, ProxyBridgeCommon

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

  • Constructor Details

    • BridgeCommon

      public BridgeCommon(P plugin)
  • Method Details

    • registerHandler

      protected BiConsumer<R,Message> registerHandler(String action, BiConsumer<R,byte[]> handler)
      Register a bridge data handler for a certain action
      Parameters:
      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
    • registerMessageHandler

      protected BiConsumer<R,Message> registerMessageHandler(String action, BiConsumer<R,BridgeCommon.BridgeMessage> handler)
      Register a bridge message handler for a certain action
      Parameters:
      action - The action to register (case sensitive)
      handler - A BiConsumer which takes the receiving player and the message
      Returns:
      The previously registered handler if there was one
    • teleport

      public abstract CompletableFuture<Boolean> teleport(R player, LocationInfo location, Consumer<String>... consumer)
      Teleport a player to a certain location in the network
      Parameters:
      player - The player to teleport
      location - The location to teleport to
      consumer - Details about the teleport
      Returns:
      A future about whether the player could be teleported
    • teleport

      public abstract CompletableFuture<Boolean> teleport(String playerName, LocationInfo location, Consumer<String>... consumer)
      Teleport a player to a certain location in the network
      Parameters:
      playerName - The name of the player to teleport
      location - The location to teleport to
      consumer - Details about the teleport
      Returns:
      A future about whether the player could be teleported
    • teleport

      public abstract CompletableFuture<Boolean> teleport(String playerName, String serverName, String worldName, Consumer<String>... consumer)
      Teleport a player to a certain location in the network
      Parameters:
      playerName - The name of the player to teleport
      serverName - The target server
      worldName - The target world
      consumer - Details about the teleport
      Returns:
      A future about whether the player could be teleported
    • teleport

      public abstract CompletableFuture<Boolean> teleport(R player, String serverName, String worldName, Consumer<String>... consumer)
      Teleport a player to a certain location in the network
      Parameters:
      player - The player to teleport
      serverName - The target server
      worldName - The target world
      consumer - Details about the teleport
      Returns:
      A future about whether the player could be teleported
    • teleport

      public abstract CompletableFuture<Boolean> teleport(R player, R target, Consumer<String>... consumer)
      Teleport a player to a certain other player in the network
      Parameters:
      player - The player to teleport
      target - The target player
      consumer - Details about the teleport
      Returns:
      A future about whether the player could be teleported
    • teleport

      public abstract CompletableFuture<Boolean> teleport(String playerName, String targetName, Consumer<String>... consumer)
      Teleport a player to a certain other player in the network
      Parameters:
      playerName - The name of the player to teleport
      targetName - The name of the target player
      consumer - Details about the teleport
      Returns:
      A future about whether the player could be teleported
    • runServerConsoleCommand

      public CompletableFuture<Boolean> runServerConsoleCommand(String server, String command, Consumer<String>... consumer)
      Run a console command on the target server
      Parameters:
      server - The server to run teh command on
      command - The command to run
      consumer - Optional Consumer (or multiple) for the messages triggered by the command
      Returns:
      A future for whether the command was run successfully
    • runProxyConsoleCommand

      public CompletableFuture<Boolean> runProxyConsoleCommand(String proxy, String command, Consumer<String>... consumer)
      Run a console command on a specific other proxy
      Parameters:
      proxy - The proxy to run the command on
      command - The command to run
      consumer - Optional Consumer (or multiple) for the messages triggered by the command
      Returns:
      A future for whether the command was run successfully
    • getLocation

      public abstract CompletableFuture<LocationInfo> getLocation(R player)
      Get the location a player is at
      Parameters:
      player - The player to get the location for
      Returns:
      A future for when the location was queried
    • getLocation

      public CompletableFuture<LocationInfo> getLocation(String player)
      Get the location a player is at
      Parameters:
      player - The player to get the location for
      Returns:
      A future for when the location was queried
    • getServer

      public abstract CompletableFuture<String> getServer(R player)
      Get the server a player is connected to
      Parameters:
      player - The player to get the server for
      Returns:
      A future for when the server was queried
    • getServer

      public CompletableFuture<String> getServer(String player)
      Get the server a player is connected to
      Parameters:
      player - The player to get the server for
      Returns:
      A future for when the server was queried
    • sendData

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

      protected void sendData(String action, MessageTarget target, R player, byte[] data)
      Send data to a specific target
      Parameters:
      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

      protected void sendData(String action, MessageTarget target, String targetData, byte[] data)
      Send data to a specific target
      Parameters:
      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
    • sendResponse

      protected void sendResponse(String target, long id, Object response, String... messages)
    • sendResponseMessage

      protected void sendResponseMessage(String target, long id, String... messages)
    • sendResponseData

      protected abstract void sendResponseData(String target, byte[] out)
    • handleResponse

      protected void handleResponse(long id, com.google.common.io.ByteArrayDataInput in)
    • isTeleporting

      public boolean isTeleporting(String playerName)
      Get whether a player with that name is currently teleporting. Useful for checking of a quit/join is from a teleport or not.
      Returns:
      Whether the player is currently teleporting with ConnectorPlugin
    • markTeleporting

      protected boolean markTeleporting(String playerName)
    • unmarkTeleporting

      protected boolean unmarkTeleporting(String playerName)
    • addPlayerInfo

      protected void addPlayerInfo(BridgeCommon.PlayerInfo playerInfo)
    • removePlayerInfo

      protected void removePlayerInfo(String player)