Search in sources :

Example 51 with User

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

the class VaultChatHook method getUserChatSuffix.

@Override
public String getUserChatSuffix(String world, UUID uuid) {
    if (uuid == null) {
        return null;
    }
    User user = getUser(uuid);
    if (user == null) {
        return null;
    }
    Contexts contexts = this.permissionHook.contextForLookup(user, world);
    MetaCache metaData = user.getCachedData().getMetaData(contexts);
    String ret = metaData.getSuffix();
    if (log()) {
        logMsg("#getUserChatSuffix: %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), ret);
    }
    return Strings.nullToEmpty(ret);
}
Also used : User(me.lucko.luckperms.common.model.User) Contexts(me.lucko.luckperms.api.Contexts) MetaCache(me.lucko.luckperms.common.caching.type.MetaCache)

Example 52 with User

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

the class VaultChatHook method setUserChatPrefix.

@Override
public void setUserChatPrefix(String world, UUID uuid, String prefix) {
    if (uuid == null) {
        return;
    }
    User user = getUser(uuid);
    if (user == null) {
        return;
    }
    setChatMeta(user, ChatMetaType.PREFIX, prefix, world);
}
Also used : User(me.lucko.luckperms.common.model.User)

Example 53 with User

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

the class VaultPermissionHook method userAddPermission.

@Override
public boolean userAddPermission(String world, UUID uuid, String permission) {
    if (uuid == null) {
        return false;
    }
    Objects.requireNonNull(permission, "permission");
    User user = getUser(uuid);
    if (user == null) {
        return false;
    }
    holderAddPermission(user, permission, world);
    return true;
}
Also used : User(me.lucko.luckperms.common.model.User)

Example 54 with User

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

the class VaultPermissionHook method userHasPermission.

@Override
public boolean userHasPermission(String world, UUID uuid, String permission) {
    if (uuid == null) {
        return false;
    }
    Objects.requireNonNull(permission, "permission");
    User user = getUser(uuid);
    if (user == null) {
        return false;
    }
    Contexts contexts = contextForLookup(user, world);
    PermissionCache permissionData = user.getCachedData().getPermissionData(contexts);
    Tristate result = permissionData.getPermissionValue(permission, CheckOrigin.INTERNAL);
    if (log()) {
        logMsg("#userHasPermission: %s - %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), permission, result);
    }
    return result.asBoolean();
}
Also used : User(me.lucko.luckperms.common.model.User) Tristate(me.lucko.luckperms.api.Tristate) PermissionCache(me.lucko.luckperms.common.caching.type.PermissionCache) Contexts(me.lucko.luckperms.api.Contexts)

Example 55 with User

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

the class BungeeConnectionListener method onPlayerPostLogin.

@EventHandler
public void onPlayerPostLogin(PostLoginEvent e) {
    final ProxiedPlayer player = e.getPlayer();
    final User user = this.plugin.getUserManager().getIfLoaded(e.getPlayer().getUniqueId());
    if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
        this.plugin.getLogger().info("Processing post-login for " + player.getUniqueId() + " - " + player.getName());
    }
    if (user == null) {
        if (this.plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) {
            // disconnect the user
            this.plugin.getLogger().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded - cancelling login.");
            e.getPlayer().disconnect(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
        } else {
            // just send a message
            this.plugin.getBootstrap().getProxy().getScheduler().schedule(this.plugin.getBootstrap(), () -> {
                if (!player.isConnected()) {
                    return;
                }
                player.sendMessage(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
            }, 1, TimeUnit.SECONDS);
        }
    }
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) User(me.lucko.luckperms.common.model.User) EventHandler(net.md_5.bungee.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