Skip to content

Instantly share code, notes, and snippets.

@TheyCallMeLinux
Created July 13, 2024 03:32
Show Gist options
  • Save TheyCallMeLinux/4f73b38a59c8f0122e7faf1d72f6be80 to your computer and use it in GitHub Desktop.
Save TheyCallMeLinux/4f73b38a59c8f0122e7faf1d72f6be80 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <normal|extended>"
exit 1
fi
MODE=$1
case $MODE in
normal)
echo "Setting time to normal mode..."
docker exec mcserver rcon-cli gamerule doDaylightCycle true
;;
extended)
echo "Setting time to extended mode..."
docker exec mcserver rcon-cli gamerule doDaylightCycle false
# Time steps for a slower cycle, low the sun moves in small increments, high less server impact but the sun is teleporting, lol
DAY_LENGTH=$((24000 * 10))
STEP=50
INTERVAL=10 # Adjust this to make the cycle slower or faster
CURRENT_TIME=$(docker exec mcserver rcon-cli time query daytime | grep -o '[0-9]*')
while true; do
docker exec mcserver rcon-cli time add $STEP
sleep $INTERVAL
done
;;
*)
echo "Invalid mode. Use 'normal' or 'extended'."
exit 1
;;
esac
echo "Time setting complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment