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: docs/paper/dev/api/command-api/misc/basic-command.mdx
+9-21Lines changed: 9 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,13 +93,9 @@ operator permissions. You can also set this permission to be `true` by default.
93
93
Now, in our `execute` method, we can retrieve the name of the executor of that command. If we do not find one, we can just get the name of the command sender, like this:
94
94
95
95
```java
96
-
finalComponent name;
97
-
if (commandSourceStack.getExecutor() !=null) {
98
-
name = commandSourceStack.getExecutor().name();
99
-
}
100
-
else {
101
-
name = commandSourceStack.getSender().name();
102
-
}
96
+
finalComponent name = commandSourceStack.getExecutor() !=null
97
+
? commandSourceStack.getExecutor().name()
98
+
: commandSourceStack.getSender().name();
103
99
```
104
100
105
101
This makes sure that we cover all cases and even allow the command to work correctly with `/execute as`.
@@ -146,13 +142,9 @@ public class BroadcastCommand implements BasicCommand {
0 commit comments