Search in sources :

Example 1 with LPPermissible

use of me.lucko.luckperms.bukkit.model.permissible.LPPermissible 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 LPPermissible

use of me.lucko.luckperms.bukkit.model.permissible.LPPermissible in project LuckPerms by lucko.

the class BukkitConnectionListener method onPlayerLogin.

@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLogin(PlayerLoginEvent e) {
    /* Called when the player starts logging into the server.
           At this point, the users data should be present and loaded. */
    final Player player = e.getPlayer();
    if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
        this.plugin.getLogger().info("Processing login for " + player.getUniqueId() + " - " + player.getName());
    }
    final User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
    /* User instance is null for whatever reason. Could be that it was unloaded between asyncpre and now. */
    if (user == null) {
        this.deniedLogin.add(e.getPlayer().getUniqueId());
        this.plugin.getLogger().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded. - denying login.");
        e.disallow(PlayerLoginEvent.Result.KICK_OTHER, Message.LOADING_ERROR.asString(this.plugin.getLocaleManager()));
        return;
    }
    // Care should be taken at this stage to ensure that async tasks which manipulate bukkit data check that the player is still online.
    try {
        // Make a new permissible for the user
        LPPermissible lpPermissible = new LPPermissible(player, user, this.plugin);
        // Inject into the player
        PermissibleInjector.inject(player, lpPermissible);
    } catch (Throwable t) {
        t.printStackTrace();
    }
    this.plugin.refreshAutoOp(user, player);
}
Also used : LPPermissible(me.lucko.luckperms.bukkit.model.permissible.LPPermissible) Player(org.bukkit.entity.Player) User(me.lucko.luckperms.common.model.User) EventHandler(org.bukkit.event.EventHandler)

Aggregations

LPPermissible (me.lucko.luckperms.bukkit.model.permissible.LPPermissible)2 User (me.lucko.luckperms.common.model.User)2 Player (org.bukkit.entity.Player)2 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 PermissibleInjector (me.lucko.luckperms.bukkit.model.permissible.PermissibleInjector)1 PermissibleMonitoringInjector (me.lucko.luckperms.bukkit.model.permissible.PermissibleMonitoringInjector)1 InjectorDefaultsMap (me.lucko.luckperms.bukkit.model.server.InjectorDefaultsMap)1 InjectorPermissionMap (me.lucko.luckperms.bukkit.model.server.InjectorPermissionMap)1