Interface CommandBridgeAPI


public interface CommandBridgeAPI
Main entry point for interacting with the CommandBridge network.

Methods returning Optional indicate proxy-only features; they return Optional.empty() on backend servers and a present value on the Velocity proxy.

  • Method Details

    • channel

      <T extends ChannelPayload> MessageChannel<T> channel(Class<T> type)
      Obtains a MessageChannel for the given payload type.
      Type Parameters:
      T - the payload type
      Parameters:
      type - the payload class that identifies the channel
      Returns:
      the message channel
    • server

      Returns:
      the identity of the current server
    • connectionState

      ConnectionState connectionState()
      Returns:
      the current connection state to the bridge network
    • connectedServers

      Optional<Set<String>> connectedServers()
      Returns:
      the IDs of all currently connected servers, or empty if not available on this platform
    • playerLocator

      Optional<PlayerLocator> playerLocator()
      Returns:
      the player location lookup service, or empty if not available on this platform
    • onServerConnected

      Optional<Subscription> onServerConnected(ServerEventListener listener)
      Subscribes to server connection events.

      Returns Optional.empty() on platforms where server connection events are not available (e.g. backend servers). On the Velocity proxy, returns a present Optional containing a Subscription that can be cancelled via Subscription.cancel(). Use Optional.ifPresent(java.util.function.Consumer) to handle safely.

      Parameters:
      listener - the listener to call when a server connects
      Returns:
      a present subscription handle on the proxy, or empty on backends
    • onServerDisconnected

      Optional<Subscription> onServerDisconnected(ServerEventListener listener)
      Subscribes to server disconnection events.

      Returns Optional.empty() on platforms where server disconnection events are not available (e.g. backend servers). On the Velocity proxy, returns a present Optional containing a Subscription that can be cancelled via Subscription.cancel(). Use Optional.ifPresent(java.util.function.Consumer) to handle safely.

      Parameters:
      listener - the listener to call when a server disconnects
      Returns:
      a present subscription handle on the proxy, or empty on backends
    • onConnectionStateChanged

      Subscription onConnectionStateChanged(Consumer<ConnectionState> listener)
      Subscribes to connection state changes.
      Parameters:
      listener - the listener to call when the state changes
      Returns:
      a subscription handle to cancel the listener