Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Remove ClientPlayNetworkHandlerAccessor Methods #4580

Open
2 tasks done
bruh1273 opened this issue May 10, 2024 · 0 comments
Open
2 tasks done

[Suggestion] Remove ClientPlayNetworkHandlerAccessor Methods #4580

bruh1273 opened this issue May 10, 2024 · 0 comments
Labels
enhancement New feature or request.

Comments

@bruh1273
Copy link
Contributor

Describe the feature

In ServerCommand.java, you use ClientPlayNetworkHandlerAccessor in order to retrieve the server command tree.
You don't need to even listen for the packet the server sends!
I've been using this method to get the command tree; it's the one similar to what Minecraft uses.

public static List<String> getCommand(String preCommand) {
        ClientPlayNetworkHandler h = client.player.networkHandler;
        CommandDispatcher<CommandSource> cmdD = h.getCommandDispatcher();
        CompletableFuture<Suggestions> sugg = cmdD.getCompletionSuggestions(cmdD.parse(preCommand, h.getCommandSource()), preCommand.length());
        return sugg.join().getList()
                .stream()
                .map(Suggestion::getText)
                .toList();
    }

For your use case, it would be beneficial to pass an empty string as the method parameter to get the default command tree.
Hopefully this helps!

Before submitting a suggestion

  • This feature doesn't already exist in the client. (I have checked every module and their settings on the latest dev build)

  • This wasn't already suggested. (I have searched suggestions on GitHub and read the FAQ)

@bruh1273 bruh1273 added the enhancement New feature or request. label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

1 participant