User Tools

Site Tools


tutorial:commands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:commands [2020/11/25 08:18] – [Advanced concepts] Reword description of arg types i509vcbtutorial:commands [2021/01/07 11:13] – fix misplaced ) in requires example juuz
Line 222: Line 222:
 | [[tutorials:commands:requirements|Requirements]]               | Only allow users to execute commands in certain scenarios.                      | | [[tutorials:commands:requirements|Requirements]]               | Only allow users to execute commands in certain scenarios.                      |
 | [[tutorials:commands:exceptions  |Exceptions]]                 | Fail execution of a command with a descriptive message and in certain contexts. |                                                                   | [[tutorials:commands:exceptions  |Exceptions]]                 | Fail execution of a command with a descriptive message and in certain contexts. |                                                                  
-| [[tutorials:commands:suggestions |Suggestions]]                | Suggesting input to be sent to the client.                                      |+| [[tutorials:commands:suggestions |Suggestions]]                | Suggesting command input for the client.                                        |
 | [[tutorials:commands:redirects_aliases|Redirects (Aliases)]]   | Allow use of aliases to execute commands.                                       | | [[tutorials:commands:redirects_aliases|Redirects (Aliases)]]   | Allow use of aliases to execute commands.                                       |
 | [[tutorials:commands:redirects_chaining|Redirects (Chaining)]] | Allow commands to have repeating elements and flags.                            | | [[tutorials:commands:redirects_chaining|Redirects (Chaining)]] | Allow commands to have repeating elements and flags.                            |
Line 237: Line 237:
 ==== Catch or throw a CommandSyntaxException ==== ==== Catch or throw a CommandSyntaxException ====
  
-The solution to this issue is to make the run or suggest methods throw a ''CommandSyntaxException''. Brigadier will handle the checked exceptions and forward the proper error message in game for you.+The solution to this issue is to make the ''run'' or ''suggest'' methods throw a ''CommandSyntaxException''. Brigadier will handle the checked exceptions and forward the proper error message in game for you.
  
 ==== Issues with generics ==== ==== Issues with generics ====
Line 280: Line 280:
  .requires(source -> source.hasPermissionLevel(4))  .requires(source -> source.hasPermissionLevel(4))
  .executes(ctx -> {  .executes(ctx -> {
- ctx.getSource().sendFeedback(new LiteralText("You are an operator", false));+ ctx.getSource().sendFeedback(new LiteralText("You are an operator"), false);
  return 1;  return 1;
  });  });
tutorial/commands.txt · Last modified: 2024/02/23 14:22 by allen1210