Minecraft – ny way to keep the minecraft server from going through the day/night cycle when no one’s online

minecraft-java-editionminecraft-java-edition-server

My friends and I use the day number as part of our server rules, so we want to keep the day from changing while we're offline, but the only way I know of to do that is to stop the server from running…

Best Answer

You should be able to use command blocks to automatically detect whether players are online or not, then appropriately set the doDaylightCycle rule appropriately. Try placing the following setup in the server spawn chunks:

enter image description here

(Piston is a sticky one.)

The general idea is that the left command checks for online players a few times every second and the comparator next to it will only output a signal if there is at least one player online. Once everyone logs off, the piston retracts and turns off the day/night cycle. As soon as someone logs in again, the comparator will turn on again and toggle the day/night cycle back on.