|
| 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