Hey SpongeCommunity,
I am DarkIce and comming from Bukkit/Spigot.
I came here because the DMCA of Bukkit and the many Buggs and Laggs in the 1.8 Spigot release.
I am curently enjoying the Sponge Dev Builds but it is not very clear to me how i can broadcast a message for all Users playing.
And my next question is if these is any other way to use chatcolors except for Color(ChatColor.RED)
Keep the eyes open maybe a Plugin get released by me soon.
@Inject Game game;
public void broadcast(String msg) {
for (Player player : this.game.getServer().getOnlinePlayers()) {
player.sendMessage(Texts.of(msg));
}
}
Possibly. I tend to for-loop through mine, though, in case there’s a specific guideline I want to abide to.
@Inject private Game game;
private final List<UUID> admins = new HashMap<UUID>();
public void broadcastAdministrators(String msg) {
for (Player player : this.game.getServer().getOnlinePlayers()) {
if (this.admins.contains(player.getUniqueId()) {
player.sendMessage(Texts.of(msg));
}
}
}
The examples that @mbaxter and I were given in the case that a pre-requisite was required. Such as @mbaxter checking for a permission, or in my post where I checked if a player was an admin.