You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/en/guides/plugin/creating-commands.mdx
+25-12Lines changed: 25 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,27 +4,40 @@ description: "Learn how to create custom commands for your Hytale mod."
4
4
authors:
5
5
- name: "Neil Revin"
6
6
link: "https://itsneil.dev"
7
+
- name: "oskarscot"
8
+
link: "https://oskar.scot"
7
9
---
8
10
9
11
In this guide, you will learn how to create custom commands for your Hytale mod.
10
12
11
-
## The `CommandBase` Class
13
+
## The `AbstractPlayerCommand` Class
12
14
13
-
To create a command, you can extend the `CommandBase` class. You need to provide a constructor that calls the superclass constructor with the command name, description, and whether the command requires confirmation (--confirm while running the command).
15
+
To create a command, you can extend the `AbstractPlayerCommand` class. You need to provide a constructor that calls the `BaseCommand` constructor with the command name, description, and whether the command requires confirmation (--confirm while running the command).
14
16
15
-
You can override the `executeSync` function to implement the command's behavior. Here is an example of a simple command that sends a message to the command sender:
17
+
You can override the `execute` function to implement the command's behavior. It gives you access to the CommandContext which is always a player in this case, the EntityStore, the Reference store, the player reference as well as the World in which the command is being executed.
18
+
It's important to know that `AbstractPlayerCommand` extends `AbstractAsyncCommand` meaning that commands do not execute on the main server thread.
16
19
17
-
```java
18
-
publicclassExampleCommandextendsCommandBase {
20
+
You can use the `Store` along with the `Ref` to access all entity components like the `Player` component, `UUIDComponent` or `TransformComponent`.
0 commit comments