Skip to content

Commit 56120fa

Browse files
committed
docs(api): replace inline code-block labels with JDK-style prose lead-ins
1 parent 798b8b5 commit 56120fa

9 files changed

Lines changed: 72 additions & 31 deletions

File tree

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,38 @@
2222
* {@link #onServerDisconnected(ServerEventListener)} are available only on the Velocity proxy;
2323
* they return {@code Optional.empty()} on backend servers.
2424
*
25-
* <p>Obtain an instance via {@link CommandBridgeProvider#get()}. The following example shows
26-
* common usage patterns:
25+
* <p>Obtain an instance via {@link CommandBridgeProvider#get()} and use {@link #channel(Class)}
26+
* to build a typed message channel:
2727
*
2828
* <pre>{@code
2929
* CommandBridgeAPI api = CommandBridgeProvider.get();
3030
* MessageChannel<CommandPayload> channel = api.channel(CommandPayload.class);
31+
* }</pre>
32+
*
33+
* <p>To send a command to a specific backend server:
3134
*
32-
* // Send a command to a backend
35+
* <pre>{@code
3336
* channel.to(List.of(Platform.backend("survival-1")))
3437
* .send(new CommandPayload("say hello", RunAs.CONSOLE));
38+
* }</pre>
39+
*
40+
* <p>To broadcast a command to every connected server:
3541
*
36-
* // Broadcast to all connected servers
42+
* <pre>{@code
3743
* channel.toAll().send(new CommandPayload("say maintenance soon", RunAs.CONSOLE));
44+
* }</pre>
45+
*
46+
* <p>To receive a notification when a backend server connects (Velocity proxy only):
3847
*
39-
* // Subscribe to server connection events (proxy only)
48+
* <pre>{@code
4049
* api.onServerConnected(server ->
4150
* System.out.println("Connected: " + server.id())
4251
* ).ifPresent(subscriptions::add);
52+
* }</pre>
53+
*
54+
* <p>To track connection state transitions on any platform:
4355
*
44-
* // React to connection state changes (all platforms)
56+
* <pre>{@code
4557
* api.onConnectionStateChanged(state -> {
4658
* if (state.isActive()) {
4759
* // ready to send

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
*
1212
* <p>This class cannot be instantiated. All access is through static methods.
1313
*
14+
* <p>To obtain the API instance:
15+
*
1416
* <pre>{@code
15-
* // Basic usage — obtain the API
1617
* CommandBridgeAPI api = CommandBridgeProvider.get();
17-
*
18-
* // Platform-specific usage (Velocity proxy only):
19-
* // VelocityCommandBridgeAPI velocityApi =
20-
* // CommandBridgeProvider.get(VelocityCommandBridgeAPI.class);
2118
* }</pre>
2219
*
20+
* <p>To access a platform-specific subtype, pass the expected class to {@link #get(Class)}.
21+
*
2322
* @see CommandBridgeAPI
2423
*/
2524
public final class CommandBridgeProvider {

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,27 @@
2222
* <p>All send operations return {@link java.util.concurrent.CompletableFuture} and are
2323
* non-blocking.
2424
*
25+
* <p>To obtain a channel and send a command to a specific backend server:
26+
*
2527
* <pre>{@code
2628
* CommandBridgeAPI api = CommandBridgeProvider.get();
2729
* MessageChannel<CommandPayload> channel = api.channel(CommandPayload.class);
28-
*
29-
* // Send a command to a specific backend
3030
* channel.to(List.of(Platform.backend("survival-1")))
3131
* .send(new CommandPayload("say hello", RunAs.CONSOLE));
32+
* }</pre>
33+
*
34+
* <p>To broadcast a command to every connected server:
3235
*
33-
* // Broadcast to all connected servers
36+
* <pre>{@code
3437
* channel.toAll().send(new CommandPayload("say maintenance soon", RunAs.CONSOLE));
38+
* }</pre>
3539
*
36-
* // Listen for incoming commands
37-
* Subscription sub = channel.listen((ctx, payload) -> {
38-
* System.out.println("Command from " + ctx.from().id() + ": " + payload.command());
39-
* });
40-
* sub.cancel(); // when done
40+
* <p>To receive incoming messages on this channel, register a listener and cancel it when done:
41+
*
42+
* <pre>{@code
43+
* Subscription sub = channel.listen((ctx, payload) ->
44+
* System.out.println("Command from " + ctx.from().id() + ": " + payload.command()));
45+
* sub.cancel();
4146
* }</pre>
4247
*
4348
* @param <P> the type of payload handled by this channel; must extend
@@ -114,6 +119,7 @@ interface Sender<P extends ChannelPayload> {
114119
* @return a {@link java.util.concurrent.CompletableFuture} that completes with the
115120
* response payload, or completes exceptionally if the default timeout elapses
116121
* before a response is received
122+
* @throws UnsupportedOperationException if this sender targets more than one server
117123
* @see #request(ChannelPayload, java.time.Duration)
118124
*/
119125
CompletableFuture<P> request(P payload);
@@ -129,6 +135,7 @@ interface Sender<P extends ChannelPayload> {
129135
* @param timeout the maximum duration to wait for a response; must not be {@code null}
130136
* @return a {@link java.util.concurrent.CompletableFuture} that completes with the
131137
* response payload, or completes exceptionally if the timeout elapses
138+
* @throws UnsupportedOperationException if this sender targets more than one server
132139
* @see #request(ChannelPayload)
133140
*/
134141
CompletableFuture<P> request(P payload, Duration timeout);

api/src/main/java/dev/objz/commandbridge/api/channel/command/CommandPayload.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,24 @@
1616
* {@link dev.objz.commandbridge.api.channel.MessageChannel} obtained from
1717
* {@link dev.objz.commandbridge.api.CommandBridgeAPI#channel(Class)}.
1818
*
19+
* <p>To run a command as the server console on a specific backend server:
20+
*
1921
* <pre>{@code
2022
* MessageChannel<CommandPayload> channel = api.channel(CommandPayload.class);
21-
*
22-
* // Execute a command as console
2323
* channel.to(List.of(Platform.backend("survival-1")))
2424
* .send(new CommandPayload("say hello", RunAs.CONSOLE));
25+
* }</pre>
26+
*
27+
* <p>To run a command as a specific online player with their normal permissions:
2528
*
26-
* // Execute as a specific player
29+
* <pre>{@code
2730
* channel.to(List.of(Platform.backend("survival-1")))
2831
* .send(new CommandPayload("home", RunAs.PLAYER, playerUUID));
32+
* }</pre>
2933
*
30-
* // Execute as a player with temporary operator permissions
34+
* <p>To run a command as a player with temporary operator-level permissions:
35+
*
36+
* <pre>{@code
3137
* channel.to(List.of(Platform.backend("survival-1")))
3238
* .send(new CommandPayload("gamemode creative", RunAs.OPERATOR, playerUUID));
3339
* }</pre>

api/src/main/java/dev/objz/commandbridge/api/channel/command/RunAs.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,21 @@
88
* commands, user-context commands with normal permissions, and elevated commands that
99
* temporarily grant operator status to a specific player.
1010
*
11-
* <p>Usage examples:
11+
* <p>To run a command as the server console, with full permissions and no player context:
12+
*
1213
* <pre>{@code
13-
* // Run a command as console
1414
* new CommandPayload("say hello", RunAs.CONSOLE)
15+
* }</pre>
1516
*
16-
* // Run a command as a specific player
17+
* <p>To run a command as a specific online player, with their normal permissions:
18+
*
19+
* <pre>{@code
1720
* new CommandPayload("home", RunAs.PLAYER, playerUUID)
21+
* }</pre>
22+
*
23+
* <p>To run a command as a player with temporary operator-level permissions:
1824
*
19-
* // Run a command as a player with operator permissions
25+
* <pre>{@code
2026
* new CommandPayload("gamemode creative", RunAs.OPERATOR, playerUUID)
2127
* }</pre>
2228
*

api/src/main/java/dev/objz/commandbridge/api/message/MessageListener.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@
1212
* which returns a {@link dev.objz.commandbridge.api.message.Subscription} that can be
1313
* used to cancel the listener.
1414
*
15+
* <p>To register a listener as a lambda and retain the returned {@link Subscription}:
16+
*
1517
* <pre>{@code
1618
* MessageChannel<CommandPayload> channel = api.channel(CommandPayload.class);
1719
*
1820
* Subscription sub = channel.listen((ctx, payload) -> {
1921
* String from = ctx.from().id();
2022
* String command = payload.command();
21-
* // handle the incoming command
2223
* });
24+
* }</pre>
2325
*
24-
* // To stop receiving messages:
26+
* <p>Pass the subscription to {@link Subscription#cancel()} to stop receiving messages:
27+
*
28+
* <pre>{@code
2529
* sub.cancel();
2630
* }</pre>
2731
*

api/src/main/java/dev/objz/commandbridge/api/message/Subscription.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@
1111
*
1212
* <p>Calling {@link #cancel()} is idempotent: invoking it more than once has no effect.
1313
*
14+
* <p>To register a listener on a channel and retain the subscription:
15+
*
1416
* <pre>{@code
15-
* // Register a listener and store the subscription
1617
* Subscription sub = api.channel(CommandPayload.class)
1718
* .listen((ctx, payload) -> handleCommand(ctx, payload));
19+
* }</pre>
1820
*
19-
* // Later, during shutdown:
21+
* <p>To cancel the listener, for example during plugin shutdown:
22+
*
23+
* <pre>{@code
2024
* sub.cancel();
2125
* }</pre>
2226
*
2327
* @see dev.objz.commandbridge.api.channel.MessageChannel#listen(dev.objz.commandbridge.api.message.MessageListener)
2428
* @see dev.objz.commandbridge.api.CommandBridgeAPI#onServerConnected(dev.objz.commandbridge.api.message.ServerEventListener)
29+
* @see dev.objz.commandbridge.api.message.MessageListener
2530
*/
2631
@FunctionalInterface
2732
public interface Subscription {

api/src/main/java/dev/objz/commandbridge/api/platform/ConnectionState.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* {@code AUTH_FAILED} and no further connection attempts are made.
1414
*
1515
* @see #isActive()
16+
* @see dev.objz.commandbridge.api.CommandBridgeAPI#connectionState()
1617
*/
1718
public enum ConnectionState {
1819

api/src/main/java/dev/objz/commandbridge/api/platform/PlayerLocator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* }</pre>
2424
*
2525
* @see dev.objz.commandbridge.api.CommandBridgeAPI#playerLocator()
26+
* @see dev.objz.commandbridge.api.platform.Platform.ServerTarget
2627
*/
2728
@FunctionalInterface
2829
public interface PlayerLocator {

0 commit comments

Comments
 (0)