Rotating Server Announcements

A simple datapack that rotates chat messages using a single function call. Designed to be triggered by a scheduler.



CUSTOMIZING MESSAGES

All messages are located in:

data/servermsg/function/announce.mcfunction



ADDING MESSAGES

Each message follows this format:

execute if score $msg msgIndex matches 0 run tellraw @a {"text":"Your message here"}

To add more messages:

1. Copy the line
2. Change the number (0, 1, 2, etc.)
3. Update the message text


EXAMPLE (3 MESSAGES)

execute if score $msg msgIndex matches 0 run tellraw @a {"text":"Message 1"}
execute if score $msg msgIndex matches 1 run tellraw @a {"text":"Message 2"}
execute if score $msg msgIndex matches 2 run tellraw @a {"text":"Message 3"}



IMPORTANT: UPDATE THE RESET VALUE

At the bottom of the file you will see:

execute if score $msg msgIndex matches 1.. run scoreboard players set $msg msgIndex 0

You MUST update this number to match your total messages.

Examples:
1 message  -> matches 1..
3 messages -> matches 3..
12 messages -> matches 12..

Example for 3 messages:

execute if score $msg msgIndex matches 3.. run scoreboard players set $msg msgIndex 0



FORMATTING MESSAGES

Messages use Minecraft tellraw JSON format.

You can generate formatted messages here:
https://minecraft.tools/en/tellraw.php

Example:

[{"text":"[Server] ","color":"gold","bold":true},{"text":"Welcome!","color":"white"}]



RUNNING THE ANNOUNCEMENTS (SCHEDULER SETUP)

To have messages send automatically, you need your server to run this command on a timer:

function servermsg:announce

How you do this depends on what you use to run your server, but the general idea is:

1. Find your server’s scheduler / task system
   (this may be called Scheduler, Tasks, Cron, Timers, or similar)

2. Create a new repeating task

3. Set the command to:
   function servermsg:announce

4. Make sure it runs as a SERVER / CONSOLE command
   (not as a player command)

5. Set how often it runs (example: every 10 minutes)

6. Save and enable the task


NOTES

- The command must be run by the server/console, not a player
- After editing messages, run:

  /reload

- If your server software does not have a scheduler, you can:
  - Use a plugin/mod that adds one
  - Use an external scheduler (such as a cron job or script)
  - Or trigger it manually with:

    /function servermsg:announce

Once set up, the server will send the next message in the rotation each time the command runs.