FakeServerCommandSource
com.jsmacrosce.jsmacros.client.api.classes.FakeServerCommandSource
A client-side command source that delegates suggestion and connection data to the client's ClientSuggestionProvider. Scripts encounter it as the source in a client command's raw context rather than constructing it directly.
js
// Read the client-side command source through the raw context.
const builder = Chat.getCommandManager().createCommandBuilder("probe");
builder.intArg("count", 1, 64);
builder.executes(JavaWrapper.methodToJava(function (ctx) {
const src = ctx.getRaw().getSource();
const players = src.getOnlinePlayerNames();
Chat.log(`${players.size()} players online`);
return true;
}));
builder.register();Constructors
new FakeServerCommandSource
Builds a client-side command source using the supplied player and suggestion provider.
Parameters:
source: the client provider used to answer suggestion and connection-data queriesplayer: the player the command is being run for
Methods
customSuggestion
Requests completions for the command input from the server. A new request cancels the previous pending request from this provider.
Parameters:
context: command context whose input is sent for completion
Returns: the future completed with the server's response; a subsequent request cancels it
getAbsoluteCoordinates
Supplies the crosshair hit point for absolute coordinate suggestions, formatted to two decimal places, or the default three tildes when it is not on a block. Unlike getRelevantCoordinates(), this uses the hit point rather than the block position.
Returns: one hit-point coordinate form, or the default three-tildes form
getAllTeams
Returns the team names in the scoreboard held by the client's connection.
Returns: the team names in the client's scoreboard
getAvailableSounds
Returns sound ids available through the client's sound manager.
Returns: a stream of sound ids available through the client's sound manager
getCustomTabSuggestions
Returns server-provided custom completions together with online player names. If no custom completions are present, the result contains the online player names alone.
Returns: custom completions and online player names from the client provider
getOnlinePlayerNames
Returns player names currently present in the client's connection player list.
Returns: names in the client's current player list
getRelevantCoordinates
Supplies the block position under the crosshair for coordinate suggestions, or the default three tildes when the crosshair is not on a block.
Returns: one block-position coordinate form, or the default three-tildes form
getSelectedEntities
Returns the UUID string of the entity under the client's crosshair, if the current hit is an entity.
Returns: the entity's UUID string, in a collection of at most one, or an empty collection otherwise
levels
Returns dimension keys available on the client's current connection.
Returns: the dimension keys available on the client's connection
registryAccess
Returns registry access from the client's current connection, including registries synchronized by the server.
Returns: registry access from the client's connection