Skip to content

Commit d209b42

Browse files
committed
docs: format Command.md
1 parent b7779f4 commit d209b42

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

docs/apis/GameAPI/Command.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mc.runcmd("say Hello!")
3838
- For a returned execution result object res, there are the following members:
3939

4040
| Members | Meaning | Data Type |
41-
| ----------- | ------------------------------------------------- | --------- |
41+
| ----------- | ------------------------------------------------- | --------- |
4242
| res.success | Whether the execution was successful. | `Boolean` |
4343
| res.output | The output result after BDS executes the command. | `String` |
4444

@@ -75,19 +75,19 @@ letters!
7575
The description text for the command.
7676
- permission : `PermType`
7777
(Optional parameter)
78-
79-
| Execution Permission | Meaning |
80-
| ---------------------- | --------------------------------------------------- |
81-
| `PermType.Any` | Anyone can execute the command. |
82-
| `PermType.GameMasters` | Only the OP can execute the command.(Default value) |
83-
| `PermType.Console` | Only the console can execute the command. |
84-
8578
- flag : `Integer`
8679
(Optional parameter) Default value is `0x80`
8780
At present, you can directly press this input, and related modifications will be made in the future.
8881
- alias : `String`
8982
(Optional argument) Add an alias for the command.
9083
Multiple aliases can be set for a command, which is equivalent to triggering the same command when executed.
84+
85+
| Execution Permission | Meaning |
86+
|------------------------|-----------------------------------------------------|
87+
| `PermType.Any` | Anyone can execute the command. |
88+
| `PermType.GameMasters` | Only the OP can execute the command.(Default value) |
89+
| `PermType.Console` | Only the console can execute the command. |
90+
9191
- Return value: Command Object.
9292
- Return value type: `Command`
9393

docs/apis/GameAPI/Command.zh.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ mc.runcmd("say Hello!")
3939

4040
- 对于返回的某个执行结果对象res,有如下这些成员:
4141

42-
| 成员 | 含义 | 类型 |
43-
| ----------- | ----------------------- | --------- |
44-
| res.success | 是否执行成功 | `Boolean` |
45-
| res.output | BDS执行命令后的输出结果 | `String` |
42+
| 成员 | 含义 | 类型 |
43+
|-------------|---------------|-----------|
44+
| res.success | 是否执行成功 | `Boolean` |
45+
| res.output | BDS执行命令后的输出结果 | `String` |
4646

4747
!!! note
4848
runcmdEx 与普通 runcmd 实现区别非常大,在于 Ex 版本拥有**隐藏输出**的机制,执行结果不会输出至控制台,因此如果有需要,要手动用
@@ -67,32 +67,26 @@ addon 中,也可以使用这里所注册的命令。
6767
`mc.newCommand(cmd,description[,permission,flag,alias])`
6868

6969
- 参数:
70-
7170
- cmd : `String`
7271
待注册的命令
73-
7472
- description : `String`
7573
命令描述文本
76-
77-
- permission : `PermType`
74+
- permission : `PermType`
7875
(可选参数)指令执行所需权限
79-
80-
| 执行权限 | 含义 |
81-
| ---------------------- | -------------------------------- |
82-
| `PermType.Any` | 任何人都可以执行这条指令 |
83-
| `PermType.GameMasters` | 只有OP可以执行这条指令(默认值) |
84-
| `PermType.Console` | 只有控制台可以执行这条指令 |
85-
8676
- flag : `Integer`
8777
(可选参数)默认值 `0x80`
8878
目前直接按此输入即可,后续会进行相关修改
89-
9079
- alias : `String`
9180
(可选参数)命令的别名
9281
可以为命令设置多个别名,执行的时候相当于触发同一条命令
9382

94-
- 返回值:指令对象
83+
| 执行权限 | 含义 |
84+
|------------------------|-------------------|
85+
| `PermType.Any` | 任何人都可以执行这条指令 |
86+
| `PermType.GameMasters` | 只有OP可以执行这条指令(默认值) |
87+
| `PermType.Console` | 只有控制台可以执行这条指令 |
9588

89+
- 返回值:指令对象
9690
- 返回值类型:`Command`
9791

9892
!!! tip

src/legacy/api/CommandAPI.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,11 @@ Local<Value> convertResult(ParamStorageType const& result, CommandOrigin const&
9999
);
100100
} else if (result.hold(ParamKind::Kind::Item)) {
101101
return ItemClass::newItem(
102-
new ItemStack(std::get<CommandItem>(result.value())
103-
.createInstance(1, 1, output, true)
104-
.value_or(ItemInstance::EMPTY_ITEM())),
102+
new ItemStack(
103+
std::get<CommandItem>(result.value())
104+
.createInstance(1, 1, output, true)
105+
.value_or(ItemInstance::EMPTY_ITEM())
106+
),
105107
false
106108
); // Not managed by BDS, pointer will be saved as unique_ptr
107109
} else if (result.hold(ParamKind::Kind::Actor)) {
@@ -131,9 +133,11 @@ Local<Value> convertResult(ParamStorageType const& result, CommandOrigin const&
131133
dim ? dim->getDimensionId().id : -1
132134
);
133135
} else if (result.hold(ParamKind::Kind::Message)) {
134-
return String::newString(std::get<CommandMessage>(result.value())
135-
.generateMessage(origin, CommandVersion::CurrentVersion())
136-
.mMessage->c_str());
136+
return String::newString(
137+
std::get<CommandMessage>(result.value())
138+
.generateMessage(origin, CommandVersion::CurrentVersion())
139+
.mMessage->c_str()
140+
);
137141
} else if (result.hold(ParamKind::Kind::RawText)) {
138142
return String::newString(std::get<CommandRawText>(result.value()).getText());
139143
} else if (result.hold(ParamKind::Kind::JsonValue)) {

0 commit comments

Comments
 (0)