도움말 명령어 추가, /안티몹 /밭보호 명령어 OP만 사용 가능하도록 수정

This commit is contained in:
Caadiq 2025-12-18 23:22:50 +09:00
parent e4337b9e12
commit ad253e8499
5 changed files with 164 additions and 28 deletions

View file

@ -17,6 +17,7 @@
- 🛡️ **안티몹** - 특정 몹 패턴 비활성화 - 🛡️ **안티몹** - 특정 몹 패턴 비활성화
- 🌾 **밭 보호** - 밟아도 밭이 망가지지 않도록 보호 - 🌾 **밭 보호** - 밟아도 밭이 망가지지 않도록 보호
- 💬 **채팅 관리** - 채팅 형식 변경 - 💬 **채팅 관리** - 채팅 형식 변경
- 🗿 **머리 아이템** - 플레이어 머리 아이템 지급
--- ---
@ -67,6 +68,13 @@
| ----------------------------- | ------------ | | ----------------------------- | ------------ |
| `/밭보호`, `/protectfarmland` | 밭 보호 토글 | | `/밭보호`, `/protectfarmland` | 밭 보호 토글 |
### 머리
| 명령어 | 설명 |
| --------------------- | ------------------------------ |
| `/머리`, `/head` | 자신의 머리 아이템 받기 |
| `/머리 <닉네임/이름>` | 해당 플레이어 머리 아이템 받기 |
### 채팅 (관리자) ### 채팅 (관리자)
| 명령어 | 설명 | | 명령어 | 설명 |

View file

@ -32,5 +32,6 @@ class Essentials(modEventBus: IEventBus) {
NeoForge.EVENT_BUS.register(CoordinateCommand) NeoForge.EVENT_BUS.register(CoordinateCommand)
NeoForge.EVENT_BUS.register(NicknameCommand) NeoForge.EVENT_BUS.register(NicknameCommand)
NeoForge.EVENT_BUS.register(HeadCommand) NeoForge.EVENT_BUS.register(HeadCommand)
NeoForge.EVENT_BUS.register(HelpCommand)
} }
} }

View file

@ -16,26 +16,28 @@ object AntimobCommand {
fun onRegisterCommands(event: RegisterCommandsEvent) { fun onRegisterCommands(event: RegisterCommandsEvent) {
listOf("antimob", "안티몹").forEach { command -> listOf("antimob", "안티몹").forEach { command ->
event.dispatcher.register( event.dispatcher.register(
Commands.literal(command).executes { context -> Commands.literal(command).requires { it.hasPermission(2) }.executes { context ->
val player = CommandUtils.getPlayerOrSendFailure(context.source) ?: return@executes 0 val player =
CommandUtils.getPlayerOrSendFailure(context.source)
?: return@executes 0
AntimobConfig.loadConfig() AntimobConfig.loadConfig()
val container = SimpleContainer(9 * 2) val container = SimpleContainer(9 * 2)
player.openMenu( player.openMenu(
SimpleMenuProvider({ windowId, inv, _ -> SimpleMenuProvider(
AntimobGui( { windowId, inv, _ ->
windowId, AntimobGui(windowId, inv, container, player)
inv, },
container, Component.literal("안티몹 설정").withStyle {
player it.withColor(ChatFormatting.DARK_GRAY)
) }
}, Component.literal("안티몹 설정").withStyle { it.withColor(ChatFormatting.DARK_GRAY) }) )
) )
1 1
} }
) )
} }
} }
} }

View file

@ -0,0 +1,113 @@
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, "/머리 <닉네임>", "해당 플레이어 머리 받기")
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)
}
}

View file

@ -13,19 +13,31 @@ object ProtectFarmlandCommand {
fun onRegisterCommands(event: RegisterCommandsEvent) { fun onRegisterCommands(event: RegisterCommandsEvent) {
listOf("protectfarmland", "밭보호").forEach { command -> listOf("protectfarmland", "밭보호").forEach { command ->
event.dispatcher.register( event.dispatcher.register(
Commands.literal(command).executes { context -> Commands.literal(command).requires { it.hasPermission(2) }.executes { context ->
val player = CommandUtils.getPlayerOrSendFailure(context.source) ?: return@executes 0 val player =
CommandUtils.getPlayerOrSendFailure(context.source)
?: return@executes 0
val enabled = ProtectFarmlandConfig.toggle() val enabled = ProtectFarmlandConfig.toggle()
player.sendSystemMessage( player.sendSystemMessage(
Component.literal("밭 보호를 ").withStyle { it.withColor(ChatFormatting.GOLD) } Component.literal("밭 보호를 ")
.append(Component.literal(if (enabled) "활성화" else "비활성화").withStyle { it.withColor(ChatFormatting.DARK_GREEN) }) .withStyle { it.withColor(ChatFormatting.GOLD) }
.append(Component.literal("했습니다.").withStyle { it.withColor(ChatFormatting.GOLD) }) .append(
) Component.literal(if (enabled) "활성화" else "비활성화")
1 .withStyle {
} it.withColor(ChatFormatting.DARK_GREEN)
}
)
.append(
Component.literal("했습니다.").withStyle {
it.withColor(ChatFormatting.GOLD)
}
)
)
1
}
) )
} }
} }
} }