Search in sources :

Example 1 with PermissionDefault

use of org.bukkit.permissions.PermissionDefault in project LuckPerms by lucko.

the class LPBukkitPlugin 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(), permDefault));
        }
    } catch (Exception e) {
    // this throws an exception if the plugin is /reloaded, grr
    }
    if (!getConfiguration().get(ConfigKeys.OPS_ENABLED)) {
        this.bootstrap.getScheduler().doSync(() -> this.bootstrap.getServer().getOperators().forEach(o -> o.setOp(false)));
    }
    // replace the temporary executor when the Bukkit one starts
    this.bootstrap.getServer().getScheduler().runTaskAsynchronously(this.bootstrap, () -> this.bootstrap.getScheduler().setUseFallback(false));
    // Load any online users (in the case of a reload)
    for (Player player : this.bootstrap.getServer().getOnlinePlayers()) {
        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(org.bukkit.plugin.PluginManager) ContextManager(me.lucko.luckperms.common.contexts.ContextManager) Arrays(java.util.Arrays) BukkitContextManager(me.lucko.luckperms.bukkit.contexts.BukkitContextManager) Contexts(me.lucko.luckperms.api.Contexts) Player(org.bukkit.entity.Player) StandardGroupManager(me.lucko.luckperms.common.managers.group.StandardGroupManager) LPSubscriptionMap(me.lucko.luckperms.bukkit.model.server.LPSubscriptionMap) ConfigKeys(me.lucko.luckperms.common.config.ConfigKeys) InjectorDefaultsMap(me.lucko.luckperms.bukkit.model.server.InjectorDefaultsMap) ExpireTemporaryTask(me.lucko.luckperms.common.tasks.ExpireTemporaryTask) ConnectionListener(me.lucko.luckperms.common.listener.ConnectionListener) LPPermissible(me.lucko.luckperms.bukkit.model.permissible.LPPermissible) Map(java.util.Map) CacheHousekeepingTask(me.lucko.luckperms.common.tasks.CacheHousekeepingTask) AbstractLuckPermsPlugin(me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin) StandardTrackManager(me.lucko.luckperms.common.managers.track.StandardTrackManager) StandardUserManager(me.lucko.luckperms.common.managers.user.StandardUserManager) PlatformCalculatorFactory(me.lucko.luckperms.common.calculators.PlatformCalculatorFactory) BukkitConnectionListener(me.lucko.luckperms.bukkit.listeners.BukkitConnectionListener) LPPermissionMap(me.lucko.luckperms.bukkit.model.server.LPPermissionMap) BukkitMessagingFactory(me.lucko.luckperms.bukkit.messaging.BukkitMessagingFactory) MessagingFactory(me.lucko.luckperms.common.messaging.MessagingFactory) ServicePriority(org.bukkit.plugin.ServicePriority) VaultHookManager(me.lucko.luckperms.bukkit.vault.VaultHookManager) LPDefaultsMap(me.lucko.luckperms.bukkit.model.server.LPDefaultsMap) PermissionDefault(org.bukkit.permissions.PermissionDefault) InjectorSubscriptionMap(me.lucko.luckperms.bukkit.model.server.InjectorSubscriptionMap) ConfigurationAdapter(me.lucko.luckperms.common.config.adapter.ConfigurationAdapter) PermissibleInjector(me.lucko.luckperms.bukkit.model.permissible.PermissibleInjector) Sender(me.lucko.luckperms.common.sender.Sender) PluginCommand(org.bukkit.command.PluginCommand) File(java.io.File) Permission(org.bukkit.permissions.Permission) BukkitPlatformListener(me.lucko.luckperms.bukkit.listeners.BukkitPlatformListener) CommandPermission(me.lucko.luckperms.common.command.access.CommandPermission) Stream(java.util.stream.Stream) InjectorPermissionMap(me.lucko.luckperms.bukkit.model.server.InjectorPermissionMap) LuckPermsApi(me.lucko.luckperms.api.LuckPermsApi) BukkitCalculatorFactory(me.lucko.luckperms.bukkit.calculators.BukkitCalculatorFactory) Optional(java.util.Optional) PermissibleMonitoringInjector(me.lucko.luckperms.bukkit.model.permissible.PermissibleMonitoringInjector) WorldCalculator(me.lucko.luckperms.bukkit.contexts.WorldCalculator) User(me.lucko.luckperms.common.model.User) PluginManager(org.bukkit.plugin.PluginManager) LPPermissible(me.lucko.luckperms.bukkit.model.permissible.LPPermissible) Player(org.bukkit.entity.Player) User(me.lucko.luckperms.common.model.User) PermissionDefault(org.bukkit.permissions.PermissionDefault) Permission(org.bukkit.permissions.Permission) CommandPermission(me.lucko.luckperms.common.command.access.CommandPermission) CommandPermission(me.lucko.luckperms.common.command.access.CommandPermission)

Example 2 with PermissionDefault

use of org.bukkit.permissions.PermissionDefault in project BKCommonLib by bergerhealer.

the class PluginBase method setPermissions.

private static void setPermissions(ConfigurationNode node) {
    for (ConfigurationNode subNode : node.getNodes()) {
        setPermissions(subNode);
    }
    PermissionDefault def = ParseUtil.convert(getNodeStringValue(node, "default"), PermissionDefault.class);
    String desc = getNodeStringValue(node, "description");
    if (def != null || desc != null) {
        Permission permission = getPermission(node.getPath().toLowerCase(Locale.ENGLISH));
        if (def != null) {
            permission.setDefault(def);
        }
        if (desc != null) {
            permission.setDescription(desc);
        }
    }
}
Also used : IPermissionDefault(com.bergerkiller.bukkit.common.permissions.IPermissionDefault) PermissionDefault(org.bukkit.permissions.PermissionDefault) ConfigurationNode(com.bergerkiller.bukkit.common.config.ConfigurationNode) Permission(org.bukkit.permissions.Permission)

Example 3 with PermissionDefault

use of org.bukkit.permissions.PermissionDefault in project MassiveCore by MassiveCraft.

the class PermissionUtil method setPermissionStandard.

public static boolean setPermissionStandard(Permission permission, PermissionDefault standard) {
    if (permission == null)
        throw new NullPointerException("permission");
    if (standard == null)
        return false;
    // NoChange
    PermissionDefault before = getPermissionStandard(permission);
    if (standard == before)
        return false;
    // Recalculation need created: TRUE
    // Recalculation auto-performed: TRUE
    permission.setDefault(standard);
    return true;
}
Also used : PermissionDefault(org.bukkit.permissions.PermissionDefault)

Aggregations

PermissionDefault (org.bukkit.permissions.PermissionDefault)3 Permission (org.bukkit.permissions.Permission)2 ConfigurationNode (com.bergerkiller.bukkit.common.config.ConfigurationNode)1 IPermissionDefault (com.bergerkiller.bukkit.common.permissions.IPermissionDefault)1 File (java.io.File)1 Arrays (java.util.Arrays)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Stream (java.util.stream.Stream)1 Contexts (me.lucko.luckperms.api.Contexts)1 LuckPermsApi (me.lucko.luckperms.api.LuckPermsApi)1 BukkitCalculatorFactory (me.lucko.luckperms.bukkit.calculators.BukkitCalculatorFactory)1 BukkitContextManager (me.lucko.luckperms.bukkit.contexts.BukkitContextManager)1 WorldCalculator (me.lucko.luckperms.bukkit.contexts.WorldCalculator)1 BukkitConnectionListener (me.lucko.luckperms.bukkit.listeners.BukkitConnectionListener)1 BukkitPlatformListener (me.lucko.luckperms.bukkit.listeners.BukkitPlatformListener)1 BukkitMessagingFactory (me.lucko.luckperms.bukkit.messaging.BukkitMessagingFactory)1 LPPermissible (me.lucko.luckperms.bukkit.model.permissible.LPPermissible)1 PermissibleInjector (me.lucko.luckperms.bukkit.model.permissible.PermissibleInjector)1 PermissibleMonitoringInjector (me.lucko.luckperms.bukkit.model.permissible.PermissibleMonitoringInjector)1