Search in sources :

Example 1 with Permissible

use of cn.nukkit.permission.Permissible in project LuckPerms by lucko.

the class InjectorSubscriptionMap method inject.

private LPSubscriptionMap inject() throws Exception {
    Objects.requireNonNull(PERM_SUBS_FIELD, "PERM_SUBS_FIELD");
    PluginManager pluginManager = this.plugin.getBootstrap().getServer().getPluginManager();
    Object map = PERM_SUBS_FIELD.get(pluginManager);
    if (map instanceof LPSubscriptionMap) {
        if (((LPSubscriptionMap) map).plugin == this.plugin) {
            return null;
        }
        map = ((LPSubscriptionMap) map).detach();
    }
    // noinspection unchecked
    Map<String, Set<Permissible>> castedMap = (Map<String, Set<Permissible>>) map;
    // make a new subscription map & inject it
    LPSubscriptionMap newMap = new LPSubscriptionMap(this.plugin, castedMap);
    PERM_SUBS_FIELD.set(pluginManager, newMap);
    return newMap;
}
Also used : PluginManager(cn.nukkit.plugin.PluginManager) Set(java.util.Set) Permissible(cn.nukkit.permission.Permissible) Map(java.util.Map)

Example 2 with Permissible

use of cn.nukkit.permission.Permissible 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)

Example 3 with Permissible

use of cn.nukkit.permission.Permissible in project Nukkit by Nukkit.

the class Command method broadcastCommandMessage.

public static void broadcastCommandMessage(CommandSender source, String message, boolean sendToSource) {
    Set<Permissible> users = source.getServer().getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
    TranslationContainer result = new TranslationContainer("chat.type.admin", new String[] { source.getName(), message });
    TranslationContainer colored = new TranslationContainer(TextFormat.GRAY + "" + TextFormat.ITALIC + "%chat.type.admin", new String[] { source.getName(), message });
    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 : TranslationContainer(cn.nukkit.lang.TranslationContainer) Permissible(cn.nukkit.permission.Permissible)

Aggregations

Permissible (cn.nukkit.permission.Permissible)3 TextContainer (cn.nukkit.lang.TextContainer)1 TranslationContainer (cn.nukkit.lang.TranslationContainer)1 PluginManager (cn.nukkit.plugin.PluginManager)1 Map (java.util.Map)1 Set (java.util.Set)1