feat: 신규 플레이어 도움말 표시

- 처음 접속한 플레이어에게 환영 메시지 표시
- 기본 명령어 안내 (/도움말, /메뉴, /스폰)
- 단축키 안내 (Shift + F)
This commit is contained in:
Caadiq 2025-12-29 16:32:01 +09:00
parent 8cc50ce449
commit 791d6f2e9f

View file

@ -5,6 +5,8 @@ import com.beemer.essentials.config.SpawnConfig
import com.beemer.essentials.data.Location
import com.beemer.essentials.util.ChatUtils
import com.beemer.essentials.util.DimensionUtils
import net.minecraft.ChatFormatting
import net.minecraft.network.chat.Component
import net.minecraft.server.level.ServerPlayer
import net.neoforged.bus.api.SubscribeEvent
import net.neoforged.neoforge.event.entity.player.PlayerEvent
@ -35,9 +37,67 @@ object PlayerEvents {
val level = DimensionUtils.getLevelById(player.server, spawn.dimension) ?: return
player.teleportTo(level, spawn.x, spawn.y, spawn.z, player.yRot, player.xRot)
// 신규 플레이어 도움말 (약간의 딜레이 후 표시)
player.server.execute { sendWelcomeGuide(player) }
}
}
/** 신규 플레이어 도움말 */
private fun sendWelcomeGuide(player: ServerPlayer) {
val separator =
Component.literal("═══════════════════════════════").withStyle {
it.withColor(ChatFormatting.DARK_AQUA)
}
player.sendSystemMessage(Component.empty())
player.sendSystemMessage(separator)
player.sendSystemMessage(
Component.literal("🎉 서버에 오신 것을 환영합니다!").withStyle {
it.withColor(ChatFormatting.AQUA).withBold(true)
}
)
player.sendSystemMessage(Component.empty())
// 기본 명령어 안내
player.sendSystemMessage(
Component.literal("▸ 기본 명령어").withStyle {
it.withColor(ChatFormatting.YELLOW).withBold(true)
}
)
sendGuideItem(player, "/도움말", "명령어 목록 보기")
sendGuideItem(player, "/메뉴", "메뉴 GUI 열기")
sendGuideItem(player, "/스폰", "스폰으로 이동")
player.sendSystemMessage(Component.empty())
// 단축키 안내
player.sendSystemMessage(
Component.literal("▸ 단축키").withStyle {
it.withColor(ChatFormatting.YELLOW).withBold(true)
}
)
sendGuideItem(player, "Shift + F", "메뉴 GUI 열기")
player.sendSystemMessage(separator)
player.sendSystemMessage(Component.empty())
}
private fun sendGuideItem(player: ServerPlayer, key: String, desc: String) {
player.sendSystemMessage(
Component.literal(" ")
.append(
Component.literal(key).withStyle {
it.withColor(ChatFormatting.WHITE)
}
)
.append(
Component.literal(" - $desc").withStyle {
it.withColor(ChatFormatting.GRAY)
}
)
)
}
@SubscribeEvent
fun onPlayerLoggedOut(event: PlayerEvent.PlayerLoggedOutEvent) {
val player = event.entity as? ServerPlayer ?: return
@ -54,19 +114,23 @@ object PlayerEvents {
val pos = oldPlayer.blockPosition()
val dimension = oldPlayer.level().dimension().location().toString()
val biome = oldPlayer.level().getBiome(pos)
.unwrapKey()
.map { it.location().toString() }
.orElse("minecraft:plains")
val biome =
oldPlayer
.level()
.getBiome(pos)
.unwrapKey()
.map { it.location().toString() }
.orElse("minecraft:plains")
val lastLoc = Location(
dimension = dimension,
biome = biome,
x = pos.x.toDouble(),
y = pos.y.toDouble(),
z = pos.z.toDouble()
)
val lastLoc =
Location(
dimension = dimension,
biome = biome,
x = pos.x.toDouble(),
y = pos.y.toDouble(),
z = pos.z.toDouble()
)
PlayerConfig.recordLastLocation(oldPlayer, lastLoc)
}
}
}