use of org.bukkit.event.server.BroadcastMessageEvent in project Glowstone by GlowstoneMC.
the class GlowServer method broadcast.
@Override
public int broadcast(String message, String permission) {
Set<CommandSender> sent = new HashSet<>();
for (Permissible permissible : getPluginManager().getPermissionSubscriptions(permission)) {
if (permissible instanceof CommandSender && permissible.hasPermission(permission)) {
CommandSender cs = ((CommandSender) permissible);
sent.add(cs);
}
}
BroadcastMessageEvent event = EventFactory.getInstance().callEvent(new BroadcastMessageEvent(message, sent));
if (event.isCancelled()) {
return 0;
}
sent.forEach(cs -> cs.sendMessage(message));
return sent.size();
}
Aggregations