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) {
when (packet.mode) {
ChatSendMode.BROADCAST -> {

View File

@ -208,6 +208,7 @@ class ServerWorld private constructor(
clients.forEach {
LOGGER.info("Kicking ${it.client.alias()} off dying world")
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)
it.client.enqueueWarp(WarpAlias.Return)
@ -807,7 +808,7 @@ class ServerWorld private constructor(
tickets.addAll(region)
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
}
@ -837,7 +838,7 @@ class ServerWorld private constructor(
tickets.addAll(region)
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)
return pos
}