Skip to content

Commit ec84192

Browse files
committed
Player Games
1 parent 11d5e6f commit ec84192

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

common/src/main/kotlin/dev/chasem/cobblemonextras/CobblemonExtras.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ object CobblemonExtras {
165165
GivePokeToken().register(dispatcher)
166166
BattleSpectate().register(dispatcher)
167167
GiveShinyBall().register(dispatcher)
168+
PlayerGames().register(dispatcher)
168169
}
169170

170171
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package dev.chasem.cobblemonextras.commands
2+
3+
import com.mojang.brigadier.CommandDispatcher
4+
import com.mojang.brigadier.context.CommandContext
5+
import net.minecraft.ChatFormatting
6+
import net.minecraft.commands.CommandSourceStack
7+
import net.minecraft.commands.Commands
8+
import net.minecraft.network.chat.ClickEvent
9+
import net.minecraft.network.chat.Component
10+
import net.minecraft.network.chat.HoverEvent
11+
import net.minecraft.network.chat.Style
12+
import net.minecraft.server.level.ServerPlayer
13+
14+
class PlayerGames {
15+
fun register(dispatcher: CommandDispatcher<CommandSourceStack>) {
16+
dispatcher.register(
17+
Commands.literal("playergames")
18+
.executes { ctx: CommandContext<CommandSourceStack> -> this.execute(ctx) }
19+
)
20+
}
21+
22+
private fun execute(ctx: CommandContext<CommandSourceStack>): Int {
23+
if (ctx.getSource().getPlayer() != null) {
24+
val player: ServerPlayer = ctx.getSource().getPlayer()!!
25+
val hoverable = Component.literal("PLAYER GAMES").withStyle(
26+
Style.EMPTY.withUnderlined(true)
27+
.withColor(ChatFormatting.LIGHT_PURPLE)
28+
.withClickEvent(ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.player.games/en-US/creator-hub"))
29+
.withHoverEvent(HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Click to go to Player.Games!")))
30+
)
31+
player.sendSystemMessage(Component.literal("Create your own Minecraft mod with ").append(hoverable))
32+
} else {
33+
ctx.getSource().sendFailure(Component.literal("Sorry, this is only for players."))
34+
}
35+
return 1
36+
}
37+
}

0 commit comments

Comments
 (0)