#luckperms-api

1 messages · Page 40 of 1

compact spruce
#

I found the maven dependency

crystal sonnet
#

As explained on the wiki it’s for all platforms

#

Btw what for do you need to iterate over the permissions?

compact spruce
#

just making a simple plugin that formats join/quit messages and check permissions for proper prefix and suffix formatting

#

something set by essentials i think

#

part of a cross-server chat plugin

compact spruce
#

I'm sure such a thing already exists

#

so like when a player joins it says [Moderator] minecraftUserName

crystal sonnet
#

BungeeChat for example 😜 (which I made)

compact spruce
#

with certain colors

#

or [Builder]

#

you made that?

crystal sonnet
#

Those are prefixes

compact spruce
#

lol

#

nice

#

so I just need to check the permissions to get the right colors basically

crystal sonnet
#

The API has methods for getting prefixes and suffixes

compact spruce
#

that's just what i need

honest anvil
#

Hey!

I've been using the API for a bit, but never used the Event System which I am currently a bit stuck on.
I have read up on the Documentation Page (https://luckperms.net/wiki/Developer-API-Usage) on how to Subscribe to Events using the EventBus and basically replicated that Code in my Project.

Now whilst running a simple task of outputting a Message in Chat once the "UserLoadEvent" should be called, sadly nothing is happening.

In my Main Class I added this: new LuckPermsListener(this, LuckPermsProvider.get());

And my Listener Class looks somewhat (shortened out most of it) like this:

public class LuckPermsListener {
    private Main main;

    public LuckPermsListener(Main main, LuckPerms api){
        this.main = main;

        EventBus bus = api.getEventBus();
        bus.subscribe(UserLoadEvent.class, this::onPlayerDatabaseLoad);
    }

    public void onPlayerDatabaseLoad(UserLoadEvent e) {
        Bukkit.getScheduler().runTask(main, () -> {
            Bukkit.broadcastMessage("UUID: " + e.getUser().getUniqueId());
        });
    }
jaunty pecan
#

That looks correct to me

#

any errors in console?

#

did you fully restart the server to load your plugin?

keen nebula
#

i wanted to set up luck perms
but when i type " lp editor "
it says plugin desabled

#

how do i enable it

turbid solar
#

!paste your latest.log

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!

honest anvil
#

@jaunty pecan Nope, no outputs in the Console. Also tried fully restarting the Server and still nothing.

Some more Infos:
Minecraft Version: 1.16.4
LuckPerms Version: 5.2.67
API-Version: 5.2

frank driftBOT
#

Hey Stunter! Please don't tag helpful/staff members directly.

honest anvil
#

o

#

mb

vague knoll
#

Hello

#

the server provider that is in there is from the luckperms website and I do not know how to access it since the website isn't as helpful like Vault's..anybody can give a hand?

turbid solar
#

!api

frank driftBOT
turbid solar
#

!cookbook

frank driftBOT
turbid solar
#

or type provider. then look at the suggestions

zealous rose
#

Hey, i was trying to find a way on how to get the permission expiry time from a player's node from the LuckPerms API. I tried different ways but none of them work. and I also searched a lot in the #Developer_API wiki but I couldn't find an example similar to it could be great if somebody knows how. and share it, it will save me time. Thanks

sorry for the bad english.

nocturne elbow
#

How are you trying to do it currently?

zealous rose
#

it always return 0

nocturne elbow
#

Aah you see, parent group nodes are not permission nodes, they are inheritance nodes (of type INHERITANCE), so getNodes(NodeType.PERMISSION) will never give you parent group nodes :d

zealous rose
#

alright, i'm going to try that out

nocturne elbow
#

And you'd filter if the group name isn't member

zealous rose
#

oh so it also gives you the group name method.

#

good

#

didn't see that

nocturne elbow
#

Yeah, InheritanceNodes contain the group name

mossy surge
#

I may be tried but I fail to give myself a parent. I'm doing lpUser.data().add(linkedNode); where linkedNode is InheritanceNode.builder("linked").build(); and linked is the name of a group in LuckPerms. Am I doing it wrong?

jaunty pecan
#

Nope, that's correct

#

are you saving afterwards?

mossy surge
#

No I did not. Must be that. Thank 🙂 🙂

compact spruce
#

I'm a little confused about how the server vs world context works

#

I'm using the following code to send the user their CachedPermissionData and their contexts when they type a command

#
public void execute(CommandSender sender, String[] args) {
    if (sender instanceof ProxiedPlayer) {
        sender.sendMessage(new TextComponent("You have these permissions:"));
        for (String perm : sender.getPermissions())
            sender.sendMessage(new TextComponent(ChatColor.GOLD + perm));

        LuckPerms api = LuckPermsProvider.get();
        User user = api.getPlayerAdapter(ProxiedPlayer.class).getUser((ProxiedPlayer) sender);
        CachedPermissionData data = user.getCachedData().getPermissionData();

        for (Map.Entry<String, Boolean> entry: data.getPermissionMap().entrySet()) {
            sender.sendMessage(new TextComponent(ChatColor.GOLD + entry.getKey() + ChatColor.RESET + ": " + ChatColor.GREEN + entry.getValue()));
        }
        ImmutableContextSet ctxSet = api.getContextManager().getContext(sender);
        QueryOptions queryOptions = api.getContextManager().getQueryOptions(sender);

        sender.sendMessage(new TextComponent(ChatColor.RED + "Context set:"));
        for (Context ctx: ctxSet) {
            sender.sendMessage(new TextComponent(ChatColor.GOLD + ctx.getKey() + ChatColor.RESET + ": " + ChatColor.GREEN + ctx.getValue()));
        }
    }
#

my server admin has a bunch of permissions for my user set with context server: creative or server:survival

#

nothing is set by world. But when that Context ctx: ctxSet loop runs, it tells me the server is bungee and the world is the servername

#

i'm trying to figure out why the context is always bungee for server

obtuse jolt
#

In bungeecord yea, server is bungee, and world is your servername

compact spruce
#

i'm expecting it to be survival or creative

#

yikes. so i need my admin to redo all the permissions?

#

I have server: survival in the luckperms config.yml for the spigot server

#

so server is always gonna be bungee?

#

that's hard to believe because the permissions work correctly on his server using server: survival and server:creative when running under bungee

#

the docs also show the example "world: world_nether". It seems odd that world would represent a spigot server under bungee since those spigot servers could have multiple worlds too

#

config.yml

# The name of the server, used for server specific permissions.
#
# - When set to "global" this setting is effectively ignored.
# - In all other cases, the value here is added to all players in a "server" context.
# - See: https://github.com/lucko/LuckPerms/wiki/Context
server: creative
#

it should be the server context as far as what this says, not world. is there anyway i can make it show the spigot servers as servers rather than worlds

nocturne elbow
#

Not on bungee LP

compact spruce
#

the bungee LP comments say exactly the same

#

the config file is the same

nocturne elbow
#

The "server" setting refers to the LP instance rather than a "server"

compact spruce
#

I see

nocturne elbow
#

There is an open issue about that

compact spruce
#

I just don't understand how it works on on our production server since our admin has all the permissions set as server: creative, server: survival etc.

#

yet when i do it on my test server using the above code i get get world:survival so there is no way i can get the correct permissions

#

unless we redo all the contexts

#

as far as i can tell we have the same setup

#

i wonder if i can force change the player's context somehow

#

when players login

nocturne elbow
#

Everywhere, "server" refers to the specific LP instance, on the survival server it'll always be "survival", on bungee it'll always be "bungee". The "world" context however refers to "where the player is in", in Bukkit that is the actual world and on bungee that is the server name they are in

nocturne elbow
#

Contexts are more like a "state" that LP "observes"

#

Say for example you wanted to give Bungee LiteBans' perms while you were in the creative server only, you would grant them for server=bungee and world=creative

compact spruce
#

That's what I figured. But my server admin has the permissions set up as server: creative, server: survival and somehow they work

#

Not sure how

compact spruce
#

So you say that I cannot force change the player's context. But could I calculate and somehow return a list of what permissions they would have under a certain context?

#

like calculate all the permissions they would have if they were under context server: survival even if their current active contexts are server: bungee and world: survival

#

that would solve my problem

nocturne elbow
#

Yeah you absolutely can

#

That's what QueryOptions and ContextSet are for :p

nocturne elbow
#

When you say "In my Main Class I added this new LuckPermsListener(this, LuckPermsProvider.get());" where is that exactly? In your onEnable?

honest anvil
#

Yeah, basically where I register all the Listeners

zealous rose
#

it's fixed

crystal sonnet
#

@honest anvil can you verify that the code is actually being called?

haughty solar
#

How can I find out when a player's permission expires?

honest anvil
crystal sonnet
#

Very interesting. That looks like a bug then. I'd recommend you report it on GitHub with all your findings

#

@honest anvil

honest anvil
#

Alrighty, will do!

prime glacier
#
            <groupId>me.lucko.luckperms</groupId>
            <artifactId>luckperms-api</artifactId>
            <version>5.2.35</version>
        </dependency>``` Why maven doesn't find the version 5.2.35 ?
turbid solar
#

!api

frank driftBOT
turbid solar
#

First link

paper hearth
#

Hey, for some odd reason I can't seem to be able to get the api on bungee, anybody may have any idea why?

turbid solar
#

No

#

What are you trying now?

paper hearth
#

Currently I'm trying to get the api using LuckPermsProvider.get();

sudden pelican
#

do you get an error?

turbid solar
#

Did you add the api?

paper hearth
# sudden pelican do you get an error?

Yes, this is the error I'm getting

java.lang.IllegalStateException: The LuckPerms API is not loaded.
        at net.luckperms.api.LuckPermsProvider.get(LuckPermsProvider.java:50) ~[?:?]
        at me.yarinlevi.parlabungeegroups.ParlaBungeeGroups.onEnable(ParlaBungeeGroups.java:56) ~[?:?]
        at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:300) ~[Waterfall.jar:git:Waterfall-Bootstrap:1.16-R0.4-SNAPSHOT:1d2221d:384]
        at net.md_5.bungee.BungeeCord.start(BungeeCord.java:289) ~[Waterfall.jar:git:Waterfall-Bootstrap:1.16-R0.4-SNAPSHOT:1d2221d:384]
        at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:62) ~[Waterfall.jar:git:Waterfall-Bootstrap:1.16-R0.4-SNAPSHOT:1d2221d:384]
        at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15) ~[Waterfall.jar:git:Waterfall-Bootstrap:1.16-R0.4-SNAPSHOT:1d2221d:384]
turbid solar
#

Show full code

sudden pelican
#

did you add depends: [LuckPerms] to your bungee plugin yml

paper hearth
# turbid solar Show full code
        if (getProxy().getPluginManager().getPlugin("LuckPerms") != null) {
            luckPerms = LuckPermsProvider.get();
            isLuckPerms = true;
            commandSender.sendMessage(Utils.newTextComponent("&fHooked into LuckPerms!"));
        } else {
            isLuckPerms = false;
        }
nocturne elbow
#

That isn't the full code

paper hearth
#

The rest of it is something else, that is a piece of code from Main

turbid solar
#

Is that the only place you're calling LuckPermsProvider.get()?

paper hearth
#

Yea

nocturne elbow
#

Where is that

#

On load, in the constructor, on enable, etc

paper hearth
#

onEnable()

nocturne elbow
#

How are you managing your dependencies?

paper hearth
#

Maven

nocturne elbow
paper hearth
nocturne elbow
#

Aah there it is

#

You are shading the API into your plugin

#

Add <scope>provided</scope> to the LP dependency

paper hearth
#

Alright, just 1 second I'll test it out

#

Yep, that's it

#

Thanks alot

untold cloud
#

how do you add/remove a permission from a User?

nocturne elbow
#

!cookbook

frank driftBOT
untold cloud
#

ty

mossy surge
#

Can I promote/demote users using the api?

turbid solar
#

Yes

mossy surge
#

Is that another node I would have to add? I couldn't find any examples.

mossy surge
#

According to a github issue it's pretty complicated. Is it still the case?

#

it's like 3 years ago. maybe something has happened? 🙂

jaunty pecan
#

Something did happen!

sterile tide
#

how can I get a list of all groups a user is member of?

nocturne elbow
#

Well, parent groups are nothing more than an InheritanceNode

sterile tide
#

And if I only want the highest group in each track?

nocturne elbow
#

"highest" meaning...?

#

With highest weight or the last one on said track?

sterile tide
#

last one

nocturne elbow
#

TrackManager#getTrack(String) and then get the last group from Track#getGroups

sterile tide
#

ok thanks

#

:)

haughty solar
#
                    permissions -> permissions.equals("system.givepremium.lock"))
                    .forEach(permissions -> System.out.println(permissions.getExpiry().getDate()));```
#

Is there a mistake?

crystal sonnet
#

Yes. the permissions are a permission node, not a string. So the .equals will always return false

haughty solar
#

What else should I use?

crystal sonnet
#

Look at the suggestions your IDE gives you when you try to call a method on the permission variable

haughty solar
#

okay

#

thx

compact spruce
#

!api

frank driftBOT
compact spruce
#

I've been reading the docs for hours and I can see how to query permissions for an active context, but what I actually need to do is, if the context is world: survival, then I want to take that word "survival" and somehow query what permissions the player WOULD have if they were currently under a context of server: survival, even if they are not currently under that context. I have no clue how to do that from anything I'm reading, and I'm not sure I understand what query options even are.

#

or how i actually use them to find a permission based on a theoretical context that may not be active, but definitely has permissions defined. like how my admin has server: survival defined as a context for like a hundred permissions but I can't query them because they show up wrong when I check the user's permissions and contexts

#

I need to get the displayname.{somewildcard} that they would have if they were under a server: survival context

#

example: I am a Moderator and i have the permission displayname.Moderator. I am using the "Moderator" part in messages sent as chat messages to proxied players, and I need to be able to obtain whatever is after the "displayname." and I need to be able to obtain this from the context it is defined under regardless of what server that user is on or what the active context is because the active context is never set correct thanks to the spigot servers being world contexts and our permissions being defined as server contexts. so I can't seem to obtain the displayname by any method i've tried with the API so far

compact spruce
#

well I figured it out mostly, but I'm just trying to figure out how to get the right display name because now i get all the displaynames for all groups inherited from

#

lol

compact spruce
#
LuckPerms api = LuckPermsProvider.get();
User user = api.getPlayerAdapter(ProxiedPlayer.class).getUser((ProxiedPlayer) sender);
String server = null;

// Loop through the active contexts to find the value for the key "world" if possible
for (Context ctx: api.getPlayerAdapter(ProxiedPlayer.class).getContext((ProxiedPlayer)sender)) {
    if (ctx.getKey().equals("world")) {
        server = ctx.getValue();
        break;
    }
}

// If world context is active
if (server != null) {
    QueryOptions opts = QueryOptions.contextual(ImmutableContextSet.of("server", server));
    CachedPermissionData data = user.getCachedData().getPermissionData(opts);

    // Display all the permissions for key "server" with a value matching the "world" value
    for (Map.Entry<String, Boolean> entry: data.getPermissionMap().entrySet()) {
        sender.sendMessage(new TextComponent(entry.getKey() + ": " + entry.getValue()));
    }
}
#

so I get the active context world: whatever and query permissions for server: whatever, but is there anyway to only get the permissions at the Moderator level? for example, right now I get displayname.B+, displayname.guest, displayname.B-, displayname.Moderator. I would like to only get the permissions at the highest level I guess, so i need only displayname.Moderator. Is this possible?

#

I tried using Flag.RESOLVE_INHERITANCE but that didn't do what I expected

#

sorry for text wall

high tiger
# nocturne elbow Say for example you wanted to give Bungee LiteBans' perms while you were in the ...

I'm the admin @compact spruce mentioned. From what I can understand, that setup would not make sense. What's the point of doing a server: context if it's always going to be server: bungee? I have a BungeeCord setup with 3 servers: lobby, survival, creative. To give players specific permissions on the survival server, I add the server: survival context to the permissions. This works perfectly. Is this not the correct way to do it?

compact spruce
#

the only reason it can possibly work perfectly as I can see it is that Essentials must have some workaround because according to the developer, what you have setup should not work as there does not seem to be a way to programmatically obtain the information that Essentials must somehow be obtaining

#

or I'm unaware of how to obtain it

nocturne elbow
#

Idk man I didn't design this, but again:

Everywhere, "server" refers to the specific LP instance (where LP is running), on the survival server it'll always be "survival", on bungee it'll always be "bungee". The "world" context however refers to "where the player is in", in Bukkit that is the actual world and on bungee that is the server name they are in

high tiger
compact spruce
#

because when I obtain the active contexts using the API, i do not get the correct permissions

#

oh, I thought you were the developer lol my bad

nocturne elbow
#

Lol no

high tiger
#

Maybe it's because Essentials and all our other plugin permissions are being checked on the local spigot server.

nocturne elbow
#

Exactly!!

compact spruce
#

it always shows me the context of world: survival when it should be server:survival

#

yeah probably.

#

so it seems like my solution is gonna have to be the one I originally had which was to send the permissions from the spigot servers to the bungee server with plugin messaging or something

nocturne elbow
#

Just get the ProxiedPlayer server name and put that as server context for the QueryOptions

compact spruce
#

i did

#

it's giving me EVERYTHING

#

i get every permission from every group

nocturne elbow
#

Well yes no shit, that's how inheritances work

compact spruce
#

I don't need 10 displaynames, i need Moderator

nocturne elbow
#

Transitivity exists

compact spruce
#

ok, but that's not the point. the context is world: survival

high tiger
#

From my (maybe incorrect) understanding, contexts are supposed to be used like this:
NO BUNGEE:

-world
-world_nether
-world_the_end```For this setup, I should add the context `world: world_the_end` to any permissions I want the player to have in The End.

BUNGEE:
```2 servers, 1 world each:
-creative (server name)
 -world (world name)
survival (server name)
 -world (world name)```For this setup, I should add the context `server: survival` to any permissions I want the player to have on the Survival server.
#

Maybe it's not correct, but it works. :/

#

If you're supposed to use world: <servername> then how do you specify a world context for that server?

nocturne elbow
#

Thing is

#

There are two separate, totally independent and unrelated "levels" of perm checks, the permission checks occurring on server level (EssentialsX, vanilla commands, Bukkit commands, WorldEdit, etc), for those the world context is the actual world you are in (end, nether, overworld) and the server context refers, again, to the specific LP instance based on the setting in config

And then there's bungee perm checks (LiteBans/AdvancedBans, bungee commands, etc), for those, the world context is which sub-server you are in, and the server context refers to, yet again, the running LP instance based on the setting in config

#

Basically:
Server context refers to what LP and where the permissions are being checked
World context refers to where the player is in, regardless of where LP is

#

There is an open issue to change that, let me find it rq

#

As for your actual displayname issue, you are getting all perms because permissions and inheritances are transitive, and since the nodes' keys themselves are different, you're gonna get all of them. If I'm not mistaken they should be sorted by how inheritances are resolved, so the first one in the resulting collection should be the one of the "closest" group (presumably direct parent group)

compact spruce
#

if they're sorted and that the defined behaviour then problem solved lol

#

i just take the first displayname i find

#

lol

#

perfect

nocturne elbow
#

I'd assume you're using the PermissionHolder#resolveInheritedNodes(QueryOptions) method?

compact spruce
#
// If world context is active
if (server != null) {
    QueryOptions opts = QueryOptions.contextual(ImmutableContextSet.of("server", server), new HashSet<Flag>() {
        {
            addAll(Arrays.asList(Flag.values()));
        }
    });
    CachedPermissionData data = user.getCachedData().getPermissionData(opts);

    // Display all the permissions for key "server" with a value matching the "world" value
    for (Map.Entry<String, Boolean> entry: data.getPermissionMap().entrySet()) {
        sender.sendMessage(new TextComponent(entry.getKey() + ": " + entry.getValue()));
    }
}
#

when I added only the RESOLVE_INHERITANCE flag, it gave me only the bungeecord.whatever permissions

#

or possibly none, i can't remember

#

but when i use either all the Flags or none of the Flags i get the full permissions list for server: <servername>

#

<servername> being a value i obtained from the world context that is currently active

#

I'm doing that specifically because @high tiger has the permissions configured with the server context not the world context

#

so with the code there, I get a list of all the correct permissions but like i said, multiple display names

#

and I know that I am part of the moderator group, so i inherit all those other displaynames, but i just need the Moderator one. if it's at the top, then i can just loop through the results and find the first occurence of displayname

nocturne elbow
#

I'm not sure how the CachedPermissionData is backed, if it's backed by a regular hash map, then it isn't sorted, but in that case you should use either PermissionHolder#resolveInheritedNodes(QueryOptions) or PermissionHolder#resolveInheritedNodes(NodeType, QueryOptions) since those are sorted according to the platform's inheritance rules (a.k.a config)

honest anvil
#

Hey!
Is there an Event that gets called once a Player finished loading out of the Database?

crystal sonnet
#

UserLoadEvent @honest anvil

#

I believe.

compact spruce
crystal sonnet
#

Like even if you insisted on using the LP API there’s a ready made call to get the prefix

honest anvil
compact spruce
#

!api

frank driftBOT
crystal sonnet
#

And embed any set of contexts there

#

I mean with vault you can only get the prefix of the user’s current context

compact spruce
#

yes but it works correctly with the way our permissions are defined using server instead of world

#

whereas with luckperms API it does not

#

so it's either redefine all our contexts as world or find a programmatic solution

#

because when i get the context it shows world: survival

crystal sonnet
compact spruce
#

yes

crystal sonnet
#

Yeah. Of course you can do it programmatically

compact spruce
#

so CachedMetaData.getPrefix()

crystal sonnet
#

Yes.

compact spruce
#

gives the highest priority prefix for the current context?

#

I just need to change it to get the context for world instead of server

crystal sonnet
#

If you want to see an example on how to do it, then have a look at BungeeChat. I implemented it there

crystal sonnet
#

But by default that means the highest prefix

#

But since you’re working with the bungee why are you even bringing up vault?

compact spruce
#

because I couldn't figure out how to do what i needed with bungee

#

but i figured out how to do it with vault at the spigot level

#

at which point i would send the information to bungee using plugin messaging

#

but if i can do it in luckperms in bungee that is preferable

crystal sonnet
#

I mean why wouldn’t you be able to?

compact spruce
#

I'm sure you would

#

I just haven't figured out how

crystal sonnet
#

Take a look at BungeeChat

#

I’ve implemented exactly what you want to do there

compact spruce
#

it's a big project, which file might I look in?

crystal sonnet
#

Look for the LuckPerms5Hook

#

Hope that helps 🙂

#

Struggled a fair bit to get it working

compact spruce
#

found it. So, if I'm understanding this right, you get the QueryOptions from the ContextManager and use that to create a copy of the original context, then foreach WORLD_KEY you add a corresponding SERVER_KEY containing the world value to the new context which you build into a new QueryOptions. Then you use that new QueryOptions to get new meta data

#

then you can get the suffix from that

#

or prefix

crystal sonnet
#

Exactly

compact spruce
#

I get the gist of it, I don't fully understand what you're doing with streams there

crystal sonnet
#

Well only difference in the newer API would be that there’s a ready made call to get the query options with a fallback

compact spruce
#

but i think I understand more or less

compact spruce
#

how i can do what i need

#

yeah, i haven't used that in Java, but i've used something similar in javascript so I get the idea

#

still kind of new to Java

crystal sonnet
compact spruce
#

yeah it is

crystal sonnet
#

Oh

#

I misread

#

Good

compact spruce
#

I just mean your code helped me understand how to use the API better

#

I just have to test it but it looks like it's what i need

crystal sonnet
#

Alright

compact spruce
#

probably won't test it tonight, time for a break

crystal sonnet
#

Up to you

restive shoal
honest anvil
#

Saw this earlier, not entirely sure tho since I haven't used this yet

restive shoal
#

Oh thank you, I wonder if it works if a user has been set to a rank instead of demote/promote, ill test

crystal sonnet
#

As long as a track is involved this should fire

restive shoal
#

nope, im looking for anything that interacts with a players rank at all (that event only does it on promote/demote on a track) i.e through the API or /lp user playername parent set rank

#

if nothing exists, I guess listening to the scheduler repeat and checking every few seconds couldn't hurt

jaunty pecan
#

NodeMutateEvent - check the node type is INHERITANCE

restive shoal
#

oh, thank you

#

sorry, how do I get the node type?

jaunty pecan
#

node.getType()

paper hearth
#

Hey, how do I add someone to a group? (Bungee if that makes a difference)

jaunty pecan
#

add an InheritanceNode to their data

#

there's an example on the wiki and in the cookbook

#

!api

frank driftBOT
jaunty pecan
#

!cookbook

frank driftBOT
turbid solar
#

In NodeAdd/RemoveEvent is there a way to find out who added said node? If not what event should I listen to for that?

jaunty pecan
#

probably LogBroadcastEvent

turbid solar
#

is there a way to just get the node that was added using that? because doing event.getEntry().getDescription() returns permission set test.permission.xd.8 true

jaunty pecan
#

No, unfortunately not

nocturne elbow
#

Nothing some regex cannot solve fingerguns

vivid cosmos
#

Hello, i'm developing a plugin using the LuckPerms API, but i couldn't find a way to listen for an event when a Player receive a group and when a group is removed from the Player, is there any event like that? If yes, could you guys provide an example on how to do it? Thanks for the great plugin!

turbid solar
#

NodeAddEvent & NodeRemoveEvent

#

!cookbook has some examples

frank driftBOT
silver sleet
#

Hello, I am trying to implement a system a bit like the unix sudo command where an Admin has to first enter a superuser state to access all admin permissions. I was trying to implement it using Events and searching an AsyncPermissionCheckEvent or something like that. I'd like to ask if there is such an event or if there is a a better way to implement what I am trying to do

jaunty pecan
#

a sudo group perhaps?

jaunty pecan
#

add them to the group before the command execution starts, then remove it shortly afterwards

silver sleet
#

I'm worried that might be problematic with the tab/nametag system

#

Although on second though, I should be fine if I don't set it as the primary group

jaunty pecan
#

mhm

silver sleet
#

Weight determines the primary group, right?

nocturne elbow
#

by default, yuh

silver sleet
#

Okay, I have a plan then, thanks!

silver sleet
#

Is there a way to prevent the inheritance node getting saved to storage? My idea is to only have the inheritance stored in cache so as soon as the player switches the server, disconnects or anything like that it gets erased

crystal sonnet
#

@silver sleet use transient nodes

#

There's a transient storage map

#

Like the nodes are the same, they just don't persist because you save them in a different place

silver sleet
#

Thanks, thats exactly what I've been looking for

turbid solar
#

get the key then check if its equals

crystal sonnet
#

Knowing how to get autocompletions out of your IDE is pretty much required

blissful basalt
#

!api

frank driftBOT
blissful basalt
#

God

#

!How api

frank driftBOT
#

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

blissful basalt
#

!hp

frank driftBOT
#

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

crystal sonnet
#

@blissful basalt what do you need help with?

blissful basalt
#

i'm understand dont Help me

long shale
#

Do you know about Luckperms api? because I will have this in my scoreboard when a player shows his group on the scoreboard that I have set with a prefix I do not know how to do it does anyone know?

obtuse jolt
#

so you are coding a scoreboard plugin?

#

if so, what have you tried?

long shale
mossy surge
#

I'm using Vault to access player prefixes/suffixes for when I'm displaying their formatted names in my plugin, it works great. But when a users prefix/suffixes changes for any reason I would like to know that so that I can update the formatted name(My plugin is creating holographic displays with formatted names). It looks like Vault doesn't have events to notify when that happens and I wouldn't like to hardcode my plugin against LuckPerms since Vault is supposed to be the abstraction layer here...

long shale
# obtuse jolt if so, what have you tried?

I haven't tried anything yet, I ask because the api is so heavy. I just want that the group in the player is displayed so the prefix with color of the group name stops

obtuse jolt
#

well if you really want a easy way its probably just use placeholderAPI

#

or else

#

!api

frank driftBOT
obtuse jolt
#

!cookbook

frank driftBOT
crystal sonnet
long shale
turbid solar
#

For?

pearl oriole
#

Just asking, did someone know how to put to a player with luckperm API a tempo group (like vote system, just have role vote for 24h) ?

turbid solar
#

inheritance node with expiry

grave canyon
#

is there a way to get a list/set of every group on a server with the api?

nocturne elbow
#

GroupManager#getLoadedGroups?

grave canyon
#

ok

#

that works!

nocturne elbow
#

you can also do GroupManager#loadAllGroups and then whenComplete GroupManager#getLoadedGroups if you want to be 100% "safe", although afaik they will all be loaded

grave canyon
#

ill do loadedgroups

long shale
turbid solar
#

method for what

#

which method

vapid terrace
#

Hi. Is it possible (and if yes, how?) to fire an UserPromoteEvent to promote a user?

nocturne elbow
#

No, you should do it the other way around

#

Promoting a user fires the event

vapid terrace
#

oh okay. Thank you.

#

Can you point me into a direction on how to do that using the API?

jaunty pecan
#

ya, you just listen to events, LP fires them :p

#

the method you want is in the Track interface

#

promote specifically

vapid terrace
#

Thanks. What is that ContextSet that has to be provided?

crystal sonnet
#

What version of the API are you using @vapid terrace

vapid terrace
#

according to my pom it's 5.2

jaunty pecan
#

the contexts to promote in -- if you don't know what they are, then don't worry and just pass ImmutableContextSet.empty()

vapid terrace
#

nice

jaunty pecan
#

!context fyi

frank driftBOT
vapid terrace
#

Do I still have to save changes after promoting, given that the promotion is the only change?

crystal sonnet
#

Yes of course

vapid terrace
#

so

            LuckPerms api = LuckPermsProvider.get();
            User user = api.getPlayerAdapter(Player.class).getUser(player);
            
            api.getTrackManager().getTrack("track").promote(user, ImmutableContextSet.empty());
            api.getUserManager().saveUser(user);

looks good enough for you, does it?

crystal sonnet
#

Looks good

vapid terrace
#

Thank you fine people 🙂

crystal sonnet
#

You're welcome

queen nacelle
#

sure 😮

nocturne elbow
queen nacelle
#

hmm

nocturne elbow
#

The cached meta data is the holder's meta data after resolving inheritances

#

So you should be able to grab it from there just fine

queen nacelle
#

wait

#

:/

#

that is not what i want :/

#

i´ll store the discord role id in the meta

nocturne elbow
#

and i just want the value with the highes weight.

#

seems totally reasonable and sounds like the default behavior suffices your needs

queen nacelle
#

the ids are not orderd from lowest to highest :c

nocturne elbow
#

could you send a new /lp editor link please?

#

and screenshot /lp user <user> info

queen nacelle
#

jo wait

#

i just fill out some missing meta ids

#
nocturne elbow
#

you play with the left hand as your main hand?

queen nacelle
#

xDD yes :c

#

bc. my right eye is 105% and my left just 96%

nocturne elbow
queen nacelle
#

wait

#

794749428472217600

#

its the first..!?

#

but wait

nocturne elbow
#

mhm it's the inherited one from the parent group with highest weight

#

a.k.a default behavior

queen nacelle
#

for what i want it´s the right one..

#

but i dont know if dont fail some day

nocturne elbow
#

?

queen nacelle
#

wait

#

let me test some things 🙂

brisk mist
#

i need help

nocturne elbow
#

!ask

frank driftBOT
#
Please ask your question!

Please ask the question you have. Don't ask to ask, or ask to DM someone. There are people here to help you, but we need to know what to help you with, so please just ask the question you want to in as much detail as possible!

Or, try here first:
Why shouldn't I ask to ask?
brisk mist
#

no encuentro respuesta en la web

queen nacelle
#

Felo...

#

that is what i mean

#

at the moment it´s from lowest to highest..

#

but if a new role is created it will be at the last place...

nocturne elbow
#

Well yes

#

You have to give that group a weight

queen nacelle
#

yes.

#

every

nocturne elbow
#

I don't see what the issue is, all this seems like the correct behavior

#

You can give a group its weight upon creation

#

/lp creategroup <name> [<weight>] [<displayname>]

queen nacelle
#

so the meta keys are orderd from weight

nocturne elbow
#

Yes

#

I thought that was crystal clear..

brisk mist
#

i have problems with mysql

nocturne elbow
queen nacelle
nocturne elbow
#

> the one from the group with highest weight is picked

> mhm it's the inherited one from the parent group with highest weight
> a.k.a default behavior

queen nacelle
#

the first is confusing...

nocturne elbow
#

I don't see the issue

queen nacelle
#

I would first load the default group...

nocturne elbow
#

What you want is already default behavior, and when creating a new group you have to specify a weight if you want it to take over

queen nacelle
#

i´m just brain dead. 😣

viral wyvern
#

can somebody help me?

#

How can i get the group prefix to my plugin?

nocturne elbow
#

!cookbook

frank driftBOT
turbid solar
#

!cookbook

frank driftBOT
turbid solar
#

!api

frank driftBOT
crystal sonnet
#

?

crystal sonnet
#

@nocturne elbow

grave canyon
#

!help

frank driftBOT
#
Available commands:

!advanced
!api
!argumentbased
!ask
!bulkupdate
!bungee
!bungeecheck
!cauldron
!colours
!commandequivalents
!commands
!config
!context
!cookbook
!default
!downloads
!editor
!editorsafety
!errors
!essentials
!extensions
!extracontexts
!faq
!formatting
!helpchat
!inheritance

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

grave canyon
#

how would i add a parent group to a player with the api? something like the equivalent of the command /luckperms user <name> parent add <group>

royal condor
#

!api

frank driftBOT
royal condor
#

!cookbook

frank driftBOT
grave canyon
#

ok

grave canyon
#

i dont see anything in the cookbook or the api docs about adding a temporary group/permission. does anyone know how? something like /lp user username parent addtemp group time

wheat breach
grave canyon
#

i didnt know i could use that!

nocturne elbow
#

Yeah but the LP way of doing things is not always a 1:1 correspondence with the API

#

Because LP does not use its own API 😛 it uses the internal implementations

grave canyon
#

but it couldnt be that much different right?

crystal sonnet
#

Typically simpler

wheat breach
#

Of course it doesn't. /s

nocturne elbow
#

It kind of depends what is it you're looking at specifically, but it is very similar (sometimes it isn't lol)

crystal sonnet
#

In any case you have to do is specify an expiry time when building the node

wheat breach
#

At any rate, just remember that 30 minutes of googling can save you 5 minutes of reading the documentation.

vapid terrace
#

I'm promoting a user on the bungeecord-side via the API (via a bungeecord plugin command). However, it seems that this information is not fully synced to all spigot servers, because of some weird behaviour with Multiverse and Worldguard.. Can i trigger an immediate sync after promoting the player?

#

When the user relogs, everything is cool, but I do not want to tell every new player to reconnect after promotion

crystal sonnet
#

Just trigger a network sync

vapid terrace
#

how can this be done via the API?

vapid terrace
#

anyone pls? :/

nocturne elbow
#

LuckPerms#getMessagingService gives you an Optional<MessagingService> (it's an Optional because it can be disabled)

#

Then you can just call MessagingService#pushUpdate if it's present ;)

#

You do that after saving the changes

vapid terrace
#

Thx

#
        LuckPerms api = LuckPermsProvider.get();
        User user = api.getPlayerAdapter(ProxiedPlayer.class).getUser(player);

        api.getTrackManager().getTrack("track").promote(user, ImmutableContextSet.empty());
        api.getUserManager().saveUser(user);

        Optional<MessagingService> messagingService = api.getMessagingService();
        messagingService.ifPresent(MessagingService::pushUpdate);

does this look correct to you?

nocturne elbow
#

Almost there :o

#

since the saveUser runs asynchronously, you'll have to pushUpdate on saveUser(blah).thenRun(...)

vapid terrace
#

Alright, thx! 🙂

vital sequoia
#

LuckPerms has a problem, it currently has many vulnerabilities and some users take advantage of this to hack into servers, for example to give themselves permissions as members and have this same plugin give them such permissions

nocturne elbow
#
  1. How is that related to the LP dev API?
  2. You'd need to provide some details on what is it exactly that's going on with that, as far as I know there are no known vulnerabilities
crystal sonnet
#

This has been brought up many times and always boils down to backend server security

#

In other words the backend servers are accessible from the internet which means people can just directly connect to them

nocturne elbow
#

i.e. set up a firewall and use online-mode=true 🙂

crystal sonnet
#

online-mode=true doesn't work for backend servers @nocturne elbow

frank driftBOT
#

Hey BrainStone! Please don't tag helpful/staff members directly.

vital sequoia
#

I will give an example on my server and go 2 times that a user executes the command lp user giving the permission of * which the user does not have permission for that as they are commands that are currently blocked

nocturne elbow
#

You can join my server without perms as many times as you want and you won't be able to do that PES_SadShrug

calm girder
#

Please can someone help me configure luckperms on bungee

crystal sonnet
#

@calm girder don't crosspost. And stay in the appropriate channels

calm girder
#

ok

magic bone
#

Does removing a node from a user happen if they inherit said node from their groups

crystal sonnet
magic bone
crystal sonnet
#

Yes you are

#

That only contains the player's directly assigned nodes

magic bone
#

Ah that makes this much easier for me then!

crystal sonnet
#

There is a call to get all nodes, but it's a read only collection for quite obvious reasons

magic bone
#

Mhm

turbid solar
#

!api me

frank driftBOT
blazing portal
#

how can i get a players luck perms prefix using the api?

crystal sonnet
#

!api

frank driftBOT
crystal sonnet
#

!cookbook @blazing portal

frank driftBOT
blazing portal
#

its not there

#

sorry iam dumb lul

#

i see it XD

#

thanks ❤️

compact spruce
#

Can anyone help me understand why a simple hasPermission check as well as registering a Command with Command(String name, String permission, String... aliases) fails EVERY time in a BungeeCord plugin? I have luckperms set up both on my spigot server and bungee server

#

both servers are connected to the same sql database

#

i have server: bungee in the bungee config.yml and server: lobby in the spigot server's config.yml. pluginmsg for messaging

#

and if i create a custom bungeecommand and set a permission, then give my player that permission in the lp editor, with the correct context, it still says I don't have permission for the command

#

and it's red when i type the command, like it doesn't exist. If i change permission to null in the Command constructor, I can run it, but with permissions I cannot

#

I must be missing something...do the permissions not sync to the CommandSender that has the permission or do I have to cast them to ProxiedPlayer or what? I've been trying to figure this out for awhile

turbid solar
#

Did you sync your permissions?

obtuse jolt
#

messaging should be sql btw

#

also are you refering to a bungeecord plugin you are making, or every single bungee plugin you tried to install in your server network

compact spruce
#

I've tried setting messaging to both sql and pluginmsg but I can try again

#

i'm referring to a bungeecord plugin I'm making

#

how do I sync permissions?

#

I tried /lp sync that didn't do it

turbid solar
#

screenshot /lp info and /lpb info

compact spruce
#

hang on booting servers

#

wait my storage type changed to h2

#

the hell?

#

lol

turbid solar
#

Then that's likely the problem ;d

compact spruce
#

but how can that be

#

it literally is set to MySQL in my config.yml

#

wait is that from the spigot server?

#

that's the spigot command isn't it

#

shit

turbid solar
#

Ye

#

They both need mysql & sql for messagging

compact spruce
#

lmao now I get it. i copied spigot servers and started using lobby which I hadn't configured

#

i'm dumb lol

#

hm, storage method is set to sql. probably should say MySQL

#

that would probably make it fall back on h2

turbid solar
#

yep

compact spruce
#

that is a silly mistake

#

permissions still aren't working though, so

#

i'll have to try sql for messenger service see if that works

#

well it seems to work now as long as I don't set a context for the permission

#

setting context server=lobby makes it fail

#

even though I'm on lobby

#

maybe world=lobby

turbid solar
#

Ye

#

context system with bungeecord servers is a bit weird

#

so server=bungee would mean on the bungee server itself and world=lobby would mean the lobby server

#

iirc

compact spruce
#

beautiful. thanks for your help man, it's working now

#

yeah it's weird, i figured that out about the world/server thing but on our production server all the contexts are set as server and it still works for some reason. but not on my test server

#

world does the trick

signal path
#

player its OfflinePlayer

obtuse jolt
#

Looks like you are not sure what CompletableFuture is?

signal path
frank driftBOT
#

Hey LoopRich161! Please don't tag helpful/staff members directly.

signal path
#

i check api

#

and copy

#

from site

#

i use version 5.2.59

obtuse jolt
#

not sure about the guide, but from the javadocs, it is suppose to return a CompletableFuture

signal path
#

kk

#

and

woven dust
#

!export

frank driftBOT
#

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

signal path
#

i must loadUser()

#

and after getUser()

#

?

obtuse jolt
#

also read lol

#

that example you screenshot is a example of what you SHOULDNT do

#

However, we can't, because #loadUser returns a CompletableFuture - as it performs lots of expensive database queries to produce a result.

signal path
#

thx, i solved problem

grand hearth
#

How do I get the weight of a prefix with the api?

grand hearth
#

?

nocturne elbow
#

Do you know the group the prefix is in / do you know which group holds the prefix?

grand hearth
#

I have an array of every group name

nocturne elbow
#

That uuh.. doesn't answer the question

#

You want to get the weight for a certain prefix

#

That prefix is being held by a certain group

#

Do you know which group?

grand hearth
#

Well, each group will only have one prefix, and I want to get the weight of it for each of them

#

So yes, I have an arraylist of every prefix, and I need to get the weight for them and make them into a hashmap or something

nocturne elbow
#

Do you have an array of group names or prefix values?

grand hearth
#

both

nocturne elbow
#

Well for each group you can do getNodes(NodeType.PREFIX), that will give you a collection of the holder's own nodes, not inherited ones

grand hearth
#

mm ok

nocturne elbow
#

Then from the PrefixNode you just getWeight or getPriority

grand hearth
#

What class is getNodes a part of?

nocturne elbow
#

PermissionHolder

#

You get the Group from the GroupManager#getGroup(String)

#

!api btw

frank driftBOT
nocturne elbow
#

!cookbook has a few common api usage examples

frank driftBOT
grand hearth
#

Sorry for all of the questions, but when I try and use the api it gives me this error, I've tried installing the legacy extension and I get the same message

org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: net/luckperms/api/LuckPermsProvider

nocturne elbow
#

Well you probably don't need the extension anyway, assuming you're using up to date LP and up to date api as dependency

#

But that sounds a whole lot like you didn't add "LuckPerms" to your depend

grand hearth
#

is that in plugin.yml?

nocturne elbow
#

mhm

grand hearth
#

mk

#

Now I get this:
org.bukkit.plugin.InvalidPluginException: java.lang.IllegalStateException: The LuckPerms API is not loaded.

#
RegisteredServiceProvider<LuckPerms> provider;
    LuckPerms luckPermsApi;

    
@Override
public void onEnable() {
    provider =  Bukkit.getServicesManager().getRegistration(LuckPerms.class);
    if(provider != null) {
        luckPermsApi = provider.getProvider();
    }
}

Here's the part of my main class that deals with it

turbid solar
#

Did you soft depend on luckperms?

nocturne elbow
#

See above :p

#

How are you managing your dependencies? maven, gradle, "external dependencies"..?

grand hearth
#

I'm manually adding them to the build path with eclipse

nocturne elbow
#

Hm... make sure you are not including the API jar into your jar when exporting

grand hearth
#

I'm not, theyre not in the project folder

nocturne elbow
#

Is there any place you're calling LuckPermsProvider.get()?

nocturne elbow
grand hearth
frank driftBOT
#
Invalid Paste!

The paste link you sent in is invalid or expired, please check the link or paste a new one.

nocturne elbow
#

clippy stfu

#

you relo----

#

don't

#

no

#

don't /reload

#

never ever

grand hearth
#

uh

#

ok....

#

another error though after a full reboot

nocturne elbow
#

send

grand hearth
frank driftBOT
#
Invalid Paste!

The paste link you sent in is invalid or expired, please check the link or paste a new one.

turbid solar
#

Whats on line 19

#

Main

grand hearth
#

RegisteredServiceProvider<LuckPerms> provider;

#

i should probably make it private

turbid solar
#

paste your whole code

grand hearth
#

just main?

turbid solar
#

Yes

grand hearth
#

formatting got weird after pasting :/

nocturne elbow
#

Hmm do me a favor

#

Open your compiled .jar with 7zip or winrar and make sure you are not compiling the API inside your plugin

grand hearth
#

wait hold on, earlier I was using the api jar with the first error I had, then I switched to the actual plugin jar (for luckperms), that could be why, i'll switch back

nocturne elbow
#

yikes stick with the api jar

turbid solar
#

Fefo, is there a difference in using the serviceprovider or just doing LuckPermsProvider.get()

grand hearth
#

oh my god i'm dumb that was why

#

yep, works now, thanks

nocturne elbow
#

Using the service provider also gives you the possibility of not crashing your plugin because something is missing, since it would return null instead of throwing ClassDefNotFoundErrorWhatever

#

So the service provider is 100% the way to go if you soft-depend on it

smoky lake
#

Hey, is it possible to check for a permission which is on a certain server context using the api?

smoky lake
#

You got any examples?

crystal sonnet
#

No. But the docs are pretty comprehensive

#

!api

frank driftBOT
crystal sonnet
#

!cookbook

frank driftBOT
smoky lake
#

Alright, thank you.

crystal sonnet
#

You’re welcome

smoky lake
#

Ah, I found it ImmutableContextSet not sure how I missed it before.

#

¯_(ツ)_/¯

crystal sonnet
#

You might want the mutable variant if you want to change it

smoky lake
#

Not sure what a mutable variant means, but I'm using it like this currently ImmutableContextSet contextSet = ImmutableContextSet.of("server", serverName);

#

Ah, I see nvm. I don't really need to change it after I create it.

crystal sonnet
#

Ok

nocturne elbow
#

how to hookup luckperms api from bungee to spigot plugin?

crystal sonnet
nocturne elbow
#

use luckperms api in spigot plugin when the luckperms in installed on bungeecord

#

how could i use it

#

im getting java.lang.NoClassDefFoundError: net/luckperms/api/LuckPermsProvider error

crystal sonnet
#

!bungee

frank driftBOT
grand hearth
#

How would I get every group a certain user is in?

#

Whether it's an arraylist or something else

sudden pelican
#

!cookbook

frank driftBOT
midnight mountain
#

is there a way to set the server name via the api?

nocturne elbow
#

You mean.. the setting in config?

midnight mountain
#

yeah

#

we have a system which syncs configs across servers, but i'm trying to avoid doing text replacement in it

nocturne elbow
#

Well, you can't really change the setting without replacing it in the config file. You could potentially do it with reflection but you are on your own there, specially because in Java 15+ final actually means something and you can't use any reflection to change final fields (afaik)

#

So no, there is no API for that

midnight mountain
#

that's about what i figured, thanks though

#

fortunately minecraft probably won't be updating to 15 for quite a while lol

nocturne elbow
#

Not minecraft itself, no, but you can't rely on server owners not using java 15 for running them

midnight mountain
#

true, but with forge it's just asking for problems

#

at least as far as i'm aware

nocturne elbow
#

oh ew the f word 🤢

midnight mountain
#

facts

nocturne elbow
#

f-fo-forge 🤢

solar siren
rustic laurel
#

please don't post in several channels, and be sure to read the channel topics to ensure that you're posting in the correct place @solar siren 😄

solar siren
#

Well

#

Will you help me

rustic laurel
#

you've already been helped @solar siren - in #support-1 which was the correct place to post it. My apologies for not having thought to help you 4 times, to correspond to your 4 redundant requests

vapid arrow
#

Is there a problem with this command (not with the command itself, but the way i typed it)

#

/lp group default permission set easykits.kit.archer true world=kitpvp

#

becouse it does not work

#

oh wait wrong channel

nocturne elbow
#

Hello, i want to ask how do you get the Next Prefix, or rank you can say, from UserPromoteEvent
and can you cast player to user?

#

I see you ignored the other 2 messages

#

Oh well

#

!cookbook

frank driftBOT
nocturne elbow
#

!api

frank driftBOT
nocturne elbow
#

You can't "cast a user to a player", you get the UUID and from it you get the player (depending on the platform it's going to be one method or another)

#

i cant search in that

#

i want to seach in JavaDocs

#

and there was a method for checking what is user beng promoted to, but forgot its class

#

Third link in the second embed

#

And yes it is UserPromoteEvent

#

wheres the search bar

#

There is no search bar, but you can click "Classes" or "Index" and Ctrl F what you want

#

k

main dagger
#

how do i remove a meta data key from a player? looking at the javadocs i see a clear method on NodeMap that either clears all nodes or accepts a ContextSet, but im not quite sure how to create the context set that it needs

#

doing /lp user <user> meta unset <key> does exactly what i want to do, but i cant figure out how to do that other than literally running the command as console which is obviously not a good solution

stark fjord
#

Is there a specific event for checking when a user's groups are updated or not? There is TrackPromote but by description that doesn't seem to be what I'm looking for...

nocturne elbow
#

@main dagger there are variants of NodeMap#clear that clear things as you want

#

e.g. NodeMap#clear(Predicate<Node>) or NodeMap#clear(ContextSet, Predicate<Node>)

nocturne elbow
nocturne elbow
#

You can use that to only clear the nodes that meet certain criteria

#

That "certain criteria" is what the Predicate evaluates

#

And that you define

stark fjord
nocturne elbow
#

I mean they will always be updated

#

Why'd you "check" that?

#

What are you trying to achieve

crystal sonnet
nocturne elbow
crystal sonnet
#

I know

#

That’s why I don’t quite understand why you’re questioning the motives when it’s pretty clear and the answer itself is pretty clear

#

Like I’d have answered but I keep forgetting the event name

#

Something like NodeMutate

nocturne elbow
#

Oh I must have misread the original question

#

I thought they were trying to check if the data was updated

#

Which... always is lol

crystal sonnet
#

No. Looking for the event

nocturne elbow
mossy surge
#

I use Vault to get offlineplayers prefix and suffix during the startup of my plugin but I'm having problems where sometimes I don't get a prefix/suffix for a offlineplayer and I believe it's because Luckperms have not had the chance to set everything up... I don't really know what luckperms is doing behind the scenes but has this come up before?

#

I use

vaultChat.getPlayerPrefix(null, offlinePlayer)
#

And I do have a softdepend on Vault

#

And I'm not running getPlayerPrefix/Suffix on the main thread

crystal sonnet
#

Throw in a softdepend on LuckPerms just to be sure

mossy surge
#

I thought about that but then I looked in the console that Luckperms always is enabled before my plugin and Vault. I can test it right now

#

My plugin is setting up some leaderboard and for each leaderboard a new thread is created where the getPlayerPrefix/Suffix is called on. It's completely random which leaderboards doesn't get the prefix/suffix back

crystal sonnet
#

I see. That’s interesting

#

My guess would be some kind of race condition

#

Just for the fun of it what happens when you don’t multithread it?

#

Like you might need to test it a few times

mossy surge
#

It unfortunately didn't work

crystal sonnet
mossy surge
#

LuckPerms gives me a warning that I shouldn't perform the getPlayerPrefix on the main thread

#

When I reload my own plugin then all leaderboards are re-created and it all looks good so the problem has to be that luckperms isn't really finished yet with whatever it's doing. I believe I can bypass this problem by waiting for some amount of time before I setup my leaderboards when my plugin gets enabled but I rather not 🙂

crystal sonnet
crystal sonnet
#

If you find a way to reliably reproduce it make a bug report on GitHub

mossy surge
#

Yes, I have managed to get the problem with around 4 leaderboards as well

#

Yes I can try

crystal sonnet
mossy surge
#

But i will file a report

crystal sonnet
mellow shadow
#

Hello!

#

I'm trying to make a basic plugin that gets the luckperms prefix, and displays below the users name using scoreboards. I added the luckperms api, and added the listener as well. This is my main class:

public class Main extends JavaPlugin implements Listener {
    
    @Override
    public void onEnable() {
        RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
        if (provider != null) {
            LuckPerms api = provider.getProvider();  
        }
            String prefix = user.getCachedData().getMetaData().getPrefix();
            User user = luckPerms.getUserManager().getUser(uuid);
        }
    
    
    @Override
    public void onDisable() {
        getLogger().info(ChatColor.RED + "Goodbye!");
        
    }
    @EventHandler
    public void join(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        
        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Scoreboard board = manager.getNewScoreboard();

        Objective objective = board.registerNewObjective("rank", "dummy");
        objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
        objective.setDisplayName(prefix);
         
        for(Player online : Bukkit.getOnlinePlayers()){
          Score score = objective.getScore(online);
            online.setScoreboard(board);
        }
    }
}
#

But for some reason, I get an error saying "user can not be resolved to a variable"

turbid solar
#

what is uuid

mellow shadow
#

It was just a quick test, let me get did of it

turbid solar
#

also can you post the full code on hastebin?

mellow shadow
#

Sure.

turbid solar
#

discord formatting isn't the best

mellow shadow
#

This is my main class.

turbid solar
#

you'd probably want to move the prefix & user variable in the playerjoinevent

#

then move LuckPerms api above the onEnable() so that you can access it from the anywhere in the class

#

then do luckPerms.getUserManager().getUser(player.getUniqueId() or whatever the correct method is from player

mellow shadow
turbid solar
#

send the full code again

mellow shadow
turbid solar
#

and you also need to register the listener

mellow shadow
crystal sonnet
#

And today we learned why making plugins requires existing Java skills

obtuse jolt
#

yea I agree... learn how variables and classes and methods works first

tired pond
#

Don't advertise

turbid solar
#

@thorny echo

thorny echo
#

@nocturne elbow Do not advertise, first warning

coarse python
coarse python
#

well then refresh the placeholders using the {medium}

#

tag

#

at the end of the placeholder

#

this will refresh the placeholders

#

even after initial load

rain hemlock
#

Hey there, I am using luckperms 5.2.76 with my plugin (I was using previous version of 5.2 aswell) and it used to allow me to update my users player group but for some reason, it stopped working! In the PlayerJoinEvent I have this System.out.println(Main.lp.getUserManager().getUser("username").setPrimaryGroup("groupname")); and it returns "FAIL" .. It was working previously and then suddenly stopped.. I am stumped as to why, please give me some advice 😄

however getPrimaryGroup() succeedes! The group exists in luckperms, and if my parent group is already set to it, luckperms returns "FAIL_ALREADY_HAS"

nocturne elbow
#

yeah..... that sounds totally normal behavior?

#

If your primary group is that group already, then it will fail because you already have it as there is nothing to change

rain hemlock
#

No, What I am saying, is that when it isn't already my primary, it Fails

#

it fails to set the primary

#

yet it is able to get the primary

#

in the case where it is the primary, it acts as it should

nocturne elbow
#

Well that's because setPrimaryGroup is likely not what you want, the primary group is, by default, calculated and it's the parent group with highest weight and you can't change that unless you change a setting in LP config which no owner should change lol

rain hemlock
#

setPrimaryGroup changes the users parent group no?

nocturne elbow
#

No

rain hemlock
#

hmm, how can I set the users parent group?

#

from the API

nocturne elbow
#

!cookbook there is an example that replicates the parent set command which sounds that is what you want to do

frank driftBOT
rain hemlock
#

thank you, this is helpful! Strangely, it used to work by setting the primary group!

#

where do I download releases of this api?

nocturne elbow
#

!api first link

frank driftBOT
rain hemlock
#

where do I download the cookbook plugin though?

#

not the luckperms API?

nocturne elbow
#

It's an example plugin, there is no built jar out there lol

rain hemlock
#

ahh I see, thank you

nocturne elbow
#

The idea is that you check how it uses the LP API

tired pond
#

was gonna say that fefo :(

nocturne elbow
rain hemlock
#

makes sense, just wondering why these features (eg setParentGroup()) isn't a function in the plugin?

nocturne elbow
#

Because a PermissionHolder (users or groups) can have many parent groups, not only one

#

And there are many variables taken into account too

rain hemlock
#

I mean, could they not just copy whats in the onCommand of the ingame user <> parent set command

main dagger
#

the command is a lot more complicated than you think

rain hemlock
nocturne elbow
#

The API isn't supposed to be easy

#

It's supposed to be flexible

rain hemlock
#

xD

nocturne elbow
#

Malleable

rain hemlock
#

so to set parent group?

nocturne elbow
#

You've got to be kidding

nocturne elbow
rain hemlock
#

SetGroupCommand.java

#

its this file right?

nocturne elbow
#

mhm

wheat elm
#

I'm writing a command that will remove all users from a list of groups, and clear all personal permissions

#

User#getNodes says it's fast, but I'm assuming modifying it won't modify the user's permission nodes

#

Or maybe it's not modifiable at all

#

What's the most efficient way to do this?

nocturne elbow
#

oh hello redempt

wheat elm
#

o/

nocturne elbow
#

Yeah getNodes returns an immutable collection (I think thonk), if you want to modify the holder's data, use PermissionHolder#getData instead

wheat elm
#

Ok

nocturne elbow
#

!cookbook you can see a few examples in here on how to modify a user's nodes and uuh other examples

frank driftBOT
wheat elm
#
        for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
            User user = luckPerms.getUserManager().getUser(player.getUniqueId());
            NodeMap data = user.data();
            user.getNodes().forEach(data::remove);
            luckPerms.getUserManager().saveUser(user);
        }```
#

This should do it, right?

#

But I'm assuming this will also clear all groups because groups are technically nodes?

nocturne elbow
#

thonk you just want to clear all nodes the user has?

#

a node is also parent group, meta key/values, prefixes, suffixes etc etc etc

wheat elm
#

Yeah, but I only want to clear specific groups

#

Ah, alright

#

user.getNodes().stream().filter(n -> n.getType() == NodeType.PERMISSION).forEach(data::remove);

#

This, then?

nocturne elbow
#

You can getNodes(NodeType.PERMISSION) 👀

#

also, UserManager#getUser will return null if the player is offline and judging by what it seems you want to do, you should use UserManager#modifyUser(UUID, Consumer<User>), it loads the user, runs the action and saves the data, all async

wheat elm
#

Ah, cool

#

So, something like this

#
            luckPerms.getUserManager().modifyUser(player.getUniqueId(), u -> {
                NodeMap map = u.data();
                u.getNodes(NodeType.PERMISSION).forEach(map::remove);
            });```
wheat elm
#

luckPerms.getUserManager().modifyUser(player.getUniqueId(), u -> u.data().clear(n -> n.getType() == NodeType.PERMISSION));

nocturne elbow
#

breh

#

NodeType.PERMISSION.predicate()

wheat elm
#

Oh, that's so unnecessary lmao

#

This API

nocturne elbow
#

what?? lol, you just end up with u.data().clear(NodeType.PERMISSION.predicate())

wheat elm
#

Yeah

nocturne elbow
#

or if you're fancy NodeType.PERMISSION::matches

wheat elm
#

Having a preciate() method seems so unnecessary

nocturne elbow
#

come on Redempt I know you're better than this hah

wheat elm
#

I don't see a NodeType.GROUP

#

Does NodeType.PERMISSION include groups?

nocturne elbow
#

INHERITANCE

wheat elm
#

Ah cool

nocturne elbow
#

afaik PERMISSION are wildcard permissions, specific permissions and shorthand permissions

wheat elm
#

I'm assuming I'd get the group name with Node#getKey

nocturne elbow
#

regex have their own type

#

mnop

#

InheritanceNode#getGroup I think?

#

getGroupName

wheat elm
#

Ah cool

nocturne elbow
#

getKey will return the whole string representing the node (group.<group> if it's a parent group)

wheat elm
#

Yeah that's what I was figuring

#

That's probably simpler honestly

#
            luckPerms.getUserManager().modifyUser(player.getUniqueId(), u -> {
                u.data().clear(NodeType.PERMISSION.predicate());
                u.data().clear(NodeType.INHERITANCE.predicate().and(n ->
                    toRemove.contains(((InheritanceNode) n).getGroupName())));
            });```
#
        for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
            luckPerms.getUserManager().modifyUser(player.getUniqueId(), u -> {
                u.data().clear(NodeType.PERMISSION.predicate());
                u.data().clear(NodeType.INHERITANCE.predicate().and(n -> toRemove.contains(n.getKey())));
        }```
nocturne elbow
#

I think this is the second time ever I see someone using Predicate#and(Predicate) lol

#

instead of &&

wheat elm
#

¯_(ツ)_/¯

nocturne elbow
#

is neat ngl

wheat elm
#

I'll just stick with the first way because it's less compact but probably better practice

nocturne elbow
#

I presume toRemove is a set/list containing the group names to remove?

wheat elm
#

It's a HashSet, yea

#

Thank you for your help

nocturne elbow
wheat elm
#

LuckPerms API is strange but I like it

nocturne elbow
#

strange how thonk

wheat elm
#

NodeType.PERMISSION.predicate()

nocturne elbow
#

Well it returns a Predicate<Node> that checks if the node type matches it

wheat elm
#

Yeah

nocturne elbow
#

Could have done ::matches too ¯_(ツ)_/¯

wheat elm
#

It's so weird

nocturne elbow
wheat elm
#

It doesn't seem to have worked

#

Groups and personal permissions of players seem to be unmodified

nocturne elbow
#

hm add a bunch of prints? lol

#

debugging is vital oldeyes

wheat elm
#

It only prints for online players .-.

#

Guess the user data was reset

#

So LuckPerms has stuff for offline players that bukkit doesn't

nocturne elbow
#

Doesn't getOfflinePlayers return the ones in usercache.json or whatever?

wheat elm
#

Yeah

nocturne elbow
#

uuuh

wheat elm
#

Assuming I can do luckPerms.getUserManager().getUniqueUsers()?

nocturne elbow
#

yeah that must be it

#

if it returns a completablefuture<collection<uuid>> then yeah

wheat elm
#
        luckPerms.getUserManager().getUniqueUsers().thenAccept(s -> s.forEach(id -> {
            luckPerms.getUserManager().modifyUser(id, u -> {
                u.data().clear(NodeType.PERMISSION.predicate());
                u.data().clear(NodeType.INHERITANCE.predicate().and(n ->
                        toRemove.contains(((InheritanceNode) n).getGroupName())));
            });
        }));```
nocturne elbow
#

or.. something similar

wheat elm
#

Ah, that worked!

#

Awesome, thank you!

nocturne elbow
clever zodiac
#

oi ma god

#

what an odd api

turbid solar
#

meh its pretty neat once you learn it

hybrid panther
#

@Redempt#0001 ohai been a while :D

#

Sadge they left

crystal sonnet
delicate briar
#

Could not load 'plugins/Myplugin.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: net/luckperms/api/LuckPermsProvider
...

#

Anyone can is able to tell me what I need to do with this error, It like 4 hours I am trying to do tests on tests

turbid solar
#

Are you (soft)depending on LP?

#

Make sure you're not statically getting the provider & that you dont shade it in

delicate briar
turbid solar
#

LuckPerms

delicate briar
#

Now it print another error

The LuckPerms API is not loaded.

But I imported with maven dependency

turbid solar
#

!paste full error

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!

delicate briar
turbid solar
#

paste your FixEssentials class

delicate briar
turbid solar
#

put LuckPermsProvider.get() under onEnable()

delicate briar
#

Same error

turbid solar
#

send code again

#

also send your pom.xml & plugin.yml

turbid solar
#

you didn't do what I said

#

move LuckPerms luckPerms = LuckPermsProvider.get(); in onEnable()

#

if I wasn't clear sorry

delicate briar
#

If I move the other things can't compile

turbid solar
#

then at the top do LuckPerms luckPerms; then in onEnable() do luckPerms = LuckPermsProvider.get();

delicate briar
#

Thank you for the patience and for the helping, this works now

uneven marten
#

I'm looking for which event to use for checking when a user's primary group is updated. Closest one I could find is UserDataRecalculateEvent but it exhibits some unexpected behavior. I'm extremely close to just making the event myself and submitting a PR

#

And the track events do nothing in my use case

nocturne elbow
#

NodeAddEvent

#

Probs, that's most likely always what people really want lol

#

Check that the target is a User and the node is of type INHERITANCE

#

That would be when a new parent group is added (which may or may not be the primary group, remember that holders can have several parent groups and even then the newly added one may not be the primary group according to settings and weights setup)

uneven marten
#

I don't know if this is LP's fault or not, but now it's doing this for all online players every 10 seconds or so. Otherwise, It's doing exactly what I need

nocturne elbow
#

I have no clue what you're talking about but (if it is what I think it is) data recalculation happens somewhat frequently, mostly when contexts update

uneven marten
#

ahh it's not LP nvm

#

Thank you ❤️

tired valley
#

F

nocturne elbow
#

Hi is there a way to allow only to do lp commands if a player has a certain ip?

turbid solar
#

No, unless you want to code a plugin that might do that?*

obtuse jolt
#

yea but abit weird that you need to do that tho

nocturne elbow
#

Someone has hacked my server and is able to spoof my admins account to get permissions and we can't fix that. So we only want to authorize commands by ip. My server is in prenium

turbid solar
#

!bungeecheck