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 revision Previous revision
tutorial:commands [2020/06/14 05:13]
i509vcb Refactor FAQ section
tutorial:commands [2020/06/14 05:17] (current)
i509vcb Move old categories below FAQ to be migrated
Line 186: Line 186:
 Arguments in Brigadier both parse and error check any inputted arguments. Arguments in Brigadier both parse and error check any inputted arguments.
 Minecraft creates some special argument types for it's own use such as the ''​EntityArgumentType''​ which represents the in-game entity selectors ''​@a,​ @r, @p, @e[type=!player,​ limit=1, distance=..2]'',​ or an ''​NbtTagArgumentType''​ that parses stringified nbt (snbt) and verifies that the input is the correct syntax. Minecraft creates some special argument types for it's own use such as the ''​EntityArgumentType''​ which represents the in-game entity selectors ''​@a,​ @r, @p, @e[type=!player,​ limit=1, distance=..2]'',​ or an ''​NbtTagArgumentType''​ that parses stringified nbt (snbt) and verifies that the input is the correct syntax.
 +
 +**TODO:** Go into more detail on how to use arguments
  
 ===== Static Imports ===== ===== Static Imports =====
Line 225: Line 227:
  
 **TODO:** Sections are being moved to sub categories and will be added to their respective articles as they are migrated. **TODO:** Sections are being moved to sub categories and will be added to their respective articles as they are migrated.
 +
 +====== FAQ ======
 +
 +===== Why does my command not compile =====
 +
 +There are two immediate possibilities for why this could occur.
 +
 +==== Catch or throw a CommandSyntaxException ====
 +
 +The solution to this issue is to make the run or suggest methods throw a CommandSyntaxException. Don't worry, brigadier will handle the exceptions and output the proper error message.
 +
 +==== Issues with generics ====
 +
 +You may have an issue with generic types once in a while. Verify you are using ''​CommandManager.literal(...)''​ or ''​CommandManager.argument(...)''​ instead ''​LiteralArgumentBuilder''​ or ''​RequiredArgumentBuilder''​.
 +
 +===== Can I register client side commands? =====
 +
 +Fabric doesn'​t currently support client side commands. There is a [[https://​github.com/​CottonMC/​ClientCommands|third-party mod]] by the Cotton team that adds this functionality.
 +
 +===== Dark Arts =====
 +
 +A few things we don't recommend, but are possible.
 +
 +==== Can I register commands in runtime? ====
 +
 +You can do this but it is not recommended. You would get the ''​CommandManager''​ from the server and add anything commands you wish to it's ''​CommandDispatcher''​.
 +
 +After that you need to send the command tree to every player again using ''​sendCommandTree(ServerPlayerEntity)''​. This is required because the client locally caches the command tree it receives during login (or when operator packets are sent) for local completions rich error messages.
 +
 +==== Can I unregister commands in runtime? ====
 +
 +You can also do this, however it is much less stable than registering commands and could cause unwanted side effects. To keep things simple, you need to use reflection on brigadier and remove the nodes. After this, you need to send the command tree to every player again using ''​sendCommandTree(ServerPlayerEntity)''​. If you don't send the updated command tree, the client may think a command still exists, even though the server will fail execution.
 +
 +----
  
 ====== Sorry for the mess ====== ====== Sorry for the mess ======
  
-__Currently this article is being migrated, so things may be a mess. Below is are the parts of the article that are yet to be migrated to the new format.__+**__Currently this article is being migrated, so things may be a mess. Below is are the parts of the article that are yet to be migrated to the new format.__**
  
 ===== Requirements ===== ===== Requirements =====
Line 595: Line 631:
 } }
 </​file>​ </​file>​
-====== FAQ ====== 
- 
-===== Why does my command not compile ===== 
- 
-There are two immediate possibilities for why this could occur. 
- 
-==== Catch or throw a CommandSyntaxException ==== 
- 
-The solution to this issue is to make the run or suggest methods throw a CommandSyntaxException. Don't worry, brigadier will handle the exceptions and output the proper error message. 
- 
-==== Issues with generics ==== 
- 
-You may have an issue with generic types once in a while. Verify you are using ''​CommandManager.literal(...)''​ or ''​CommandManager.argument(...)''​ instead ''​LiteralArgumentBuilder''​ or ''​RequiredArgumentBuilder''​. 
- 
-===== Can I register client side commands? ===== 
- 
-Fabric doesn'​t currently support client side commands. There is a [[https://​github.com/​CottonMC/​ClientCommands|third-party mod]] by the Cotton team that adds this functionality. 
- 
-===== Dark Arts ===== 
- 
-A few things we don't recommend, but are possible. 
- 
-==== Can I register commands in runtime? ==== 
- 
-You can do this but it is not recommended. You would get the ''​CommandManager''​ from the server and add anything commands you wish to it's ''​CommandDispatcher''​. 
- 
-After that you need to send the command tree to every player again using ''​sendCommandTree(ServerPlayerEntity)''​. This is required because the client locally caches the command tree it receives during login (or when operator packets are sent) for local completions rich error messages. 
- 
-==== Can I unregister commands in runtime? ==== 
- 
-You can also do this, however it is much less stable than registering commands and could cause unwanted side effects. To keep things simple, you need to use reflection on brigadier and remove the nodes. After this, you need to send the command tree to every player again using ''​sendCommandTree(ServerPlayerEntity)''​. If you don't send the updated command tree, the client may think a command still exists, even though the server will fail execution. 
tutorial/commands.txt ยท Last modified: 2020/06/14 05:17 by i509vcb