Skip to content

Commit 01ab41d

Browse files
authored
Update failure methods to reflect relocated methods to platform-specific classes (#19)
1 parent fc78c68 commit 01ab41d

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

docs/en/create-commands/executors/handle-failures.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
order: 6
3+
preferences: ["paper-spigot"]
34
authors:
45
- DerEchtePilz
56
- willkroboth
@@ -11,14 +12,26 @@ authors:
1112

1213
Sometimes, you want your command to fail on purpose. This is the way to "gracefully" handle errors in your command execution. This is performed by throwing any of the following methods:
1314

15+
<div class="paper">
16+
1417
```java
1518
throw CommandAPI.failWithString(String message);
1619
throw CommandAPI.failWithMessage(Message message);
17-
throw CommandAPIBukkit.failWithBaseComponents(BaseComponent... message);
18-
throw CommandAPIBukkit.failWithAdventureComponent(Component message);
19-
throw CommandAPIBukkit.failWithAdventureComponent(ComponentLike message);
20+
throw CommandAPIPaper.failWithAdventureComponent(Component message);
21+
throw CommandAPIPaper.failWithAdventureComponent(ComponentLike message);
2022
```
2123

24+
</div>
25+
<div class="spigot">
26+
27+
```java
28+
throw CommandAPI.failWithString(String message);
29+
throw CommandAPI.failWithMessage(Message message);
30+
throw CommandAPISpigot.failWithBaseComponents(BaseComponent... message);
31+
```
32+
33+
</div>
34+
2235
When the CommandAPI handles the fail method, it will cause the command to return a _success value_ of 0, to indicate failure.
2336

2437
::::tip Example - Command failing for an element not in a list
@@ -39,4 +52,4 @@ Therefore, to gracefully handle this with a proper error message, we use one of
3952
:::info
4053
In general, it's a good idea to handle unexpected cases with one of the `CommandAPI.failWithXXX()` methods.
4154
Most arguments used by the CommandAPI will have their own built-in failsafe system _(e.g., the `EntitySelectorArgument` will not execute the command executor if it fails to find an entity)_, so this feature is for those extra cases.
42-
:::
55+
:::

0 commit comments

Comments
 (0)