#luckperms-api

1 messages · Page 21 of 1

raven mason
#

I mean the real docs

crystal sonnet
#

It's literally the second link of that page. Are you sure you read it?

raven mason
#

I think I got it

crystal sonnet
#

Actually not

#

That's the old link

night phoenix
#

it always returns Tristate.UNDEFINED

#

(my goal is to check an offline player's permission node value)

#

@ripe thorn

frank driftBOT
#

Hey Gabriele C.! Please don't tag staff members.

jaunty pecan
#

@night phoenix that looks correct to me

crystal sonnet
#

@jaunty pecan are the flags on by default?

jaunty pecan
#

errrr no they're not!

#

good point

#

so yeah instead of

#
QueryOptions.builder(QueryMode.NON_CONTEXTUAL).build()
#

you should instead use

#
QueryOptions.nonContextual()
crystal sonnet
#

That should be in the Javadocs btw

jaunty pecan
#

yeah gonna change that

crystal sonnet
#

👍🏻

vague obsidian
#

I'm updating my plugins to 5.0 api, and you used to be able to do this for getting all permissions, what is the equivalent?

#

I'm a little confused about the context part, how does that work

austere furnace
#

hmm, i'm jumping to 5.0 API however I used user cached data and contexts to retrieve prefixes from metadeta

#

how would I do this now?

#

this new api is foreign to me

open pendant
#

How i do get the prefix in new api?

raven mason
#

@vague obsidian

for(Node node : u.getPermissions())
  if(node instanceof PermissionNode)
    strings.add(((PermissionNode) node).getPermission());
#

@austere furnace @open pendant to get group prefixes, I use the following code

QueryOptions queryOptions = api.getContextManager().getQueryOptions(p);

String name api.getGroupManager().getGroup(group).getCachedData().getMetaData(queryOptions).getPrefix();
#

where group is a string

#

and p is a Player

open pendant
#

@raven mason i did that as i seen javadoc but it doesn't return with colors it just returnes in chat like this &cAdmin

raven mason
#

ChatColor.translateAlternateColorCodes('&', prefix);

#

or if you want

#

ChatColor.stripColor(prefix) after translating

open pendant
#

thanks.

nocturne elbow
#

[19:20:43 WARN]: [PlaceholderAPI] Task #20 for PlaceholderAPI v2.10.4 generated an exception java.lang.NoClassDefFoundError: net/luckperms/api/LuckPerms at me.lucko.luckperms.placeholders.LuckPermsExpansion.canRegister(LuckPermsExpansion.java:48) ~[?:?] at me.clip.placeholderapi.expansion.ExpansionManager.registerExpansion(ExpansionManager.java:102) ~[?:?] at me.clip.placeholderapi.expansion.ExpansionManager.registerAllExpansions(ExpansionManager.java:154) ~[?:?] at me.clip.placeholderapi.PlaceholderAPIPlugin.lambda$onEnable$0(PlaceholderAPIPlugin.java:145) ~[?:?] at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) ~[server.jar:git-Spigot-21fe707-e1ebe52] at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [server.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:723) [server.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [server.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [server.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [server.jar:git-Spigot-21fe707-e1ebe52] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222] Caused by: java.lang.ClassNotFoundException: net.luckperms.api.LuckPerms at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_222] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_222] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_222]

#

Can someone help me ? I don't know what I can try next. - > Manual Install, Papi ecloud install. I asked a lot of people but nobody understand 😦

neat jackal
nocturne elbow
#

Damn I am stupid

#

Thanks Tobi

vague obsidian
languid socket
#

Hi, I'm using maven to resolve LuckPerms as dependency but it's import's don't work? (the pom itself doesn't give any errors, but my classes do)

crystal sonnet
#

@languid socket the new API uses a different package than the old one

#

Also it’s very different

languid socket
#

yes, i've got it to work now

languid socket
#

in 4.x this was the way to get prefix:

public static String getPrefix(Player p) {
        User user = loadUser(p);
        ContextManager contextManager = Main.getLuckpermsApi().getContextManager();
        Contexts contexts = contextManager.lookupApplicableContexts(user).orElseGet(contextManager::getStaticContexts);

        MetaData metaData = user.getCachedData().getMetaData(contexts);
        return ChatColor.translateAlternateColorCodes('&', metaData.getPrefix());
    }```
Now since ``5.x`` this doesn't work anymore? So what to change tot get it back working?
languid socket
#

Anyone?

glass vector
crystal sonnet
glass vector
#

hey brainstone could you help me?

crystal sonnet
#

Are you trying to work with offline players?

glass vector
#

no online

crystal sonnet
#

You also seem to be using the old API

glass vector
#

like what i'm doing is that if they inherit a group like Developer it would show an item in the Inventory?

#

oh

#

where's the new API?

crystal sonnet
#

Groups need to be lowercase

glass vector
#

is that causing the issue?

#

because the error is giving me a NullPointerException

languid socket
#

@crystal sonnet so there is no option to use LuckPerms itself to retrieve prefixes?

frank driftBOT
#

Hey Horizons! Please don't tag staff members.

languid socket
#

Oops

crystal sonnet
#

Of course

#

That's what that class is doing

languid socket
#

Oh, will check it out, thanks

glass vector
#

Hey BrainStone what is the new API?

#

or where*

crystal sonnet
#

!api

frank driftBOT
glass vector
#

thanks

glass vector
#

BrainStone

#

how do you check if a user is in a group?

#

if true then run something if false then run something else?

#

Hey I used Maven to add LuckPerms as a dependencies but it's showing red in my pom.xml? pls help

opaque sparrow
#

how do I make it so people are able to use disposal essentials signs?

glass vector
#

and also the ```RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
LuckPerms api = provider.getProvider();

}``` shows lots of errors?

#

@crystal sonnet

frank driftBOT
#

Hey Lightning225! Please don't tag staff members.

languid socket
#

@opaque sparrow that's not an Api thingy (at least if you provide more info) #general or #support-1

@glass vector could you show me your pom.xml? And what kind of errors does it give (the snippet)?

glass vector
#

i've got the errors fix 😄

#

but i have another issue...

languid socket
#

And what is it?

glass vector
#

how do i do this part? it says to do in the wiki page

if (provider != null) {
    LuckPerms api = provider.getProvider();
    
}```
#

idk where to put it n stuff

#

or how do i initialize luckperms? in the main class?

languid socket
#

I would rather suggest to use the instance method using: LuckPerms api = LuckPermsProvider.get();

You can put it in any class you want but I suggest in your Main class.

glass vector
#

and the api would work just like that?

#

or do i need public static etc

languid socket
#

Just as I said it.

crystal sonnet
#

That gives you an instance of the API

#

If you don't know what you can use that for or how to handle that, then I'd say learn Java and programming first before you get back here. Because those things are basics you must know before using that API @glass vector

glass vector
#

nice

mild flax
#

How can I query whether a user is a group with LuckPerms v5?

crystal sonnet
#

You don’t need to. A user is never a group

#

Unless of course you mean if a user is in a group.
Then check this:

#

!api

frank driftBOT
glass vector
#

Hey, how do you check if a user inherits a specific group and if they do it shows an item In a GUI for example. But if they don’t inherit that specific group then it doesn’t show that item? I don’t want the group. + permission thing because most of my players have op and it would should all the groups as they have it even though they are only apart of one. Like for example an Admin would have a operator but it would show that they are a part of owner group, developer group and admin group. But they are only an admin so how do I check if a player inherits a group without the permission as in the wiki?

crystal sonnet
#

@glass vector even if they have OP those group checks only succeed if they actually have the group

glass vector
#

For real? I thought on the wiki it said if players with ‘op’ or ‘*’ will have the permissions?

glass vector
#

!api

frank driftBOT
crystal sonnet
#

The group permissions are an exception

glass vector
#

?

slate forum
#

Sorry, I'm new y'all. Trying to implement luckperms into an unmaintained Bungeecord plugin, but I'm struggling to register it. Obviously Bukkit class isn't available in Bungee's API, anyone able to help?

https://i.imgur.com/H19L80x.png

I imported import net.luckperms.api.LuckPerms;

#

Again, sorry for the noobish questions. I've taken a look at the API usage but cannot find bungee reference maybe I'm missing something.

crystal sonnet
#

Right below that line it tells you how to get it without that

#

@slate forum

#

@glass vector group. and other internal permissions are unaffected by * and OP

#

Try it

slate forum
#

BrainStone, I'm a little confused which line you're referring too, the "Create type parameter"? The if statement or the line on the API where I C&P'd this from?

#

Thanks for your help btw 🙂

crystal sonnet
#

!api

frank driftBOT
glass vector
#

Brain stone

crystal sonnet
#

Yes?

glass vector
#

So If i do the group. Plus permission on the wiki op and star wouldn’t affect it?

crystal sonnet
#

Yes. As mentioned several times now

glass vector
#

Are you sure

slate forum
#

Okay, thank you Brain. I've found it. 🙂

#

Slightly offtopic, in the JavaDocs what do the italicised classes mean? Deprecated?

crystal sonnet
#

@glass vector yes

#

Just try it

glass vector
#

it still shows while i'm opped even though i'm not in the group?

slate forum
#

What method can I call to list all permissions the user has? I see player.hasPermission(); but I need to iterate over permissions beginning with, not a specific permission.

#

player.getPermissions() is only reading from bungee's config fine and not LuckPerms, however player.hasPermission() is reading correctly from Luckperms.

#

I'm a little bit lost by this one...

crystal sonnet
#

You naturally need to use the API and the user objects of LP, not the player objects of Bungee

#

@glass vector what's your code?

glass vector
#
    public static boolean isPlayerInGroup(Player player, String group) {
        return player.hasPermission("group." + group);
    }
                    if (isPlayerInGroup(target, "developer")){
                        grantsMenu.addItem(dev);
                    }else {
                        
                    }```
slate forum
#

Okay I will take a better luck at the API, is there a public version of the API? I'm using the .jar locally but I can't search for stuff.

glass vector
#

it's a bukkit inventory, so if they are in group developer it would show the developer block in the inventory

crystal sonnet
#

@slate forum yes there is...

#

!api

frank driftBOT
slate forum
#

oh ya thank you

crystal sonnet
#

@glass vector weird. I could have sworn that works

#

In that case it's a fair bit more compilcated

glass vector
#

is it still possible?

#

can you do this?

    public static boolean isPlayerInGroup(Player player, String group) {
        if (!player.isOp()){
            return player.hasPermission("group." + group);
        }
    }```
#

but wait

#

probably not

crystal sonnet
#

Of course it's still possible

#

Not like this

glass vector
#

oh

#

do you know how to do it? because i'm out of ideas

#

🤣

#

because that's the only thing i see in the wiki about if a user is in a group

crystal sonnet
#

I know it roughly

glass vector
#

anything would help xD

crystal sonnet
#

In essence iterate over the player's nodes and find all the group nodes and find if it's the right one

glass vector
#

🤔

slate forum
#

Ugh... I'm looking at getDistinctNodes() but I can't figure out how to filter out all permissions, or at least iterate over each permission.

#

I see ways to check a specific permission, but for getting all perms I ain't quite sure what to do here

#

So far I'm getting this as an output ImmutableNode(key=group.admin, value=true, expireAt=0, contexts=ImmutableContextSet(contexts={}))

#

Code I'm using...

LuckPerms api = LuckPermsProvider.get();
    public User loadUser(ProxiedPlayer player) {
        return api.getUserManager().getUser(player.getUniqueId());
    }
[....]
    for (Object ob : loadUser(player).getDistinctNodes().toArray()) {
        System.out.println("List Nodes: " + ob);
    }
crystal sonnet
#

Use Streams

#

@slate forum

slate forum
#

I'm gonna take a break for a bit, I'm struggling to understand how to get a list of permissions from LuckPerm. Spent over 1 hour trying to do this now lmao... :l

Does anyone know where I can find in the javadocs reference to use getDistinctNodes()? Cheers.

teal tartan
#

@versed dagger ask here

versed dagger
#

ik

#

for some reason my events does not trigger im checking for usertrackupdate event and im using eventbus and subscribing thru lambda and my code just does not want to run i tried in class that was suppose to handle all those events and in main to subscribe but it doesn't trigger at all not even a debug console output i added to see if event triggers. Im using luckperms v5, also here is the code: https://paste.chinesemarc.tech/toyutayapi.kotlin

glass vector
#

hey is there a way to find the temporary time of a parent using the luckperms nodes? on the wiki it showed temporary times for prefixes but i was wondering what about for groups?

crystal sonnet
#

Everything is a node

#

So yes

surreal comet
#

Since LuckPerms api changed, how I set and unset a player permission/group?
Before I used User.setPermission and User.unsetPermission

slate forum
#

Does anyone have any example code where you list ALL the users permissions when they join?

surreal comet
#

Did I got a ghost ping?

neat jackal
surreal comet
crystal sonnet
#

It tells you which class to use

#

@surreal comet

surreal comet
crystal sonnet
#

That's the correct node

#

But as the error tells you, you're not supposed to create these nodes with the PermissionNode.Builder class

surreal comet
#

Tanks

surreal comet
glass vector
#

Hey brianstone what is the node for a temporary group time?

crystal sonnet
#

?

glass vector
#

So I said hey is there a way to find the temporary time of a parent using the luckperms nodes? on the wiki it showed temporary times for prefixes but i was wondering what about for groups?

#

Earlier and you said there is a node for everything so I was wondering what the node was?

crystal sonnet
#

I said everything is a node

#

So the same method works

glass vector
#

???

#

What is the methods tf

surreal comet
#

Hummm
BrainStone, you know whats happening so I'm getting the error?
Its weird, bc it says nullable, and I can't get what is wrong......

frank driftBOT
#

Hey Awakened Redstone! Please don't tag staff members.

surreal comet
#

Humm, oops, did wrong, sorry

#

@glass vector you can either look javadocs or look on the wiki, or look on the code.

spring reef
#

In LuckPerms 4 after I saved a User using api.userManager.saveUser(user), I usually also did a user.refreshCachedData(). I don't know if this was even required, but should I still do this in LuckPerms 5 using user.cachedData.invalidate(), or does this happen automatically?

spring reef
#

Also, when doing something like user.data().contains(node, EXACT).asBoolean(), it triggers a NodeMutateEvent, but afaik this just does a lookup, so is it supposed to broadcast a the NodeMutateEvent or is this a bug?

crystal sonnet
#

Don't invalidate the cache

#

Everything that needs to be updated/invalidated gets updated/invalidated

#

If you do that you force the plugin to load everything from the database

spring reef
#

ah I see

rotund light
#

How can I check if version is 4 <? Maybe class check?

crystal sonnet
#

Exactly that

glass vector
#

So I said hey is there a way to find the temporary time of a parent using the luckperms nodes? on the wiki it showed temporary times for prefixes but i was wondering what about for groups?

#

Earlier and you said there is a node for everything so I was wondering what the node was?

#

Like what do I type in the program

surreal comet
#

*ignored*
Hummm, my issue just got ignored....

glass vector
#

BrainStone you said there is a node for everything so what is the node?

#

What do I type cause I can’t find it anywhere??

covert jacinth
#

Is there a way to check if x user has x permission in a plugin?

crystal sonnet
#

@surreal comet you're not getting ignored

#

It's just that nobody that's on knows

#

@glass vector I said everything LP stores is a node

#

@covert jacinth just check for the permission...?

#

Like with the platform method

glass vector
#

Oh my ducking god

#

I’m so done

#

WHAT IS THE NODE!!!!???????!?

#

Wtf

#

I’ve said this so many ducking times

#

What is the node

#

What is the node

#

What is the node

#

?????

#

@crystal sonnet

frank driftBOT
#

Hey Lightning225! Please don't tag staff members.

crystal sonnet
#

The node for what?

glass vector
#

So I said hey is there a way to find the temporary time of a parent using the luckperms nodes? on the wiki it showed temporary times for prefixes but i was wondering what about for groups?

#

So I said hey is there a way to find the temporary time of a parent using the luckperms nodes? on the wiki it showed temporary times for prefixes but i was wondering what about for groups?

crystal sonnet
#

I said it works the same way

glass vector
#

Omg

#

Yeah what is it?

#

What do I need to type huh

crystal sonnet
#

Find the parent node and use the same method

glass vector
#

What method??!!!?

crystal sonnet
#

The same as on the wiki

glass vector
#

Omg

#

Which one huh

crystal sonnet
#

I don’t know

#

I haven’t worked much with the API

glass vector
#

🤦‍♀️

crystal sonnet
#

And second I’m not throwing around code

#

I know how it works.

#

Just not the the method names

#

Cut that shit. That’s your first warning

urban verge
#

danm

crystal sonnet
#

That’s the second warning

#

I can see that, you know

#

Last chance

urban verge
#

What an irresponsible idiot lol

crystal sonnet
#

Yup

#

Congrats. That’s a ban

#

Idiots be idiots

urban verge
#

Hopefully he will regret that in the future when he is mature enough to see his mistake and he wont be able to get support

crystal sonnet
#

Hahaha good one XD

urban verge
#

do u know anything about using mongoDB with luckperms?

crystal sonnet
urban verge
#

yeah I already posted there sorry

covert jacinth
#

Wait so how i installed the API into the libraries (java plugin not Maven) but idk how to procceed...

#

if( LuckPerms.){}

crystal sonnet
#

I don’t know what you’re asking/saying

#

!api

frank driftBOT
tardy bramble
#

Hello, how can I add the permission to user that will persist only on the server command was called on without knowing name of the server? (Bungee server network). Do I have to get name of the server manually by calling Bungee messaging channel?

alpine nest
#

Hello!

#

Is there a way that I can automate the ranks that players by from the store in to the game

#

example:

#

I buy a rank on my webpage

#

And i want to use that rank at the moment

#

Can i automated ?

#

Help Please !

alpine nest
#

@everyone HELP

#

OK THEN IF YOU DONT HELP ME IM LEAVING !

#

BYE !

lost bronze
#

bruh

#

lmao

languid socket
#

Lol

crystal sonnet
#

Didn’t even ask in the right channel

#

@tardy bramble you should be able to get the server name through the API

surreal comet
#

So, the group manager is returning null on my api, when I try tu use it I get a NullPointerException

#

Seams that happens the same for userManager

#

Is weird because there is a method that uses user and group manager and doen't get error

ripe token
#

What's the way of finding out if a player inherits a group?

#

API doesnt have luckpermsUser.inheritsGroup(group)

#

anymore

#

in v5

neat jackal
#

You can just check if he has the "group" + group permission

#

Using the normal permission check method of your platform

ripe token
#

so

#

if player has permission "group.admin"

#

admin being the group name defined in lp

languid socket
#

Yes

ripe token
#

okay

#

thats magic

#

and how do I get the suffix of a group?

#

group.getCachedData().getMetaData(); doesnt want my context anymore

#

but some queryoption

neat jackal
#

!api

frank driftBOT
neat jackal
#

This page should answer this (hopefully)

ripe token
#

Thanks

surreal comet
#

Weird, the GroupManager is returning null [NullPoiterException], but I have a class that uses it and doesn't return null, only on my sub commands it happens

#

Same for UserManager

surreal comet
#

nvm

crystal sonnet
#

@surreal comet if that happens you're accessing the API too early

surreal comet
#

Yeah, I was literally setting the AdminCommand before the onEnable.

alpine mountain
#

Hey, how do I check the whether a a user has inherited a group with the 5.0 api?

crystal sonnet
#

!api

frank driftBOT
sudden kelp
#

Optional<? extends Node> nodeOpt = permission.getUserManager().getUser(player.getUniqueId()).getPermissions().stream() .filter(n -> n.getPermission().equalsIgnoreCase(clearedPermission)) .filter(n -> n.getValue() == clearedIsTrue) .findAny();
Whats the repplacement for getPermissions?
getNodes isn't enough, as I need inherited nodes

jaunty pecan
#

resolveInheritedNodes is what you're after

sudden kelp
#

Okay good, would this be the 1:1 replacement?

User user = permission.getUserManager().getUser(player.getUniqueId()); Optional<? extends Node> nodeOpt = user.resolveInheritedNodes(permission.getContextManager().getQueryOptions(user).get()).stream() .filter(n -> n.getType() == NodeType.PERMISSION) .filter(n -> ((PermissionNode)n).getPermission().equalsIgnoreCase(clearedPermission)) .filter(n -> n.getValue() == clearedIsTrue) .findAny();

Before I really didn't touch Context stuff besides adding server etc. Thanks for your help

jaunty pecan
#

Instead of passing permission.getContextManager().getQueryOptions(user).get()

#

You can just use QueryOptions.nonContextual()

sudden kelp
#

okay thanks

rare rapids
#

How to get user group prefix in api?

native wolf
nocturne elbow
#

How can I get a player's prefix?

#

via api ofc

wet veldt
#

I'm getting a java.lang.NoClassDefFoundError when I call LuckPerms.getApi();, why is this?

#

oh wait - has it been changed..?

raven mason
#

yeah

#

LuckPermsProvider.get()

wet veldt
#

kk thanks, is this equivalent to using the Bukkit ServicesManager?

raven mason
#

yes

wet veldt
#

coolio, thanks. I'm guessing this is a popular issue lol

crystal sonnet
#

The API got updated

wet veldt
#

I'm guessing I'll have to update my code too then

humble ivy
#

/papi ecloud download LuckPerms

And it just make my server messed up

#

Wat the heck bruhm

crystal sonnet
idle seal
#

how can i get the weight from a player?

crystal sonnet
#

What weight?

#

Players don’t have a weight. Only groups do @idle seal

idle seal
#

Okay. How can i get the hightest group from the player

crystal sonnet
#

That’s the primary group

languid mural
#

i can add a user to multiple groups right?

crystal sonnet
#

Yes

languid mural
#

is there a method for that in the user object?

jaunty pecan
#

You need to add an inheritance node in order to set groups

lusty kindle
#

how do i set Primary Group and Parents of a user?

crystal sonnet
#

The primary group is calculated automatically

#

Parents are added through inheritance nodes

lusty kindle
#

this is what i have```
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null)
{
LuckPerms api = provider.getProvider();
String primGroup = api.getUserManager().getUser(uuid).getPrimaryGroup();
if (hours >= 150)
{
//Set Primary group to legend
}

    }
how would i do that?
dense steeple
lusty kindle
#

ah ty

lusty kindle
#

i dont get the nodes pls help

#

InheritanceNode node = InheritanceNode.builder(group).build();
is what i use to set primary group for players?

crystal sonnet
#

No. This generates a node

#

You now need to add that to a player and remove the others

lusty kindle
#

how do i do that?

crystal sonnet
#

!api

frank driftBOT
lusty kindle
#

i am reading there

crystal sonnet
#

Good

lusty kindle
#

but im not understanding it

#

is it user.getNodes?

crystal sonnet
#

That’s a different story

#

And yes

lusty kindle
#

okey

#

this is so confusing for me :(

        .filter(NodeType.INHERITANCE::matches)
        .map(NodeType.INHERITANCE::cast)
        .map(InheritanceNode::getGroupName)
        .collect(Collectors.toSet());
``` doesnt work for me
#

user, NodeType & Collectors get red

#

what should they be?

#

and what does .filter, .map & .collect do?

crystal sonnet
#

Those are Java (8) stream functions

#

Make sure you imported the classes

#

And that you’re using the v5 API

dense steeple
#

yeah he's using v5

#

java version is prob the issue

lusty kindle
#

but what is user?

#

is it the playerobj?

crystal sonnet
#

It’s a User object

dense steeple
#

from your snippet from earlier:

            String primGroup = api.getUserManager().getUser(uuid).getPrimaryGroup();
#

it's the result form getUser in this line

crystal sonnet
#

Using this API assumes you know basic Java

#

And so does MC plugin programming btw

#

That’s not beginner level stuff

lusty kindle
#

ik im still learning on the go

crystal sonnet
#

MC is not suited to learn Java basics

#

And using this API doubly not

#

And I’m not saying this to bring you down. I’m really just trying to help you by making sure you learn the basics before you dive into the harder stuff

lusty kindle
#

i get that

crystal sonnet
#

Good

#

I wish I could recommend you good resources to learn

#

But I don’t have any. My apologies on that

lusty kindle
#

well how do i know if i have basic java knowledge

dense steeple
#

Kinda a subjective thing tbh

#

Javadoc and information gathering knowledge is a pretty good thing to have since it makes learning things easier

crystal sonnet
#

If Java code doesn’t throw you off anymore

#

Especially when it’s open in your IDE

loud marsh
#

Hi.. wow the API changed

#

How can I get a player's prefix? :)

#

I managed to do the java RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class); if (provider != null) { LuckPerms api = provider.getProvider(); following the online documentation.

#

edit found the usage page, was hiding :>

#

Uh

#

Is PermissionData not a thing?

jaunty pecan
#

Ya, it's just called CachedPermissionData now

nocturne elbow
#

I'm trying to get a LuckPerms api instence but I get a class not found exception

nocturne elbow
#

@ripe thorn

frank driftBOT
#

Hey Oscar! Please don't tag staff members.

crystal sonnet
#

@nocturne elbow you’re using the v5 API on a v4 instance. Update your LP

nocturne elbow
#

I've downloaded the recent LP

#

@crystal sonnet the only ne avaliable on spigotmc is v4

frank driftBOT
#

Hey Oscar! Please don't tag staff members.

crystal sonnet
#

!downloads

frank driftBOT
nocturne elbow
crystal sonnet
#

So?

#

I linked you to the up to date downloads. Use them

nocturne elbow
#

Ok let's see if it works now

#

Ok, it loaded

#

thanks

crystal sonnet
#

You’re welcome

crystal sonnet
#

@nocturne elbow you wanted to ask something?

nocturne elbow
#

Yeah, but i figured it out

#

Actually

nocturne elbow
#

Okay, so I'm trying to loop through the loaded groups but it returns a null pointer exception

crystal sonnet
#

Find out what returns null

nocturne elbow
#
getLuckPerms().getGroupManager().loadAllGroups();```
#

this

#

returns null

crystal sonnet
#

Are you sure loadAllGroups() returns null?

nocturne elbow
#

Yes

loud marsh
#

Any idea on how I can list all groups a player has and list out their prefixes? e.g "Admin, DonorRank, etc".

String group = api.getGroupManager().getGroup(player.getName()).getCachedData().getMetaData(queryOptions).getPrefix();```
I know that's a thing but I don't know how to get going with this. Any ideas?
crystal sonnet
#

Not it does not @nocturne elbow

nocturne elbow
#

Look

crystal sonnet
#

getLuckPerms() return null

nocturne elbow
#

oh

#

Wait how

crystal sonnet
#

Because you're loading it too early

nocturne elbow
#

so when should I load it?

crystal sonnet
#

You can't get the API instance before onEnable

#

And make sure your plugiin depends on LP in the plugin.yml

nocturne elbow
#

It does 🙂

crystal sonnet
#

@loud marsh why are you not getting the prefix from the user itself?

#

And I'm pretty sure on the metadata object is a method to list all prefixes

#

And getting all groups is done by iterating over all nodes of a player and looking for group nodes

loud marsh
#

Oh, sorry. Wrong line, I didn't mean to get the group one

#

I'm using the
String group = api.getUserManager().getUser(player.getName()).getCachedData().getMetaData(queryOptions).getPrefix();

#

Edited the line, ignore the group :P

#

Only seems to list out the current prefix tho

nocturne elbow
#

so i need help with rank prefixes

crystal sonnet
#

Yeah

#

That gives you the prefix @loud marsh

loud marsh
#

What about getting all groups a player has and displaying their prefix?

crystal sonnet
#

But as I said on the object returned by getMetaData should be a method that gives you all prefixes

loud marsh
#

ah

crystal sonnet
#

Are you even reading what I'm saying?

nocturne elbow
#

still null

#
for(Group g : Essence.getLuckPerms().getGroupManager().getLoadedGroups()){```
loud marsh
#

Yes, I understand now

nocturne elbow
#

this line returns null

crystal sonnet
#

Which part of that call does?

#

Please get the returns of each function and print them

#

@nocturne elbow is your question API related?

#

(if you don't know what an API is, then no)

nocturne elbow
#

ig

#

i have essentials chat and i ran the command and there is a suffix and a prefix on the rank i am currently and it isnt popping up in chat'

crystal sonnet
#

So no

nocturne elbow
#

ight

#

What do you mean by get the returns of each function?

loud marsh
#

I did not mean to come across ignoring you or anything, sorry if that's what you thought lol
You said the getMetaData should give me all prefixes but it's only giving me one prefix

crystal sonnet
#
System.out.println(Essence.getLuckPerms());
System.out.println(Essence.getLuckPerms().getGroupManager());
System.out.println(Essence.getLuckPerms().getGroupManager().getLoadedGroups());
#

Basic debugging @nocturne elbow

nocturne elbow
#

oh right that's what you ment

crystal sonnet
#

No @loud marsh.

And I'm pretty sure on the metadata object is a method to list all prefixes

loud marsh
#

Gotcha, thanks. misinterpretation

nocturne elbow
#

okay

#

You still here?

#
Essence.getLuckPerms();```
#

returns null

#

okay fixed it but

#
            for(Group g : Essence.getLuckPerms().getGroupManager().getLoadedGroups()){
                if(event.getPlayer().hasPermission("group." + g.getName().toLowerCase())){
                    if(section.getString(g.getName().toLowerCase()) == null) throw new NullPointerException("Group " + g.getName().toLowerCase() + " doesn't have a chat format in the config");
                    event.setFormat(Chat.coloured(section.getString(g.getName().toLowerCase())
                            .replace("{PLAYER}", event.getPlayer().getName())
                            .replace("{MESSAGE}", event.getMessage())));
                }
            }```
#

why isn't this working?

#

the group exists

#

and I have it on my test server

loud marsh
#

Alrighty, I managed to list out the ranks. But they include a weight attached to them (weight#=rank)

crystal sonnet
#

@nocturne elbow what's not working?

#

@loud marsh so...?

loud marsh
#

?

nocturne elbow
#

so i want to set a players chat format from the config

#

and it's a different one per group

loud marsh
#

How can I replace the weight? Sorry

crystal sonnet
#

What's the problem with that @loud marsh ?

#

Replace?

#

What do you mean?

loud marsh
#

Yeah, replace it with an empty string - or just generally remove it so it just keeps the rank and not the weight attachment

crystal sonnet
#

@nocturne elbow that's what you want to do. Not what's not working...

#

@loud marsh ?

#

You do get a map

nocturne elbow
#

so it returns the group name like I wanted

crystal sonnet
#

What is wrong?!?

#

JFC

#

What's so hard about answering simple questions?!

nocturne elbow
#

I'm debugging it

crystal sonnet
#

@loud marsh just call .entrySet() on the map you get back

#

This is Java basics

loud marsh
#

Alright.

crystal sonnet
#

I'm gonna say it outright to both of you

#

If you're not comfortable with programming Java, Minecraft plugins are not for you

#

Learn Java first

loud marsh
#

I appreciate the concern, and I am still learning Java while I use the Spigot API

crystal sonnet
#

The only somewhat exeception to this is if you are very eperienced with another OOP lamguage

#

@loud marsh don't

#

MC is not the place to learn Java

nocturne elbow
#

Yeah, that's a no no

loud marsh
#

of course it's not

crystal sonnet
#

You just said you did

loud marsh
#

misinterpretation. I'm learning Java but also using Spigot. i.e in my free-time

#

not with using spigot with learning java, sorry

nocturne elbow
#

Learn Java, and it's frameworks before spiot

#

spigot*

loud marsh
#

👍

crystal sonnet
#

You don't need to learn any frameworks really

#

Spigot is essentially just one

#

The pure basics are what's needed here

#

Like knowing what a map is

#

And how you get the values out of it

loud marsh
#

Yeah I never learnt how to use one lol

nocturne elbow
#

Yeah that's basic stuff

loud marsh
#

I'm aware lol

#

I'm still in the process of learning, sorry if I frustrated y'all :P

crystal sonnet
#

And the LP API requires an even higher level

nocturne elbow
#

okay so

#
            for(Group g : Essence.getLuckPerms().getGroupManager().getLoadedGroups()){
                System.out.println("1" + event.getPlayer().hasPermission("group." + g.getName().toLowerCase()));
                if(event.getPlayer().hasPermission("group." + g.getName().toLowerCase())){
                    if(Essence.getInstance().getConfig().getString("chat-format." + g.getName().toLowerCase()) == null) throw new NullPointerException("Group " + g.getName().toLowerCase() + " doesn't have a chat format in the config");
                    event.setFormat(Chat.coloured(Essence.getInstance().getConfig().getString("chat-format." + g.getName().toLowerCase()))
                            .replace("{PLAYER}", event.getPlayer().getName())
                            .replace("{MESSAGE}", event.getMessage()));
                }
            }```
crystal sonnet
#

Especially in terms of data models

nocturne elbow
#

did some debugging and i have the permission

#

but it still doesn't set the correct formar?

#

format*

#

it sets to default instead of the one it is ment to

crystal sonnet
#

well the permission check is true for all groups the player has

#

Including inherited ones

#

And thank for finally telling me what the issue is

#

In other words that your code always detects the player as being in default

#

Was that really that hard?

nocturne elbow
#

No 😄

crystal sonnet
#

Then why didn't you tell me 10 minutes ago?

nocturne elbow
#

I was debugging it

crystal sonnet
#

You you were very clearly seeing that before, didn't you?

#

Anyways if you just want to "the group" a player is in, get the primary group

#

There's a simple method on the user object

#

You really need to work on being concise

nocturne elbow
#

Got it ❤️

#

Thank you so much

crystal sonnet
#

You're welcome

#

@nocturne elbow for future referece

#

If someone asks what you issue is, they want to know the symptoms of your problem

nocturne elbow
#

Ok, sorry again

wet veldt
#

I was using api.getStorage().loadUser(offlinePlayer.getUniqueId()) to obtain a User for an OfflinePlayer. Is something similar still applicable? I saw in the docs there's a CompletableFuture which will block a thread until they're obtained but this could block an indefinite number of threads..?

crystal sonnet
#

The old method also returned a completable future

#

So I’m not sure what you’re talking about @wet veldt

wet veldt
#

ah, it was implemented in that way?

crystal sonnet
#

Yes

#

All database interactions have returned a CompletableFuture

#

In v4 as they do in v5 @wet veldt

wet veldt
#

Okay thanks, just never directly interfaced with a CompletableFuture in the past so didn't realise, apologies.

crystal sonnet
#

No problem

astral thicket
#

How do you guys manage dependencies?

#

LuckPerms deffinately does not include H2 and redis drivers in it's 1.3MB jar file

#

Are you using some classloader trickery?

#

It's really clever whatever it is

crystal sonnet
#

They are downloaded and injected into the class loader

#

I’ve created a system that is even better and uses a custom class loader that isolates the loaded classes from the rest

#

@astral thicket

astral thicket
#

Thats really cool. And it doesn't conflict with java 11+?

crystal sonnet
#

Yes

#

At least in theory

#

Haven’t tested that yet because my test env is Java 8

frank driftBOT
#

Hey N3G4T1V3! Please don't tag staff members.

vital hemlock
#

nothing nothing... I just solved my problem

vital hemlock
#

Im updating my plugin to the last version of the api and I don't know if this is the way to make this:

In the version 4.4 I had this:

  public static boolean existsGroup(String group) {
    return API.getGroupSafe(group).isPresent();
  }

And in the version 5.0 I don't know if there is an method or this is the way:

  public static boolean existsGroup(String group) {
    return API.getGroupManager().getLoadedGroups().stream().anyMatch(g -> g.getName().equals(group));
  }

jaunty pecan
#

Just check if getGroup returns null

bold plover
#

By the way, 2 questions
Does the later API update safe to update? will it effect the database structure at all?
Secondly, How do the node mutate (add) events work on a network? Is there some wizardry that sends the event to another server sharing the db, or just the server that issued the command?

crystal sonnet
#

Yes there is some wizardry. Namely the messaging services

#

And I don’t know what you mean with the first question at all

bold plover
#

i mean, has there been any db schema changes recently or should all versions be compatable with the same db?

crystal sonnet
#

No changes at all in that department

sudden kelp
#

Shiny, 4 and 5 are working with the same db, but messaging service changed, so that will error out when tryong to use 4 and 5 on the same network. So you have to update all servers at once

bold plover
#

ah ok

sharp timber
#

So I am relatively new at this and I am trying to make a plugin for doing /rankup and I need to check if they are in a specific group on a specific track. I pasted this in but i'm not too sure how to use it

public static String getPlayerGroup(Player player, Collection<String> possibleGroups) {
  for (String group : possibleGroups) {
    if (player.hasPermission("group." + group)) {
      return group; 
    }
  }
  return null;
}

I have that put in.. How would I make an if statement to say like..

if(sender.getPlayerGroup().equals("moderator", "staff")) { //Checks if player group equals moderator on staff track
  sender.promote("staff") //Promotes on Staff Track 
}
crystal sonnet
#

Did you check those links?

#

!api

frank driftBOT
crystal sonnet
#

@sharp timber

sharp timber
#

Yes I did, sorry. That’s where I got that first example method

gloomy saffron
#

I'm not really asking about the LuckPerms api, but more general permission API here, so sorry if this is in the wrong section. I was using Player#hasPermission and it was returning true when I'd set it to False in their permission data.

#

Has anyone had this problem before?

#

like I'd run lp user <name> permission checkinherits and it'd say False in game

#

but the permission would work for the action

sharp timber
#

You most likely have some type of logic error

hardy badge
#

Hey I've got a question.. I'm using the API and when invoking the java api.getUserManager().getUser(target.getName()).setPrimaryGroup(rank); the primary group is not being altered.

crystal sonnet
#

@hardy badge that's because setting the primary group is not equivalent to the parent set command.

hardy badge
#

How might I be able to simulate that?

crystal sonnet
#

All it does is change which of the groups already applied to the user are the primary. One

#

In addition by default this does absoutely nothing because the primary group is being calculated automatically

#

Have a look here:

#

!api

frank driftBOT
lusty kindle
#

how does the nodes work? im reading the docs but im not getting it 😦

crystal sonnet
#

In what context. There’s a fair bit to them.

past ivy
#

how do i make it so normal players can do /spawn it works for me people who arent opped cant do it

crystal sonnet
nocturne elbow
#

!install

frank driftBOT
nocturne elbow
#

!downloads

frank driftBOT
nocturne elbow
#

!extension

#

!help

frank driftBOT
#
Available commands:

!advanced
!api
!argumentbased
!bulkupdate
!bungee
!commands
!context
!default
!downloads
!editor
!errors
!faq
!install
!meta
!migration
!permissions
!placeholders
!stacking
!storage
!switchstorage
!sync
!tracks
!usage
!verbose
!wiki

crystal sonnet
#

@nocturne elbow what do you need help with? This is the channel for plugin devs

opal cradle
#

!permissions

frank driftBOT
opal cradle
#

!placeholders

frank driftBOT
nocturne elbow
#

I need some help with using the API to add permissions to a user in code

crystal sonnet
#

!api

frank driftBOT
nocturne elbow
#

if you listen to an event such as UserPromoteEvent on a bukkit server attached to a bungeecord proxy will the event still fire if the command that fired the event was ran on a different server?

wet veldt
#

Does Vault support LuckPerms API v5 now?

crystal sonnet
#

Vault supports nothing

#

Everything else supports vault

#

LP5 was supporting Vault from day one @wet veldt

wet veldt
#

As in, if I used Vault to query permissions and prefixes, and the server had LuckPerms v5+, would it work..?

crystal sonnet
#

Of course

wet veldt
#

Great, thanks

crystal sonnet
#

Why wouldn’t it?

wet veldt
#

I was thinking Vault would need to update to the new API version of LP

#

unless it doesn't work like that

crystal sonnet
#

The LP support of Vault is provided by LP

#

As I said. Vault supports nothing

wet veldt
#

ah I thought it was the other way round haha

crystal sonnet
#

The support is always coming from the plugin itself

#

It’s the same for all plugins supporting vault

wet veldt
#

okie that makes sense

#

would be horrible to maintain if it was the other way round lol

crystal sonnet
#

Exactly

wet veldt
#

Small query regarding the implementation LP provides to Vault...
Are Vault queries for OfflinePlayers blocking? because LP uses those CompletableFuture things, would it block the thread until the data is obtained?

crystal sonnet
#

Yes it does

wet veldt
#

It's blocked until the player comes online..?

crystal sonnet
#

No...

#

It’s blocked until the data is loaded

#

Or not at all if it’s already loaded

#

@wet veldt

wet veldt
#

okay thanks, I'm just worried using that because I don't want a potential huge block

#

is there an upper bound on the time it'll block for? sorry

crystal sonnet
#

Just work with it async @wet veldt

ornate silo
#

How do I change the weight of a group using the api?

#

are all groups represented as weightnodes? e.g. if my group was "admin" then the node would be a WeightNode with key "group.admin"?

#

or can I just add any weightnode to the group's NodeMap, and delete the existing weightnodes? should I use any specific key for my weightnode?

surreal comet
#

How I get a User of a offline player based on it name?

ornate silo
#
        User user = userManager.getUser(username);
        return user != null
                ? CompletableFuture.completedFuture(user)
                : userManager.lookupUniqueId(username).thenCompose(this::loadUser);
    }

    CompletableFuture<User> loadUser(UUID player) {
        User user = userManager.getUser(player);
        return user != null
                ? CompletableFuture.completedFuture(user)
                : userManager.loadUser(player);
    }```
#

you get the userManager instance using LuckPermsProvider.get().getUserManager();

tacit fox
#

is it possible to put a user on a specific position in a track using the api ? Dont see an option in the track manager unless im missing it 😛

surreal comet
#

Tanks, but a thing, How I get the User from the CompletionStage?

#

@ornate silo

ornate silo
#

if you're not on the main server thread you can use CompletableFuture#get (you'd have to change the return type in the signature)

#

otherwise you can use CompletionStage#thenAccept, CompletionStage#thenApply or CompletionStage#thenCompose

#

note that obtaining a user can fail - if you want to 'catch' the exception you can use CompletionStage#handle or CompletionStage#handleAsync

#

if you're not familiar with the CompletionStage and CompletableFuture api's, I'd recomment that you read their javadoc pages first

surreal comet
#
        loadUser(args[0]).thenAccept(user -> {lpUser = user;});
        User lp_target = lpUser;
        if(lp_target == null) throw new CommandException("invalid player");
        OfflinePlayer target = Bukkit.getOfflinePlayer(lp_target.getUniqueId());
        database.createPlayer(lp_target.getUniqueId(), target.getPlayer());
        Group group = luckPerms.getGroupManager().getGroup(args[1]);
        if(group == null) throw new CommandException("invalid group");
        database.setLevel(lp_target.getUniqueId(), args[1]);
        lp_target.data().add(PermissionNode.builder("stafflog.commands.staff-mode").build());
        sender.sendMessage("§7Defined §b" + target.getName() + "§7 as §b" + args[1]);
        luckPerms.getUserManager().saveUser(lp_target);
    }```
I'm not sure if this will work...
ornate silo
#

it won't, because the Consumer that accepts the user is invoked when the user is retreived, that is after the command completes.

#

you need to do everything inside the body of the lambda

surreal comet
#

the exception doen't work if I do so

ornate silo
#

you can return a new CompletableFuture from your 'execute' method

surreal comet
#

Humm, the examples use CompletableFuture but the code u sent use CompletableStage, and I can't understand right what to do to use the CompletableFuture...

ornate silo
#

just change the return types of my methods to CompletableFuture<User> (I updated the example code)

surreal comet
surreal comet
#

@ornate silo I can't get it, is it right or I should do something else?

ornate silo
#
public CompletableFuture<Void> execute(CommandSender, String label, String[] args) {
    return loadUser(args[0]).thenCompose(user -> {
        if (user == null) {
            return CompletableFuture.failedFuture(new CommandExcetpion("invalid player"));
        } else {
            //ideally createPlayer returns a CompletableFuture as well, such that we can cantinue after the row was created.
            database.createPlayer(user.getUniqueId, user.getName());
            Group group = luckPerms.getGroupManager().getGroup(args[1]);
            if (group == null) {
                return CompletableFuture.failedFuture(new CommandException("invalid group"));
            } else {
                database.setLevel(user.getUniqueId(), args[1]);
                user.data().add(PermissionNode.builder("stafflog.commands.staff-mode").build());
                sender.sendMessage("§7Defined §b" + target.getName() + "§7 as §b" + args[1]);
                return luckPerms.getUserManager().saveUser(user);
            }
        }
    });
}```
#

if you must still use java 8 then instead of return CompleteableFuture#failedFuture(new CommandException(…)); you can use CompletableFuture<Void> cf = new CompletableFuture<>(); cf.completeExceptionally(new CommandException(…)); return cf;

surreal comet
#

It requires to be void

ornate silo
#

is there any problem changing the return type of the base method to CompletableFuture<Void>?

surreal comet
#

there's more 3 classes that use the base method, and I think that they won't like this change, neither me, bc I would need to recode all again, and it was a pain to do 1st time.

ornate silo
#

this will perform very poor for players that are offline

languid granite
#

hmm trying to add support for luckperms to my plugin, but the user has perm check works only if the perms are in a group and the user has that group.

#

I have my plugins perms as a non op but I still cannot use my commands

#

I have a proper permissions tree in the plugin.yml

#

I'm an experienced java programmer btw

#

I think it has to do with context?

jaunty pecan
#

@ornate silo yes this is correct

#

or can I just add any weightnode to the group's NodeMap, and delete the existing weightnodes

#
public void setWeight(Group group, int weight) {
    group.data().clear(NodeType.WEIGHT::matches);
    group.data().add(WeightNode.builder(weight).build());
}
#

@languid granite I don't really understand your question

#

if you're defining your permissions in plugin.yml as non-op, then players will only have access to them if you explicitly grant them that permission

languid granite
#

So
op: true?

#

By default only op has access

#

But I just want to perform a simple check if a specific player has the permission via luckperms

#

Ie just like
Player.hasPermission(...)

#

But through luckperms

ornate silo
#

Ty!

#

@languid granite if the player is online you don't need anything other than Player#hasPermission - LuckPerms will take care that the permissions are set correctly.

languid granite
#

So the bukkit one is fine?

ornate silo
#

yup

languid granite
#

But I've had reports that my plugin doesn't work properly with luckperms

ornate silo
#

that is.. interesting. Are you sure that the server admins who filed the reports had their permissions set up correctly? can you reproduce their problems?

languid granite
#

Yes

#

And yes

#

For whatever reason some perms work and others don't

#

If you'd like to try yourself my plugin is called UberEnchant

#

It works flawlessly with essentials GroupManager

#

Oh I think they may also be using paper spigot

ornate silo
#

I think there is a mistake in your plugin.yml

#

when you define children, you define whether to 'enable'/'disable' a child permission.

#

you don't set their truth values

languid granite
#

Huh? But it works flawlessly with groupmanager

#

Even the inherited nodes

ornate silo
#

never mind what I just said

languid granite
#

?

ornate silo
#

I don't think there was a mistake in your plugin.yml

languid granite
#

Hmm
It has to be how LP handles perms

ornate silo
#

when do you check for permissions? only in command executors?

languid granite
#

Pretty much

ornate silo
wheat veldt
#

yoo

#

how can I get a groups prefix?

#

I know how to get the group but there doesnt seem to be a getPrefix() method

ornate silo
#

group.getNodes().stream().filter(PrefixNode.class::isInstance).map(PrefixNode.class::cast).max(Comparator.comparing(PrefixNode::getPriority)).map(PrefixNode::getMetaValue);

wheat veldt
#

ty

ornate silo
#

this sample code does not take inheritance into account

lilac shoal
#

can someone help me please?

ornate silo
#

don't know until you tell us what's up.

lilac shoal
#

how do i make it where when someone joins the server they automatically get a rank so i dont have to manually add them to a group

wheat veldt
#

@ornate silo how would I do it to get the prefix from the group itself rather than all the inherited prefixes?

ornate silo
#

with the sample code I pasted @wheat veldt

#

@lilac shoal LuckPerms already provides a default group that by default is called "default" :)

wheat veldt
#

ok ty

lilac shoal
#

ahh i see

#

i just put all the permissions and prefix into that group?

ornate silo
#

yes

lilac shoal
#

okay tysm!

wheat veldt
#

@ornate silo the .stream method isnt available in the Node class

ornate silo
#

that is correct. in api version 5 Group#getNodes returns a Collection<Node>, Collection has the stream method.

wheat veldt
#

Weird that i cant seem to find the .Stream method

ornate silo
#

it's available in Java 8 and newer verions

wheat veldt
#

getNodes returns ImmutableSetMultimap<ImmutableContextSet>

ornate silo
#

I think you're using LuckPerms api 4 then

#

to get the collection of nodes you can use group.getOwnNodes()

wheat veldt
#

That works thanks

#

the only other thing is "PrefixNode" isnt found

ornate silo
#

right

#

you can use Node::isPrefix then as the filter

ornate silo
#

I haven't worked out the last parts yet, there is no #getPriority method on Node.

#

you can omit the cast, and the final call in the chain can be .map(node -> node.getPrefix().getValue())

#

then only the comparator needs to be fixed still..

#

a dirty fix would be to just call .findFirst instead of .max, but that is probably incorrect if a group has multiple prefixes.

wheat veldt
#

Oof I am so new to this stream/filter shit

#

Lol

#

thank you for helping me out

ornate silo
#

oh, turns out the key in the entry is the priority

#
    .filter(Node::isPrefix)
    .map(Node::getPrefix)
    .max(Comparator.comparing(Map.Entry::getKey)))
    .map(Map.Entry::getValue);```
#

you can get the prefix string using Optional#get but be sure to check Optional#isPresent first!

wheat veldt
#

ty

#

How would I get groups main prefix from this?

ornate silo
#

if (prefix.isPresent()) { String pre = prefix.get(); /* code that is executed when the group has a prefix */}

#

(forgive me for forgetting parentheses sometimes, I am used to writing Scala lately instead of Java.. :3)

wheat veldt
#

Ty!

#

For some reason that is returning the prefix at the bottom of the inheritance

ornate silo
#

the code I pasted does not consider child/parent groups. It just computes the prefix with the most priority that is set on that group specifically.

#

maybe you need to replace max by min. Don't know whether higher priorities also mean that they come first..

wheat veldt
#

are lower prefixes higher priority?

#

like the prefix with meta value of "1"

#

will be higher priority

#

then 2

#

thats weird

#

its attaching two prefixes together...

ornate silo
#

in that case you can just join them

#

String prefix = group.getOwnNodes().stream().filter(Node::isPrefix).map(Node::getPrefix).sort(Comparator.comparing(Map.Entry::getKey)).map(Map.Entry::getValue).collect(Collectors.joining(ChatColor.RESET.toString()))

surreal comet
#

So, when I get the group diplay name it shows right, but if I chahnge my plugin doen't get the new name, it get every time I open the GUI, but I have to reload the server to get the new display name

ornate silo
#

you can subscribe to NodeRemoveEvent and NodeMutateEvent to get notified of changes to nodes. luckPerms.getEventBus().subScribe(NodeMutateEvent.class, event -> { Set<Node> newNodes = event.getDataAfter(); /*TODO check for DisplayNameNodes*/ };

surreal comet
#

It does query the name every time I open the GUI, but it get the same result unless I reload for some reason

ornate silo
#

did you save the user data with userManager#saveUser?

#

there is also UserDataRecalculateEvent by the way.

tight brook
#

How could I change the suffix of a user using the api?

ornate silo
#

user.data().clear(NodeType.SUFFIX::matches); user.data().add(SuffixNode.builder(suffix, priority).build());

agile river
#

How do you add a parent to a user? This is the command to do it:
/luckperms user WiebeHero parent add admin
But i can't find it anywhere on how to do this with the api...

#

And for some context, this is ADDING, not setting. It would also be appericiated if you could show me on how to remove a parent from the player

ornate silo
#

just add an InheritanceNode to the user

#
    public void addParent(User user, Group /*can also use String*/ group) {
        user.data().add(InheritanceNode.builder(group).build());
    }
    
    public void removeParent(User user, String group) {
        user.data().clear(node -> NodeType.INHERITANCE.matches(node) && NodeType.INHERITANCE.cast(node).getGroupName().equals(group));
    }
agile river
#

InheritanceNode cannot be resolved

#

@ornate silo

#

Il try to get the newest version

#

Alright many thanks koekenpan

#

hey @ornate silo sorry to disturb you again, but would this be good to see if a User has a specific parrent?

public void containsParrent(User user, String group) {
    user.data().contains(InheritanceNode.builder(group).build(), NodeEqualityPredicate.EXACT);
}
#

Im very new to Nodes, sorry

ornate silo
#

that expression will only evaluate to true if the group that the player is in does not expire, and has no contexts

#

(and of course the user has to be in a a group with the same name)

#

and your version does not take grandparent groups into account

agile river
#

With no contexts meaning, no permissions @ornate silo

ornate silo
#

no I mean ContextSet

#

a node can be 'server-specific' or 'world-specific', that is done through contexts

#

the EXACT predicate tests key equality, value equality as well as context equality and expiry equality

agile river
#

Alrighty, got it ty 😄

ornate silo
#

np, yw :)

agile river
#

@ornate silo does a player need to be online for that query to work?

nocturne elbow
#

well yes

#

to execute the command

agile river
#

Oki

ornate silo
#

no

tardy quail
#

Hi all, I am just checking. Should this add/remove groups from players? Does remove a node remove the permission from the player?

    /**
     * Add a group to the user
     * @param user User instance
     * @param group group to add
     */    
    public static void addGroup(User user, String group) {
        Node node = luckPermsApi.getNodeBuilderRegistry().forInheritance().group(group).build();    
        user.data().add(node);
        luckPermsApi.getUserManager().saveUser(user);        
    }
    
    /**
     * Add a group to the user
     * @param user User instance
     * @param group group to remove
     */        
    public static void removeGroup(User user, String group) {
        Node node = luckPermsApi.getNodeBuilderRegistry().forInheritance().group(group).build();    
        user.data().remove(node);
        luckPermsApi.getUserManager().saveUser(user);        
    }    
#

for example

        LuckPermsHelper.removePermission(luckPermsUser, "group.oldgroup");
        LuckPermsHelper.addPermission(luckPermsUser, "group.newgroup");
#

Will it just remove the group if the user has it?

#

oh! I just realised

#

i need to remove the "group." from the front

#

adds it automatically

ornate silo
#

it will only in some cases. Keep in mind that UserManager#saveUser returns a CompletableFuture - meaning that after you call one of these methods changes to the user aren't guaranteed to be propagated to the storage back-end yet. If you call both methods in sequence then there is a race condition, only one of the users states will be saved in the end because one user state will be overwritten by the other.

#

I'd recommend returning that CompletableFuture - callers of these methods can choose to ignore the return value anyway.

#

even better would be to do the add and remove operation for the User in one method, and save only once

#
    Node remove = InheritanceNode.builder(oldGroup).build();
    Node add = InheritanceNode.builder(newGroup).build();
    user.data().remove(remove);
    user.data().add(node);
    return luckPermsApi.getUserManager().saveUser(user);
}```
tardy quail
#

I will implement the change group. Thank you kindly.

agile river
#

@ornate silo so the player doesn't need to be online?

#

For the command to work?

agile river
#

Nvm i already got it, sorry for the tag

surreal comet
#

Is there a part on tha api that allow me to bridge with bungee lp?

azure cosmos
#

Hi, might be being a bit thick here, but I'm having trouble getting a group prefix using v5 of the api

crystal sonnet
#

@surreal comet what for?

#

@azure cosmos did you check those two links?

#

!api

frank driftBOT
nocturne elbow
#

any example of getPrefix in version 5.x?

azure cosmos
#

ah I didn't see those usage pages, i'll check them out now, thanks!

surreal comet
#

My plugin chnage the player group on bukkit luckperms, but not on bungee lp, and I'm not considering making a bungee version of the plugin as a option...

#

oh nvm

#

the chat plugin just didn't updated

lavish snow
#

Is it possible to obtain anyone uuid from luckperms db?

ornate silo
#

UserManager#lookupUniqueId

nocturne elbow
#

why doesnt this work in the new api and how can I fix it?

gaunt chasm
#

gChat (Bungeecord) doesn't show my prefix, does anyone know, what i did wrong?

crystal sonnet
lofty orbit
#

Are there any code examples of finding a User, getting its nodes and setting Metadata for the User?

ornate silo
#

finding a user is as simple as LuckPermsProvider.get().getUserManager().getUser(String/UUID) if the user is online, otherwise use UserManager#loadUser

lofty orbit
#

I can get the users, and got it to pull the Metadata from a player, both prefix and custom. but I set the custom meta with the plugins commands. I would like to add custom metadata with the API and that is definitely not as clear as how to go about it.

ornate silo
#

oh when you create the node use NodeBuilder#withMetaData

#

you'd have to define the metadatakeys as constants in your own plugin

lofty orbit
#

do you have an example of doing this?

ornate silo
#
private static final NodeMetadataKey<Integer> NUM_KILLS_KEY = NodeMetadataKey.of("#kills", Integer.class);

public CompletableFuture<Void> setKills(UUID player, int kills) {
    UserManager userManager = LuckPermsProvider.get().getUserManager();
    User user = userManager.getUser(player);
    CompletableFuture<User> userFuture = user == null ? userManager.loadUser(player) : CompletableFuture.completedFuture(user);

    return userFuture.thenCompose(user -> {
        Node killsNode = Node.builder("myplugin.kills")
            .withMetadata(NUM_KILLS_KEY, kills)
            .build();
        user.data().add(killsNode);
        return userManager.saveUser(user);
    });
}``` something like this should do the trick
#

though I am not sure whether the implementation supports user-defined types for metadata values, the type signature of #withMetaData suggests it does.

lofty orbit
#

awesome thank you! I will give this a try.

ornate silo
#

i'm reading through the source code now - it looks like node metadata does support every reference type imaginable, but it isn't ever saved to the database

#

so you'll need to handle saving/loading that in your own plugin.

lofty orbit
#

Yeah, that's what I am seeing. The code appears to work (doesn't error) but the meta is never added to the database.
Maybe I will turn this data into a permission. Now to try turning this code into Add permission to user instead of Add metadata.

ornate silo
#

that's a possibility too

lofty orbit
#

ah it was adding the key as a permission. So I can do it this way. yay

ornate silo
#

yeah. only works if your custom data is convertable from and to a string though.

lofty orbit
#

yeah, in my case it is plugin.key.value will work fine.

jaunty pecan
#

Sorry I'm late to reply here

#

You want MetaNode

#

there are examples here

#

@lofty orbit ^

idle seal
#

which event is triggered when someone gets a rank?

thorny echo
#

@idle seal Pretty sure it's just a Node Add event

#

The node in question would just begin with group.

idle seal
#

ok

neat jackal
#

You can also check if the Node is an instance of InheritanceNode iirc

idle seal
#

and how can i get the player from this node?

ornate silo
#

you check event.isUser() and if so you cast event.getTarget() to User

idle seal
#

the event will not run if i give someone a parent

idle seal
#

and which event do I have to use now?

languid socket
#

the event will not run if i give someone a parent
Any errors? And what did you try to check it? @idle seal

idle seal
#

No there are no errors. I am getting a message in the event

idle seal
#

hello?

lofty orbit
#

What's the message?

tardy quail
#

When permissions are updated by the API changes don't replicate to all servers instantly unless the player relogs or a query on the player is performed

#

this is said code to update perms

    /**
     * Add a permission to the user
     * @param user User instance
     * @param permission permission to add
     */
    public static void addPermission(User user, String permission) {        
        Node node = luckPermsApi.getNodeBuilderRegistry().forPermission().permission(permission).build();        
        user.data().add(node);
        luckPermsApi.getUserManager().saveUser(user);
    }
crystal sonnet
#

@tardy quail what LP version are you using?

tardy quail
#

LuckPerms v5.0.50

#

on Waterfall as well

jaunty pecan
#

@tardy quail I replied on github

tardy quail
#

Thank you kindly

robust trellis
#

Hi, I'm actully using LP v4 and I want to know if there is a way to add several permissions in one time.
I have a list of permissions that I want to apply on both online and offline players. Currently I want to apply 4 permissions but sometimes I have 2 of them apply, next 3 one of them... But never the four.
If someone have the solution...

for(String permission : currentReward.getPermissionsList()) {
                futureUser = LuckPerms.getApi().getUserManager().loadUser(player.getUUID());
                futureUser.thenApplyAsync(user -> user.setPermission(LuckPerms.getApi().getNodeFactory().newBuilder(permission).build()));
                futureUser.thenApplyAsync(user -> LuckPerms.getApi().getUserManager().saveUser(user));
            }

Thanks in advance

neat jackal
#

Why are you using v4 instead of v5?

nocturne elbow
#

how do we set perms for one spesific warp?

#

for prison

jaunty pecan
#

@robust trellis highly recommend upgrading to v5 - once you've done that, this code will work for what you want to do

#
private LuckPerms luckPerms = Bukkit.getServicesManager().load(LuckPerms.class);

public void giveMultiple(Player player, List<String> permissions) {
    User user = this.luckPerms.getUserManager().getUser(player.getUniqueId());
    for (String permission : permissions) {
        Node node = Node.builder(permission).build();
        user.data().add(node);
    }
    this.luckPerms.getUserManager().saveUser(user);
}
#

@nocturne elbow are you asking about the API? or is this a general question

nocturne elbow
#

question

crystal sonnet
nocturne elbow
#

oh shit yeah

robust trellis
#

Thank you for your response

languid socket
#

How do I add a rank to a player if the player stands on a pressureplate on a exact location while holding an item (the pressureplate and item part is already set, but I have no clue about adding the rank to a player)

crystal sonnet
wheat lake
#

Hi, can someone help me with some code? I'm using lp API v5.0
I set the prefix of players with the LP API, but it looks like lp doesn't save this prefix. This is my code:

void setPrefix(User user, String prefix){
        PrefixNode prefixNode = PrefixNode.builder(prefix, main.nodeWeight).build();
        loadUser(user).getData(DataType.TRANSIENT).add(prefixNode);
        api.getUserManager().saveUser(user);

        api.getUserManager().saveUser(user).thenRun(() -> api.getMessagingService().ifPresent(service -> service.pushUserUpdate(user)));
}```
crystal sonnet
#

@wheat lake that's because you're setting transient data

#

Transient are temporary overrides that don't get stored to data

#

Just call data()

#

@wheat lake

wheat lake
#

Thanks! It worked

maiden vault
#

Hello, i try to update my plugin with luckperms 5 but i don't know how i can retrieve an group prefix and suffix.

Currently i have that (on bungee) :

try {
    final LuckPerms api = LuckPermsProvider.get();
    final User user = api.getUserManager().getUser(getUniqueId());
    final Optional<Group> group = getGroup().flatMap(s -> Optional.ofNullable(api.getGroupManager().getGroup(s)));

    if (user != null && group.isPresent()) {
        final CachedMetaData data = group.get().getCachedData().getMetaData(api.getContextManager().getQueryOptions(user).orElse(api.getContextManager().getStaticQueryOptions()));
        String prefix = (data.getPrefix() != null) ? MFString.colorize(data.getPrefix().trim()) : "";
        String suffix = (data.getSuffix() != null) ? MFString.colorize(data.getSuffix().trim()) : "";

        // Add space if is not only color
        if (!ChatColor.stripColor(prefix).isEmpty()) {
            prefix = prefix + " ";
        }
        if (!ChatColor.stripColor(suffix).isEmpty()) {
            suffix = " " + suffix;
        }

        proxiedPlayer.setDisplayName(prefix + getName() + suffix + ChatColor.RESET);
    }
} catch (IllegalStateException ignored) {
}

But with that my prefix and suffix is doesn't retrieved but i doesn't have error.

Thanks for your help

jaunty pecan
#

you want the user's prefix?

#

or the groups?

crystal sonnet
#

User's prefix includes the group's prefix

maiden vault
#

I have found my problem, its just because i doesn't have update my spigot plugin (for manage the tab list name) 😄

jaunty pecan
#

👍

rare rapids
crystal sonnet
#

That’s not an error...? @rare rapids

rare rapids
#

Okey, so why don't you want it to work?

crystal sonnet
#

Do you mean “why doesn’t it want to work”?

#

And you’ve not shown any error whatsoever

rare rapids
#

Is it highlighted in red, can it work?

jaunty pecan
#

try refreshing the maven project

crystal sonnet
#

I don’t think the color means anything here

#

Just try it

rare rapids
#

I make sure ;p

#

Okey its work, sorry 😦

hardy badge
#

So I understand that setting the primary group doesn't change their parent group, but I've still got an itch to see if I can change users parent groups using the API. Any luck? (No pun indended)

crystal sonnet
#

Of course you can

#

You can do anything with the API that you can do with commands

#

And more @hardy badge

hardy badge
#

How might that be acomplished?

crystal sonnet
#

Adding is just adding an inheritance node to the player

#

Setting is just removing all existing inheritance nodes before adding the new one

#

There should be plenty of examples in this channel @hardy badge

#

And I think this page is getting better too

#

!api

frank driftBOT
hardy badge
#

Would that mean the note like group.<group>?

crystal sonnet
#

Yes and no

#

There are builders for all kinds of node types

#

@deep wigeon how are you loading it right now?

deep wigeon
#

You told me to put it in /config/luckperms/extensions and that's what I did. I believe I might also have it in the main luckperms folder, though.

crystal sonnet
#

I mean the API code wise

#

Not the extension

#

@deep wigeon

deep wigeon
#

It's just in my mods folder

crystal sonnet
#

Code

#

As in plugin code

deep wigeon
#

I don't know the code :(

crystal sonnet
#

Then tell the dev to fix it

deep wigeon
#

I've been trying. Lol

#

I don't have the src and the dev is gone

crystal sonnet
#

Then it’s very difficult

#

And for future reference

deep wigeon
#

Rip. I'll just try to get a different one made that works or something

crystal sonnet
#

Insist on getting the code when you get a custom plugin made

deep wigeon
#

I typically do, but this is one of the only ones that I don't have.

crystal sonnet
#

Any dev not offering that is not worth their salt

#

That sucks

#

It can be partially recovered through decompiling

#

Though that’s not an ideal solution

deep wigeon
#

I'll either get someone to decompile it or try to get a new one made. Thanks for the help :)

crystal sonnet
#

Anyways good luck with getting this sorted

#

You’re welcome

vernal mango
#

How can i change the name of a group?

ornate silo
#

you don't, but you can create a new group with a different name and add the same nodes to it

#

and you'll have to make sure that all other permissionholder that inherited from the old group now will inherit from the new group

haughty solar
#

How to set a permission. What has to be in brackets?
LuckPerms.getApi().getUser(pp.getUniqueId()).setTransientPermission(HERE)

crystal sonnet
#

First off, you don’t want to set a transient permission

#

Second, search this channel. I think several snippets have been posted

#

And third have a look here

#

!api @haughty solar

frank driftBOT
hollow zodiac
#

That is for luckperms, right?

#

This is my pom.xml:

#
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.lumengaming</groupId>
    <artifactId>Skillsaw3</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging> 
    <build>
        <finalName>Skillsaw3</finalName>
    </build>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <repositories>
        <repository>
            <id>spigot-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
        <repository>
            <id>bungeecord-repo</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
<!--        <repository>
            <id>parallelblock-public</id>
            <name>ParallelBlock Public Repository</name>
            <url>https://repo.parallelblock.com/repository/maven-public/</url>
        </repository>-->
        <repository>
            <!-- NuVotifier -->
            <id>bintray-repo</id>
            <url>https://dl.bintray.com/ichbinjoe/public/</url>
        </repository>
    </repositories>
#

    <dependencies><dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-translate</artifactId>
  <version>1.64.0</version>
</dependency>
        <!-- https://hub.spigotmc.org/versions/ -->
        <dependency>
            <!-- https://oss.sonatype.org/content/repositories/snapshots/net/md-5/bungeecord-api/maven-metadata.xml -->
            <groupId>net.md-5</groupId>
            <artifactId>bungeecord-api</artifactId>
            <version>1.15-SNAPSHOT</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>net.md-5</groupId>
            <artifactId>bungeecord-api</artifactId>
            <version>1.15-SNAPSHOT</version>
            <type>javadoc</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.15.1-R0.1-SNAPSHOT</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.15.1-R0.1-SNAPSHOT</version>
            <type>javadoc</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.vexsoftware</groupId>
            <artifactId>nuvotifier-universal</artifactId>
            <version>2.6.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>net.luckperms</groupId>
            <artifactId>api</artifactId>
            <version>5.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>
hollow zodiac
#

Alright, just going to remove luckperms from the project for now then...

crystal sonnet
#

!api

frank driftBOT
crystal sonnet
#

@hollow zodiac

ionic aurora
#

can a german(it doesnt matter )player help me on my Server .. I have Luckperms on in and i dont can edit it because when i use the command /lp creategroup (group) that doesnt work ...

neat jackal
#

#support-1 as it seems like it is a question about LuckPerms in general and not the developer API.

Please explain in that channel what exactly doesn't works

crystal sonnet