Per player system message, display notification in chat when player is kicked off world

This commit is contained in:
DBotThePony 2024-06-02 21:52:17 +07:00
parent 56c154cc96
commit 77a9beb665
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 12 additions and 2 deletions

View File

@ -19,6 +19,15 @@ class ChatHandler(val server: StarboundServer) {
)) ))
} }
fun systemMessage(target: ServerConnection, string: String) {
target.send(ChatReceivePacket(
ChatMessage(
MessageContext.BROADCAST,
text = string
)
))
}
fun handle(source: ServerConnection, packet: ChatSendPacket) { fun handle(source: ServerConnection, packet: ChatSendPacket) {
when (packet.mode) { when (packet.mode) {
ChatSendMode.BROADCAST -> { ChatSendMode.BROADCAST -> {

View File

@ -208,6 +208,7 @@ class ServerWorld private constructor(
clients.forEach { clients.forEach {
LOGGER.info("Kicking ${it.client.alias()} off dying world") LOGGER.info("Kicking ${it.client.alias()} off dying world")
it.remove("World shutting down", setReturnWarp = !uncleanShutdown) it.remove("World shutting down", setReturnWarp = !uncleanShutdown)
server.chat.systemMessage(it.client, "You were kicked from current world due to it being shut down")
if (!server.isShutdown) if (!server.isShutdown)
it.client.enqueueWarp(WarpAlias.Return) it.client.enqueueWarp(WarpAlias.Return)
@ -807,7 +808,7 @@ class ServerWorld private constructor(
tickets.addAll(region) tickets.addAll(region)
region.forEach { it.chunk.await() } region.forEach { it.chunk.await() }
foundGround = anyCellSatisfies(spawnRect) { tx, ty, tcell -> foundGround = chunkMap.anyCellSatisfies(spawnRect) { tx, ty, tcell ->
tcell.foreground.material.value.collisionKind != CollisionType.NONE tcell.foreground.material.value.collisionKind != CollisionType.NONE
} }
@ -837,7 +838,7 @@ class ServerWorld private constructor(
tickets.addAll(region) tickets.addAll(region)
region.forEach { it.chunk.await() } region.forEach { it.chunk.await() }
if (!anyCellSatisfies(spawnRect) { tx, ty, tcell -> tcell.foreground.material.value.collisionKind != CollisionType.NONE } && spawnRect.maxs.y < geometry.size.y) { if (!chunkMap.anyCellSatisfies(spawnRect) { tx, ty, tcell -> tcell.foreground.material.value.collisionKind != CollisionType.NONE } && spawnRect.maxs.y < geometry.size.y) {
LOGGER.debug("Found appropriate spawn position at {}", pos) LOGGER.debug("Found appropriate spawn position at {}", pos)
return pos return pos
} }