-1

This question already has an answer here:

I want to make a command block output a message in chat every half hour on my server. The purpose of this is to remind players to read the rules of the server.

Would plugins be necessary to do something like this?

marked as duplicate by Virusbomb, galacticninja, Schism, greg-449, Ivo Coumans Jul 30 at 6:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

Command delay part

Refer to: How do I delay a command

This solution only works on Minecraft 1.9 and above!

This is possible with scoreboard objectives. You will have to do the following for each command you want to delay. Note that this also only works on commands executed on entities.


How to make:

  1. Create a scoreboard objective to hold delays (I will use time as an example)

    /scoreboard objectives add time dummy
    
  2. Create a command block arrangement like this: Repeating > Chain > Conditional Chain

  3. Place the following commands into each command block:

    • Repeat Command Block:

      /scoreboard players add @e[score_time_min=1] time 1
      
    • Chain Command Block 1: Put your delayed command here. For example:

      /tp @e[type=ArmorStand,score_time_min={delay}] ~ ~1 ~
      
    • Chain Command Block 2:

      /scoreboard players set @e[score_time_min={delay}] time 0
      
  4. Start the delay by running this command:

    /scoreboard players set {entity} time 1
    

A few things to note:

  • Replace {delay} with the delay you want in ticks, plus one. For example, if you want a delay of 5 seconds, you would put 101 there since 5sec * 20 tick/sec + 1 = 101.
  • Replace {entity} with the selector for the entity that you want to run the command. For example, @e[type=ArmorStand,name=Bob].
  • The command in the second command block is up to you to. Just know that your need to run the command with {entity} targeted and you must have score_time_min={delay} in the entity selector for that command.


Broadcast part

Put the following command into Chain Command Block 1:

tellraw @a <raw json message>

If you are not familiar with json messages, you can use a generator like this one.

Not the answer you're looking for? Browse other questions tagged or ask your own question.