Skip to content

Commit 6040b2d

Browse files
committed
PlayerVariable.kt improved.
Signed-off-by: Pavel Erokhin (MairwunNx) <[email protected]>
1 parent a0738aa commit 6040b2d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/main/kotlin/com/mairwunnx/projectessentials/chat/impl/variables/PlayerVariable.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,20 @@ package com.mairwunnx.projectessentials.chat.impl.variables
22

33
import com.mairwunnx.projectessentials.chat.api.variables.IChatVariable
44
import net.minecraft.entity.player.ServerPlayerEntity
5+
import net.minecraft.util.text.ITextComponent
6+
import net.minecraft.util.text.Style
7+
import net.minecraft.util.text.TextComponentUtils
8+
import net.minecraft.util.text.event.ClickEvent
59

610
object PlayerVariable : IChatVariable {
711
override val variable = "player"
8-
override fun process(player: ServerPlayerEntity) = player.gameProfile.name!!
12+
override fun process(
13+
player: ServerPlayerEntity
14+
): ITextComponent = TextComponentUtils.toTextComponent { player.gameProfile.name!! }.setStyle(
15+
Style().apply {
16+
clickEvent = ClickEvent(
17+
ClickEvent.Action.SUGGEST_COMMAND, "/m ${player.gameProfile.name!!}"
18+
)
19+
}
20+
)
921
}

0 commit comments

Comments
 (0)