Is there a way to display shrinking vanilla world border size in chat?

I would like to know if it is possible to have my auto message plugin display current world border size. It will shrink from a diameter of 20000 to 213 at a rate of 34 meters per hour. So occasionally players should get a message like: Warning! The world border is shrinking! Worldborder is currently 18354 meters from spawn. And the number would be in the next message eg. 18320 and gradually getting smaller.

Does anyone know if this even possible? I don't know if auto message plugin can deliver other placeholders than its own.

I am using an automessage by ELCHILEN096 dev.bukkit.org/projects/automessage If you know any better up to date plugin like this one, or that supports papi and can put any placeholder in the message, if happy to hear one.

EDIT: I have come to a partial solution on this issue. My current solution is to have automessage tell a message that runs a command "/worldborder get" by the player when clicked the text. also added a permission minecraft.command.worldborder.get to let them run the command.

I am still looking for a placeholder type of result without the player having to click the text to get the information.


This answer works on 1.13+. It does not use a plugin, and is much simpler, and better for your use.

Setup

Run the following command one time:

/scoreboard objectives add border

Additionally, if you are planning to display the radius of the WB square (midpoint of edge to centre) instead of the diameter (length of edge), you must also run the following commands one time each in order:

/scoreboard objectives add constants
/scoreboard players set 2 constants 2

Usage

To display the diameter of the worldborder square (edge to edge):

/execute store result score wb border run worldborder get
/tellraw @a [{"text":"Warning!","color":"red","bold":true}, {"text":" The world border is shrinking. Currently "}, {"score":{"name":"wb","objective":"wb"}}, {"text":" wide."}]

To display the distance from the midpoint of an edge of the WB square to the centre of the square:

/execute store result score wb border run worldborder get
/scoreboard players operation wb border /= 2 constants
/tellraw @a [{"text":"Warning!","color":"red","bold":true}, {"text":" The world border is shrinking. Currently at radius of "}, {"score":{"name":"wb","objective":"border"}}, {"text":"."}]

Expected Result of Samples

Warning! The worldborder is shrinking. Currently XXXXX blocks wide.

or

Warning! The worldborder is shrinking. Currently at radius of XXXXX.

Both results are displayed in RED.

How it Works

Learn how your Minecraft commands work in this section so you can apply them to other uses! If you only plan on this one use of the commands, feel free to skip this section.

Setup Commands

/scoreboard objectives add border

Add a scoreboard objective named border to the scoreboard.

The first command adds a scoreboard objective to the scoreboard. This acts as the area for the variable where the worldborder diameter is stored.

/scoreboard objectives add constants
/scoreboard players set 2 constants 2

Add a scoreboard objective named constants to the scoreboard.
Set fake player 2's score of objective constants to 2.

These commands add another objective to the scoreboard. These are more variables that are always set to a constant number. You'll need this to calculate the radius, because math operations can only be performed on existing variables, not constant numbers.

Usage Commands

/execute store result score wb border run worldborder get

Run /worldborder get and store it in fake player wb's score of objective border.

Place the worldborder diameter in the scoreboard space we reserved for it earlier. This lets us access it from the JSON text in the tellraw command later.

/scoreboard players operation wb border /= 2 constants

Divide fake player wb's score of objective border by fake player 2's score of objective constants. Overwrite the score where we got the dividend from with the result of the division.

This command will divide the diameter by 2 to give us the radius. The diameter will be overwritten by the result of this division, meaning fake player wb's score of objective border is now the radius.

/tellraw @a [{"score":{"name":"wb","objective":"border"}}]

Tell all players wb's score of objective border.

This command will print the world border diameter or radius (depending on which commands you executed before) as a message to all players. Add more components to this to change the formatting of the text, or add text before and after.