ru:tutorial:commands
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
ru:tutorial:commands [2022/02/28 12:58] – furnygo | ru:tutorial:commands [2022/03/03 12:50] – furnygo | ||
---|---|---|---|
Line 2: | Line 2: | ||
Создание команд позволяет разработчику наращивать функционал и способ воздействия с пользователем через, собственно, | Создание команд позволяет разработчику наращивать функционал и способ воздействия с пользователем через, собственно, | ||
- | Это руководство расскажет как регистрировать команды и общую инофрмацию о структуре Brigadier. | + | Это руководство расскажет как регистрировать команды и общую информацию о структуре Brigadier. |
Примечание: | Примечание: | ||
Line 100: | Line 100: | ||
Примечание: | Примечание: | ||
- | Аргументы | + | Аргументы |
Аргументы Minecraft находятся в разделе '' | Аргументы Minecraft находятся в разделе '' | ||
CommandManager находится в '' | CommandManager находится в '' | ||
- | ==== Подкоманда ==== | + | ===== Подкоманда |
Чтобы добавить команде подкоманду, | Чтобы добавить команде подкоманду, | ||
Line 115: | Line 115: | ||
В целом, чтобы получить подкоманду, | В целом, чтобы получить подкоманду, | ||
- | То, что показано ниже, создаёт команду '' | + | То, что показано ниже, создаёт команду '' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Line 123: | Line 123: | ||
</ | </ | ||
- | It is advised to indent your code as you add nodes to the command. Usually the indentation corresponds to how many nodes deep one is on the command tree. The new line also makes it visible that another node is being added. There are alternative styles to formatting the tree command that are shown later on in this tutorial. | + | Рекомендуется делать отступы в вашем коде при добавлении узлов в команду. Обычно отступ соответствует количеству глубоких узлов в дереве команд. Новая строка также делает видимым, |
- | **So let's try running the command** | + | **Итак, давайте попробуем выполнить команду** |
- | Most likely if you typed ''/ | + | Скорее всего, если вы наберете |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Line 141: | Line 141: | ||
</ | </ | ||
- | ===== Registering the commands | + | ===== Регистрация команд |
- | Registering commands is done by registering a callback using the '' | + | Регистрация команд выполняется путем регистрации обратного вызова с помощью |
- | The event should be registered in your mod's initializer. The callback has two parameters. The '' | + | Событие должно быть зарегистрировано в инициализаторе вашего мода. Обратный вызов имеет два параметра. '' |
Line 159: | Line 159: | ||
</ | </ | ||
- | Inside your lambda, method reference or whatever you have chosen, you will register your commands. | + | Внутри вашего лямбда-выражения, ссылки на метод или чего бы вы ни выбрали, зарегистрируете свои команды: |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Line 175: | Line 175: | ||
</ | </ | ||
- | If desired, you can make sure a command is only registered on a dedicated server by checking the '' | + | При желании вы можете убедиться, что команда зарегистрирована только на выделенном сервере, |
Line 191: | Line 191: | ||
</ | </ | ||
- | And vice versa | + | И наоборот: |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Line 206: | Line 206: | ||
</ | </ | ||
- | ===== Arguments | + | ===== Аргументы |
- | Arguments in Brigadier | + | Аргументы в Brigadier |
- | Minecraft | + | Minecraft |
- | **TODO:** Go into more detail on how to use arguments | + | **Будет сделано позже:** Подробнее о том, как использовать аргументы. |
- | ====== | + | ====== |
- | Below are links to the articles about more complex concepts used in brigadier. | + | Ниже приведены ссылки на статьи о более сложных концепциях, |
- | ^ Page ^ Description | + | ^ Страница |
- | | [[tutorials: | + | | [[ru:tutorial: |
- | | [[tutorials: | + | | [[ru:tutorial: |
- | | [[tutorial:command_suggestions|Suggestions]] | Suggesting input to be sent to the client. | | + | | [[ru:tutorial:commands: |
- | | [[tutorials: | + | | [[ru:tutorial: |
- | | [[tutorials: | + | | [[ru:tutorial: |
- | | [[tutorials: | + | | [[ru:tutorial: |
- | **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. | + | ==== Поймать или вызвать исключение CommandSyntaxException ==== |
- | ==== Catch or throw a CommandSyntaxException | + | Решение этой проблемы состоит в том, чтобы заставить методы run или suggest вызывать исключение |
- | 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 '' | + | ===== Могу ли я зарегистрировать команды на стороне клиента? |
- | ===== Can I register client side commands? ===== | + | Fabric в настоящее время не поддерживает команды на стороне клиента. Существует [[https:// |
- | Fabric doesn' | + | ===== " |
- | ===== 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 '' | + | После этого вам нужно снова отправить дерево команд каждому игроку, |
- | After that you need to send the command tree to every player again using '' | + | ==== Могу ли я отменить регистрацию команд во время выполнения? |
- | ==== 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 '' | + | |
---- | ---- | ||
- | ====== | + | ====== |
**__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.__** |
ru/tutorial/commands.txt · Last modified: 2022/03/03 13:27 by furnygo