@Override
    public void execute(@Nonnull SessionData sessionData, Element command)
    {
        final Locale preferredLocale = SessionManager.getInstance().getLocaleForSession(sessionData.getOwner());

        Element note = command.addElement("note");

        Map<String, List<String>> data = sessionData.getData();

        boolean requestError = false;
        final List<String> announcement = data.get("announcement");
        if (announcement == null || announcement.isEmpty()) {
            note.addAttribute( "type", "error" );
            note.setText(LocaleUtils.getLocalizedString("commands.admin.sendannouncementtoonlineusers.note.text-required", preferredLocale));
            requestError = true;
        }

        if ( requestError )
        {
            // We've collected all errors. Return without applying changes.
            return;
        }

        // No errors.
        XMPPServer.getInstance().getSessionManager().sendServerMessage(null, String.join(System.lineSeparator(), announcement));

        // Answer that the operation was successful
        note.addAttribute("type", "info");
        note.setText(LocaleUtils.getLocalizedString("commands.global.operation.finished.success", preferredLocale));
    }
Sends a message to all online users

@author Guus der Kinderen, guus@goodbytes.nl
@see <a href="https://xmpp.org/extensions/xep-0133.html#announce">XEP-0133 Send Announcement to Online Users</a>
xmppserver/src/main/java/org/jivesoftware/openfire/commands/admin/SendAnnouncementToOnlineUsers.java