도움말 명령어 추가, /안티몹 /밭보호 명령어 OP만 사용 가능하도록 수정
This commit is contained in:
parent
e4337b9e12
commit
ad253e8499
5 changed files with 164 additions and 28 deletions
|
|
@ -17,6 +17,7 @@
|
|||
- 🛡️ **안티몹** - 특정 몹 패턴 비활성화
|
||||
- 🌾 **밭 보호** - 밟아도 밭이 망가지지 않도록 보호
|
||||
- 💬 **채팅 관리** - 채팅 형식 변경
|
||||
- 🗿 **머리 아이템** - 플레이어 머리 아이템 지급
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -67,6 +68,13 @@
|
|||
| ----------------------------- | ------------ |
|
||||
| `/밭보호`, `/protectfarmland` | 밭 보호 토글 |
|
||||
|
||||
### 머리
|
||||
|
||||
| 명령어 | 설명 |
|
||||
| --------------------- | ------------------------------ |
|
||||
| `/머리`, `/head` | 자신의 머리 아이템 받기 |
|
||||
| `/머리 <닉네임/이름>` | 해당 플레이어 머리 아이템 받기 |
|
||||
|
||||
### 채팅 (관리자)
|
||||
|
||||
| 명령어 | 설명 |
|
||||
|
|
|
|||
|
|
@ -32,5 +32,6 @@ class Essentials(modEventBus: IEventBus) {
|
|||
NeoForge.EVENT_BUS.register(CoordinateCommand)
|
||||
NeoForge.EVENT_BUS.register(NicknameCommand)
|
||||
NeoForge.EVENT_BUS.register(HeadCommand)
|
||||
NeoForge.EVENT_BUS.register(HelpCommand)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,25 +16,27 @@ object AntimobCommand {
|
|||
fun onRegisterCommands(event: RegisterCommandsEvent) {
|
||||
listOf("antimob", "안티몹").forEach { command ->
|
||||
event.dispatcher.register(
|
||||
Commands.literal(command).executes { context ->
|
||||
val player = CommandUtils.getPlayerOrSendFailure(context.source) ?: return@executes 0
|
||||
Commands.literal(command).requires { it.hasPermission(2) }.executes { context ->
|
||||
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(
|
||||
SimpleMenuProvider({ windowId, inv, _ ->
|
||||
AntimobGui(
|
||||
windowId,
|
||||
inv,
|
||||
container,
|
||||
player
|
||||
)
|
||||
}, Component.literal("안티몹 설정").withStyle { it.withColor(ChatFormatting.DARK_GRAY) })
|
||||
)
|
||||
1
|
||||
}
|
||||
player.openMenu(
|
||||
SimpleMenuProvider(
|
||||
{ windowId, inv, _ ->
|
||||
AntimobGui(windowId, inv, container, player)
|
||||
},
|
||||
Component.literal("안티몹 설정").withStyle {
|
||||
it.withColor(ChatFormatting.DARK_GRAY)
|
||||
}
|
||||
)
|
||||
)
|
||||
1
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -13,18 +13,30 @@ object ProtectFarmlandCommand {
|
|||
fun onRegisterCommands(event: RegisterCommandsEvent) {
|
||||
listOf("protectfarmland", "밭보호").forEach { command ->
|
||||
event.dispatcher.register(
|
||||
Commands.literal(command).executes { context ->
|
||||
val player = CommandUtils.getPlayerOrSendFailure(context.source) ?: return@executes 0
|
||||
Commands.literal(command).requires { it.hasPermission(2) }.executes { context ->
|
||||
val player =
|
||||
CommandUtils.getPlayerOrSendFailure(context.source)
|
||||
?: return@executes 0
|
||||
|
||||
val enabled = ProtectFarmlandConfig.toggle()
|
||||
val enabled = ProtectFarmlandConfig.toggle()
|
||||
|
||||
player.sendSystemMessage(
|
||||
Component.literal("밭 보호를 ").withStyle { it.withColor(ChatFormatting.GOLD) }
|
||||
.append(Component.literal(if (enabled) "활성화" else "비활성화").withStyle { it.withColor(ChatFormatting.DARK_GREEN) })
|
||||
.append(Component.literal("했습니다.").withStyle { it.withColor(ChatFormatting.GOLD) })
|
||||
)
|
||||
1
|
||||
}
|
||||
player.sendSystemMessage(
|
||||
Component.literal("밭 보호를 ")
|
||||
.withStyle { it.withColor(ChatFormatting.GOLD) }
|
||||
.append(
|
||||
Component.literal(if (enabled) "활성화" else "비활성화")
|
||||
.withStyle {
|
||||
it.withColor(ChatFormatting.DARK_GREEN)
|
||||
}
|
||||
)
|
||||
.append(
|
||||
Component.literal("했습니다.").withStyle {
|
||||
it.withColor(ChatFormatting.GOLD)
|
||||
}
|
||||
)
|
||||
)
|
||||
1
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue