feat: 신규 플레이어 도움말 표시
- 처음 접속한 플레이어에게 환영 메시지 표시 - 기본 명령어 안내 (/도움말, /메뉴, /스폰) - 단축키 안내 (Shift + F)
This commit is contained in:
parent
8cc50ce449
commit
791d6f2e9f
1 changed files with 76 additions and 12 deletions
|
|
@ -5,6 +5,8 @@ import com.beemer.essentials.config.SpawnConfig
|
||||||
import com.beemer.essentials.data.Location
|
import com.beemer.essentials.data.Location
|
||||||
import com.beemer.essentials.util.ChatUtils
|
import com.beemer.essentials.util.ChatUtils
|
||||||
import com.beemer.essentials.util.DimensionUtils
|
import com.beemer.essentials.util.DimensionUtils
|
||||||
|
import net.minecraft.ChatFormatting
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.server.level.ServerPlayer
|
import net.minecraft.server.level.ServerPlayer
|
||||||
import net.neoforged.bus.api.SubscribeEvent
|
import net.neoforged.bus.api.SubscribeEvent
|
||||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent
|
import net.neoforged.neoforge.event.entity.player.PlayerEvent
|
||||||
|
|
@ -35,9 +37,67 @@ object PlayerEvents {
|
||||||
val level = DimensionUtils.getLevelById(player.server, spawn.dimension) ?: return
|
val level = DimensionUtils.getLevelById(player.server, spawn.dimension) ?: return
|
||||||
|
|
||||||
player.teleportTo(level, spawn.x, spawn.y, spawn.z, player.yRot, player.xRot)
|
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
|
@SubscribeEvent
|
||||||
fun onPlayerLoggedOut(event: PlayerEvent.PlayerLoggedOutEvent) {
|
fun onPlayerLoggedOut(event: PlayerEvent.PlayerLoggedOutEvent) {
|
||||||
val player = event.entity as? ServerPlayer ?: return
|
val player = event.entity as? ServerPlayer ?: return
|
||||||
|
|
@ -54,18 +114,22 @@ object PlayerEvents {
|
||||||
|
|
||||||
val pos = oldPlayer.blockPosition()
|
val pos = oldPlayer.blockPosition()
|
||||||
val dimension = oldPlayer.level().dimension().location().toString()
|
val dimension = oldPlayer.level().dimension().location().toString()
|
||||||
val biome = oldPlayer.level().getBiome(pos)
|
val biome =
|
||||||
.unwrapKey()
|
oldPlayer
|
||||||
.map { it.location().toString() }
|
.level()
|
||||||
.orElse("minecraft:plains")
|
.getBiome(pos)
|
||||||
|
.unwrapKey()
|
||||||
|
.map { it.location().toString() }
|
||||||
|
.orElse("minecraft:plains")
|
||||||
|
|
||||||
val lastLoc = Location(
|
val lastLoc =
|
||||||
dimension = dimension,
|
Location(
|
||||||
biome = biome,
|
dimension = dimension,
|
||||||
x = pos.x.toDouble(),
|
biome = biome,
|
||||||
y = pos.y.toDouble(),
|
x = pos.x.toDouble(),
|
||||||
z = pos.z.toDouble()
|
y = pos.y.toDouble(),
|
||||||
)
|
z = pos.z.toDouble()
|
||||||
|
)
|
||||||
|
|
||||||
PlayerConfig.recordLastLocation(oldPlayer, lastLoc)
|
PlayerConfig.recordLastLocation(oldPlayer, lastLoc)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue