Search in sources :

Example 1 with TextContainer

use of cn.nukkit.lang.TextContainer in project Nukkit by Nukkit.

the class Command method broadcastCommandMessage.

public static void broadcastCommandMessage(CommandSender source, TextContainer message, boolean sendToSource) {
    TextContainer m = message.clone();
    String resultStr = "[" + source.getName() + ": " + (!m.getText().equals(source.getServer().getLanguage().get(m.getText())) ? "%" : "") + m.getText() + "]";
    Set<Permissible> users = source.getServer().getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
    String coloredStr = TextFormat.GRAY + "" + TextFormat.ITALIC + resultStr;
    m.setText(resultStr);
    TextContainer result = m.clone();
    m.setText(coloredStr);
    TextContainer colored = m.clone();
    if (sendToSource && !(source instanceof ConsoleCommandSender)) {
        source.sendMessage(message);
    }
    for (Permissible user : users) {
        if (user instanceof CommandSender) {
            if (user instanceof ConsoleCommandSender) {
                ((ConsoleCommandSender) user).sendMessage(result);
            } else if (!user.equals(source)) {
                ((CommandSender) user).sendMessage(colored);
            }
        }
    }
}
Also used : TextContainer(cn.nukkit.lang.TextContainer) Permissible(cn.nukkit.permission.Permissible)

Aggregations

TextContainer (cn.nukkit.lang.TextContainer)1 Permissible (cn.nukkit.permission.Permissible)1