How to mimic vanilla command suggestions?

Discussion in 'Plugin Development' started by JimiIT92, Nov 10, 2022.

  1. Offline

    JimiIT92

    Hello everyone :D I'm messing around with tab completions for commands and was wondering: is there any way to mimic how vanilla tab completions works?
    Let me explain:
    In vanilla if you type a wrong argument for a command you are immediately blocked from going forward. For example, if you start typing the /time command and use something like 'blabla' as subcommand, you are blocked and notified immediately that 'blabla' is not a valid subcommand
    upload_2022-11-10_12-46-31.png

    Now, in my plugin I've created a command which takes some subcommads.
    Specifically I have a /blazepoints add command which takes a numeric input. However if I type something that is not a valid argument (in this case a string), nothing stops me until I actually send the command and see an error

    upload_2022-11-10_12-49-15.png
    upload_2022-11-10_12-49-23.png

    So, is it possible to notify the user about any error in the arguments they are passing _before_ actually sending the command?

    Also: how can I suggest a JSON input, like the /tellraw command, and check at any point if that json is valid?
    For example, in the tellraw command, as long as you type a valid property for the JSON it takes it prompts you with the suggestion
    upload_2022-11-10_12-53-4.png
    However as soon as you type an unknown property you get the error
    upload_2022-11-10_12-53-31.png
     

    Attached Files:

  2. Offline

    Kars

    Yes a TabCompleter has a CommandSender which you can call .sendMessage on.
     
  3. Offline

    KarimAKL

    @JimiIT92 I believe what you're looking for is Brigadier, the open-source library by Mojang.
     

Share This Page