Search in sources :

Example 66 with User

use of me.lucko.luckperms.common.model.User in project LuckPerms by lucko.

the class SpongeConnectionListener method onClientLogin.

@Listener(order = Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onClientLogin(ClientConnectionEvent.Login e) {
    /* Called when the player starts logging into the server.
           At this point, the users data should be present and loaded.
           Listening on LOW priority to allow plugins to further modify data here. (auth plugins, etc.) */
    final GameProfile profile = e.getProfile();
    if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
        this.plugin.getLogger().info("Processing login event for " + profile.getUniqueId() + " - " + profile.getName());
    }
    final User user = this.plugin.getUserManager().getIfLoaded(profile.getUniqueId());
    /* User instance is null for whatever reason. Could be that it was unloaded between asyncpre and now. */
    if (user == null) {
        this.deniedLogin.add(profile.getUniqueId());
        this.plugin.getLogger().warn("User " + profile.getUniqueId() + " - " + profile.getName() + " doesn't have data pre-loaded. - denying login.");
        e.setCancelled(true);
        e.setMessageCancelled(false);
        // noinspection deprecation
        e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
    }
}
Also used : User(me.lucko.luckperms.common.model.User) GameProfile(org.spongepowered.api.profile.GameProfile) Listener(org.spongepowered.api.event.Listener) AbstractConnectionListener(me.lucko.luckperms.common.listener.AbstractConnectionListener) IsCancelled(org.spongepowered.api.event.filter.IsCancelled)

Example 67 with User

use of me.lucko.luckperms.common.model.User in project LuckPerms by lucko.

the class NukkitConnectionListener 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.setCancelled();
        e.setKickMessage(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager()));
        return;
    }
    // Care should be taken at this stage to ensure that async tasks which manipulate nukkit 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.nukkit.model.permissible.LPPermissible) Player(cn.nukkit.Player) User(me.lucko.luckperms.common.model.User) EventHandler(cn.nukkit.event.EventHandler)

Aggregations

User (me.lucko.luckperms.common.model.User)67 Group (me.lucko.luckperms.common.model.Group)20 UUID (java.util.UUID)16 Node (me.lucko.luckperms.api.Node)14 Contexts (me.lucko.luckperms.api.Contexts)10 List (java.util.List)9 NodeFactory (me.lucko.luckperms.common.node.NodeFactory)9 Tristate (me.lucko.luckperms.api.Tristate)8 Track (me.lucko.luckperms.common.model.Track)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 CommandPermission (me.lucko.luckperms.common.command.access.CommandPermission)7 ProgressLogger (me.lucko.luckperms.common.logging.ProgressLogger)7 Sender (me.lucko.luckperms.common.sender.Sender)7 Map (java.util.Map)6 Set (java.util.Set)6 Collectors (java.util.stream.Collectors)6 LuckPermsPlugin (me.lucko.luckperms.common.plugin.LuckPermsPlugin)6 MutableContextSet (me.lucko.luckperms.api.context.MutableContextSet)5 CommandResult (me.lucko.luckperms.common.command.CommandResult)5 SubCommand (me.lucko.luckperms.common.command.abstraction.SubCommand)5