1313import java .util .function .Consumer ;
1414
1515/**
16- * Primary interface for interacting with the CommandBridge network from a third-party plugin.
16+ * Primary interface for interacting with the CommandBridge network from a
17+ * third-party plugin.
1718 *
18- * <p>Use {@link #channel(Class)} to obtain typed message channels for sending and receiving
19- * payloads. {@link #server()} and {@link #connectionState()} expose the current server's identity
19+ * <p>
20+ * Use {@link #channel(Class)} to obtain typed message channels for sending and
21+ * receiving
22+ * payloads. {@link #server()} and {@link #connectionState()} expose the current
23+ * server's identity
2024 * and connection status. {@link #connectedServers()}, {@link #playerLocator()},
2125 * {@link #onServerConnected(ServerEventListener)}, and
22- * {@link #onServerDisconnected(ServerEventListener)} are available only on the Velocity proxy;
26+ * {@link #onServerDisconnected(ServerEventListener)} are available only on the
27+ * Velocity proxy;
2328 * they return {@code Optional.empty()} on backend servers.
2429 *
25- * <p>Obtain an instance via {@link CommandBridgeProvider#get()} and use {@link #channel(Class)}
30+ * <p>
31+ * Obtain an instance via {@link CommandBridgeProvider#get()} and use
32+ * {@link #channel(Class)}
2633 * to build a typed message channel:
2734 *
2835 * <pre>{@code
2936 * CommandBridgeAPI api = CommandBridgeProvider.get();
3037 * MessageChannel<CommandPayload> channel = api.channel(CommandPayload.class);
3138 * }</pre>
3239 *
33- * <p>To send a command to a specific backend server:
40+ * <p>
41+ * To send a command to a specific backend server:
3442 *
3543 * <pre>{@code
3644 * channel.to(List.of(Platform.backend("survival-1")))
37- * .send(new CommandPayload("say hello", RunAs.CONSOLE));
45+ * .send(new CommandPayload("say hello", RunAs.CONSOLE));
3846 * }</pre>
3947 *
40- * <p>To broadcast a command to every connected server:
48+ * <p>
49+ * To broadcast a command to every connected server:
4150 *
4251 * <pre>{@code
4352 * channel.toAll().send(new CommandPayload("say maintenance soon", RunAs.CONSOLE));
4453 * }</pre>
4554 *
46- * <p>To receive a notification when a backend server connects (Velocity proxy only):
55+ * <p>
56+ * To receive a notification when a backend server connects (Velocity proxy
57+ * only):
4758 *
4859 * <pre>{@code
49- * api.onServerConnected(server ->
50- * System.out.println("Connected: " + server.id())
51- * ).ifPresent(subscriptions::add);
60+ * api.onServerConnected(server -> System.out.println("Connected: " + server.id())).ifPresent(subscriptions::add);
5261 * }</pre>
5362 *
54- * <p>To track connection state transitions on any platform:
63+ * <p>
64+ * To track connection state transitions on any platform:
5565 *
5666 * <pre>{@code
5767 * api.onConnectionStateChanged(state -> {
6777public interface CommandBridgeAPI {
6878
6979 /**
70- * Obtains a typed {@link dev.objz.commandbridge.api.channel.MessageChannel} for the given
80+ * Obtains a typed {@link dev.objz.commandbridge.api.channel.MessageChannel} for
81+ * the given
7182 * payload type.
7283 *
73- * @param <T> the payload type; must extend {@link dev.objz.commandbridge.api.channel.ChannelPayload}
74- * @param type the {@link Class} token identifying the payload type; used for channel routing
75- * @return the message channel for sending and receiving payloads of type {@code T}
84+ * @param <T> the payload type; must extend
85+ * {@link dev.objz.commandbridge.api.channel.ChannelPayload}
86+ * @param type the {@link Class} token identifying the payload type; used for
87+ * channel routing
88+ * @return the message channel for sending and receiving payloads of type
89+ * {@code T}
7690 * @see dev.objz.commandbridge.api.channel.MessageChannel
7791 */
7892 <T extends ChannelPayload > MessageChannel <T > channel (Class <T > type );
7993
8094 /**
8195 * Returns the identity of the server this API instance is running on.
8296 *
83- * @return the {@link dev.objz.commandbridge.api.platform.Platform.ServerTarget} of the current
84- * server, containing its configured identifier and platform type
97+ * @return the {@link dev.objz.commandbridge.api.platform.Platform.ServerTarget}
98+ * of the current
99+ * server, containing its configured identifier and platform type
85100 */
86101 Platform .ServerTarget server ();
87102
88103 /**
89- * Returns the current connection state of this server to the CommandBridge network.
104+ * Returns the current connection state of this server to the CommandBridge
105+ * network.
90106 *
91107 * @return the current {@link ConnectionState}
92108 * @see ConnectionState#isActive()
93109 */
94110 ConnectionState connectionState ();
95111
96112 /**
97- * Returns the identifiers of all servers currently connected to the bridge network.
113+ * Returns the identifiers of all servers currently connected to the bridge
114+ * network.
98115 *
99- * <p>This method is available only on the Velocity proxy. On backend servers, it returns
116+ * <p>
117+ * This method is available only on the Velocity proxy. On backend servers, it
118+ * returns
100119 * {@code Optional.empty()}.
101120 *
102- * @return an {@link java.util.Optional} containing a snapshot of the connected server IDs if
103- * called on the Velocity proxy, or an empty {@code Optional} on backend servers
121+ * @return an {@link java.util.Optional} containing a snapshot of the connected
122+ * server IDs if
123+ * called on the Velocity proxy, or an empty {@code Optional} on backend
124+ * servers
104125 * @see #onServerConnected(ServerEventListener)
105126 */
106127 Optional <Set <String >> connectedServers ();
107128
108129 /**
109- * Returns the player location service for resolving which server a player is connected to.
130+ * Returns the player location service for resolving which server a player is
131+ * connected to.
110132 *
111- * <p>This method is available only on the Velocity proxy. On backend servers, it returns
133+ * <p>
134+ * This method is available only on the Velocity proxy. On backend servers, it
135+ * returns
112136 * {@code Optional.empty()}.
113137 *
114- * @return an {@link java.util.Optional} containing the {@link PlayerLocator} if called on the
115- * Velocity proxy, or an empty {@code Optional} on backend servers
138+ * @return an {@link java.util.Optional} containing the {@link PlayerLocator} if
139+ * called on the
140+ * Velocity proxy, or an empty {@code Optional} on backend servers
116141 * @see dev.objz.commandbridge.api.platform.PlayerLocator#locate(java.util.UUID)
117142 */
118143 Optional <PlayerLocator > playerLocator ();
119144
120145 /**
121146 * Subscribes to server connection events.
122147 *
123- * <p>This method is available only on the Velocity proxy. On backend servers, it returns
148+ * <p>
149+ * This method is available only on the Velocity proxy. On backend servers, it
150+ * returns
124151 * {@code Optional.empty()} and the listener is not registered.
125152 *
126- * @param listener the listener to invoke when a backend server connects to the bridge network;
127- * must not be {@code null}
128- * @return an {@link java.util.Optional} containing the {@link Subscription} on the proxy, or
129- * an empty {@code Optional} on backends
153+ * @param listener the listener to invoke when a backend server connects to the
154+ * bridge network;
155+ * must not be {@code null}
156+ * @return an {@link java.util.Optional} containing the {@link Subscription} on
157+ * the proxy, or
158+ * an empty {@code Optional} on backends
130159 * @see #onServerDisconnected(ServerEventListener)
131160 * @see dev.objz.commandbridge.api.message.Subscription#cancel()
132161 */
@@ -135,13 +164,17 @@ public interface CommandBridgeAPI {
135164 /**
136165 * Subscribes to server disconnection events.
137166 *
138- * <p>This method is available only on the Velocity proxy. On backend servers, it returns
167+ * <p>
168+ * This method is available only on the Velocity proxy. On backend servers, it
169+ * returns
139170 * {@code Optional.empty()} and the listener is not registered.
140171 *
141- * @param listener the listener to invoke when a backend server disconnects from the bridge
142- * network; must not be {@code null}
143- * @return an {@link java.util.Optional} containing the {@link Subscription} on the proxy, or
144- * an empty {@code Optional} on backends
172+ * @param listener the listener to invoke when a backend server disconnects from
173+ * the bridge
174+ * network; must not be {@code null}
175+ * @return an {@link java.util.Optional} containing the {@link Subscription} on
176+ * the proxy, or
177+ * an empty {@code Optional} on backends
145178 * @see #onServerConnected(ServerEventListener)
146179 * @see dev.objz.commandbridge.api.message.Subscription#cancel()
147180 */
@@ -150,12 +183,16 @@ public interface CommandBridgeAPI {
150183 /**
151184 * Subscribes to connection state changes on this server.
152185 *
153- * <p>Available on all platforms, unlike the server event methods. The listener is invoked on
186+ * <p>
187+ * Available on all platforms, unlike the server event methods. The listener is
188+ * invoked on
154189 * every state transition.
155190 *
156- * @param listener the consumer to call with the new {@link ConnectionState} on each transition;
157- * must not be {@code null}
158- * @return a {@link Subscription} that can be cancelled to stop receiving state change events
191+ * @param listener the consumer to call with the new {@link ConnectionState} on
192+ * each transition;
193+ * must not be {@code null}
194+ * @return a {@link Subscription} that can be cancelled to stop receiving state
195+ * change events
159196 * @see ConnectionState
160197 */
161198 Subscription onConnectionStateChanged (Consumer <ConnectionState > listener );
0 commit comments