Skip to content

FakeServerCommandSource ​

com.jsmacrosce.jsmacros.client.api.classes.FakeServerCommandSource

Since1.8.4

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 ​

new FakeServerCommandSource(ClientSuggestionProvider source, LocalPlayer player)Since1.8.4#
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 queries
  • player: the player the command is being run for

Methods ​

customSuggestion ​

customSuggestion(CommandContext<?> context): CompletableFuture<Suggestions>Since1.8.4#
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 ​

getAbsoluteCoordinates(): Collection<SharedSuggestionProvider.TextCoordinates>Since1.8.4#
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 ​

getAllTeams(): Collection<String>Since1.8.4#
Returns the team names in the scoreboard held by the client's connection.
Returns: the team names in the client's scoreboard

getAvailableSounds ​

getAvailableSounds(): Stream<ResourceLocation>Since1.8.4#
Returns sound ids available through the client's sound manager.
Returns: a stream of sound ids available through the client's sound manager

getCustomTabSuggestions ​

getCustomTabSuggestions(): Collection<String>Since1.8.4#
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 ​

getOnlinePlayerNames(): Collection<String>Since1.8.4#
Returns player names currently present in the client's connection player list.
Returns: names in the client's current player list

getRelevantCoordinates ​

getRelevantCoordinates(): Collection<SharedSuggestionProvider.TextCoordinates>Since1.8.4#
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 ​

getSelectedEntities(): Collection<String>Since1.8.4#
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 ​

levels(): Set<ResourceKey<Level>>Since1.8.4#
Returns dimension keys available on the client's current connection.
Returns: the dimension keys available on the client's connection

registryAccess ​

registryAccess(): RegistryAccessSince1.8.4#
Returns registry access from the client's current connection, including registries synchronized by the server.
Returns: registry access from the client's connection

sendSuccess ​

sendSuccess(Supplier<Component> feedbackSupplier, boolean broadcastToOps): voidSince1.8.4#
Sends the supplied feedback to the local player's chat. The broadcast flag is ignored, and the supplier is evaluated once.

Parameters:

  • feedbackSupplier: supplies the feedback component
  • broadcastToOps: ignored