#luckperms-api

1 messages · Page 48 of 1

dull rover
#

Yeah so I'm not really sure the proper way to approach this situation. It's literally bottom line adding and removing perms from users but with multiple permission plugins existing these days, not all like how Vault works.

nocturne elbow
#

I don't think there is an easy "one size fits all" solution here; what I'm having in mind is:

  1. keep the sync/async setting you have and hope for the best lmao
    1.1) hard code some sync-only perms plugin list and ignore the setting?

  2. tell LP users to turn vault-unsafe-lookups to true in LP config to let it do the thing. it's not like it will actually lag the server unless they are using a remote database that is literally on the other side of the world

  3. remake an internal Vault-like async-friendly interface and use plugin-specific implementations and APIs?

#
  1. lucko/synapse 😩
stoic jetty
#

Hello. I'm having a bit of difficulty to promote a player in a track using luckperm API.
First, I think I don't understand ContextSet.

    final static private LuckPerms lp = LuckPermsProvider.get();
        User user = lp.getUserManager().getUser(player.getUniqueId());
        Track track = lp.getTrackManager().getTrack("main");
        ImmutableContextSet set = ImmutableContextSet.builder()
                .add("world", "world")
                .add("server", "survival")
                .build();
        track.promote(user, set);

this code gives me error of java.lang.NoClassDefFoundError: net/luckperms/api/context/ContextSet

can anyone give me some little code to promote a player in a track to help me understand a bit? thanks

turbid solar
#

!paste your pom.xml or build.gradle

frank driftBOT
#
Please use pastebin!

Seeing a paste of the problem makes everything so much easier! Use https://paste.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!

obtuse jolt
#

and also ensure you are using the latest version of lp on your mc server itself.

obtuse jolt
stoic jetty
#

the luckperm itself is working well as I got

        //InheritanceNode node= InheritanceNode.builder("rank1").value(true).build();
        //DataMutateResult result = user.data().add(node);

this working fine

        <dependency>
            <groupId>net.luckperms</groupId>
            <artifactId>api</artifactId>
            <version>5.3</version>
            <scope>provided</scope>
        </dependency>
#

is my dependency

obtuse jolt
#

screenshot /lp info

stoic jetty
#

uh wait shit why luckperm is deleted -_-;.. one sec.. sorry. I think I accidently cleaned it or something

obtuse jolt
#

lol

#

(although not the current issue) using static for LuckPermsProvider.get(); is not a good idea. As it may be null since it only loads when lp loads.

stoic jetty
#

ha. funny it works. oh is it

#

so instantiate it whenever using?

#

well not gonna be invoked that many times anyways

turbid solar
#

I'd just check if LP is enabled

stoic jetty
#

yea sounds better

#

anyways sorry for stupid question -_-.. resolved now

pallid nymph
#

How do I set the permission to false or true with
user.data().add(PermissionNode.builder("custom.music.toggle").build());

dull rover
obtuse jolt
lime rune
#

Idk if this is the best place to ask but why did LuckPerms choose to use h2 as its default storage type? Just out of curiosity.

obtuse jolt
#

It’s faster compared to readable types like yaml or json.

#

And the point is to use commands or web editor instead of editing the data file itself. Reducing user error.

turbid solar
#

@nocturne elbow

lime rune
#

Fair, although why h2 over sqlite? Speed?

frank driftBOT
#

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

rustic laurel
#

We have our ways 😄

royal compass
#

if i wanna add someone to a group using the api do i just add the group.<group> node to them or is there a better way to do it

nocturne elbow
#

Jason didn't we go through this before?

royal compass
#

idk lol

#

before i was modifying groups

nocturne elbow
#

InheritanceNode.builder(group)... or InheritanceNode.builder(groupName)...

royal compass
#

never seen that before in my life ngl :p

nocturne elbow
#

lmao

royal compass
#

!cookbook

frank driftBOT
royal compass
#

ty

#

good?

user.data().add(InheritanceNode.builder(group).build());
luckPerms.getUserManager().saveUser(user);```
nocturne elbow
#

sure

royal compass
candid fjord
#

Hello!
I'm trying to use luckperms api in a plugin but for some reason luckperms return in services manager is null.

Server version: 1.17
LuckPerms version: 5.3.48
API version: 5.3
LuckPerms logs:

>.... [23:35:29 INFO]: [LuckPerms] Enabling LuckPerms v5.3.48
>.... [23:35:30 INFO]: __
>.... [23:35:30 INFO]: | |__) LuckPerms v5.3.48
>.... [23:35:30 INFO]: |___ | Running on Bukkit - Paper
>.... [23:35:30 INFO]:
>.... [23:35:30 INFO]: [LuckPerms] Loading configuration...
>.... [23:35:30 INFO]: [LuckPerms] Loading storage provider... [H2]
>.... [23:35:30 INFO]: [LuckPerms] Loading internal permission managers...
>.... [23:35:30 INFO]: [LuckPerms] Performing initial data load...
>.... [23:35:30 INFO]: [LuckPerms] Successfully enabled. (took 965ms)
>.... [23:35:30 INFO]: [LuckPerms] Registered Vault permission & chat hook.

My code:

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

I've already tried using "LuckPermsProvider#get()" too (Give me "The LuckPerms API isn't loaded yet!")

#

luckperms is defined as a dependency in plugin.yml^

nocturne elbow
#

@candid fjord please paste your plugin.yml and your pom.xml/build.gradle please

candid fjord
nocturne elbow
#

Pardon the delay, got caught up in something

#

implementation "net.luckperms:api:5.3"
Don't do that

#

You're shading the API, it's already provided, use compileOnly

candid fjord
candid fjord
prisma trout
#

How expensive is it to save metadata back into luckperms

#

Like, should I only save once in a while or not worry about it

prisma trout
#

also how can i get all nodes under another node

#

basically i want to sum everything under "fishing.catch"

obtuse jolt
#

meta are always strings, so you will need to get, convert to int and add them yourself.

distant osprey
#

How do I add a parent to a user with the api?

#

all I can find is setprimarygroup

obtuse jolt
distant osprey
#

Thank u, so basically just user.data().add(InheritanceNode.builder("groupname").build()); to add a parent and user.data().remove(InheritanceNode.builder("groupname").build()); to remove a parent, right?

obtuse jolt
#

yea, just remember to save

#

or you can use the .modifyUser consumer style method

distant osprey
#

Okay thank you! I'm using this for my use case rn for adding one group and removing a bunch of other groups

obtuse jolt
#

yea that works

distant osprey
#

awesome!

prisma trout
#

because the keys might not be known before hand (the part that says "fish_stingray" could be anything, it's based off of the caught item's id)

obtuse jolt
#

you can just every singl meta a user have and filter yourself yea

prisma trout
#

oh

#

OH

#

yea i gotchu

#

alright thanks ben

still echo
#

Hey, is there an api for bungeecord plugin ?

nocturne elbow
#

It's the same API regardless of the platform you're using

#

!api The first page linked has all you need to include it in your project

frank driftBOT
still echo
#

I have already api on spigot

nocturne elbow
#

Yeah it's still the same API everywhere else

rich flare
#

How would I update a player's group using the API (in a different plugin)?

turbid solar
#

!cookbook

frank driftBOT
wispy harness
#

I feel like there is another way to do this java UUID uuid = UUID.fromString(nodeMutateEvent.getTarget().getIdentifier().getName());

obtuse jolt
#

Cast nodeMutateEvent.getTarget() to a User object

#

e.g. User user = (User) e.getTarget();

rocky topaz
#

hi, how can i get which permission do i need to execute command?

nocturne elbow
#

!verbose

frank driftBOT
nocturne elbow
#

Or just look in the wikis for all plugins you are using. Permission nodes are usually listed there.

rocky topaz
#

is there api for verbose?

nocturne elbow
#

no

rocky topaz
#

so is there other way to get needed permission witch api?

nocturne elbow
#

What are you trying to do exactly?

#

What's the goal?

rocky topaz
#

i want to get needed permission to execute command and if player doesnt have show which rank he need to use this command

nocturne elbow
#

right that isn't quite possible, or not with the LP API just by itself; what platform is this for? Bukkit, bungee, fabric...

rocky topaz
#

paper/purpur

nocturne elbow
#

right so bukkit

rocky topaz
#

yea

nocturne elbow
#

problem is that permission for commands can be checked at any time, not only when you run them (e.g. when changing worlds, when tab completing, when joining)

rocky topaz
#

i know but i need this only when player run command

nocturne elbow
#

your best bet would be to listen to something like PlayerCommandPreprocessEvent, get the command, get the permission for it, and check against the LP API

rocky topaz
#

i use PlayerCommandPreprocessEvent but i dont know how to get permission

#

spigot doesnt have any method to get this

nocturne elbow
#

it very much does

#

you can get the command with Bukkit.getPluginCommand(String)

#

But again, without doing some injecting reflection shit that is most likely your best bet

nocturne elbow
#

Even verbose itself doesn't, even if there was an API for it it does not tell the difference, a permission check is just a permission check as far as it can tell

rocky topaz
#

When i use /anvil this doesnt work but if i use /cmi:anvil its work

nocturne elbow
#

That seems unrelated to LuckPerms and permission checking, the error is very descriptive

nocturne elbow
#

Is it possible to get players permissions from groups it doesn’t have on global context?

#

Without having to define the context the group is in, because that’d be for all gamemodes

#

uh you can probably use PermissionHolder#resolveInheritedNodes(QueryOptions) with non-contextual query options, then stream the resulting collection and remove those nodes that have an empty context set

viral lotus
#

I may be doing this completely wrong but how would you guys go about mapping group names to their corresponding prefixes/suffixes? (I know you can do .getPrefixes(), but I'm looking to map the group and prefix together somehow) This is how I'm doing it now and it does not like me at all (getPlayerGroups just gets a collection of all inheritance nodes a user has)

nocturne elbow
#

Yeah that is not how you do it at all lmao

viral lotus
#

Noooooooo lmao I figured

nocturne elbow
#

resolveInheritedGroups and get the prefix from the CachedMetaData of each, that's how I would do it

viral lotus
#

I'll give that a try thank you ^^

#

That worked thank you. You are wonderful ❤️

amber silo
#

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?
amber silo
#

How do i add luckperms groups to discordsrv

#

Example i want the Owner prefix to show up on discord chat

nocturne elbow
#

There is a format listed in discordsrv. You can try displaying the placeholder for ranks there.

amber silo
#

Wait which formot

#

Format*

nocturne elbow
#

messages.yml

amber silo
#

Ahh

obtuse jolt
amber silo
#

What does it look like

turbid solar
amber silo
#

Is it the red one?

obtuse jolt
#

this channel is for Developer API

nocturne elbow
#

So adding a permission to a group with context global doesn’t really affect anything as far as I know now, that’d only work if the group is global as well, just in case someone runs in to that as well

simple lodge
#

hello

#

i have a question how can i get player group ?

turbid solar
#

!cookbook

frank driftBOT
bright badger
#

How does this work?

CompletableFuture<Void> loadGroups = getApi().getGroupManager().loadAllGroups();
loadGroups.thenAcceptAsync((Void group) -> {
  // what can I do now?
});
obtuse jolt
#

not much, it just loads all groups so you can ensure getGroup​(@NonNull String name) isnt null or you dont have to do isLoaded​(@NonNull String name)

bright badger
#

When do I know when its finished loading? Is it sync?

#

in thenAcceptAsync?

obtuse jolt
#

yea

bright badger
#

k

#

and whats the Void argument for?

#

what is it called?

obtuse jolt
#

nothing lol

#

its a CompletableFuture<Void>, means it doesnt return any result

bright badger
#

ok

obtuse jolt
bright badger
#

Maybe this is becoming the 'xy problem' thing

#

Okay

#

I'm doing a chat pings and I want to be able to ping groups, so I need to:
#1) know if it is a valid group name, if yes get the group
#2) get all online players in that group

obtuse jolt
#

the Function interface cant define the var types correctly for some reason....

bright badger
#

Idk if I should query everytime or maybe cache the entire group/users?

bright badger
#

yeah

silk star
#

Hey guys, is there a way to get the weight of the players group?

turbid solar
#

Get tje group objecr

#

d;lp Group#getWeight

slate deltaBOT
silk star
#

ah I see, thanks man!

nocturne elbow
#

Hey @jaunty pecan why do you return Optional in your api?

frank driftBOT
#

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

turbid solar
#

Because a rank can have no weight set

nocturne elbow
turbid solar
#

or just keep the optionalint

nocturne elbow
#

._.

#

lol

nocturne elbow
#

then just simply disallow that

#

lol no

#

throw a custom exception, i would do that

#

that sounds like bad plugin design ngl

#

what made you think about that

#

it's like "oh you can do all of this except when this happens"

#

you give freedom to your users but constrain them with that just because you want to api return -1

#

Then what does OptionalInt return

nocturne elbow
turbid solar
#

Yea?

nocturne elbow
#

that's why you check if it's present first

#

or use orElse

#

or whatever

#

it's only good on the side of logic

#

you can't call getAsInt if there is nothing to get

#

no more advantages

#

not really a bad design tbh

#

using OptionalInt for this use case fits perfectly really

#

a group may not have a weight in which case the optional will contain nothing, but if it does then the group's weight can be any value within the int range, and the optional will contain it

jaunty pecan
#

weird thing to argue about :p

#

but yes, OptionalInt is definitely the correct choice there imo

clever zodiac
#

no, it very much is the correct choice

#

an Optional represents a value that can respresent null, and it doesn't mean something went wrong

#

that's exactly what it's being used for

wicked coral
#

How do i retrieve the goup metadata for one specific player.

#

to be more clear i know i can do

luckPerms.getPlayerAdapter(Player.class).getMetaData(source);

and then stuff like getPrefix/getSuffix/getValue which returns metadata value from groups having highest priority, but is there an easy way to get values from all groups in somewhat sorted order? not just from the group with highest priority

wicked coral
#

also is there any way to add transient metadata to an user that will be cleared when a player disconnects the server?

turbid solar
#

trasientData().add or something

wicked coral
#

those doesnt seems to be able to set meta prefix and suffix

turbid solar
#

iirc it takes a node?

#

d;lp SuffixNode

slate deltaBOT
#
public interface SuffixNode
extends Builder>```
SuffixNode has 2 methods, 1 extensions, and  5 super interfaces.
Description:

A sub-type of Node used to store suffix assignments.

mild shell
#

how i can check if user group is permanent or temporary?

nocturne elbow
opal chasm
#

is there an alternative to checking if a player has the group.<group> permission to check if a player is in a group? since this is ineffective for opped players

nocturne elbow
#

Hm PermissionHolder#getInheritedGroups(QueryOptions) probably

frail quest
#

Hi :D! Sorry for the trouble, but i'm having issues with specifying the User (User user = ...)

#

Eclipse can't find "luckPerms"

#

(I did already the registering of luckperms in onEnable())

#

How can i resolve that?

dark meteor
#

Hey the prefix wont show up ive used stylist chatx and others ive changed the weigh and nothing

nocturne elbow
#

Wrong channel

frail quest
turbid solar
#

LuckPerms luckPerms;

#

Put that in your main class

#

onEnable luckPerms = ...

obtuse jolt
frail quest
turbid solar
#

Yeah

obtuse jolt
#

yea its just an example code snippet

turbid solar
#

You need to get an instance of LuckPerms

obtuse jolt
#

you need to get the instance of LuckPerms and store in a variable named luckPerms

#

!api

frank driftBOT
frail quest
#

Another thing... for adding a user in a group i need to add the permission "group." And the name of the group?

obtuse jolt
#

its based on what you created in luckperms for your server

frail quest
#

Hi, i have another problem

#

when i try to do a command of my plugin, my console print a NullPointerExpection error in this line:

User user = luckPerms.getPlayerAdapter(Player.class).getUser(player);

How can i solve that?

turbid solar
#

Is the player online?

#

Is luckPerms set?

#

Show full code

#

!paste

frank driftBOT
#
Please use pastebin!

Seeing a paste of the problem makes everything so much easier! Use https://paste.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!

frail quest
#

okay one moment

#

@turbid solar

frank driftBOT
#

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

frail quest
#

yes, the player is online

turbid solar
#

Luckperms is null

frail quest
#

wait a moment

#

now the console print another error

#

java.lang.IllegalArgumentException: Attempting to build non-permission node with PermissionNode.Builder. permission = 'group.market', correct builder type = me.lucko.luckperms.co

turbid solar
#

Remove the LuckPerms on line 41

#

qnd Replace api with luckPerms

frail quest
#

oh okay

turbid solar
#

Not sure

frail quest
#

powercas

#

if i change api with luckPerms the code below can't find it

turbid solar
#

Send code again

frail quest
turbid solar
#

Above onEnable

#

LuckPerms luckPerms;

#

Then in onEnable

#

luckPerms = provider.getProvider()

frail quest
#

oh okay

dire remnant
#

does luckperms usermanager reset on restart

#

I have a weird issue where I do /ignore list and it shows the correct formatting, then I restart the server and it shows gray until the player rejoins

#

and its not to do with the player not being online

#
public String getPrefixFromName(String name) {
        if (TwistBungeecore.getAPI().getUserManager().getUser(name) == null) return "&7";
        else return Objects.requireNonNull(TwistBungeecore.getAPI().getUserManager().getUser(name)).getCachedData().getMetaData().getPrefix();
    }```
#

thats my method

turbid solar
#

because the player is offline

#

Load the player to get data if they're offline

dire remnant
#

but if they've joined and then they leave, it still shows formatting after their name

#

its only after a restart

turbid solar
#

Btw i swear getUser takes an uuid?

dire remnant
#

It can take a name

nocturne elbow
#

If you run that code 2 or 5 minutes after they have left, the user will be unloaded and getUser will return null

dire remnant
#

ah right, so how do I load the player when they're offline?

nocturne elbow
#

!api The second page linked goes over that

frank driftBOT
dire remnant
#

Thanks!

odd vapor
#
Main.luckPerms.getPlayerAdapter(Player.class).getUser(p)
                    .getNodes(NodeType.PERMISSION).stream()
                    .filter(Node -> Node.getPermission().equals("group.vip"))
                    .filter(permissionNode -> !permissionNode.getValue()).count();```
#

I want check whether the player is in or inherited from any group

#

this code can check if a player belongs to a group but cannot check if he inherits from it

odd vapor
#

a and I need expiry but a know how get this with permission but idk how get this with group

wispy peak
#

What would be the most efficient way to get a list of UUIDs that have a specific permission? It also needs to query offline players.

maybe this?

    public CompletableFuture<Set<UUID>> getUsersWithOfflinePerm(String perm) {
        return luckPerms.getUserManager().searchAll(NodeMatcher.key(PermissionNode.builder(perm).build())).thenApply(Map::keySet);
    }
nocturne elbow
#

Yep, that's how you'd do it (although you can skip the node building and just pass the perm string)

nocturne elbow
#

For that you would getNodes INHERITANCE and filter for group name (InheritanceNode has a grtGroupName method or something similar)

odd vapor
#
Collection<InheritanceNode> nodes = user.getNodes(NodeType.INHERITANCE);
getTime(nodes);``` ```java
public static long getTime(Collection<InheritanceNode> nodes) {
        long time = -1;
        for (InheritanceNode node : nodes) {
            if (node.getGroupName().equals("vip")) {
                if (node.hasExpiry()) {
                    time = node.getExpiryDuration().getSeconds();
                } else {
                    time = 0;
                }
            }
        }
        return time;
    }```
#

I have this source

#

but I have one problem

#

how I check player with vip+ (with extends vip) this return -1

#

-1 player haven't rank
0 player have rank on unlimited time
more how 0 player have rank on time X

nocturne elbow
#

Hm then you may have to use resolveInheritedNodes or getInheritedNodes (I don't remember the exact name) instead of getNodes(...)

frail quest
#

Hi! sorry for the trouble, but i'm having problems with luckperms api

#

Here the error

#

and here the code (wait)

#
marketl.add(player);
                market.remove(player);
                user.data().add(PermissionNode.builder("group.market").build());
                player.sendMessage(ChatColor.BLUE + "Hai appena accettato il contratto lavorativo per il market");
                luckPerms.getUserManager().saveUser(user);
#

thanks in advance

nocturne elbow
#

@frail quest you wanna add permission to the player?

frail quest
#

I fixed that with InheritanceNode.builder

#

I needed to add player in a group

odd vapor
odd vapor
#
public static long getTime(Collection<InheritanceNode> nodes) {
        long time = -1;
        for (InheritanceNode node : nodes) {
            if (node.getGroupName().equals("vip")) {
                if (node.hasExpiry()) {
                    time = node.getExpiryDuration().getSeconds();
                } else {
                    time = 0;
                }
            }
        }
        return time;
    }```
#

but I have one problem

#

how I have vip+ on 2 week program return 0 (unlimited time vip) (return expiry with vip+)

plain meadow
#

Hey !
I have a question ? How to add a permission to a player with LuckPerms ?

turbid solar
#

With the api?

plain meadow
#

Yes ! ^^

turbid solar
#

!cookbook

frank driftBOT
turbid solar
#

!api

frank driftBOT
plain meadow
#

Thank you !

#

😄

fervent current
#

guys, is it possible to get an api from luckperms bungee? looking for the provider, (which is obvious) has to have the spigot jar on the server.

turbid solar
#

??

#

!api

frank driftBOT
fervent current
# turbid solar !api
    private void registerLuckPerms() {
        final RegisteredServiceProvider<LuckPerms>registeredServiceProvider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
        if (registeredServiceProvider == null) {
            throw new NotFoundException("LuckPerms is not present");
        }
        luckPerms = registeredServiceProvider.getProvider();
    }

looking for the provider, it can't find the luckperms api.

turbid solar
#

Look at the 2nd one

#

3rd*

fervent current
turbid solar
#

Yes

fervent current
#

oh, ok.

fervent current
# turbid solar Yes
Exception

Caused by: java.lang.ClassNotFoundException: net.luckperms.api.LuckPermsProvider
//

    private void registerLuckPerms() {
        try {
            luckPerms = LuckPermsProvider.get();
        } catch (IllegalStateException exception) {
            Bukkit.getConsoleSender().sendMessage("§cLuckPermsAPI not found");
        }
    }
turbid solar
#

Soft depend on LuckPerms

#

Also make sure LP is installed

#

And make sure you dont shade LPApi in

fervent current
#

is installed only on the bungee

nocturne elbow
#

It needs to be installed ok the server you want LP to work on

#

Bungee LP is not a replacement for the whole network

#

You still need to install it on each server

fervent current
nocturne elbow
#

No

#

That's not a thing

#

How would the API work without LuckPerms

#

Doesn't make any sense

#

!network

frank driftBOT
fervent current
#

ok, ty

#

ok, just read...
sorry lol

shell bobcat
#

!database

frank driftBOT
#

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

shell bobcat
#

!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
!translationprogress
!translations
!upgrade
!usage
!userinfo
!verbose
!version
!weight
!whyluckperms
!wiki

blazing ledge
#

!api

frank driftBOT
marble shore
#

If I wanted to set a permission to a player on only "this" server using the API, is this the proper approach?

fun EntityPlayerMP.setServerPermission(permission: String, allowed: Boolean = true, expirySeconds: Long = -1L, mergeStrategy: TemporaryNodeMergeStrategy = TemporaryNodeMergeStrategy.NONE) {
    val api = LuckPermsProvider.get()

    api.userManager.modifyUser(uniqueID) { user ->
        val node = PermissionNode.builder(permission)
            .withContext("server", api.serverName)
            .value(allowed)

        if (expirySeconds != -1L) {
            node.expiry(expirySeconds)
        }

        user.data().add(node.build(), mergeStrategy)
    }
}```

Essentially using `LuckPermsProvider.get().serverName` to set the `server` context on a node
nocturne elbow
#

That's one way yeah

marble shore
#

Is there another one that'd be better?

nocturne elbow
#

Eh probably not

marble shore
#

alright, thanks ^^

astral current
#

!downloads

frank driftBOT
astral current
#

!version

frank driftBOT
#
Latest version

5.3.51

astral current
#

!notworking

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

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

For Console Errors:
nocturne elbow
crude flax
#

For BungeeCord, Am I going to use skeleton method?

nocturne elbow
#

The what??

crude flax
#

Oops it was my auto correct, I meant singleton

nocturne elbow
#

Lmao

#

Yes

crude flax
#

kk!

crude flax
#

What is the suitable event for Listening User Group Update?

nocturne elbow
#

"group update" as in "update parent group" or "added node to a group"?

#

Well whichever the case is, the cookbook has an example for those and more

#

!cookook

frank driftBOT
celest flame
#

Is there any way to retrieve the user's previous primary group directly from a NodeAddEvent?

nocturne elbow
#

I think there's a getDataBefore/After methods

#

You would need to compare those

#

d;methods LP NodeMutateEvent

slate deltaBOT
#
Methods:
net.luckperms.api.event.node.NodeMutateEvent#getDataAfter
net.luckperms.api.event.node.NodeMutateEvent#getDataType
net.luckperms.api.event.node.NodeMutateEvent#getTarget
net.luckperms.api.event.node.NodeMutateEvent#isUser
net.luckperms.api.event.node.NodeMutateEvent#isGroup
net.luckperms.api.event.node.NodeMutateEvent#getDataBefore```
nocturne elbow
#

Yep

nocturne elbow
#

I'm trying to alert users with a staff rank if they are using a permission which non-staff lack. How would I check if a permission node is part of a group (or its children) while using the same context as a User object?
For example, the rank default may inherit smpdefault if server=smp.

I tried to create a User object and use setPrimaryGroup("default") and then check user.resolveInheritedNodes but it didn't take into account the group change. I also tried using a Group object to do group.resolveInheritedNodes but I would need the player's context. Thank you!

#

How would I check if a permission node is part of a group (or its children) while using the same context as a User object?
I mean in reality using the platform's permission API (e.g. Bukkit player.hasPermission("permission")) should suffice, but if you need the tristate value (true/false/unset) then you need to do this: see in here the section about cached data and performing permission checks with it https://luckperms.net/wiki/Developer-API-Usage

Both of those options take the user's active contexts into consideration (in fact, LP's platform permission checks are backed by the cached data)

#

Thanks! Would it be possible to do something like hasPermission given a User and if the user's primary group was default?

nocturne elbow
#

Ok I think a better question to ask would be whether there is a method to get a query option representing a user context that way I could check against "default" using the user's server and world. Or would I have to build the user context and convert it to QueryOptions myself?

#

i have no idea what you're asking exactly

#

the primary group is also calculated with the active contexts taken into consideration

#

I want to check if given a player with a non-default rank, a permission node is coming from any of their ranks besides default (or children of default)

#

okay there is probably an easier way of doing that

#

give me a minute

#

Thanks! 😄

#
#

This is great thank you so much!

My plugin works now. 😄 I used all the links you sent me. Only problem I had was I couldn't use getQueryOptions because in Bungee, server=bungee and world=serverName.

crude flax
#

uh, I'm lost.. I'm trying to check when a user has a group added or removed

#

im trying to use nodeaddevent

#

but im sadly failing

#

My code is,

private void onNodeAddEvent(NodeAddEvent e) {
        if((e.isUser() && e.getNode().getType() == NodeType.INHERITANCE) || (e.isUser() && e.getNode().hasExpired())){
            System.out.println(e.getTarget().getFriendlyName());
            RankSyncer.syncRanks(e.getTarget().getFriendlyName(), Objects.requireNonNull(lp.getUserManager().getUser(e.getTarget().getFriendlyName())).getPrimaryGroup());
        }
    }

and Yes I've registered everything properly

nocturne elbow
#

lp.getUserManager().getUser(e.getTarget().getFriendlyName())
uh.. you can just.. use the event target?

#

you can cast it to a User if it's a user

#

anyway, what about that doesn't work?

#

Also, chances are this e.getNode().hasExpired() will be false in NodeAddEvent :d a node is being added, it won't be added when it's already expired, it makes no sense

prime glacier
#

How to check, the expiry of a MetaNode?

nocturne elbow
#

what?

#

ah

#

there's a getExpiry method

prime glacier
#

yes

nocturne elbow
#

returns an Instant, or a getExpiryDuration that returns a Duration if you need it like that

prime glacier
#

But how to get the Node?

#

From a User

#

from their metadata

nocturne elbow
#

so you want to retrieve a meta node to check its expiry date

prime glacier
#

yes

nocturne elbow
#

uh probably something like

Set<MetaNode> temporaryMetaNodes = user.getNodes(NodeType.META)
                                       .stream()
                                       .filter(Node::hasExpiry)
                                       .filter(NodeMatcher.metaKey("meta-node-key"))
                                       .collect(Collectors.toSet());

that will result in all temporary meta nodes for that meta key

#

or if you only want the "first" one (if any) then .findFirst() instead of .collect(...)

prime glacier
#

Thanks!

#

How can I display the expiraty in a dd.MM.yyyy HH:mm format?

#

never worked with that before

nocturne elbow
#

exist a event to check if the rank of the player was changed?

vale wren
nocturne elbow
#

thanks

vale wren
#

Hello, I need some help.
Is it possible for user.getPrimaryGroup() to return null, even though 1) the user is an online player (its me) and 2) the role is not null?

nocturne elbow
#

I have an Idea

#

Do you use shade or shadow?

vale wren
#

?

nocturne elbow
#

for the maven or gradle buildtool

vale wren
#

Java

#

xd

nocturne elbow
#

so you dont use a build tool?

obtuse jolt
vale wren
nocturne elbow
#

can you show me your code

obtuse jolt
#

lol both not understanding each other, but how will dependency manager be relevant for the above questions anyways?

nocturne elbow
vale wren
#

public static boolean methodName(String playerName) {
API.sendDebugMsg(playerName); //this returns my nickname, which is correct and not null
User user = api.getUserManager().getUser(playerName);
String role = user.getPrimaryGroup().toString(); //this returns null
}

#

and i am in a role

obtuse jolt
nocturne elbow
#

But when you fail its start and returns an error or null

#

ahh

#

wait i send you the right code

obtuse jolt
#

yea but still unrelated, the null is not at api instance

obtuse jolt
#

!update

frank driftBOT
vale wren
#

alright

nocturne elbow
vale wren
#

well, my whole plugin works with the code i sent and literally just this one method does not work

nocturne elbow
#

user.getprimarygroup returns only the name of the group, so you have to get the group over the groupmanager

vale wren
#

all the other methods do work

obtuse jolt
vale wren
#

the tostring wasnt there originally

obtuse jolt
#

also if getPrimaryGroup is null, .toString() will fail with NPE

vale wren
#

yeah

obtuse jolt
#

so thats what is happening?

vale wren
#

it was not there before, i just tried to add it cuz sometimes it fixes stuff

nocturne elbow
#

yes because getprimarygroup is a string - its the name of the primary group of the player, but its not a group object, so if you want to get the group object, you have to get it with the api

vale wren
#

cuz my code works with the name

nocturne elbow
#

then i cant help you, the string should return the name of the group

vale wren
#

OOOOOOOOOOOOOOh, now i realised its even more messed up

obtuse jolt
#

nothing about the group object, its about what getPrimaryGroup returns

vale wren
#

player.getName() (which is playerName) returns...... uh

obtuse jolt
#

maybe the user is not loaded yet

vale wren
obtuse jolt
#

whats that

obtuse jolt
vale wren
#

public static boolean methodName(String playerName) {
API.sendDebugMsg("1" + playerName);

#

sendDebugMsg is just a msg that is sent just to me

#

playerName is player.getName

#

but it sends name and role on the other line

#

but its executed just once so idk why 2 lines

#

and then the role is null

obtuse jolt
#

is the player online in the server?

vale wren
#

its me

#

and yes

obtuse jolt
#

screenshot /lp user USER info and /lp info

vale wren
obtuse jolt
# vale wren

looks like it logged the correct primary group?

#

no?

vale wren
#

yes but... it shouldnt

obtuse jolt
#

why not?

vale wren
#

spigot Player #getName

#

shouldnt return my role

obtuse jolt
#

??????

vale wren
#

i said imma mess it up even more.

#

i didnt lie

#

so

turbid solar
#

Where are you called methodName

vale wren
#

playerName is player.getName() which returns Vojtiisek as thats my name

turbid solar
#

Right click to check usages

obtuse jolt
#

99% chance its a different log code

vale wren
#

it is not

#

thats why i made the "1" +

turbid solar
obtuse jolt
#

means your code logic elsewhere is wrong, and you are passing groupname as playerName into the method

vale wren
turbid solar
#

Oh idk

obtuse jolt
#

I use intelliJ lol

vale wren
#

player is commandsender

#

i mean

#

player is player

#

that is commandsender

obtuse jolt
#

well then it has to called twice

turbid solar
#

Thats a different method?

obtuse jolt
#

for it to log twice

vale wren
#

its the same

obtuse jolt
#

code aint magic

vale wren
#

i just didnt rename it

#

xD

turbid solar
#

Well go look thru your files

#

Your calling it somewhere

vale wren
#

btw it worked week ago and i didnt even touch that code

#

and anything related

obtuse jolt
obtuse jolt
#

no way its a lp issue, if it logs twice with one log message and you dont even know why

vale wren
#

I am a dumbass

#

sorry for wasting yall times im just blind

#

the method was used once and then the second time through an another method

#

and in the another method there were wrong args there

#

but thanks for helping me, you were right, ben

rocky marlin
#

french guy can mention me ?

crude flax
#

How do I get all the Groups/Parents of a user is there a API method OR Do I've to make a filter loop.

turbid solar
#

!cookbook

frank driftBOT
turbid solar
#

Hss examples iirc

crude flax
#
perms.getUserManager().getUser(username).getInheritedGroups(QueryOptions.defaultContextualOptions()).forEach((e) -> {
                            if(!e.getName().equalsIgnoreCase(group)) {
                                if(!config.getStringList("donoroles").contains(e.getName())) {
                                    manager.setDono(username, false, SQLManager.AccountType.UUID);
                                }
                            }
                        });
#

will this work?

odd vapor
wispy harness
#

Where do I find the javadocs?

#

!javadoc

frank driftBOT
wispy harness
#

Ay

nocturne elbow
#

I have downloaded grant+ but don't know how to add ranks any advice?

#

with lukcperms

turbid solar
unique olive
#

anyone know how i can get what server a Node applies to

#

in api 5.x

celest flame
#

I'm trying to pool the information I need into one event but am failing because 'NodeMutateEvent' throws twice with each time providing half the information

#
    public void onGroupChange(NodeMutateEvent e) {
        if (e.isUser() && e.getDataType().equals(DataType.NORMAL)) {
            Player player = Bukkit.getPlayer(e.getTarget().getFriendlyName());
            Node[] before = e.getDataBefore().toArray(new Node[0]);
            Node[] after = e.getDataAfter().toArray(new Node[0]);
            String originalGroup = before[0].getKey();
            String updatedGroup = after[0].getKey();
            Bukkit.getPluginManager().callEvent(new LuckPermsGroupUpdateEvent(player, originalGroup, updatedGroup));
        }
    }```
#

Could anyone advise?

nocturne elbow
#

then see the methods in the ContextSet interface

nocturne elbow
#

First, NodeMutateEvent is not a Bukkit Event, you don't register it as an EventHandler

#

Secondly, this...

String originalGroup = before[0].getKey();
String updatedGroup = after[0].getKey();

this is so unreliable

#

what are you trying to achieve exactly

celest flame
#

RE the second point, I threw that together to try and show the information I'm attempting to retrieve

#

The outcome I would like is an event where I can get: The Player who has had their group changed, the name of the original group they had, and the name of the new group they have

turbid solar
#

@rustic laurel

rustic laurel
#

ty

nocturne elbow
#

and what are you doing exactly that dispatches the event?

celest flame
#

Triggering nodemutateevent in the first place is me changing the primary group of a player - /lp user * group set *

nocturne elbow
#

Well it triggers twice because parent set are two actions really

#

First NodeAdd and then NodeClear

celest flame
nocturne elbow
#

hm

#

well there is no single "node clear and add" or whatever event

#

I guess your best bet is to just listen to NodeAddEvent and check if the node that was added is a node of nodetype INHERITANCE

ocean citrus
#

if i do chat.getplayerprefix() will that return the luckperms prefix? (chat is the vault chat)

turbid solar
#

Yea

ocean citrus
#

and is there also a way to get all prefixes in a list or something

#

i want to use the length

bold solstice
#

Is there a temporary permission expiration event?

ocean citrus
turbid solar
#

What are you trying to do

#

length returns an int

ocean citrus
#

trying to get the length of all the groups of that players and that way create a gui with the corresponding amount of slots

turbid solar
#

remove the for loop and use the .length value

ocean citrus
#

smh what was i doing iterating over an int

ocean citrus
#

now i'm trying to get all the group prefixes

celest flame
# ocean citrus now i'm trying to get all the group prefixes
private static void loadGroups() {
    groups.clear();
    Set<Group> groupsSet = luckPerms.getGroupManager().getLoadedGroups();
    for (Group group : groupsSet) {
        groups.add(group.getName());
    }
}

public static HashMap<String, String> prefixes = new HashMap<>(); //group, prefix
private static void loadPrefixes() {
    prefixes.clear();
    for (String groupName : groups) {
        String prefix = luckPerms.getGroupManager().getGroup(groupName).getCachedData().getMetaData().getPrefix();
        if (prefix == null || prefix.equalsIgnoreCase("null")) {
            prefix = "&7";
        }
        prefixes.put(groupName, prefix);
    }
}```
this is how I do it
crude flax
#

how do i get all groups of a offline proxiedplayer

ocean citrus
#

is there also a way to check if a player is in a specific group?

nocturne elbow
#

!cookbook

frank driftBOT
ocean citrus
#

ah bruh an api is existing

#

forgot it

nocturne elbow
#

:D

ocean citrus
#

now i'm trying to get all groups of a player :/

nocturne elbow
#

lol good luck

ocean citrus
#

something like this?

public static Set<String> getPlayerGroups(Player player) {
        Set<String> groups = new HashSet<>();
        for (Group g : Main.getApi().getGroupManager().getLoadedGroups()) {
            if (player.hasPermission("group." + g)) {
                groups.add(g.toString());
            }
        }
        return groups;
    }
turbid solar
#

No

#

g.getName()

ocean citrus
#

ah ki

#

and i changed it to a list

#

i'm creating a gui where players can choose their prefix :/

nocturne elbow
#

Why no use deluxetags :P

ocean citrus
#

uhh never used

nocturne elbow
#

Is quite easy. Lmk if you'd consider it, I could give you a crash course on it

late pelican
#

So I can add permissions via the API, but what about adding permissions as false? Otherwise known as negating them?

#

Basically negating scoreboard permissions for my users on Bedrock, since the scoreboard is messed up on Bedrock

late pelican
# ocean citrus i'm creating a gui where players can choose their prefix :/

I was able to do this with a custom command to set the prefix, custom file to store the user's prefix (pre-set prefix) and then a menu from DeluxeMenu to set/choose the prefix, and to store permissions

Basically: Created a file for storing user data, made a custom command /setprefix <player> <prefix> (set the prefix options in the code) and then made it only runnable through console, and then created a GUI in DeluxeMenus to let the players choose it, and also made my own placeholder for the prefix as well via PlaceholderAPI

With this they don't create their own prefixes, but they can if you do it differently, kinda like how I made custom join messages, but that's a different story

#

I was also able to do it using DeluxeTags and a custom GUI via DeluxeMenus (just to change the look of it)

#

Also changed the alias in DeluxeTag's plugin.yml to "/prefix" and then in commands.yml for spigot set "/tags" to a different tags plugin (ImmortalTags) but honestly that's more complicated (and requires a different tags plugin ImmortalTags for example if you also want to use tags as suffixes

late pelican
obtuse jolt
#

the Node object should have a method setValue(boolean)

late pelican
#

So I have this, Node scoreboardOffNode = Node.builder(scoreboardOff).build();
do I just add ".setValue(false); after .build()?

obtuse jolt
#

I believe its before

late pelican
#

or just do scoreboardOffNode.setValue ..

obtuse jolt
#

second example should show something similar

late pelican
#

Ahh okay so it's just .value

#

Thanks

next meadow
#

i want to have a single permission group, but the prefix changes depending on the player's gamemode, is it possible to make a group like this with the api? or is there some easier solution?

nocturne elbow
#

You don't even need the API for that really, you can use contexts since LP provides a gamemode context

frank driftBOT
next meadow
#

cool ty

thorn dove
#

How can i Import thr api to my maven Spigot project

nocturne elbow
#

!cookbook Isn't that covered somewhere here? Not sure

frank driftBOT
neat jackal
#

Haha. No

severe pendant
#

how can i add permission to player

turbid solar
#

With the api?

severe pendant
#

yes

turbid solar
#

!api

frank driftBOT
turbid solar
#

!cookbook

frank driftBOT
severe pendant
#

what is "luckPerms"

turbid solar
severe pendant
#

it doesnt add permission "hihihihihi" to me

turbid solar
#

Use userr instead of user

severe pendant
#

oh ok

#

ummm nope , still not having the permission hihihihihi

severe pendant
#

?

obtuse jolt
severe pendant
#

actually i run it in a command

#

how can i know the provider is null or not

turbid solar
#

Log to console

severe pendant
#

do not have any logs after /progress per

#

bruhhhh

#

wait it works now

turbid solar
#

PluginInstance#getLogger().info("LP not null");

severe pendant
#

no i just so dumbass

rich flare
#

I was wondering about that...

severe pendant
#

it work perfectly now thx a lot minecraftheart

neon silo
#

is there a way to get arbitrary permissions starting with a prefix through the API?

#

as in, say you had a claims plugin, you had a permission like claim.10 and that permission would indicate that user/group could claim up to 10 chunks

turbid solar
#

d;lp UserManager#searchAll

slate deltaBOT
neon silo
#

guessing NodeMatcher can be formed into a prefix then

#

cool thanks

turbid solar
#

iirc it has a atartsWith method

teal quest
#

Hey, we want to rewrite a plugin from bukkit to bungeecord so I have just a question about how to get the luckperms provider in bungeecord

#

For bukkit we used

#

But what is it in bungeecord

nocturne elbow
#

!API I believe the second page linked explains how to get the API instance

frank driftBOT
wooden fable
#

Hello, I'm new to using LuckPerm's API and would like your help in a matter:
I want to reset a player's group in a specific Track using the API. I found Track#demote and decided to just use it until the player can no longer be demoted, but I have 4 questions:

  1. The demote function requires a User and a ContextSet - I understand how to get the player as a User (#getPlayerAdapter(Player.class)#getUser), but what is the ContextSet and how do I get it? (I want to demote everywhere, not in a specific situation/place)
  2. How do I know I reached the first group in the chain so I don't end up kicking them out of the Track? Meaning: do I just need to check their current group in said Track after each demotion or is there an easier way?
  3. How do I get a player's current group (or index at least) in a Track?
  4. Do I need to save the data after I finish demoting them or does demote do it automatically?

Thx in advance!

nocturne elbow
wooden fable
#

Thx!
But how do I get the player's parent groups? There's only a function to get their primary group

nocturne elbow
#

There's a resolveInheritedGroups method or smth

#

You should end up with something like user.resolveInheritedGroups(user.queryOptions().toBuilder().flag(Flag.INHERITANCE, false).build(), can't remember off the top of my head, play around with it

wooden fable
#

found it, thx!

wooden fable
#

Last question for now: how do I add a permission to a Group? Do I just get its data with #data, add a new Node and save it, or something else?

nocturne elbow
#

no, nothing else, it's pretty much just like a user

wooden fable
#

sweet...

#

not too difficult - I like it

neon silo
#

is there a UserManager#searchAll alternative that takes into account the user's groups?

nocturne elbow
#

no

#

what are you trying to do?

nocturne elbow
#

eh you should definitely use meta nodes for that

#

also like you want to get every user with a claim.* perm?

onyx trench
#

How do I get the players rank?

stark void
#

Hey, I'm not sure if this is right channel but let's try. I'm creating plugin which utilizes luckperm's group. Currently something like that happens:

#

can I get already formatted group using legacy color codes?

nocturne elbow
#

uh is this to do with the API?

nocturne elbow
#

What's your goal?

onyx trench
nocturne elbow
#

wat

#

what event?

onyx trench
#

its javascript

nocturne elbow
#

okay cool

#

what event

onyx trench
#
events.on('AsyncPlayerChatEvent', event => {
    const name = event.getPlayer().getDisplayName()
    event.setFormat(event.getPlayer().getGroupName() + name + c(" &7» &f") + event.getMessage());
});```
nocturne elbow
#

yeah idk what getGroupName() is, neither the event nor that method are from LP

#

depending on your environment it may be correct or not, wouldn't know

onyx trench
#

I got it off some spigot thread

nocturne elbow
#

I mean getGroupName doesn't exist in spigot either

onyx trench
#

Looks like it was from "groupmanager"

nocturne elbow
#

no clue

onyx trench
#

another perms manager iirc

trim wave
#

not really a quesion with the api but does luckperms store what permissions each user has or is it done by bukkit?

nocturne elbow
#

LP

#

Since it also is implemented for other platforms (Sponge, Bungee, Fabric, ... Nukkit?) something like storage is pretty much just abstracted away from the platform LP is running on

trim wave
#

okay thanks

trim wave
#

how is it actually stored in the db? is it a table for each player? or are is tehre a table for each player or something

nocturne elbow
trim wave
#

thanks

brittle veldt
#

Hey guys! I am making a bungeecord plugin along side luckperms, and I have put the luckperms developer API into my bungee project. However after reading through all the documentation and researching online, I'm afraid I'm still very confused on how everything works. Are luckperms permissions and groups completely separate from bungeecord permissions and groups? If so, how can I check if a player is part of a group, or has a permission etc..

Thanks in advance, sorry if this an extremely basic question I can't wrap my head around :P

nocturne elbow
#

!api

frank driftBOT
nocturne elbow
#

!cookbook

frank driftBOT
nocturne elbow
#

Between all those you should get the hang of it, the API itself is the same everywhere (and yes, BungeeCord groups are separate from LP groups)

brittle veldt
#

Perfect, thanks! Will take a look at all of those

jade grotto
#

How can i obtain an instance of the LP API in Velocity 3.X.X

turbid solar
#

!api

frank driftBOT
jade grotto
turbid solar
#

Have you read a, b & c?

jade grotto
turbid solar
#

No the errors

jade grotto
#

oh

turbid solar
#

Have you stated luckperms as a dependency in @Plugin?

jade grotto
#

ohhhh thanks i'd guess thats the error

dreamy perch
#

Is there a Luckperms event when a user gets a new rank or something like this?

neat jackal
#

here you can see an example of a listener listening to permission changes. you can do a similar thing and check if node.getType() == NodeType.INHERITANCE

lethal sigil
#

If I add those 2 permission nodes into single user.

luckPerms.userManager.modifyUser(player.uniqueId) { user ->
    user.data().add(Node.builder("foo.bar").expiry(Duration.ofDays(1L)).build())
    user.data().add(Node.builder("foo.bar").expiry(Duration.ofDays(2L)).build())
}

the expiry duration will be merge to 3 days?

round skiff
#

I'm not sure whats wrong

#

I copied it exactly

#

wait nvm

#

How do I add the repository? I'm a noob

#

I have no idea what I'm doing

#

ok wll

#

I restarted

#

and for some reason its fine now

#

thanks

jade grotto
turbid solar
#

Send code here

#

Whole class

jade grotto
turbid solar
#

Do the LuckPermsUtil(LuckPermsProvider...) in the proxy enable event or something

#

Whenever LP loads

jade grotto
#

ohhh thanks <3

floral mesa
#

I need to add this code on onEnable() to use the api?

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

Yes

floral mesa
#

and if I plugin in onload
it will work too?

turbid solar
#

Well, in the class make a LuckPerms api;

#

Then in there do api = LuckPermsProvider.get()

#

Dont think so

#

Its onEnable iirc

floral mesa
#

I mean that my plugin is starting before most of the plugins bcz I have a world generation class there

#

load: STARTUP

floral mesa
turbid solar
#

Make sure you softdepend on LuckPerms

floral mesa
#

yeah of course

floral mesa
#

and then I need to access this api varible if I want to use the api?

turbid solar
#

Yea

floral mesa
#

how I can get the player prefix?

turbid solar
#

!cookbook

frank driftBOT
dreamy perch
#

How do i get the prefix of a group

odd vapor
sacred radish
#

HI, how to settemp perms with Api?

nocturne elbow
#

NodeBuilder#expiry​(long duration, TimeUnit unit)

sacred radish
#

thx

sacred radish
#

why null?

#

"net.luckperms.api.LuckPerms.getUserManager()" because "me.mateo.Hooks.LuckPermsAPI.luckPerms" is null

turbid solar
#

Well, it says why

sacred radish
#

java.lang.NullPointerException: Cannot invoke "net.luckperms.api.LuckPerms.getUserManager()" because "me.mateo.Hooks.LuckPermsAPI.luckPerms" is null

#

I'm trying to make a method to add temporary permissions, but it marks me empty

turbid solar
#

Send your luckPermsAPI class

#

!paste

frank driftBOT
#
Please use pastebin!

Seeing a paste of the problem makes everything so much easier! Use https://paste.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!

sacred radish
#

sorry i new :v

turbid solar
#

Somewhere you need to do luckPerms = LuckPermsProvider.get()

sacred radish
#

omg thx

#

already works

idle folio
#

/lp editor

ashen pine
#

java.lang.NoClassDefFoundError: net.luckperms.api.LuckPermsProvider
at net.pixelplays.extendedsurvival.ExtendedSurvival.onEnable(ExtendedSurvival.java:50) ~[?:?]

#

im getting this error when using the luckperms api

#
luckPerms = LuckPermsProvider.get();

that is line 50

#
private LuckPerms luckPerms;

and here for "luckPerms"

#

can someone explain what the problem is

nocturne elbow
#

is this on bukkit/bungee/..?

ashen pine
#

bukkit

#

(*paper)

nocturne elbow
#

Is LuckPerms installed on the server..?

ashen pine
#

yes

nocturne elbow
#

Also is it in your (soft-)depend in the plugin.yml?

ashen pine
#

no but before changing to 1.17.1 it wasnt still a problem

nocturne elbow
#

well it should be there, there are no guarantees about Bukkit's plugin loading order unless you define it yourself (loadbefore/depend/soft-depend)

gritty portal
#

hello world

#

pls help

#

how can I trigger a group (parent) change event for a player

#

and get a player name

nocturne elbow
#

!api if you are unfamiliar with the API as a whole you should definitely read these wiki pages

frank driftBOT
jade grotto
#

Is there an event for updating the Users Parent Group?

#

i coudn't find one on gh

jade grotto
#

ohh, yeah, i mb should read or filter first thanks

onyx trench
#

what java.pkg do i need to use to get luckperms ranks (I have vault vtw, so if theres a way I can use their hooks that would be great)

nocturne elbow
onyx trench
#

See I'm writing in javascript

nocturne elbow
#

okay ...?

#

the LP API is written in Java

onyx trench
#

and all the plugin suports is importing pkgs (I assume that means packages), so would I do something like this?

const { net.luckperms.api.LuckPerms } = Java.pkg("me.lucko.lpcookbook.listener"}
``` or...
onyx trench
nocturne elbow
#

I know

nocturne elbow
#

not the actual LP API

twilit jasper
#

how can I get a user's group in a specific track

nocturne elbow
# twilit jasper how can I get a user's group in a specific track

Unfortunately the user can be on many groups on a track (without using promote/demote/parent settrack but rather parent add directly)
You'll have to manually loop the user's (direct) parent groups (PermissionHolder::getInheritedGroups and turn off the Flag.RESOLVE_INHERITANCE) and check which one(s) are on said track with Track::containsGroup

twilit jasper
#

ok thanks

vocal plover
#

Which event would be the best to listen to for when a player is added/removed from a group

jaunty pecan
#

NodeMutateEvent

vocal plover
#

and look for group.xxxx i assume?

jaunty pecan
#

check event.getNode() instanceof InheritanceNode

vocal plover
#

ah okay and then I can do InheritanceNode#getGroupName, perfect thanks

jaunty pecan
#

yep exactly, np

sharp yarrow
#

I'm trying to add a context for rank progression

#

Every time a player would promote themselves it would cost money

#

I got as far as downloading ExtraContexts

tired sky
#

i want get group list

sharp yarrow
#

I hooked luckperms and ess with papi

nocturne elbow
#

what?

night pier
#

why are you here?

nocturne elbow
sharp yarrow
#

someone put the..

#

nvm

night pier
#

that was to minjae-

prime jackal
#

Few questions

  1. Can this easily be used on BungeeCord
  2. Is there an easy way to see how long is left of a player’s temp rank.
    -> I’m thinking of making a bungeecord command for /rank which returns what rank the player has and (if applicable) how long is left.

thanks

nocturne elbow
#

not sure what you mean/imply by "easily on BungeeCord"?

#

The API is the exact same on every platform

#

so if you find the API hard to use on Fabric you'll find it just as hard to use on Bungee lmao

prime jackal
#

Well that is number 1 answered. Just wanted to make sure it would work the same on bungee as it would bukkit

nocturne elbow
#

Is there an easy way to see how long is left of a player’s temp rank
pretty much just:

  1. get the player's own INHERITANCE nodes
  2. filter those that have an expiry
  3. map the group name to the expiry (both of which you can get from the InheritanceNode)
    done ig?
prime jackal
#

I’ll play around with that, thanks.

tired sky
#
private static net.luckperms.api.LuckPerms luckPerms;

public static void createTeam(String team){
        luckPerms.getGroupManager().createAndLoadGroup(team);

    }

is NullPointerException

nocturne elbow
#

Do you ever initialize the luckPerms field?

tired sky
nocturne elbow
tired sky
#

how can i do?

shadow pulsar
shadow pulsar
#

How often does UserDataRecalculateEvent fire?

obtuse jolt
shadow pulsar
#

alright thank you 🙂

nocturne elbow
#

Listen to the NodeRemoveEvent, check that the node is an InheritanceNode with an expiry and that the event target is a User

shadow pulsar
#

this other person had the exact same request hahah

#

no problem

stuck terrace
#

Hello guys! Who know, why sometimes UserManager#getUser(UUID) returns null? Player is also on server (Example)

#

Code

  @Override
  public @NotNull String resolvePrefix(@NotNull UUID uuid) {
    final User user = luckPerms.getUserManager()
        .getUser(uuid);

    if (user == null) {
      return "";
    }

    final String prefix = user
        .getCachedData()
        .getMetaData()
        .getPrefix();

    return prefix == null ? "" : prefix;
  }
#

just excluded NPE but it's annoying a bit

#

or is there any other way which is null-safe?

neat jackal
#

d;lp UserManager#loadUser#join

slate deltaBOT
#
@NonNull
default CompletableFuture<User> loadUser(@NonNull UUID uniqueId)
throws NullPointerException```
Description:

Loads a user from the plugin's storage provider into memory.

Parameters:

uniqueId - the uuid of the user

Throws:

NullPointerException - if the uuid is null

Returns:

the resultant user

neat jackal
#

Maybe that helps?

stuck terrace
#

ye, gonna try it rn, ty

#

looks like all fine, gonna test other cases

nocturne elbow
#

I mean if the player is actually on the server, getUser won't (or at least it seriously shouldn't) return null

stuck terrace
#

ye, that's strange

nocturne elbow
#

If I were you I'd rather fix the underlying issue instead of working around it :d

#

But if you're wanting to work with offline players too then loadUser is the way to go (although you should work with the CompletableFuture continuation design (whenComplete/thenAccept) rather than calling join/get blocking the current thread (unless you're already async in which case it won't really matter to the main thread))

stuck terrace
#

ye, i mean like, i should also load if player is offline, it's displays just top player

pastel brook
#

did the luckperms API change in 1.17?
user.data().add(Node.builder(test.permission).withContext("server","testserver").build())
used to work fine but now it has no output or anything

nocturne elbow
#

what's there to output?

pastel brook
#

giving them the permission

nocturne elbow
#

using the API gives no feedback to any person unless you do that yourself

pastel brook
#

here's the full method (kotlin)

    private fun addPerkPerms(userUUID: UUID, perkPerms: List<String>) {
        luckPerms.userManager.modifyUser(userUUID) { user: User ->
            perkPerms.forEach {
                user.data().add(Node.builder(test.permission).withContext("server","testserver").build())
                println("test")
            }
        }
    }
#

by "or anything", i meant that it wasn't giving them permissions

nocturne elbow
#

where's test even coming from lol

clever zodiac
#

also with kotlin you dont need to explicity state the type of the consumer, nor in java really

nocturne elbow
#

anyway to answer your initial question: no

clever zodiac
#

^ perkPerms could be empty, and in that case it wouldn't run

pastel brook
#

nah it's running according to debug

#

user.data().add(Node.builder(test.permission).withContext("server","testserver").build()) is just not doing anything

#

println(test) gave output in multiple different test scenarios as expected

clever zodiac
#

thats so odd since modifyUser should also handle saving

pastel brook
#

testing with an older build of luckperms

clever zodiac
#

can you tell us what test.permission is?

pastel brook
#

it's a permission node

pastel brook
#

sorry

clever zodiac
#

oh its not copy pasted?

#

😕 ok then

pastel brook
#

it was println(it) but that wasn't descriptive so I just replaced it with a string in what i sent you

clever zodiac
#

ah ok I was wondering why you weren't using it in a for loop

#

all right then 🤔

#

honestly thats very odd

pastel brook
#
    private fun addPerkPerms(userUUID: UUID, perkPerms: List<String>) {
        luckPerms.userManager.modifyUser(userUUID) { user: User ->
            perkPerms.forEach {
                user.data().add(Node.builder(it).withContext("server","earth").build())
                println(it)
            }
        }
    }

that's the copied code

#

hmm now it's working on my test server, gonna see if it just randomly starts working on my prod server too

solid kiln
#

does anyone know why im getting this error?

[14:21:52 ERROR]: [BentoBox] BentoBox v1.17.3-SNAPSHOT-LOCAL attempted to register an invalid EventHandler method signature "public void world.bentobox.bentobox.listeners.LuckPermsListener.onNodeAdd(net.luckperms.api.event.node.NodeAddEvent)" in class world.bentobox.bentobox.listeners.LuckPermsListener
#

here's my method signature

#

public void onNodeAdd(NodeAddEvent e) {

#

there is no @EventHandler anotation

nocturne elbow
#

how and where are you trying to register it?

nocturne elbow
#

the error kinda contradicts that statement lol

solid kiln
#

where manager is the Server.getPluginManager()

#

this is called in onEnable()

nocturne elbow
solid kiln
nocturne elbow
#

hm all I can think of is bukkit is dumb

#

are you sure the jar in the plugins dir is updated to that of the code?

solid kiln
#

yep

nocturne elbow
#

well idrk what to tell you lol that straight up cannot happen without an annotation

            final EventHandler eh = method.getAnnotation(EventHandler.class);
            if (eh == null) continue;
            // ...
            if (method.getParameterTypes().length != 1 || !Event.class.isAssignableFrom(checkClass = method.getParameterTypes()[0])) {
                plugin.getLogger().severe(plugin.getDescription().getFullName() + " attempted to register an invalid EventHandler method signature \"" + method.toGenericString() + "\" in " + listener.getClass());
                continue;
            }
#

why are you registering it in the bukkit plugin manager in the first place lmao

solid kiln
#

😬 thanks im stupid

dreamy perch
#

When I'm using the NodeAdd event on a server when the event got called something changes, but when I'm changing the rank of someone one for example lobby and the player is in Freebuild the changes don't change is it possible that this happens?

obtuse jolt
dreamy perch
#

the permissions are synced the admins on freebuild receive the message that the rank changes, but for example the scoreboard does not update, but when I'm on freebuild and change the rank of a player on freebuild the scoreboard update

nocturne elbow
# dreamy perch the permissions are synced the admins on freebuild receive the message that the ...

events do not propagate throughout the network, your best bet is to subscribe to events from these packages
https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/event/log/package-summary.html
https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/event/sync/package-summary.html
and "manually" parse the received log messages, there is no way for other LPs to know which data exactly to update

uncut temple
#

Hello, is there a way using the developer API to get the remaining time of a temporary permission?

viral lotus
#

I have a luckperms event listener right now on velocity, but it only detects the event from /lpv command and not /lp. Is there any way to detect both? Or did I just set it up wrong? (Where plug-in is the instance of the velocity plug-in)

public void register() {
        EventBus eventBus = plugin.getLuckPerms().getEventBus();
        eventBus.subscribe(plugin, NodeAddEvent.class, this::onUserPromote);
        eventBus.subscribe(plugin, NodeRemoveEvent.class, this::onUserDemote);
    }
obtuse jolt
viral lotus
nocturne elbow
#

->

dark viper
#

I'm having an issue getting my plugin to load after LuckPerms. I do have it as a dependency & I am loading it on the onEnable.

I am just getting the normal error:

net.luckperms.api.LuckPermsProvider$NotLoadedException: The LuckPerms API isn't loaded yet!
This could be because:
  a) the LuckPerms plugin is not installed or it failed to enable
  b) the plugin in the stacktrace does not declare a dependency on LuckPerms
  c) the plugin in the stacktrace is retrieving the API before the plugin 'enable' phase
     (call the #get method in onEnable, not the constructor!)

& luck perms loads directly after it throws that error.

This is how I have it added as a dependency.

Depends: [LuckPerms]

This is a Bungee Plugin.

I am also running the bungee version of luck perms.

solemn saffron
#

I would like to output in a string how long the player is still in the primary group. Is there any API there?

obtuse jolt
#

Likely not the issue

obtuse jolt
solemn saffron
#

@obtuse jolt can you give me an example?

frank driftBOT
#

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

obtuse jolt
#

!cookbook

frank driftBOT
jaunty pecan
nocturne elbow
#

yaml bad terrible disgusting yuck
yes I know it isn't yaml's fault
:)

night pier
nocturne elbow
#

:(

obtuse jolt
#

But yea checking the logs would have discover teh issues anyways

vernal matrix
#

@obtuse jolt try

frank driftBOT
#

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

obtuse jolt
#

Lol

solemn saffron
#

I want to set a player with the Api in the primary group for 5 days and I don't understand how I do that

obtuse jolt
#

what have you tried?

solemn saffron
nocturne elbow
frank driftBOT
solemn saffron
nocturne elbow
#

Add the expiry in the node builder

solemn saffron
nocturne elbow
#

??

#

Also please read my nickname thank you

#

Care to elaborate on "what should you do in "?

stray solar
#

What should I use to get the API in maven? Specifically for bungeecord

#

Okay well I ended up with

<repository>
  <id>luckperms-repo</id>
  <url>https://mvnrepository.com/artifact/net.luckperms/api</url>
</repository>

<dependency>
 <groupId>net.luckperms</groupId>
 <artifactId>api</artifactId>
 <version>5.3</version>
 <scope>provided</scope>
</dependency>

Is this right?

turbid solar
#

Dont need that repo

stray solar
gentle gulch
#

How do I make this message silent?

turbid solar
#

With the api?(

gentle gulch
#

that message shows up in chat but i dont want it too

nocturne elbow
#

What is this to do with the API?

gentle gulch
#

i thought it was an api displaying the text

fossil mauve
#

I think there is a command to silence the logs

fossil mauve
oak storm
#

Hi, there is a way to:

  1. ADD parent group with API
  2. GET all permission of a given player with API?
nocturne elbow
#

I mean it would be pretty useless if you couldn't

#

lmao

#

!api You should read over these wiki pages: the first one contains overall info about adding and using the API in your project + important info about the API's design you will most definitely want to have in mind when using it

frank driftBOT
nocturne elbow
#

the second page is just a whole bunch of things you will use in your journey throughout the LP API

oak storm
#

Oook I hadn't seen this page, thank you! 🙂

nocturne elbow
#

in addition to that you can also use the api cookbook to take as guide/"real life" example