Search in sources :

Example 6 with Permission

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

the class LPDefaultsMap method refreshNonOp.

/**
 * Refreshes the non op data in this provider.
 */
private void refreshNonOp() {
    Map<String, Boolean> builder = new HashMap<>();
    for (Permission perm : getNonOpPermissions().values()) {
        String name = perm.getName().toLowerCase();
        builder.put(name, true);
        for (Map.Entry<String, Boolean> child : this.plugin.getPermissionMap().getChildPermissions(name, true).entrySet()) {
            builder.putIfAbsent(child.getKey(), child.getValue());
        }
    }
    this.resolvedNonOpDefaults = ImmutableMap.copyOf(builder);
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Permission(cn.nukkit.permission.Permission) ForwardingMap(com.google.common.collect.ForwardingMap) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Example 7 with Permission

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

the class LPPermissionMap method put.

@Override
public Permission put(@Nonnull String key, @Nonnull Permission value) {
    this.plugin.getPermissionVault().offer(key);
    Permission ret = super.put(key, value);
    update();
    return ret;
}
Also used : Permission(cn.nukkit.permission.Permission)

Example 8 with Permission

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

the class LPNukkitPlugin method performFinalSetup.

@Override
protected void performFinalSetup() {
    // register permissions
    try {
        PluginManager pm = this.bootstrap.getServer().getPluginManager();
        PermissionDefault permDefault = getConfiguration().get(ConfigKeys.COMMANDS_ALLOW_OP) ? PermissionDefault.OP : PermissionDefault.FALSE;
        for (CommandPermission p : CommandPermission.values()) {
            pm.addPermission(new Permission(p.getPermission(), null, permDefault.toString()));
        }
    } catch (Exception e) {
    // this throws an exception if the plugin is /reloaded, grr
    }
    if (!getConfiguration().get(ConfigKeys.OPS_ENABLED)) {
        Config ops = this.bootstrap.getServer().getOps();
        ops.getKeys(false).forEach(ops::remove);
    }
    // replace the temporary executor when the Nukkit one starts
    this.bootstrap.getServer().getScheduler().scheduleTask(this.bootstrap, () -> this.bootstrap.getScheduler().setUseFallback(false), true);
    // Load any online users (in the case of a reload)
    for (Player player : this.bootstrap.getServer().getOnlinePlayers().values()) {
        this.bootstrap.getScheduler().doAsync(() -> {
            try {
                User user = this.connectionListener.loadUser(player.getUniqueId(), player.getName());
                if (user != null) {
                    this.bootstrap.getScheduler().doSync(() -> {
                        try {
                            LPPermissible lpPermissible = new LPPermissible(player, user, this);
                            PermissibleInjector.inject(player, lpPermissible);
                        } catch (Throwable t) {
                            t.printStackTrace();
                        }
                    });
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    }
}
Also used : PluginManager(cn.nukkit.plugin.PluginManager) LPPermissible(me.lucko.luckperms.nukkit.model.permissible.LPPermissible) Player(cn.nukkit.Player) User(me.lucko.luckperms.common.model.User) PermissionDefault(me.lucko.luckperms.nukkit.model.PermissionDefault) Config(cn.nukkit.utils.Config) CommandPermission(me.lucko.luckperms.common.command.access.CommandPermission) Permission(cn.nukkit.permission.Permission) CommandPermission(me.lucko.luckperms.common.command.access.CommandPermission)

Example 9 with Permission

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

the class PluginManager method disablePlugin.

public void disablePlugin(Plugin plugin) {
    if (plugin.isEnabled()) {
        try {
            plugin.getPluginLoader().disablePlugin(plugin);
        } catch (Exception e) {
            MainLogger logger = this.server.getLogger();
            if (logger != null) {
                logger.logException(e);
            }
        }
        this.server.getScheduler().cancelTask(plugin);
        HandlerList.unregisterAll(plugin);
        for (Permission permission : plugin.getDescription().getPermissions()) {
            this.removePermission(permission);
        }
    }
}
Also used : MainLogger(cn.nukkit.utils.MainLogger) Permission(cn.nukkit.permission.Permission) PluginException(cn.nukkit.utils.PluginException)

Aggregations

Permission (cn.nukkit.permission.Permission)9 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 PluginManager (cn.nukkit.plugin.PluginManager)3 ForwardingMap (com.google.common.collect.ForwardingMap)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 Player (cn.nukkit.Player)1 Config (cn.nukkit.utils.Config)1 MainLogger (cn.nukkit.utils.MainLogger)1 PluginException (cn.nukkit.utils.PluginException)1 CommandPermission (me.lucko.luckperms.common.command.access.CommandPermission)1 User (me.lucko.luckperms.common.model.User)1 PermissionDefault (me.lucko.luckperms.nukkit.model.PermissionDefault)1 LPPermissible (me.lucko.luckperms.nukkit.model.permissible.LPPermissible)1