Interface CommandBridgeAPI
Methods returning Optional indicate proxy-only features;
they return Optional.empty() on backend servers and a present value on the Velocity proxy.
-
Method Summary
Modifier and TypeMethodDescription<T extends ChannelPayload>
MessageChannel<T> Obtains aMessageChannelfor the given payload type.onConnectionStateChanged(Consumer<ConnectionState> listener) Subscribes to connection state changes.onServerConnected(ServerEventListener listener) Subscribes to server connection events.onServerDisconnected(ServerEventListener listener) Subscribes to server disconnection events.server()
-
Method Details
-
channel
Obtains aMessageChannelfor the given payload type.- Type Parameters:
T- the payload type- Parameters:
type- the payload class that identifies the channel- Returns:
- the message channel
-
server
Platform.ServerTarget server()- Returns:
- the identity of the current server
-
connectionState
ConnectionState connectionState()- Returns:
- the current connection state to the bridge network
-
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
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 presentOptionalcontaining aSubscriptionthat can be cancelled viaSubscription.cancel(). UseOptional.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
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 presentOptionalcontaining aSubscriptionthat can be cancelled viaSubscription.cancel(). UseOptional.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
Subscribes to connection state changes.- Parameters:
listener- the listener to call when the state changes- Returns:
- a subscription handle to cancel the listener
-