Skip to content

Commit f3e467c

Browse files
committed
o o p s
1 parent 68b485c commit f3e467c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/kotlin/one/devos/nautical/winterisms/commands/RestartCommand.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ private fun Int.rebooting(): Component {
2020
}
2121

2222
fun restartCommand(dispatcher: CommandDispatcher<CommandSourceStack>) {
23-
var ticks = 0
23+
var ticks = -1
2424
var startCountdown = false
2525
var didServerSaveCorrectly = false
26-
var lastSource: CommandSourceStack? = null
2726

2827
dispatcher.literal("restart") {
2928
require { hasPermission(4) }
@@ -35,8 +34,8 @@ fun restartCommand(dispatcher: CommandDispatcher<CommandSourceStack>) {
3534
if (didServerSaveCorrectly) {
3635
player.displayClientMessage(Component.literal("Saved server!").withStyle(ChatFormatting.GREEN), false)
3736
ticks = 15 * 20
38-
lastSource = it.source
3937
player.displayClientMessage(15.rebooting(), false)
38+
player.connection.send(ClientboundSetTitleTextPacket(Component.literal("Rebooting in 15 second(s)")))
4039
} else {
4140
player.displayClientMessage(Component.literal("Server failed to save!").withStyle(ChatFormatting.RED), false)
4241
throw ERROR_FAILED.create()
@@ -46,6 +45,7 @@ fun restartCommand(dispatcher: CommandDispatcher<CommandSourceStack>) {
4645
}
4746

4847
ServerTickEvents.END_SERVER_TICK.register { server ->
48+
if (ticks < 0) return@register
4949
ticks--
5050

5151
val message = when (ticks) {
@@ -61,7 +61,7 @@ fun restartCommand(dispatcher: CommandDispatcher<CommandSourceStack>) {
6161
if (message != null) {
6262
for (player in server.playerList.players) {
6363
player.displayClientMessage(message, false)
64-
player.connection.send(ClientboundSetTitlesAnimationPacket(0, 20, 0))
64+
player.connection.send(ClientboundSetTitlesAnimationPacket(5, 25, 5))
6565
player.connection.send(ClientboundSetTitleTextPacket(message))
6666
}
6767
}
@@ -74,6 +74,6 @@ fun restartCommand(dispatcher: CommandDispatcher<CommandSourceStack>) {
7474
player.displayClientMessage(Component.literal("Restarting server...").withStyle(ChatFormatting.GREEN), false)
7575
}
7676

77-
lastSource?.server?.halt(false)
77+
server.halt(false)
7878
}
7979
}

0 commit comments

Comments
 (0)