Skip to content

Commit c624383

Browse files
committed
docs(api): apply formatting cleanup across all API JavaDocs
1 parent 56120fa commit c624383

13 files changed

Lines changed: 473 additions & 231 deletions

api/src/main/java/dev/objz/commandbridge/api/CommandBridgeAPI.java

Lines changed: 79 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,55 @@
1313
import 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 -> {
@@ -67,66 +77,85 @@
6777
public 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);

api/src/main/java/dev/objz/commandbridge/api/CommandBridgeProvider.java

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,30 @@
33
import java.util.Objects;
44

55
/**
6-
* Static provider for obtaining the {@link CommandBridgeAPI} singleton instance.
6+
* Static provider for obtaining the {@link CommandBridgeAPI} singleton
7+
* instance.
78
*
8-
* <p>CommandBridge registers its implementation when the plugin enables. Third-party plugins
9-
* retrieve the instance by calling {@link #get()} or {@link #get(Class)} for platform-specific
10-
* subtypes. The provider holds a single volatile reference accessible across threads.
9+
* <p>
10+
* CommandBridge registers its implementation when the plugin enables.
11+
* Third-party plugins
12+
* retrieve the instance by calling {@link #get()} or {@link #get(Class)} for
13+
* platform-specific
14+
* subtypes. The provider holds a single volatile reference accessible across
15+
* threads.
1116
*
12-
* <p>This class cannot be instantiated. All access is through static methods.
17+
* <p>
18+
* This class cannot be instantiated. All access is through static methods.
1319
*
14-
* <p>To obtain the API instance:
20+
* <p>
21+
* To obtain the API instance:
1522
*
1623
* <pre>{@code
1724
* CommandBridgeAPI api = CommandBridgeProvider.get();
1825
* }</pre>
1926
*
20-
* <p>To access a platform-specific subtype, pass the expected class to {@link #get(Class)}.
27+
* <p>
28+
* To access a platform-specific subtype, pass the expected class to
29+
* {@link #get(Class)}.
2130
*
2231
* @see CommandBridgeAPI
2332
*/
@@ -32,11 +41,13 @@ private CommandBridgeProvider() {
3241
/**
3342
* Returns the registered {@link CommandBridgeAPI} instance.
3443
*
35-
* <p>This method is safe to call from any thread after CommandBridge has enabled.
44+
* <p>
45+
* This method is safe to call from any thread after CommandBridge has enabled.
3646
*
3747
* @return the registered {@code CommandBridgeAPI} instance; never {@code null}
38-
* @throws IllegalStateException if CommandBridge is not installed, not yet enabled,
39-
* or the API has not been registered
48+
* @throws IllegalStateException if CommandBridge is not installed, not yet
49+
* enabled,
50+
* or the API has not been registered
4051
* @see #get(Class)
4152
*/
4253
public static CommandBridgeAPI get() {
@@ -47,17 +58,23 @@ public static CommandBridgeAPI get() {
4758
}
4859

4960
/**
50-
* Returns the registered {@link CommandBridgeAPI} instance cast to the specified subtype.
61+
* Returns the registered {@link CommandBridgeAPI} instance cast to the
62+
* specified subtype.
5163
*
52-
* <p>Use this method when accessing a platform-specific extension of the API. The cast is
53-
* validated at runtime; if the registered instance does not implement the requested type,
64+
* <p>
65+
* Use this method when accessing a platform-specific extension of the API. The
66+
* cast is
67+
* validated at runtime; if the registered instance does not implement the
68+
* requested type,
5469
* an {@link IllegalStateException} is thrown.
5570
*
56-
* @param <T> the expected API subtype; must extend {@link CommandBridgeAPI}
57-
* @param type the {@link Class} token of the expected subtype; must not be {@code null}
71+
* @param <T> the expected API subtype; must extend {@link CommandBridgeAPI}
72+
* @param type the {@link Class} token of the expected subtype; must not be
73+
* {@code null}
5874
* @return the API instance cast to {@code T}; never {@code null}
59-
* @throws IllegalStateException if the API is not registered, or if the registered instance
60-
* is not an instance of {@code type}
75+
* @throws IllegalStateException if the API is not registered, or if the
76+
* registered instance
77+
* is not an instance of {@code type}
6178
* @see #get()
6279
*/
6380
public static <T extends CommandBridgeAPI> T get(Class<T> type) {
@@ -71,12 +88,14 @@ public static <T extends CommandBridgeAPI> T get(Class<T> type) {
7188
/**
7289
* Registers the {@link CommandBridgeAPI} implementation.
7390
*
74-
* <p>This method is called internally by the CommandBridge plugin during startup and is not
91+
* <p>
92+
* This method is called internally by the CommandBridge plugin during startup
93+
* and is not
7594
* intended for use by third-party plugins.
7695
*
7796
* @param impl the implementation to register; must not be {@code null}
7897
* @throws IllegalStateException if an implementation is already registered
79-
* @throws NullPointerException if {@code impl} is {@code null}
98+
* @throws NullPointerException if {@code impl} is {@code null}
8099
*/
81100
public static synchronized void register(CommandBridgeAPI impl) {
82101
Objects.requireNonNull(impl);
@@ -89,8 +108,11 @@ public static synchronized void register(CommandBridgeAPI impl) {
89108
/**
90109
* Clears the registered {@link CommandBridgeAPI} implementation.
91110
*
92-
* <p>Called internally by the CommandBridge plugin during shutdown. After this method returns,
93-
* calls to {@link #get()} will throw {@link IllegalStateException} until a new implementation
111+
* <p>
112+
* Called internally by the CommandBridge plugin during shutdown. After this
113+
* method returns,
114+
* calls to {@link #get()} will throw {@link IllegalStateException} until a new
115+
* implementation
94116
* is registered.
95117
*/
96118
public static synchronized void unregister() {

api/src/main/java/dev/objz/commandbridge/api/channel/ChannelPayload.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@
44
* Marker interface for all data types that can be sent over a
55
* {@link dev.objz.commandbridge.api.channel.MessageChannel}.
66
*
7-
* <p>Implementing this interface registers a type as a valid payload. The
8-
* {@link dev.objz.commandbridge.api.channel.MessageChannel} uses the payload's {@code Class}
7+
* <p>
8+
* Implementing this interface registers a type as a valid payload. The
9+
* {@link dev.objz.commandbridge.api.channel.MessageChannel} uses the payload's
10+
* {@code Class}
911
* token for channel routing and type-safe dispatch.
1012
*
11-
* <p>{@link dev.objz.commandbridge.api.channel.command.CommandPayload} is the built-in
12-
* implementation for command execution. Custom payload types can be created by implementing
13+
* <p>
14+
* {@link dev.objz.commandbridge.api.channel.command.CommandPayload} is the
15+
* built-in
16+
* implementation for command execution. Custom payload types can be created by
17+
* implementing
1318
* this interface and using them with
1419
* {@link dev.objz.commandbridge.api.CommandBridgeAPI#channel(Class)}.
1520
*
16-
* <p>Example of a custom payload type:
21+
* <p>
22+
* Example of a custom payload type:
23+
*
1724
* <pre>{@code
18-
* public record MyPayload(String data) implements ChannelPayload {}
25+
* public record MyPayload(String data) implements ChannelPayload {
26+
* }
1927
*
2028
* MessageChannel<MyPayload> channel = api.channel(MyPayload.class);
2129
* channel.toAll().send(new MyPayload("hello"));

0 commit comments

Comments
 (0)