#luckperms-api

1 messages · Page 25 of 1

hollow geyser
#

Beeep.. Boopp

crystal sonnet
#

@hollow geyser replace getUser with loadUser

#

getUser only works with online players

#

And work with queryoptions instead of contexts

hollow geyser
#

@hollow geyser replace getUser with loadUser
@crystal sonnet

Haha its not that easy x)

frank driftBOT
#

Hey MR.CLEAN! Please don't tag staff members.

crystal sonnet
#

Why?

hollow geyser
#

I only have a username, but it needs uuid

#

An the 2. option loadUser(uniqueId, username) throws Nullpointer if: if the uuid is null

hollow geyser
#

Bruh really. Thx.

crystal sonnet
#

Javadocs typically help 😉

hollow geyser
#

CTRL + Space xD

crystal sonnet
#

Or that

grim cape
#

How would I obtain a list of the people in a specific group?

short fossil
#

I don't know if the issue is on my-side of the plugin however any changes made through my plugin don't go into affect until after you do /lp sync

#

I've made sure to save the user everytime I do any changes to nodes or parents

#

as well as pushUpdate() after I am all done with node editing

#

however it still takes a manual /lp sync to see one of the changed groups

nocturne elbow
#

Everytime I add permissions by writting the permission in the highlighted area nothing happens. How am I suppose to add permissions for a group?

crystal sonnet
jovial saffron
#

Hey I am trying to use the api to create a custom context but it returns an error in my console saying "[LuckPerms] An exception was thrown by com.ralphy.morecontexts.PlaceholderApiCalculator whilst calculating the context of subject CraftPlayer{name=[player's name]}"

crystal sonnet
#

Full error?

#

@short fossil what LP version?

jovial saffron
#

I'm on v5.0.140 and the console reads:

crystal sonnet
#

You get a NullPointerException your code

#

This has nothing to do with the LP API

#

This is an issue in your code

jovial saffron
#

Can I send my code so you can tell me what I’m doing wrong? I’m confused

#

There is my code, I followed the guide on Github, and I am trying to creating a class that will make a context for checking a player in a group

pseudo bramble
#

You never set the luckperms variable

crystal sonnet
#

@jovial saffron well the error happens on line 17, which you didn't provide, so it's hard to tell

#

But again. Nothing LP specific

#

It's probably you never initializing the luckPerms variable

jovial saffron
#

How do I do that?

crystal sonnet
#

basic programming

#

My dude

#

You should must know that

jovial saffron
#

Sorry I don't, I am not that great at programming. I haven't done it in a while.

crystal sonnet
#

Learn the basics, then make plugins, and then use external APIs

#

If initializing a field is too advanced for you, then I'm sorry but this won't work out for you

jovial saffron
#

Look I know the basics but I dont know the terms, are you referring to placing an argument after LuckPerms luckPerms = .....;?

crystal sonnet
#

Yes

jovial saffron
#

Okay thanks I'll try that

short fossil
#

No error in chat BrainStorm, I made a ticket on git with a bunch more information and code snippets and stuff

#

Or error in console

#

Everything runs as normal, but nothing is updated

crystal sonnet
#

I asked you waht LP version you are using... @short fossil

short fossil
#

I said it was in the GitHub ticket but it’s 5.0.78

crystal sonnet
#

Update

#

!downloads

frank driftBOT
short fossil
#

I’ve updated and the issue still persists, same as before

candid tapir
#

I seem to be having a hell of a time navigation the docs or understanding. Can I be pointed into the correct direction on how to grab a specific data, like a user's prefix?

rustic laurel
#

!api have you tried both of these links?

frank driftBOT
candid tapir
#

that is what i'm currently looking at yes

rustic laurel
candid tapir
#

yup I'm looking at that, there is nothing on the specific types of data you can grab so I'm left to wonder what I need to filter through

rustic laurel
#

ngl, I'm really unfamiliar with this side of luckperms. I'd guess it's similart to this but without the time/expiry filters:

int maxWeight = user.getNodes().stream()
        .filter(Node::hasExpiry)
        .filter(NodeType.PREFIX::matches)
        .map(NodeType.PREFIX::cast)
        .filter(n -> n.getContexts().getAnyValue(DefaultContextKeys.SERVER_KEY)
                .map(v -> v.equals("factions")).orElse(false))
        .mapToInt(ChatMetaNode::getPriority)
        .max()
        .orElse(0);
#

also without the context, unless you wanted that

#

not sure, sorry, I'll wait for someone more qualified to respond

candid tapir
#

that is fine, thank you for trying to help me

#

Yea it does not seem to like the mapToInt too well

crystal sonnet
#

@candid tapir there’s a link to the javadocs on the very top

candid tapir
#

I know

grim cape
#

is there a way to filter out ops when checking if a player is in a group unless if they actually are in that group

grim cape
#

cause right now I'm filtering them completely

thorny echo
#

Afaik the player should only have the group permission node if it's directly added to them

#

OP shouldn't affect group memberships

grim cape
#

On the wiki it says it does

#

And they do from my testing

thorny echo
#

So the getnodes call returns every single group node if you're OP'd?

grim cape
#

wait I did player.hasPermission

#

was I not supposed to

thorny echo
#

hasPermission will return true for ops, yes, you'll want to get the users permission nodes / inherited permission nodes and check if the group is there

grim cape
#

oh ok

#

i mean it was the first thing on the wiki so yeah

nocturne elbow
#

Hi is it possible to give a player permission in your code if the player clicks on something?

summer zephyr
#

hey so im running a server and i was wonder how to use this plugin

#

i already have it installed and need to learn the commands

crystal sonnet
#

No idea why you're asking here @summer zephyr

summer zephyr
#

same :/

dreamy schooner
#

Humm on the Doc, i havent see how add a permission to a player.

crystal sonnet
#

!api

frank driftBOT
crystal sonnet
#

Check the section on adding nodes @dreamy schooner

dreamy schooner
#

Is there an example ?

crystal sonnet
#

Not sure

#

Check the oage

dreamy schooner
#

Do you have an example please?

nocturne elbow
#

User user = api.getUserManager().getUser(p.getUniqueId());
DataMutateResult result = user.data().add(PermissionNode.builder("permission").build());
api.getUserManager().saveUser(user);

works for me

dreamy schooner
#

Humm ok ty, one other question , hasPermission work ?

crystal sonnet
#

Please ask a properly worded question

dreamy schooner
#

hasPermission work if we use for check if the player have the permission on LuckPerms

crystal sonnet
#

Yes

short fossil
nocturne elbow
#

Hi i have a problem he is not reading the api.getusemanager with me

crystal sonnet
#

What?

jolly herald
#

Hi, I currently have a problem with the LuckPermsAPI in conjunction with Multibungee. When I try to query a user via API and the user is on a different bungee cord, I sometimes get the user and sometimes null back. The UUID that is passed is on the network and correct. LuckPerms itself is connected to Redis and should be compatible with Multibungee, I thought?

this.userModule.getLuckPerms().getUserManager().getUser(this.uuid)
                                                ^ null

Does anyone have any idea what I'm doing wrong?

crystal sonnet
#

Use loadUser instead @jolly herald

jolly herald
#

thank you 🙏 worked!

ebon osprey
#

Hello how can i check permissions with your api please cant see anything on DEv API

crystal sonnet
#

Why do you need the API?

#

And have a look here:

#

!api @ebon osprey

frank driftBOT
abstract moon
#

where is the doc to get the prefix of a user

#

in java

crystal sonnet
#

!api

frank driftBOT
chrome rain
#

Is there a way to overwrite the * permission for LuckPerms?

rustic laurel
#

be super specific in what youre trying to do

chrome rain
#

Ok so. We have a togglerank plugin, which removes your prefix and adds the one you're toggling to.

#

This is done via deluxe chat

#

It removes the permission chatformat.group and adds the new one thus keeping your group permission so you appear as a different rank

#

However it doesn't work with my owner group as it's conflicting with the * permission.. If someone has any ideas please @ me

nocturne elbow
#

Hi. It would be great if someone could help me. Basically, I own a network server. We moved to a dedicated host about a month ago and since the transition, everything has been messed up. Recently, all servers in our network crashed due to a 'database issue' and our only dev struggled to get them back, and so far has only managed to get one. On this one open server I have noticed that as I start to type /lpb, not even enter it, the server completely crashes and takes forever to get back. Also, all our ranks are cleared. I will point out that I am not a dev, and our only one is getting really pissed off and requesting pay even tho we didn't say we'd pay him when we hired him. Is there anyone that can help - and make sure ranks are safe in the future??

#

@jaunty pecan @proud crypt

frank driftBOT
#

Hey Megan! Please don't tag helpful/staff people directly.

obtuse jolt
nocturne elbow
#

Sorry

#

I'm just stressing out sm rn

pine mulch
#

could someone help me with setting up my ranks in a bungee server

#

i have the ranks the same name as each other

#

but im not sure on how to sync em

pine mulch
#

also is there a way to like merge two ranks together?

obtuse jolt
#

!bungee @pine mulch

frank driftBOT
obtuse jolt
#

Also this should be in #support-1 unless it’s related to luckpermsAPI

rustic laurel
#

@nocturne elbow whoever hosts the database should be contacted. Luckperms relies (like most other programs) on a solid connection to a database that doesn't change. Also when typing /lpb is that the only thing that crashes the server? Also, what version of LP are you on, what messaging service, and what kind of database? Please bytebin your startup log for the proxy and the server that crashes, as well as send /LP info from a server and /lpb info from the console of the proxy

#

!paste

frank driftBOT
#
Please use pastebin!

Seeing a paste of the problem makes everything so much easier! Use https://bytebin.lucko.me/ for easy pasting!

For console errors:

Pastebin any relevant segments of the console log. If it's a startup error, this includes the entire startup log!

Other errors:

Pastebin the entire LuckPerms config file (passwords removed) as well as any other relevant files!

chrome rain
#

Hey @nocturne elbow do you still need help?

verbal finch
#

Hello, how does someone get all the permissions & groups from a player?

rustic laurel
#

What do you mean? just a list of a player's stuff?

#

lp user <user> info will show groups

#

lp tree <scope> <user> will show all permissions checked against a player that partially match <scope> and what they returned

verbal finch
#

no I mean code wise

#

is it possible?

rustic laurel
#

ah sorry didn't notice what channel this was lol

#

!api check the docs here

frank driftBOT
verbal finch
#

yea I already tried. tho I've only read the API package XD I'll try to read others

crystal sonnet
#

All you need to know is on those pages

verbal finch
#

oof nvm it's not the same lol

#

oke found it, thanks!

subtle reef
#

hey, is this proper way to remove a permission

plugin.getPermissions().getUserManager().getUser(player.getUniqueId()).data().remove(Node.builder("randomspawnplus.wild").build());```
crystal sonnet
#

I think that works. Be sure to save the changes in the user object @subtle reef

subtle reef
#

That's probably what I'm missing 😂 been trying to get this to work for a little while

#

Thanks

crystal sonnet
#

You’re welcome

dusky wagon
#

how i can get from loaduser the user sync?

crystal sonnet
#

What do you mean? @dusky wagon

dusky wagon
#

how i get from loaduser the user?

#

without async

short fossil
#

Use the loaduser function but do .get(int, TimeUnit.[Seconds/Minutes/etc]

#

Don't believe it is possible to load it, however you can treat it as a sync function using .get

#

@dusky wagon

dusky wagon
#

and why not only .get?

short fossil
#

You can but it can error out if it takes too long

#

much safer to specify a timeout

dusky wagon
#

ok

crystal sonnet
#

The API gurantuees that it'll return eventually.

#

And don't load players sync

#

It'll lag

#

If you're on a async thread just add .get()

chrome rain
#

Ok so. We have a togglerank plugin, which removes your prefix and adds the one you're toggling to.

This is done via deluxe chat
It removes the permission chatformat.group and adds the new one thus keeping your group permission so you appear as a different rank
Is there anyway to override the * permision as theat is blocking this working.

crystal sonnet
#

If you know the user is online, use getUser @dusky wagon

#

@chrome rain Those are statements. What is your question?

chrome rain
#

Sorry I pressed enter too early, Brainstone, I've edited my message :p

dusky wagon
#
public static boolean hasPermission(UUID uuid, String permission) {
        LuckPerms lp = LuckPermsProvider.get();
        User user = null;
        if(lp.getUserManager().isLoaded(uuid)) {
            user = lp.getUserManager().getUser(uuid);
        } else {
            try {
                user = lp.getUserManager().loadUser(uuid).get();
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }
        }

        ContextManager contextManager = lp.getContextManager();
        ImmutableContextSet contextSet = contextManager.getContext(user).orElseGet(contextManager::getStaticContext);

        CachedPermissionData permissionData = user.getCachedData().getPermissionData(QueryOptions.contextual(contextSet));
        return permissionData.checkPermission(permission).asBoolean();
    }

I use this

crystal sonnet
#

Why? Do you need to check offline players?

#

@dusky wagon

dusky wagon
#

yes i need this.

crystal sonnet
#
        if(lp.getUserManager().isLoaded(uuid)) {
            user = lp.getUserManager().getUser(uuid);
        } else {
            try {
                user = lp.getUserManager().loadUser(uuid).get();
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }
        }

That's completely pointless

#

In that case just use lp.getUserManager().loadUser(uuid).get()

#

Does the same

#

But in any case it's important that you run that code async if you don't want to lag the server

dusky wagon
#

but if the player is already loaded I don't have to load it again

crystal sonnet
#

And lastly use this:

        ContextManager contextManager = lp.getContextManager();
        QueryOptions queryOptions = contextManager.getQueryOptions (user).orElseGet(contextManager::getStaticQueryOptions);

        CachedPermissionData permissionData = user.getCachedData().getPermissionData(queryOptions);
#

LP does that already

#

Which you knew if you read the javadocs

dusky wagon
#

ok

crystal sonnet
#

!nowildcard

frank driftBOT
crystal sonnet
#

@chrome rain

chrome rain
#

Oh I see

crystal sonnet
#

Though the easiest way to fix it is setting chatformat.* to false

#

It overrides the *

chrome rain
#

I'll give it a try, thank you Brain!

dusky wagon
#
    public static boolean hasPermission(UUID uuid, String permission) {
        LuckPerms lp = LuckPermsProvider.get();
        User user = null;
        try {
            user = user = lp.getUserManager().loadUser(uuid).get();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
        

        ContextManager contextManager = lp.getContextManager();
        QueryOptions queryOptions = contextManager.getQueryOptions (user).orElseGet(contextManager::getStaticQueryOptions);

        CachedPermissionData permissionData = user.getCachedData().getPermissionData(queryOptions);
        return permissionData.checkPermission(permission).asBoolean();
    }

it is so right?

crystal sonnet
#

And the individual chatformat.group override in turn the chatformat.*

chrome rain
#

I'll negate the chatformat.* now

#

So now I should only have chatformat.owner

#

?

crystal sonnet
#

Except that you'll get a NullPointerException if loading the player fails and that you have consequently ignore what I said about sync and async, yes that looks ok

#

@chrome rain yes

chrome rain
#

Perfect thank you :)

#

I'll give it a try

#

I can keep the * permission on the group ?

crystal sonnet
#

Yes

dusky wagon
#

Except that you'll get a NullPointerException if loading the player fails and that you have consequently ignore what I said about sync and async, yes that looks ok
i run the methode async, or what you mean?

frank driftBOT
#

Hey Meerpaluten! Please don't tag helpful/staff people directly.

dusky wagon
#

sry

crystal sonnet
#

Make sure that whenever you are checking permissions with that method that you are not on the main server thread

#

(Or that you're not making the main server thread wait on your thread)

#

Else you'll lag the game

dusky wagon
#

ok

#

must i use Bukkit#getScheduler()#runTaskAsynchronously?

chrome rain
#

Thank you BrainStone that's fixed it!

crystal sonnet
#

Yes @dusky wagon

#

But your entire code

#

Not just that function

#

Are you even understand what I'm talking about?

#

Because I have the feeling you don't have a clue

dusky wagon
#

Yeah, I see what you mean, maybe it doesn't come across that way.

crystal sonnet
#

Ok. Good

charred shell
#

Is there a way to check if the user has ever joined (data created). I need this non async

#

@crystal sonnet

frank driftBOT
#

Hey !Tom! Please don't tag helpful/staff people directly.

crystal sonnet
#

non async
Not possible.

charred shell
#

And async?

crystal sonnet
#

!dev

frank driftBOT
#

Sorry! I do not understand the command !dev
Type !help for a list of commands.

crystal sonnet
#

Check the userManager in the Javadocs

charred shell
#

I did

#
        BukkitCore.getPlugin().getLuckpermsHook().getApi().getUserManager().lookupUniqueId(str).thenAcceptAsync(s -> {
            System.out.println(s.toString());
        });
crystal sonnet
#

Ok

charred shell
#

This isn't working

crystal sonnet
#

!nw

frank driftBOT
#
Please tell us what's going on!

We really would absolutely love to help you out! However, telling us that it isn't working wastes everyone's time. Please, just describe the issue you're having clearly and with as much detail as possible, and send any relevant screenshots of whatever problems you're having.

For Console Errors:
charred shell
#

Nvm...

crystal sonnet
#

Ok

charred shell
#

bad support tho

crystal sonnet
#

Why?

#

I mean what am I supposed to do with that info?

charred shell
#

I said it isn't working

#

Maby help to make working code 😆

rustic laurel
#

? You know that he can't read your mind to know how it's supposed to work or what it's supposed to do, right

crystal sonnet
#

Not working can reach from the code not compiling to it blowing up your computer

#

You gotta be more specific

#

Hence I droped this

#

!nw

frank driftBOT
#
Please tell us what's going on!

We really would absolutely love to help you out! However, telling us that it isn't working wastes everyone's time. Please, just describe the issue you're having clearly and with as much detail as possible, and send any relevant screenshots of whatever problems you're having.

For Console Errors:
crystal sonnet
#

@charred shell

verbal finch
#

lol

#

he probs wanted to be spoon fed

nocturne elbow
#

!help

frank driftBOT
#
Available commands:

!advanced
!api
!argumentbased
!ask
!bulkupdate
!bungee
!cauldron
!chat
!colours
!commandequivalents
!commands
!config
!context
!default
!downloads
!editor
!errors
!essentials
!extensions
!faq
!helpchat
!install

!locale
!meta
!migration
!notworking
!nowildcard
!pasteit
!permissions
!placeholders
!selfhosting
!stacking
!storage
!suggestions
!switchstorage
!sync
!tracks
!upgrade
!usage
!userinfo
!verbose
!weight
!whyluckperms
!wiki

nocturne elbow
#

!essentials

frank driftBOT
#
Essentials

Make sure you are using EssentialsX and Vault for prefixes. For any other issues with Essentials, you should seek support in either #general or the official EssentialsX support Discord.

EssentialsX Discord
crystal sonnet
#

@verbal finch I mean even if I wanted to I couldn’t have. Too little information

lilac mountain
#

!config

frank driftBOT
lilac mountain
#

is there a way to read and/or edit the config through the api (I know seems kinda odd)

terse cipher
#

Can somebody pls help me i got a struggle with lucky perms ! 😦 Pls reply..

scarlet harness
#

is there anyone who would be able to tell me how i get the prefix of a player via the api?

nocturne elbow
#

if you don't find in 6~ hours, I'll be able to tell

scarlet harness
#

o mad it be like that xD

crystal sonnet
#

@lilac mountain you can’t edit it. Why do you want that in the first place?

#

!api @scarlet harness

frank driftBOT
crystal sonnet
#

@terse cipher is your question about the developer API?

terse cipher
#

Its already done thanks 🙂

scarlet harness
#

@crystal sonnet so i was just asking how i would get the prefix of a players group so i can display it next to their name within a chat event

frank driftBOT
#

Hey Joshツ! Please don't tag helpful/staff people directly.

scarlet harness
#

^^ mybad

crystal sonnet
#

!api

frank driftBOT
burnt summit
#

Does anyone know what method I would need to call to get a particular player's position in a promotion track? This is my first time building a plugin with dependencies so any help is much appreciated

scarlet harness
#

i came up wit this but getting errors any ideas?

#
        User user = plugin.luckapi.getUserManager().getUser(p.getUniqueId());
        
        ContextManager contextManager = plugin.luckapi.getContextManager();
        ContextSet context = contextManager.getContext(user).orElseGet(contextManager::getStaticContext);
        return user.getCachedData().getMetaData((QueryOptions) context).getPrefix();
        
    }```
crystal sonnet
#

What errors?

#

And where to you guys keep getting the part with the contexts from?

scarlet harness
#

thats on the javadocs

#

i gathered the context part from the javadocs tryed to cache the prefix using something i made up

crystal sonnet
#

Use QueryOptions directly

#

QueryOptions queryOptions = contextManager.getQueryOptions(user).orElseGet(contextManager::getStaticQueryOptions); @scarlet harness

twilit jasper
#

how do I get the global context? I need it to pass into the track promote method

crystal sonnet
#

From the context manager @twilit jasper

twilit jasper
#

right but how, do I just say global like api.getContextManager().getContext("global")

white topaz
#

trop compliqué

crystal sonnet
#

It should have a method for getting the global context directly @twilit jasper

#

@white topaz what do you mean?

twilit jasper
#

nothing shows up in the code hint

white topaz
#

i mean "too hard" sorry !

crystal sonnet
#

What’s too hard?

white topaz
#

for me to understand what he said, sorry for this

#

i'm french thats why

crystal sonnet
#

This is for plugin developers working with the LuckPerms API

#

!api @twilit jasper Check the second link and there should be some example on how to create a context

frank driftBOT
crystal sonnet
#

If I’m not mistaken the empty context is the global one

white topaz
crystal sonnet
#

Don’t worry. I check the channels

#

When and only when I feel like it

lilac mountain
#

I was thinking of adding a little plugin that would add a fallback database but I think that might be far more useful in the full plugin

#

especially since the plugin denies players from joining which isn't a bad thing but a like internal or external fallback database that gets updated every hour or so would help out so that there are fallback permissions

crystal sonnet
#

Trust me in 9/10 cases you're better off knowing that something is wrong

#

Because having a backup could easily lead to only the backup working without you knowing

#

And then if that dies you're just as screwed, if not more

lilac mountain
#

Yeah but the fallback database is more when cough cough a provider of such database cough cough MCPH cough cough decides that without notice there database server is going offline and that would go for any provider really. But I'm thinking of it more as a if the server can't connect than an issue where the database is corrupted

crystal sonnet
#

Get a better host 😛

stiff thistle
lilac mountain
#

We use shockbyte for the main servers other than the hub. I think I might move the database over when it starts up again soon or later were going to host it ourselves so we never have to worry about these issues again

#

means it doesn't know what that is

#

You probably need to reload the maven dependencys

crystal sonnet
#

@stiff thistle that's just syntax highlighting I guess

ancient heron
#

This is a startup error.
https://pastebin.com/x7HZVaYw

I stumbled on the code I made after seeing WIKI.

What are the possible causes?
(I am bad at English.)

The following is the source code for that part.```java
private boolean setupLuckPerms() {
if (getServer().getPluginManager().getPlugin("LuckPerms") == null) {
return false;
}
RegisteredServiceProvider<LuckPerms> rsp = getServer().getServicesManager().getRegistration(LuckPerms.class);
if (rsp == null) {
return false;
}
luckpermsApi = rsp.getProvider();
return luckpermsApi != null;
}

crystal sonnet
#

@ancient heron you don't have LuckPerms installed

ancient heron
#

Is it a plugin?

rustic laurel
#

It's luckperms

crystal sonnet
#

So you try to add support for LuckPerms but don't know what it is in the first place?!

ancient heron
#

Well, I don't understand much.

#

I have LuckPerms in my plugins folder.

#

Ah...
I have to apologize ...
I was using the wrong version.

crystal sonnet
#

You need a 5.x.x version

radiant kiln
#

just double checking, I should use luckperms getpermission method over the player#getPermission method?

short fossil
#

Either should work

#

I use getPermission across all my plugins withn no issue @radiant kiln

radiant kiln
#

do you think luckperms method is faster than the player one?

short fossil
#

I'd say the player one is probably faster however speed is going to be negligable

crystal sonnet
#

Use the platform one

#

(The player one)

eager shore
#

i can only find a way to get/set the primary group for a user, how do i add/get additional groups?

#

do i just use the permission nodes group. etc?

short fossil
#

Group group = luckPerms.getGroupManager().getGroup(groupName);

#

@eager shore

eager shore
#

i want to check if a user is in a group, or put them in a group

short fossil
#

I use java Set<String> groups = permission.getUserManager().getUser(playerUUID).getNodes().stream() .filter(NodeType.INHERITANCE::matches) .map(NodeType.INHERITANCE::cast) .map(InheritanceNode::getGroupName) .collect(Collectors.toSet());

#

to get a set of a user's groups (parents)

#

and then you can filter through this

#

using a for each loop on groups

#

then use the user manager to load the user

#

CompletableFuture<User> userFuture = permissions.getUserManager().loadUser(player.getUniqueId());

#

then use ```userFuture.thenAcceptAsync(user -> {
//Modify user groups &| permissions here
});````

#

to modify the users group

#

or permissions

#

and then finally save the user using UserManager#saveUser(user)

#

@eager shore

eager shore
#

ok thanks

short fossil
#

yup

crystal sonnet
#

!api for reference

frank driftBOT
rustic laurel
#

@tender walrus scroll up a little bit here, you should see what you're looking for

tender walrus
#

I’m using Vault

rustic laurel
#

Oops sorry

tacit grove
#

How i can get the highest rank of user ?

eager shore
#

if i promote a user up a track, do I then have to save the user, group and track?

#

i.e
LuckPermsProvider.get().getUserManager().saveUser(user); LuckPermsProvider.get().getGroupManager().saveGroup(group); LuckPermsProvider.get().getTrackManager().saveTrack(track));

subtle reef
#

if anyone familiar with the API + perms stuff could help me here, trying to work on this again

#
luckPerms.getUserManager().getUser(player.getUniqueId()).data().remove(Node.builder("randomspawnplus.wild").build());```
trying to remove  a permission when a command is executed
#

line is executed, no errors or anything

#

seems to not do anything

short fossil
#

Did you save the user?

subtle reef
#

i definitely didn't

#

trying that now, thank you

subtle reef
#

should I be using User#savePlayerData or User#saveUser

#

both seem to not work for me

crystal sonnet
#

@eager shore only the things you changed need to be updated

#

So typically only the user

#

@subtle reef saveUser

#

Now does the permission you try to remove have a context?

hardy violet
#

Is anyone else having issues where you set a player's permission using the permission set command but when the player is typing the command it shows as red and auto-complete doesn't work until the player reconnects to the server or there's a /reload?
It also does it reversed where if you take the permission from the player then it shows that you can type it and auto-complete works until you reconnect. ( Latest version of Minecraft [1.15.2] )

crystal sonnet
#

That’s normal behavior

lilac kernel
#

Hello all,
Is the expiry stackable on multiple use in same NodeBuilder or overwrite it the time?

jaunty pecan
#

it overwrites

lilac kernel
#

oh okay.

crystal sonnet
#

Just keep track of the time elsewhere 😉

lilac kernel
#

Is the expiry not the time for temp group/permission?!

jaunty pecan
#

it's easy enough to extend the expiry of an existing node, if that's what you're trying to do

#

yes it is

lilac kernel
#

Ah ok , thanks 😉

lilac kernel
#

Hello again,
in the Node list of a User, represent the key of the Node a Group name and/or Permission string? I had think first that's only the permissions but now i cant find the groups of the user.

crystal sonnet
#

I don’t understand anything

#

Can you try to rephrase?

subtle reef
#

@crystal sonnet I don't think so? It's just set in group default. I'm trying to negate it for whoever uses a command

frank driftBOT
#

Hey apt! Please don't tag helpful/staff people directly.

crystal sonnet
#

@subtle reef alright

#

Try finding the existing node and removing that from the set

#

@subtle reef can I see your current code?

jaunty pecan
#

apt, if you're trying to negate a node

#

you need to use something like

#
luckPerms.getUserManager().getUser(player.getUniqueId()).data().add(Node.builder("randomspawnplus.wild").value(false).build());
#

data().remove(...) removes a node from the set

#

which as you can see from /lp user ... permission info - is empty :p

#

so instead, you need to data().add(...) a negated node

subtle reef
#

Thanks so much luck 👍👍

subtle reef
#

finally got around to testing out that code, and yeah it worked flawlessly first time. again, thanks a ton 😄

crystal sonnet
#

Ah. I thought you were trying to unset that permission (which was set to true) in the first place

lilac kernel
#
luckPerms.getUserManager().getUser(player.getUniqueId()).data().add(Node.builder("randomspawnplus.wild").value(false).build());

Same works with groups? And without luckPerms.getUserManager().saveUser(user)?

neat jackal
#

You can use InheritanceNode instead of Node for groups.
And you still have to save the changes

coarse oxide
#

Hi, if I want to get to user's group/rank(for example Admin) do I use UserManager?

crystal sonnet
#

You get the User Instance from the UserManager

scarlet harness
#

hi all i see this on the git wiki page and curious what needs to be put in place when calling this method for the possiblegroups ?

#
    for (String group : possibleGroups) {
        if (player.hasPermission("group." + group)) {
            return group;
        }
    }
    return null;
}```
short fossil
#

What are you trying to do @scarlet harness

scarlet harness
#

just trying to retrive the players rank

#

to display in a scoreboard

short fossil
#

That will return the first group and nothing more

#

do you want to return primary, most weighted, or?

scarlet harness
#

primary

short fossil
#

Ok so rather then use hasPermission I would use LuckPerm's api

#
            Set<String> groups = permission.getUserManager().getUser(playerUUID).getNodes().stream()
                    .filter(NodeType.INHERITANCE::matches)
                    .map(NodeType.INHERITANCE::cast)
                    .map(InheritanceNode::getGroupName)
                    .collect(Collectors.toSet());```
scarlet harness
#

that is within luckperms api i got that from the wiki

short fossil
#

player#hasPermission is a bukkit method

#

It will only return if a player is in a group, not anything more

#

however I wouldn't recommend it because it doesn't take into account much else then if in the group

#

the code I sent gets a string set of all groups a user inherits

scarlet harness
#

but if im trying to display only one how am i then choosing the primary

short fossil
#

Well you will have use the groupManager in luckperms

#

then you can get info about the group

#

Group group = luckPerms.getGroupManager().getGroup(groupName);

#

for example you can get a group's weight through group#getWeight

#

However if you are just going for primary group

#

%luckperms_primary_group_name%

#

will do the trick @scarlet harness

#

If you are insistant of doing it through the api

#

load the user using userManager#loadUser(uuid)

#

then do user#getPrimaryGroup()

#

Either one will do the trick

scarlet harness
#

so @short fossil i just tried something like this am i doing it wrong or am i juyst getting confused

#
        User user = plugin.luckapi.getUserManager().getUser(p.getUniqueId());
        String group = user.getPrimaryGroup();
        return group;
    }```
short fossil
#

I would use getUserManager().loadUser

#

as it is much safer long-term

scarlet harness
#

wait instead of what or a new line?

short fossil
#

Well i guess since you aren't modifying the user it doesn't matter much

#

But that looks good to me

scarlet harness
#

i just tried it and it erroed

short fossil
#

Send error?

scarlet harness
#

wait nvm i believe the erroe may or been caused by somethjing else

short fossil
#

Ok let me know

scarlet harness
#

yeah it worked now

short fossil
#

Coolio

scarlet harness
#

is there a way to get the primary group display name tho?

short fossil
#

YEah

scarlet harness
#

how would that be done

short fossil
#

permissions.getGroupManager().getGroup(user.getPrimaryGroup()).getDisplayName()

scarlet harness
#

wait so what am i going about with that

short fossil
#

What do you mean?

scarlet harness
#

so how am i calling that in my method

short fossil
#

plugin.luckapi.getGroupManager().getGroup(group).getDisplayName();

scarlet harness
#

ooo i see i got u makes alot more sense now thank you alot bud helps so much very healful

#

helpful

short fossil
#

np

coarse oxide
#

Hi, I have a problem with getting user's group:

User player = manager.getUser(minecraftID);
                                    if (player != null) {
                                        String primaryRank = player.getPrimaryGroup();
                                        event.getMessage().getChannel().block().createMessage("Rank: " + primaryRank).subscribe();
                                    }
                                    else {
                                        return;
                                    }
#

I have the user stored in LuckPerms/json-storage/users

#

player seems to be null all the time

short fossil
#

I would use the userManager#loadUser(uuid)

lucid rapids
#

hello, just checked the wiki quickly, i'm not perfectly sure if i am able to find any way to modify a user's prefix?

#

with that, i mean mostly a direct method from LP, not adding prefixes as permissions

rustic laurel
#

!api try both of these links, including the javadocs which are here somewhere

frank driftBOT
lucid rapids
#

oh, must have missed this

#

// build a prefix node
PrefixNode node = PrefixNode.builder(100, "[Some Prefix]").build();
``` this one correct?
rustic laurel
#

thiiinkkk so, you'd have to try (or wait for someone who really actually knows) cause idrk

short fossil
#

Yeah that is what I use to modify prefix's @lucid rapids it should work

lucid rapids
#

👍 with addNode right?

short fossil
#

user#data#add(node)

lucid rapids
#

yeah that

short fossil
#

yeah

lucid rapids
#

okay seems good, asynchronously or won't matter much?

short fossil
#

I'd use loadUser just out of habit, but it shouldn't matter either way

#

loadUser just allows offline I believe

#

and thus access database and needs to be async

lucid rapids
#

okay seems good, thanks!

short fossil
#

np

hardy badge
#

Is it not currently possible to set meta data with the API as of now?

rustic laurel
#

!api it is, check both of these links, should be there. If it's not, ask a really specific question

frank driftBOT
hardy badge
#

weird, I found it, wasn't looking in the right place!

rustic laurel
#

glad to hear it! 😄

thick robin
#

UserDataRecalculateEvent is this event called when a player gets added to a node?

crystal sonnet
#

Yes. Plus a lot more, so be sure to filter for what you want

thick robin
#

sweet. also, how can I get an instance of luck perms on a bungee cord server?

crystal sonnet
#

Use the singleton

#

!api

frank driftBOT
thick robin
#

sweet, thank you

crystal sonnet
#

You're welcome

thick robin
#

how can I get what was updated in UserDataRecalculateEvent? can't seem to find anything

#

I just need to know if a node was given or taken from the user

crystal sonnet
#

It should have methods that tell you

thick robin
#
User getUser();
CachedDataManager getData();
LuckPerms getLuckPerms();
Class<? extends LuckPermsEvent> getEventType();
#

thats the methods

crystal sonnet
#

getData?

#

Ah wait

#

Keep in mind that that event might have been triggered for various reasons

#

So either keep track of the relevant nodes yourself and look for changes or use another even

thick robin
#

alright, sounds good

#

thank you

crystal sonnet
#

*event

thick robin
#

do I check if a player has a group in bungee using if (player.hasPermission("group.admin")?

#

or do I have to do something weird like

CachedPermissionData permissions = user.getCachedData().getPermissionData(QueryOptions.defaultContextualOptions());
if (permissions.checkPermission("group.admin").asBoolean()) {
    
}
dense kelp
#

That should work

#

There's probably another way

#

But when you add someone to a group, if u check /lp user (name) permission info it would say group.whatevergroupname

thick robin
#

it prints out admin and owner from this .peek(System.out::println)

#

so getRanks() is not empty

dense kelp
#

Lemme read the docs for u

#

!api

frank driftBOT
thick robin
#

thanks. I just need to get a list of all the groups a user has access to

dense kelp
#

Wait i thhink i found it on the javadoc

#

Lemme link hold up

#

Oh shit u need all the ranks

#

Not just orimary

#

Ill keep lookin

thick robin
#

http://prntscr.com/sch8o7
I did the command /lp user SimonM34 parent add admin and it made my primary rank admin, do you know why this is? does primary rank show the heaviest rank the player has?

Lightshot

Captured with Lightshot

dense kelp
#

Yes

#

The one with the heaviest weight

thick robin
#

thats exactly what I need 😛 I didn't know that

dense kelp
#

Lol alrighty

thick robin
#

sorry about that

dense kelp
#

No api need? xD

thick robin
#

well I guess not lol

dense kelp
#

Npnp i have nothing else to do

#

Imma keep lookin tho

thick robin
#

thank you, luck perms really confuses me

dense kelp
#

The javadocs really confuse me lmao

thick robin
#

actually

dense kelp
#

Idk it's unorganized

thick robin
dense kelp
#

Wtf

#

Heh

#

Try user. Getprimarygroup. Getweight if that exists

#

Sorry for caps

#

Im on mobile rn

#

If the weight is the admin's weight, ur good

thick robin
#

getPrimaryGroup returns a string

dense kelp
#

Ye

#

Ik thats weird that it says default

#

What if u put default as a higher weight

#

Check if then it aays admin

#

BrainStone you got anything?

thick robin
#

I set the default weight to 1000 and to 1 and it still returned default both times ;p

dense kelp
#

Hmm

#

That's odd

#

If u can wait 4hrs ill be up

#

Ill go on my pc and check

thick robin
#
user.getNodes()
        .forEach(node -> System.out.println("node: " + node.getKey()));

this also only prints out the default group when I have given myself admin group ._.

dense kelp
#

Actually 2 - 3

#

Lol it loves default

#

Are you sure you're using the new jar?

thick robin
#

downloaded it like 10 minutes ago

dense kelp
#

Sometimes i forget lmao

rustic laurel
#

Do you have context on either of the groups that might be excluding it

dense kelp
#

Oh yea

#

Thats a thing

thick robin
#

what do you mean?

dense kelp
#

It means like different weight for different worlds, areas, etc

rustic laurel
#

Is the group added to your user with context

#

Delected weight is not per context except for prefixes and suffixes

thick robin
#

I don't think so. all ive done is /lp user SimonM34 parent add admin

dense kelp
#

Its added as seen on sidebar

#

So it should still be primary group

#

Higher weight etc

rustic laurel
#

Delected, if you know what's going on, feel free to help out,, but if you don't, let's wait for BrainStone who knows a lot more about LPAPI than either of us

dense kelp
#

I was just helping him find methods off the javadoc

#

Ill literally readthe description

#

Hmm "which method is configured..."

thick robin
#

I appreciate you helping tho

dense kelp
#

Not sure

rustic laurel
#

That's in the config, where you set primary group calculation

dense kelp
#

Cant be tha

#

That*

#

Sunce it says his primary group is admin on mc

rustic laurel
#

!config check here to see what's up with why that method is returning what it is

frank driftBOT
dense kelp
#

Just the api

rustic laurel
#

The API might be different than in-game if it's configured different, no?

dense kelp
#

Hsve u changed config values for the calculator ?

thick robin
#

well im using the bungee luck perms api

#

primary-group-calculation: parents-by-weight thats in the config

rustic laurel
#

It should be as stated then, hm

dense kelp
#

Thats the one

#

Ok try amthn

#

Try using the set method

#

To set to admin

#

And then get it

#

Just to see what happens

#

You could also use GroupManager (the class, not the plugin) to check for the highest weighted rank iirc

thick robin
#

it must be something wrong with how I am doing it. I removed the default rank and set the primary rank to admin and it still returned default ;-;

#

maybe the ranks haven't loaded yet?

dense kelp
#

Nah

#

Ok delete the plugin

#

Rebuild it

rustic laurel
#

@thick robin try saving and then do the age old turn it off and back on again

dense kelp
#

Andthen /reload

#

Well addadmin back too ofc

#

And give it a higher weight

thick robin
#

I may have not setup luckperms properly. could it be something to do with the bungee and spigot servers not communicating or its only setting the rank on the spigot server not the bungee?

rustic laurel
#

Waiit

#

In the proxy console

#

What is your user info

dense kelp
#

Lol they're both dif ranks

#

That's what bungee's for, aint it?

rustic laurel
#

Cause if you simply haven't synced, that's not a tough one to solve

#

Delected idek what you're on about tbh

thick robin
#

whats the proxy commands?

rustic laurel
#

Lpb

#

Instead of lp

#

Same commands though

dense kelp
#

Ok i thought i knew more than i did about bungeecord

#

I need to use it

#

All i know is how to set it up

#

Like configwise

thick robin
dense kelp
#

Did u do what i said?

#

Rebuild the plugin

#

And /reload

rustic laurel
#

No. Don't do that.

obtuse jolt
#

/reload wot?!

dense kelp
#

Or restart w/e

rustic laurel
#

Delected, stop suggesting bad practice

#

It's misleading and harms more than helps

dense kelp
#

Ok then stop and start smh

thick robin
#

ive done that many times lol

rustic laurel
#

Simon, the uuid mismatch error is what's concerning me

dense kelp
#

It's just quick

thick robin
#

oh

#

well that could be a problem

dense kelp
#

U on offline mode?

thick robin
#

my spigot server is

rustic laurel
#

You need a solid uuid for luckperms to know who you are

#

Make sure you have ip_forward, and online_mode true in the bungee config

dense kelp
#

Because when people's names change, there is no other way to tell eho thwy are on cracked

#

Uuids never change

rustic laurel
#

And set bungeecord to true in spigot config.yml

#

Delected you're incredibly incorrect

obtuse jolt
#

Because when people's names change, there is no other way to tell eho thwy are on cracked
wottttttttttttt

#

cracked means no stable UUID mate

dense kelp
#

Because theyhave no uuid

#

Thags what i said

thick robin
#

well they do, but its random

dense kelp
#

So u dont know

rustic laurel
#

Wut

#

Simon make sure the three things I suggested are true

dense kelp
#

Larry how tf?

When you're on cracked, you are given a random uuid. If you change your name, it makes matters worse.

On non-cracked servers, even name change can screw things up for plugins w/o uuid support

#

Thus why luckperms has uuid support

#

That's what im getting at

obtuse jolt
#

Uuids never change
hM

dense kelp
#

Im saying on non-cracked

rustic laurel
#

Best to get what you're getting at while you're getting at it

dense kelp
#

Im on mobile i cant type fast

#

Or type properly, for that matter lmao

thick robin
#

I guess that was the issue. http://prntscr.com/schttt the primary group is still default but now there is an extra node which I can use 🙂

Lightshot

Captured with Lightshot

rustic laurel
#

Fantastic! Hope its all smooth sailing from here on out

thick robin
#

thank you all for the help 🙂

rustic laurel
#

Np!

thick robin
#
PendingConnection connection = event.getConnection();
CompletableFuture<User> future = LuckPermsProvider.get().getUserManager().loadUser(connection.getUniqueId());
future.thenAcceptAsync(user -> {
    if (user.getNodes().stream()
            .anyMatch(node -> plugin.getRanks().contains(node.getKey().replace("group.", "")))) {
        plugin.getDatabase().createSession(connection.getName(), connection.getUniqueId());
        System.out.println("has group");
    }
});

perfect 😉

dense kelp
#

Noice 👌

rustic laurel
#

Try setting codeblocks like this, super cool:

```java
Code here
```

#

Or whatever language you write in, just about

thick robin
#

I did?

rustic laurel
#

Ohhh my display is screwy then, mb haha

thick robin
#

ahaha, all good

#

thanks thoooo

dense kelp
#

Ye it doesn't show on mobile for some reason aaaa

#

I keep dissinmobike but it deserves it

#

Ok its 6:15 imma try to get at least 1hr of sleep today lmfao

#

Pce

thick robin
#

night night

coarse oxide
#

Hi, I have a question, what am I doing wrong here?

                                    UUID mcID = Bukkit.getOfflinePlayer(minecraftName).getUniqueId();
                                    minecraftID = mcID.toString();
                                    User player = manager.getUser(mcID);
                                    if (player != null) {
                                        String primaryRank = player.getPrimaryGroup();
                                        event.getMessage().getChannel().block().createMessage("Rank: " + primaryRank).subscribe();
                                    }
                                    else {
                                        return;
                                    }
#

I am trying to get a player's rank from LuckPerms

#

but player is always null

dense kelp
#

can you send it in pastebin?

#

also send the whole class in possible

coarse oxide
#

I can't send the whole class due to the contract, sorry 😦

dense kelp
#

alright

#

is .subscribe() a JS function?

#

in that case, I cannot help

#

I know nothing abt JS

coarse oxide
#

it's from Discord4J

dense kelp
#

oh

#

ok

coarse oxide
#

it just sends a message

dense kelp
#

alright

#

equivalent to the JDA .queue I gotchu

#

actually when I got on my pc I'll send what I did for a mc -> discord "link" system

#

I used JDA but it stil lshould work just change it up a bit

#

I used a /link cmd on mc which would send you a code to type in on discord

#

is that what you're trying to do?

coarse oxide
#

basically yes

#

that's one of the ways I considered

dense kelp
#

there's always DiscordSRV too lol

coarse oxide
#

I have to do it myself 😦

dense kelp
#

ok

#

hold up I'm on a laptop rn

#

lemme load up my desktop

coarse oxide
#

No problem, take your time 😄

dense kelp
#

I didn't cover the rank sync but I could help w/ that too

#

I only did the /link cmd

#

since I gave up

#

after DiscordSRV

coarse oxide
#

I just need rank sync + confirmation of link

dense kelp
#

I could always spoonfeed but I'll try to explain it while my pc loads

#

so basically what I did was

#

When a player runs /link, I would check if they were added to an arraylist called inQueue or smthn like that

#

if they were on the list, return because they already had a code

coarse oxide
#

Yea, I store players' data in JSON file

dense kelp
#

alright cool

#

and so if not, generate a random code

#

then add them to inQueue

#

then on the discord side

#

I would check for the command !link (code)

#

if the code was in the list, it would store the player's link in a YAML file like so:

playeruuid, discordid
#

probs not the best way

#

I just wanted it done quickly

coarse oxide
#

Okey

dense kelp
#
# so like:
players:
  4faf8bf9-c59f-47b6-895a-af141434e787, 707919905978318860
#

would be mine

#

I don't remember exactly but it was similar to that

#

ofc there's more checks but I just didn't mention them since I'm lazy lol

#

ok lemme hop on my desktop

#

then I'll help w/ role sync

coarse oxide
#

Thanks a lot!

dense kelp
#

you're using SpigotAPI, correct?

#

and the Discord4J API

coarse oxide
#

Yes, Spigot + Discord4J

dense kelp
#

aight

coarse oxide
#

Can we hop on DM? Then I'd be able to send you a little bit more maybe

#

If it's not a problem ofc

dense kelp
#

ok sure

opaque apex
#

hey guys

#

how can I change the group of a player using the api?

#
    me.lucko.luckperms.bukkit.LPBukkitPlugin bukkitPlugin = (me.lucko.luckperms.bukkit.LPBukkitPlugin) eazyNick.getReflectUtils().getField(me.lucko.luckperms.bukkit.LPBukkitBootstrap.class, "plugin").get((me.lucko.luckperms.bukkit.LPBukkitBootstrap) Bukkit.getPluginManager().getPlugin("LuckPerms"));
    me.lucko.luckperms.common.model.User commonUser = new me.lucko.luckperms.common.model.User(p.getUniqueId(), bukkitPlugin);
    net.luckperms.api.context.ImmutableContextSet context = bukkitPlugin.getContextManager().getContext(p);
    List<net.luckperms.api.node.types.InheritanceNode> nodes = commonUser.normalData().immutableInheritance().get(context.immutableCopy()).stream().filter(net.luckperms.api.node.Node::getValue).distinct().collect(Collectors.toList());

    if(!(nodes.isEmpty()))
        commonUser.unsetNode(net.luckperms.api.model.data.DataType.NORMAL, nodes.get(0));
    
    commonUser.setNode(net.luckperms.api.model.data.DataType.NORMAL, me.lucko.luckperms.common.node.types.Inheritance.builder(groupName).withContext(context).build(), true);
    commonUser.getPrimaryGroup().setStoredValue(groupName);
} catch (Exception e) {
}```
#

this is what I tried, but it didn't work

dense kelp
#

change the primary group?

opaque apex
#

that didn't work either

neat jackal
#

Primary group changes don't have an effect iirc

dense kelp
#

depends

#

on config

#

This modifies the "stored value" for the users primary group, which may or may not actually take effect, depending on how the platform is calculating primary groups.

opaque apex
#

IllegalStateException - if the user is not a member of that group

neat jackal
#

Anyways, why are you not using the API?

opaque apex
#

so that won't work

dense kelp
#

ye lol

#

that code is all messy

opaque apex
#

Anyways, why are you not using the API?
@neat jackal because I couldn't find a way to do it with it

frank driftBOT
#

Hey Justix! Please don't tag helpful/staff people directly.

dense kelp
#

you sure can

opaque apex
#

how

dense kelp
#

we'll help you if you get the API

opaque apex
#

that was my only question

neat jackal
#

Just add an InheritanceNode to the Users' data

opaque apex
#

how can I do that?

neat jackal
#

!api that should cover most of that

frank driftBOT
dense kelp
#

or you could just uhh

#

setPrimaryGroup() if you have it setup correctly

#

just an easy way out

opaque apex
#

IllegalStateException - if the user is not a member of that group

dense kelp
#

wtf why would it throw ise

opaque apex
#

idk

neat jackal
opaque apex
#

and how can I unset all other groups?

neat jackal
#

Get all other group nodes and remove them

#

Something similar is described on the docs here, so you can get all group names (or don't use group names and use a Set<InheritanceNode> directly) a user has and then loop trough them

opaque apex
#

user.data().toMap().values().forEach(node -> node.stream().filter(node2 -> (node2 instanceof InheritanceNode)).forEach(node2 -> user.data().remove(node2)));

#

like this?

#

or like this: ```ArrayList<net.luckperms.api.node.Node> toRemove = new ArrayList<>();

user.data().toMap().values().forEach(node -> node.stream().filter(node2 -> (node2 instanceof InheritanceNode)).forEach(toRemove::add));
toRemove.forEach(node -> user.data().remove(node));```

neat jackal
#

Both seem as they could work, try it out

opaque apex
#

alright

#

I thought the first one could throw a ConcurrentModificationException

neat jackal
#

You also have to save the changes. Don't forget that.

opaque apex
#

I did

#

ArrayList<net.luckperms.api.node.Node> toRemove = new ArrayList<>();

user.data().toMap().values().forEach(node -> node.stream().filter(node2 -> (node2 instanceof InheritanceNode)).forEach(toRemove::add));
toRemove.forEach(node -> user.data().remove(node));
user.data().add(InheritanceNode.builder(groupName).build());

api.getUserManager().saveUser(user);

neat jackal
#

Try it out, I have no idea if it actually does, but if it does, great!

short fossil
#

Don't know how much simpler this is but to me this is easier to understand and a bit cleaner imo but to each their own

#
Set<String> groups =   
    permission.getUserManager().getUser(playerUUID).getNodes().stream()
    .filter(NodeType.INHERITANCE::matches)
    .map(NodeType.INHERITANCE::cast)
    .map(InheritanceNode::getGroupName)
    .collect(Collectors.toSet());```
#

But I guess if you want to store them all as nodes your way may make more sense

scarlet harness
jade vine
#

have the same issue now, think you need to use the UserManager#loadUser(uniqueId) method

#

appears getUser might only be for online players, correct me anyone if i'm wrong

scarlet harness
#

o really i shall look at that now

dense kelp
#

yes it is

#

as confirmed by

#

@coarse oxide

coarse oxide
#

I confirm

scarlet harness
#

so i tried this but i assume that is wrong as the orefix is not loaded at all now

short fossil
#

Haven't had it tested yet but this should work for @scarlet harness 's problem

#
CompletableFuture<User> userFuture = permissions.getUserManager().loadUser(player.getUniqueId());

AtomicReference<String> prefix = new AtomicReference<>("");

userFuture.thenAcceptAsync(user -> {
    ContextManager contextManager = permissions.getContextManager();
                    prefix.set(user.getCachedData().getMetaData(contextManager.getQueryOptions(user).orElseGet(contextManager::getStaticQueryOptions)).getPrefix());
                    
}).get(5, TimeUnit.SECONDS);```
#

If you don't mind about long wait time (e.g. not waiting on it for an event like a login) feel free to remove the .get() params

#

and use prefix.get() to get the string

crystal sonnet
#

@scarlet harness remove the cast in the 3rd line and add .get()

#

You can't just cast a completable future into a string

#

And I'd recommend that you print the exceptions for debugging

#

Else you'll never know what's going wrong

#

And be sure to not run the code sync (aka on the main server thread)

tired sequoia
#

Does this go under onEnable?

RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
    LuckPerms api = provider.getProvider();
    
}
#

Im just trying to be able to set users permissions

lucid rapids
#

@tired sequoia you'd need to assign a variable of LuckPerms outside your onEnable()

tired sequoia
#

Do I also need it in the onEnable

lucid rapids
#

would be like

private LuckPerms luckPermsAPI;

public void onEnable() { 
 ...
 //do your service checks before
 luckPermsAPI = provider.getProvider(); 
}

public LuckPerms getLuckPermsAPI() { return luckPermsAPI; }```
tired sequoia
#

oh ok

lucid rapids
#

nono you aren't caching the service

tired sequoia
#

I'm confused. Sorry.

#

Im looking up other tutorials on youtube about using an api and none are like luckperms

crystal sonnet
#

@tired sequoia I mean he put the code right there

tired sequoia
#

When I put what he put I get errors

crystal sonnet
#

Though frankly you only need to get API in classes where you need that

#

Like what?

tired sequoia
#

Oh he edited the code thing

#

one sec

#

and i could do Main.getLuckPermsAPI().methodExample()

crystal sonnet
#

You posted the wrong link

tired sequoia
crystal sonnet
#

That would work

tired sequoia
#

ty

crystal sonnet
#

And no, you need an instance of your plugin

#

But then it would work

#

But again

#

I'd recommend you only get the API in classes you need them in

#

Unless it's a lot of them

tired sequoia
#

ok

crystal sonnet
#

In that case you make a helper class

#

That may even hold some common functionality

#

Like getting the prefix

#

So the API is only ever inside that helper class

tired sequoia
#

ok. Thank you

crystal sonnet
#

You're welcome

tired sequoia
#

has #data changed?

crystal sonnet
#

What do you mean?

tired sequoia
#

On the wiki it says in order to change someones permission you can do this
DataMutateResult result = user.data().add(Node.builder("your.node.here").build());

#

wait

#

I messed up something

#

I needed to cast player to user

short fossil
#

what

#

no

crystal sonnet
#

No

#

You need to get the user

#

If you're casting there's a 99% chance you're dong it wrong

#

Unless the classes are in a direct relationship

#

Like casting Nodes to InheritanceNodes

tired sequoia
#

Oh yeah not casting.

crystal sonnet
#

After checking they are InheritanceNodes

tired sequoia
#

What would be better, loadUser or getUser

crystal sonnet
#

Read the Javadoc and decide

#

I mean it all depends on what you want to achieve

tired sequoia
#

What do I do with DataMutateResult?

#

    public static void lpAddPerm(Player player, String... perms) {
        User user = Utils.loadUser(player);
        for(String perm : perms) {
            DataMutateResult result = user.data().add(Node.builder(perm).build());
        }
        luckPermsAPI.getUserManager().saveUser(user);
    }
#

thats my method

#

but there is the DataMutateResult type just sitting there. I know I'm missing something but idk what.

crystal sonnet
#

Ignore it

#

Don't capture it

#

Don't care for it

#

Just because a method returns something doesn't mean you need to care for it @tired sequoia

tired sequoia
#

Alrighty

#

ty

crystal sonnet
#

You're welcome

upper nacelle
#

a

rustic laurel
#

wut

hardy badge
#

Here's a command that I've been working on for a server I'm developing... For some reason I cannot get the MetaNode node to change their metadata? Any help?

public class rankup implements CommandExecutor {
    Economy econ = Core.getEcon();
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Player player = (Player) sender;
        EconomyResponse canRank = econ.withdrawPlayer(player,prisonUtils.rankValue(player));
        double newRank;
        newRank=prisonUtils.getPrisonRankInt(player)+1;
        String nextRanked = prisonUtils.getRankFromInt(player,newRank);
        if (canRank.transactionSuccess()){
            MetaNode node = MetaNode.builder("prison_rank",nextRanked).build();
            prisonUtils.printMessage(player,"You ranked up to "+prisonUtils.getPrisonRank(player)+"&7 for &a"+econ.format(prisonUtils.rankValue(player)));
        }else {
            prisonUtils.printMessage(player,"&cYou cannot afford to rankup to &f"+nextRanked);
            prisonUtils.printMessage(player,"You still need &c"+econ.format(prisonUtils.rankValue(player)-econ.getBalance(player)));
        }
        return true;
    }
}
#

!api

frank driftBOT
crystal sonnet
#

@hardy badge well, you’re not doing anything with the node after you created it. Not sure what you’re expecting

young vault
#

Can you create a group using the API instead of commands?

hardy badge
#

How would I build the node then?

crystal sonnet
#

@hardy badge I mean that's how you build the node

#

But you're just not doing anything with it

#

@young vault yes

#

!api Check the methods of the GroupManager in the javadocs

frank driftBOT
hardy badge
#

How would I apply it to the player then?

young vault
#

Thanks.

crystal sonnet
#

!api @hardy badge

frank driftBOT
crystal sonnet
#

You need to add it like you would with any other node

#

I mean look at this line:
MetaNode node = MetaNode.builder("prison_rank",nextRanked).build();
How is that ever going to get assigned to a player?

#

The player isn't even mentioned at all

#

And the variable is unused

#

(Which your IDE should warn you about btw)

hardy badge
#

Okay, I've rewrote it using the DataMutateResult, but I now see the result of that being unused. Thoughts?

            if (canRank.transactionSuccess()){
                User user = api.getUserManager().getUser(player.getUniqueId());
                MetaNode node = MetaNode.builder("prison_rank",nextRanked).build();
                DataMutateResult result = user.data().add(node);
                api.getUserManager().saveUser(user);
                //getServer().dispatchCommand(getServer().getConsoleSender(), "lp user " + player.getName() + " meta set prison_rank "+nextRanked);
                prisonUtils.printMessage(player,"You ranked up to &f"+nextRanked+"&7 for &a"+econ.format(prisonUtils.rankValue(player)));
            }else {
                prisonUtils.printMessage(player,"&cYou cannot afford to rankup to &f"+nextRanked);
                prisonUtils.printMessage(player,"You still need &c"+econ.format(prisonUtils.rankValue(player)-econ.getBalance(player)));
            }```
crystal sonnet
#

Don’t store return values you’re not using @hardy badge

#

So don’t store the data mutate result

hardy badge
#

Okay yup, i got that working, next problem is I need to actually set the value, rather than adding a new one (:

crystal sonnet
#

Remove the old one and set the new one

hardy badge
#

I've been trying that, but when I check using the DataMutateResult, it shows it was unsucessful

#
                        User user = api.getUserManager().getUser(player.getUniqueId());
                        DataMutateResult result = user.data().remove(MetaNode.builder("prison_rank",prisonUtils.getPrisonRank(player)).build());
                        user.data().add(MetaNode.builder("prison_rank","A2").build());
                        staffUtils.informativeMessage((Player) sender,"Your prison rank is: "+prisonUtils.getPrisonRank(player));
                        staffUtils.informativeMessage(player, String.valueOf(result.wasSuccessful()));
#

Oh i found it

crystal sonnet
#

I'd recommend using streams to find the other node to remove it

flat void
#

Hi!

#

How get primaryGroup for oflinePlayer?

#

Because If the user was not on the server after starting the server i have NPE

#

net.luckperms.api.model.user.User.getPrimaryGroup() is null

#

i think, i need load user:
getUserManager().loadUser(Bukkit.getPlayer(user).getUniqueId()).get()

short fossil
#

Load a user using loadUser & get the primary group in a CompletableFuture @flat void

quaint oak
#

I need this methods for LuckPerms:
PermissionsEx.getPermissionManager().getUser(p).getPrefix()
PermissionUser user = PermissionsEx.getUser(p);
PermissionsEx.getPermissionManager().getGroup(g).getWeight();

crystal sonnet
#

!api

frank driftBOT
dense jolt
#

Hey, I have a method like that to save a user after modifications :

private static void saveUser(User user) {
    luckPermsApi.getUserManager().saveUser(user);
}

Should it be called async or not necessary, because it's a save in the database for example (I use mariaDB) ? Thanks 🙂

crystal sonnet
#

To my knowledge it's run async.

twilit jasper
#

I'm trying to auto-rank people in a custom plugin, I tested this originally and it appeared to work but recently it didn't promote a real user and threw no errors. Any ideas?

User user = api.getUserManager().getUser(p.getUniqueId());
ImmutableContextSet contextSet = api.getContextManager().getContext(user).orElse(api.getContextManager().getStaticContext());

api.getTrackManager().getTrack("default").promote(user, contextSet);
crystal sonnet
#

Make sure to save the changes to the user @twilit jasper

twilit jasper
#

ok, didn't know that was a thing. Is this how? api.getUserManager().saveUser(user);

crystal sonnet
#

Yes

mossy grotto
#

Hello, how can i set player meta with the help API?

crystal sonnet
#

!api

frank driftBOT
mossy grotto
#

i didnt find it

#

;/

naive patrol
#

@mossy grotto I think it would fall underMetaNode

mossy grotto
#

Thank, i already found

gray agate
#

is it possible to change the primary group through a custom plugin with the api i have my script here I'm setup to an sql database but when i run the code the primary group stays as default

#
        UserManager userManager = api.getUserManager();
        if (!player.isOnline()){
            throw  new IllegalStateException("Player offline");
        }
        User user = userManager.getUser(player.getUniqueId());
        Group group1 = api.getGroupManager().getGroup(group);
        System.out.println(group1);
        if (group == null){
            System.out.println("Returned");
            return;

        }
        user.setPrimaryGroup(group1.getName());
        System.out.println(user.getPrimaryGroup());
        userManager.saveUser(user);

    } ```
#

any help would be apreciated

#

or is there anyway to do an rank up system through code?

crystal sonnet
#

!api @gray agate

frank driftBOT
crystal sonnet
gray agate
#

Alright thank you

mossy grotto
#
    public static DataMutateResult setPrefix(String playerName, String prefix) {
        User user = LuckPermsProvider.get().getUserManager().getUser(playerName);
        PrefixNode prefixNode = PrefixNode.builder(prefix, 100).build();
        user.data().add(prefixNode);
        LuckPermsProvider.get().getUserManager().saveUser(user);
        return LuckPermsProvider.get().getUserManager().getUser(playerName).data().add(MetaNode.builder("prefix", "100").build());
}

why doesnt it work, help please)

crystal sonnet
#

@mossy grotto
a) use a prefix node
b) you need to save changes to the user
c) unless you really need it, you don't need to care for the DataMutateResult
d) Have a look here: https://github.com/LuckPerms/api-cookbook

mossy grotto
#

thank you, but i have trouble, when add prefix, then remove it

#

how remove old player meta/

crystal sonnet
#

Find the node in the existing ones and remove it

dense jolt
#

Thanks BrainStone ! But sincerely, is it useful to manually save the user after modifications, or it will be saved automatically after 🤔

crystal sonnet
#

You need to save it

gray agate
#

before changing a user's group would one need to load that users before then saving it

gray agate
#

or does anyone know a reason why User.setprimarygroup would fail?

jaunty pecan
#

they need to already be a member of the group

#

the way group memberships are set is using inheritance nodes

#

see here for an example

gray agate
#

ok that makes sense thanks alot

twilit jasper
#

Ok so it seems like my auto-promote code works temporarily, but then after some time they're back to the original rank

#
User user = api.getUserManager().getUser(p.getUniqueId());
ImmutableContextSet contextSet = api.getContextManager().getContext(user).orElse(api.getContextManager().getStaticContext());

api.getTrackManager().getTrack("default").promote(user, contextSet);
api.getUserManager().saveUser(user);
#

my player says this ran once and didn't promote her at all, then ran later and did promote, but after switching worlds and typing in chat she was back down at the original rank. I have this code running every hour on players whose playtime meets a min requirement for the next rank

twilit jasper
#

ok it seems like teleporting worlds is key

#

my player thinks she got the right rank once she returned to the main world

#

and she died and is back to default rank

#

so that code above isn't saving

#

ok confirmed it happens on death. sorry for wall of text!

#

ok so I watched. user in my group "respected". player dies. is back to group "default". player teleports home, get "respected" back. none of my code ran during this phase, only for the initial promotion

#

all in the same world

twilit jasper
#

ok running through a debug, it fires and seems like it's promoting but doesn't.

#
[08:44:36 INFO]: user: me.lucko.luckperms.common.api.implementation.ApiUser@f41af24
[08:44:36 INFO]: contextSet: ImmutableContextSet(contexts={gd_claim=[5aa6bebc-1e40-43b2-9923-a3eb36a9e28d], server=[global], world=[world]})
[08:44:36 INFO]: res.getStatus(): ADDED_TO_FIRST_GROUP
[08:44:36 INFO]: res.wasSuccessful(): true
#

but immediately running /lp user [user] info still shows them in the default group

jaunty pecan
#

it's because you're promoting using their active context

#

so when that context changes, the promotion no longer applies

#

so just promote using

#
api.getContextManager().getStaticContext()
#

in your case, griefdefender claims and worlds are affecting active context

twilit jasper
#

ok thanks! when I asked how to get the right context, I did feel a little unsure it was right for my needs

#

a few days back

jaunty pecan
#

well to be fair that's a tricky question to answer

#

because if you're querying permissions, it doesn't matter if you have a few extra contexts in there

#

generally, you want as many as possible, so using the active contexts is perfect

twilit jasper
#

understood, that makes sense

jaunty pecan
#

but when you're setting new nodes, you need to decide where you want the node to apply

twilit jasper
#

ya I felt I was clear on my use case, but anyway that's seems like it's clearly my problem

jaunty pecan
#

I wasn't blaming you :p

#

i'm sure you were clear too, it's just it can be tricky to understand, that's all haha

twilit jasper
#

I didn't think you were, I was just saying, I should have been more questioning when I accepted the code the first time I asked

#

also lp is amazing btw, as someone who used pex for ~6 years it's like night and day. command auto-complete helps, but the commands are so straight-forward and consistent

sturdy niche
#

I am going to make a tablist with that owner is on the top etc

#

Do i need to add the API for that?

rustic laurel
#

Perhaps, depending on how advanced you want the group calc to be. If you just want to use primary group on top you can just use vault afaik. If you want something more advanced and LP specific, you'll need the LPAPI

sturdy niche
#

So i only need vault to put it on the top?

#

and making the Name Yellow or smth

rustic laurel
#

The colour is set by luckperms, ideally, so you don't really need to worry about that in your plugin. I'd suggest taking a look at how TAB manages to order the tablist to get a better look at what you're going for- TAB orders it by group name through vault afaik

sturdy niche
#

but how would i do so that owner is on top etc with Vault?

#

or thats not gonna be asked here

rustic laurel
#

Well, have your plugin look at a players primary group

#

And order it by name of group

sturdy niche
#

can't i use the weights?

sturdy niche
#

Could someone hlep me out?

#

I get up this?

jaunty pecan
#

what are you trying to do?

sturdy niche
#
        RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
        if(provider !=null) {
            LuckPerms api = provider.getProvider();
        }
    }```
#

Make luckperms as a dependency

jaunty pecan
sturdy niche
#
    for (String group : possibleGroups) {
        if (player.hasPermission("group." + group)) {
            return group;
        }
    }
    return null;
}```
#

uhhh

#

how do i get the group?