minecraft-mod/Essentials/src/main/kotlin/com/beemer/essentials/command/HelpCommand.kt
Caadiq 8cc50ce449 feat: Shift+F 메뉴 GUI 구현
- EssentialsMenuGui 추가 (스폰, 좌표, 제작대, TPA 바로가기)
- Mixin으로 손 바꾸기 패킷 가로채기 (빈 손에서도 작동)
- Shift+F: 손 바꾸기 차단 + 메뉴 GUI 열기
- /메뉴, /menu 명령어 추가
- 도움말에 메뉴 카테고리 추가
2025-12-29 15:44:48 +09:00

124 lines
5.3 KiB
Kotlin

package com.beemer.essentials.command
import net.minecraft.ChatFormatting
import net.minecraft.commands.Commands
import net.minecraft.network.chat.Component
import net.minecraft.server.level.ServerPlayer
import net.neoforged.bus.api.SubscribeEvent
import net.neoforged.neoforge.event.RegisterCommandsEvent
object HelpCommand {
@SubscribeEvent
fun onRegisterCommands(event: RegisterCommandsEvent) {
listOf("도움말", "help", "essentials").forEach { command ->
event.dispatcher.register(
Commands.literal(command).executes { context ->
val player = context.source.entity as? ServerPlayer ?: return@executes 0
showHelp(player)
1
}
)
}
}
private fun showHelp(player: ServerPlayer) {
val header =
Component.literal("══════════ ")
.withStyle { it.withColor(ChatFormatting.DARK_GRAY) }
.append(
Component.literal("도움말").withStyle {
it.withColor(ChatFormatting.GOLD).withBold(true)
}
)
.append(
Component.literal(" ══════════").withStyle {
it.withColor(ChatFormatting.DARK_GRAY)
}
)
player.sendSystemMessage(header)
player.sendSystemMessage(Component.empty())
// 좌표 관리
sendCategory(player, "좌표 관리", ChatFormatting.YELLOW)
sendCommand(player, "/좌표", "저장된 좌표 목록 (GUI)")
sendCommand(player, "/좌표추가 <이름>", "현재 위치 저장")
sendCommand(player, "/좌표이동 <이름>", "해당 좌표로 이동")
sendCommand(player, "/좌표제거 <이름>", "저장된 좌표 삭제")
player.sendSystemMessage(Component.empty())
// 스폰
sendCategory(player, "스폰", ChatFormatting.GREEN)
sendCommand(player, "/스폰", "스폰으로 이동")
sendCommand(player, "/스폰설정", "현재 위치를 스폰으로 설정")
sendCommand(player, "/스폰삭제", "커스텀 스폰 삭제")
player.sendSystemMessage(Component.empty())
// 텔레포트
sendCategory(player, "텔레포트", ChatFormatting.AQUA)
sendCommand(player, "/tpa", "플레이어 선택 (GUI)")
sendCommand(player, "/back", "이전 위치로 이동")
player.sendSystemMessage(Component.empty())
// 닉네임
sendCategory(player, "닉네임", ChatFormatting.LIGHT_PURPLE)
sendCommand(player, "/닉네임 변경 <닉네임>", "닉네임 설정")
sendCommand(player, "/닉네임 초기화", "닉네임 초기화")
player.sendSystemMessage(Component.empty())
// 머리
sendCategory(player, "머리", ChatFormatting.GOLD)
sendCommand(player, "/머리", "내 머리 아이템 받기")
sendCommand(player, "/머리 <닉네임>", "해당 플레이어 머리 받기")
player.sendSystemMessage(Component.empty())
// 제작대
sendCategory(player, "제작대", ChatFormatting.WHITE)
sendCommand(player, "/제작대", "제작대 열기")
player.sendSystemMessage(Component.empty())
// 메뉴
sendCategory(player, "메뉴", ChatFormatting.LIGHT_PURPLE)
sendCommand(player, "/메뉴", "메뉴 GUI 열기")
sendCommand(player, "Shift + F", "메뉴 GUI 열기 (단축키)")
val footer =
Component.literal("═══════════════════════════════").withStyle {
it.withColor(ChatFormatting.DARK_GRAY)
}
player.sendSystemMessage(footer)
}
private fun sendCategory(player: ServerPlayer, name: String, color: ChatFormatting) {
val message =
Component.literal("")
.withStyle { it.withColor(color) }
.append(
Component.literal(name).withStyle {
it.withColor(color).withBold(true)
}
)
player.sendSystemMessage(message)
}
private fun sendCommand(player: ServerPlayer, cmd: String, desc: String) {
val message =
Component.literal(" ")
.append(
Component.literal(cmd).withStyle {
it.withColor(ChatFormatting.WHITE)
}
)
.append(
Component.literal(" - ").withStyle {
it.withColor(ChatFormatting.DARK_GRAY)
}
)
.append(
Component.literal(desc).withStyle {
it.withColor(ChatFormatting.GRAY)
}
)
player.sendSystemMessage(message)
}
}