We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
CommandContext<...>.playerName()
#server
1 parent 7b462cc commit 0f31e84Copy full SHA for 0f31e84
src/main/kotlin/com/mairwunnx/projectessentials/core/extensions/CommandContextExtensions.kt
@@ -14,7 +14,10 @@ fun CommandContext<CommandSource>.isPlayerSender(): Boolean =
14
this.source.entity is ServerPlayerEntity
15
16
/**
17
- * @return player nickname from CommandContext.
+ * @return if command source is player then nickname
18
+ * from CommandContext. If command source is server
19
+ * then return `#server`.
20
* @since 1.14.4-1.0.1.0
21
*/
-fun CommandContext<CommandSource>.playerName(): String = this.source.asPlayer().name.string
22
+fun CommandContext<CommandSource>.playerName(): String =
23
+ if (this.isPlayerSender()) this.source.asPlayer().name.string else "#server"
0 commit comments