How to broadcast message with Bukkit?

15,196

Remember that Bukkit.broadcastMessage(message); records a message also on Console. You do not actually need that in most of cases.

You can do a simple for loop:

for (Player player : Bukkit.getOnlinePlayers()) {
    player.sendMessage("It works!");
}

Or if you want you can just use

Bukkit.broadcastMessage("It works too, but for console & players!");

Share:
15,196
ThisIsEcho
Author by

ThisIsEcho

Updated on June 18, 2022

Comments

  • ThisIsEcho
    ThisIsEcho almost 2 years

    In a Bukkit plugin, there's option to send message directly to player like this:

    p.sendMessage(message);
    

    Is there an option to send the message to all online players, "broadcasting" the message to everyone?

  • ThisIsEcho
    ThisIsEcho over 7 years
    That's great thanks! :) i was looking for Bukkit.broadcastMessage("It works too, but for console & players"!); :P