#luckperms-api

1 messages · Page 47 of 1

lucid dagger
#

It worked before

#

I opened IntelliJ now and it stopped working

nocturne elbow
#

send your pom.xml ig

#

!pasteit

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!

lucid dagger
nocturne elbow
#

and you're building with mvn package right?

lucid dagger
#

building what?

nocturne elbow
#

your-- plugin?

lucid dagger
#

no?

#

uh

#

its worked without doing that..

nocturne elbow
#

how are you building your plugin

lucid dagger
#

Im working with a friend

#

I was told to build it like that

nocturne elbow
#

oh boy

lucid dagger
#

uh

#

I'll go tell him

nocturne elbow
#

maven is the build toolchain, you're not really supposed to use artifacts and "project libraries" when you're using maven

#

it takes care of all that, managing dependencies, compiling etc

lucid dagger
#

but does that break imports..

#

because i think thats whats wrong

nocturne elbow
#

I mean using a weird ass mixture between those 2 things probably

lucid dagger
#

mm

lean crypt
#

could a User be loaded at startup and stored for use later (maybe when they are offline)

nocturne elbow
#

Ideally you load the user as needed

queen rose
#

Is it possible to cancel the NodeAddEvent? I don't believe it is, so the best alternative solution would be to remove the node from the User, right?

turbid solar
#

Why

queen rose
#

I previously setup usages of /lp user (name) permission set (permission) but never included the context. I'm not setting everything up with mySQL and want to basically force those old commands to give context

lean crypt
# nocturne elbow Why?

I'm storing a players "balance" for my plugin in their meta value, and i'd like to still be able to query it even if they have logged out. I will always have a list of their UUIDs in config, so was wondering if i could just .getUserManager().loadUser(uuid).join() at the start of the server and cache the Users so I don't get any null exceptions. Purely because I can't figure out how to do a CompletableFuture that works with how I've structured the code.

public int getOfflineLimit(User p){
        LuckPerms lp = LuckPermsProvider.get();
        net.luckperms.api.model.user.User u = getLPUser(p.getUniqueId()).get();
        String s = lp.getGroupManager().getGroup(u.getPrimaryGroup()).getCachedData().getMetaData().getMetaValue("bloader_offline_max");
        String s2 = lp.getUserManager().getUser(p.getUniqueId()).getCachedData().getMetaData().getMetaValue("bloader_offline_personal");
        if(s2==null){
            s2="0";
        }
        if(s!=null)
            return Integer.valueOf(s) + Integer.valueOf(s2);
        else
            return 0;
    }

i need to return an int, but ofc with CompletableFuture i don't believe i can? maybe I'm missing something. Alternative is to just cache the specific meta values and run an update Task every so often i guess

turbid solar
#

CompleteableFuture<Integer> i think

lean crypt
# turbid solar CompleteableFuture<Integer> i think

I think i figured it out, is it okay to call CompletableFuture.get() to get the results async?

public CompletableFuture<List<String>> getOfflineValuesAsync(UUID who) {
        return luckPerms.getUserManager().loadUser(who)
                .thenApplyAsync(user -> {
                    List<String> strings = new ArrayList<>();
                    strings.add(user.getCachedData().getMetaData().getMetaValue("bloader_offline_max"));
                    strings.add(user.getCachedData().getMetaData().getMetaValue("bloader_offline_personal"));
                    return strings;
                });
    }
    
    //FIND MAX NUMBER OF OFFLINE LOADERS THIS PLAYERS PRIMARY GROUP CAN PLACE
    public int getOfflineLimit(User p) throws ExecutionException, InterruptedException {
        CompletableFuture<List<String>> future = getOfflineValuesAsync(p.getUniqueId());
        List<String> offlineBalances = future.get();
        String bloader_offline_max = offlineBalances.get(0);
        String bloader_offline_personal = offlineBalances.get(1);
        if(bloader_offline_personal==null){
            bloader_offline_personal="0";
        }
        if(bloader_offline_max!=null)
            return Integer.valueOf(bloader_offline_max) + Integer.valueOf(bloader_offline_personal);
        else
            return 0;
    }
thin turret
#

Hey guys am I doing this right in order to receive the user's uuid? ```java
public User giveMeADamnUser(UUID uniqueId) {
UserManager userManager = LuckPermsProvider.get().getUserManager();
CompletableFuture<User> userFuture = userManager.loadUser(uniqueId);

    return userFuture.join(); // ouch! (block until the User is loaded)
}
#

I'm getting the method like this User user2 = giveMeADamnUser(target.getUniqueId());

#

I just keep getting NullPointerException so I presume not

#

I'm basically trying to get the suffix of an offline user

obtuse jolt
nocturne elbow
#

AllianceTagCommand.java:217
what's in there at that line?

obtuse jolt
#

yea ^^

thin turret
#

User user2 = giveMeADamnUser(target.getUniqueId());

nocturne elbow
#

ah right

#

target is null

thin turret
#

Ahh I see... which makes sense tbh. Do you know how I can resolve this then? I basically wanna get the UUID of the Player in Args[1]. I'm currently getting it like this obviously Player target = Bukkit.getPlayer(args[1]);

nocturne elbow
#

getPlayer will only return a player if they are online

thin turret
#

Yeah

nocturne elbow
#

if you want to include offline players, getOfflinePlayer is what you're looking for

thin turret
#

Will that get both Online and Offline I presume?

nocturne elbow
#

yea

thin turret
#

Thank you! It is fixed 🙂

weary wyvern
#

Hello, I'm using Velocity and I wanna use the API of LuckPermsVelocity. Is the dependency the same as in Spigot/Paper or is there another dependency / do I have to shade it?

turbid solar
#

Yes

#

No

#

No

weary wyvern
turbid solar
#

Same api

#

No other depend

#

Dont shade

weary wyvern
#

which depend?

weary wyvern
turbid solar
#

Yes

weary wyvern
#

Yes

rustic laurel
#

!api first link here haz the guide, btw

frank driftBOT
rustic laurel
#

might make it easier

weary wyvern
#

Yeah I know

#

But there is no tutorial for Velocity

#

I have to use the singleton static access

rustic laurel
#

it's all the same

turbid solar
#

Yes

rustic laurel
#

well, most

weary wyvern
#

kinda sad

turbid solar
#

Huh?

lean crypt
#

hello i was in here for some help with CompletableFuture and async stuff earlier, i just wanted to run this by someone to make sure i can nest CompletableFutures like this without any issue

util.getOfflineLimitAsync(p).thenAcceptAsync(maxOff -> {
                util.getOnlineLimitAsync(p).thenAcceptAsync(maxOn -> {
                    util.getAvailableOfflineChunksAsync(p).thenAcceptAsync(offline -> {
                        util.getAvailableOnlineChunksAsync(p).thenAcceptAsync(online -> {
                            txtList.add(Text.builder().append(util.textSerializer("&l&6-&r&bOnline: &6"+online+"&8/&6"+maxOn+"&b chunks")).build());
                            txtList.add(Text.builder().append(util.textSerializer("&l&6-&r&bOffline: &6"+offline+"&8/&6"+maxOff+"&b chunks")).build());
                            PaginationList.builder()
                                    .title(util.textSerializer("&l&8[&r&bB&aChunks&r&l&8]&r - &6Your Available Balance:"))
                                    .contents(txtList)
                                    .padding(util.textSerializer("&8="))
                                    .sendTo(src);
                        });
                    });
                });
            });
nocturne elbow
#

oh jesus what in the world is that lmao

obtuse jolt
#

I feel like it’s very poor class design lol

lean crypt
#

this is true it is but it works so now i can optimise it thank u friends

lean crypt
#

helo it me again

#
public CompletableFuture<Map<String, String>> getPlayerLimitsAsync(UUID who) {
        return luckPerms.getUserManager().loadUser(who)
                .thenApplyAsync(user -> {
                    Map<String, String> strings = new HashMap<>();
                    luckPerms.getGroupManager().loadGroup(user.getPrimaryGroup()).thenAcceptAsync(group -> {
                        if (group.isPresent()) {
                            BChunks.getInstance().getLogger().info("group is present");
                            Group foundGroup = group.get();
                            strings.put("bloader_offline_max", foundGroup.getCachedData().getMetaData().getMetaValue("bloader_offline_max"));
                            strings.put("bloader_online_max", foundGroup.getCachedData().getMetaData().getMetaValue("bloader_online_max"));
                            strings.put("bloader_offline_personal", user.getCachedData().getMetaData().getMetaValue("bloader_offline_personal"));
                            strings.put("bloader_online_personal", user.getCachedData().getMetaData().getMetaValue("bloader_online_personal"));
                            BChunks.getInstance().getLogger().info("getLPGroup: " + strings.toString());
                        }
                    });
                    BChunks.getInstance().getLogger().info("loadUser: " + strings.toString());
                    return strings;
              

How can i make sure that strings does not return until the second CompletableFuture is finished? the first logger is always an empty map, followed by the populated map

obtuse jolt
#

you can create a new CompletableFuture lol

#

public CompletableFuture<Map<String, String>> getPlayerLimitsAsync(UUID who) {
    CompletableFuture<Map<String, String>> future = new CompletableFuture<>();
    luckPerms.getUserManager().loadUser(who).thenAccept(user -> {
        Map<String, String> strings = new HashMap<>();
        luckPerms.getGroupManager().loadGroup(user.getPrimaryGroup()).thenAccept(group -> {
            // stuff
            future.complete(strings);
        });
    });
    return future;
}
#

ig something like this

lean crypt
#

something... went wrong

obtuse jolt
#

loll

lean crypt
#

it's like it just stops running at some point during the Future

#

it's 7AM though and i'll figure it out later megalul

#

thanks anyway friend

sly bramble
#

Ч$ааа$аааааа$каааа👍 💩 🍴 💩 😋 🍴

obtuse jolt
#

turbid solar
#

??

lean crypt
#
util.getAllPlayerBalancesAsync(p).thenAcceptAsync(stringStringMap -> {
                BChunks.getInstance().getLogger().info("after future" + stringStringMap.toString());
                src.sendMessage(util.textSerializer("0"+stringStringMap.toString()));
                String onlinePersonal = stringStringMap.getOrDefault("bloader_online_personal", "0");
                String offlinePersonal = stringStringMap.getOrDefault("bloader_offline_personal", "0");
                String maxOn = stringStringMap.getOrDefault("bloader_online_max", "0");
                String maxOff = stringStringMap.getOrDefault("bloader_offline_max", "0");
                src.sendMessage(util.textSerializer("1"+stringStringMap.toString()));
                int bloader_offline_total = Integer.parseInt(maxOff) + Integer.parseInt(offlinePersonal);
                int bloader_online_total = Integer.parseInt(maxOff) + Integer.parseInt(onlinePersonal);
                src.sendMessage(util.textSerializer("2"+stringStringMap.toString()));
});

hello it me (again part 2) so i have a CompletableFuture and i want to use some of the results it gives me to calculate something, but every time i try to do a calculation like int bloader_offline_total = Integer.parseInt(maxOff) + Integer.parseInt(offlinePersonal); inside the future, the future stops entirely, because i receive the "0" and "1" messages but not "2". I'm assuming I can't calculate inside the future, how would I get the value i needed?

nocturne elbow
#

it's nothing to do with the future

#

Integer.parseInt is probably throwing an exception (likely a IllegalArgumentException), you can try and catch that and handle the exception

lean crypt
#

even if i'm using .getOrDefault on the map? I will try anyway though, thank you 💚

nocturne elbow
#

getOrDefault does not guarantee the string will be number-like

#

it just returns whatever value is there for that key, whether it's number-like or not; if there is no value it will return the default, yes

lean crypt
#

I see, thank you so much as i believe you have just solved my issue 😄

thin turret
#

Hey guys wondering if someone could help me. ```java
Player target = (Player) i.getInventory().getHolder();
target = (Player) Bukkit.getOfflinePlayer(target.getUniqueId());
String name = target.getName();
User user = giveMeADamnUser(target.getUniqueId());
user.getCachedData().getMetaData().getSuffixes().clear();
LuckPermsProvider.get().getUserManager().saveUser(user);

turbid solar
#

What is that code..?

#

The beginning

nocturne elbow
#

like 30% of all that is redundant

turbid solar
#

Whats on L73

thin turret
#

user.getCachedData().getMetaData().getSuffixes().clear();

#

It seems this keeps throwing a Null error, even in my normal class where I'm getting the player directly, which is weird

nocturne elbow
#

right because the map returned by getSuffixes is unmodifiable

thin turret
#

I see.... so how could I then instead clear all of their suffixes in a different way?

#

Still getting used to the API sorry haha

turbid solar
#

getNodes()

#

And some stuff, not sure what cus im on phone

thin turret
#

Nodes include the prefix too though correct?

#

I just want to remove the suffix instead of both prefix and suffix

turbid solar
#

user.data().clear(NodeType.SUFFIX::matches);

#

should work?

thin turret
#

That worked! Thanks

cobalt venture
#

!maven

frank driftBOT
#

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

cobalt venture
#

?maven

turbid solar
#

!api

frank driftBOT
cobalt venture
#

oo thanks ❤️

#

were is repo?

turbid solar
#

Its on maven central

cobalt venture
#

okey

cobalt venture
#

how to check permission by context?
code logic:
if (User has permission ("plugin.command", on server "survival")) {

}

cobalt venture
#

@jaunty pecan Can you help me? I still have a problem with that... >. <

frank driftBOT
#

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

cobalt venture
#

Sorry :<

nocturne elbow
cobalt venture
#

❤️

#

it woork thanks ❤️

#

add this example to wiki luckperms for other developers

obtuse jolt
#

!cookbook should have it somewhere alr

frank driftBOT
dim ferry
#

Hey!

I am currently changing my LuckPerms Groups with a command using the #modifyUser Method of the API.
It works fine on the spigot server meaning that /lp user <User> info shows up the new group with the correct prefix.

But my Scoreboard and Chat is handled by my BungeeCord plugin, which gets the Prefix with the LuckPerms API as well.
My issue is, that the update is not recognized by the BungeeCord LuckPerms -> the old Prefix is still shown.

This is only fixed, if the player relogs to the network. Can I fix this somehow?

turbid solar
#

look pins

dim ferry
#

I already looked at those, and it seems like using #modifyUser should handle this update via PluginMessage, shouldnt it?

turbid solar
#

no

#

you need to manually push the update

dim ferry
#

Oh my god, sorry I can't read. Thanks!

halcyon geyser
#

So im new to using maven in plugins but idk what ive done wrong as i copied it from the website

turbid solar
#

Try refreshing

#

Or re importing

halcyon geyser
#

Oh thanks

prisma lantern
#

luckperms api is not loaded?
im using bungee
i've depended on luckperms

#

why

nocturne elbow
#

how are building your plugin?

prisma lantern
#

maven

nocturne elbow
#

send your pom.xml please

#

!pasteit

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!

prisma lantern
nocturne elbow
#

well 1st of all there is no reason whatsoever to use such an ancient version like 4.0... use 5.3 which is latest
2nd add <scope>provided</scope> in the LP dependency

prisma lantern
#

uh

#

what does provided do?

#

also do i need a repo for the 5.3?

#

it cant find it

turbid solar
#

Its on central

prisma lantern
#

well then it cant find it

#
        <dependency>
            <groupId>me.lucko.luckperms</groupId>
            <artifactId>luckperms-api</artifactId>
            <version>5.3</version>
            <scope>provided</scope>
        </dependency>```
turbid solar
#

!api

frank driftBOT
nocturne elbow
#

because it's not under that group+artifact coordinates

#

read the docs ^^

prisma lantern
#

ah

#

ok

#

fixed

#

lemme see if it worked

nocturne elbow
prisma lantern
#

how to get luckperms instance now

nocturne elbow
prisma lantern
#

yea

#

i figured

#

uh

#

last question

#

why is this null

#

nullpointerexceptiobn

#
    public static String getPrefix(UUID p) {
        LuckPerms lp = LuckPermsProvider.get();
        
        User user = lp.getUserManager().getUser(p);
        Map<Integer, String> prefixes = user.getCachedData().getMetaData().getPrefixes();
        return ChatColor.translateAlternateColorCodes('&', prefixes.get(1)) + getColor(p);
    }```
turbid solar
#

Is the user online M

#

?*

prisma lantern
#

this line

Map<Integer, String> prefixes = user.getCachedData().getMetaData().getPrefixes();
#

yes

#

they are

#

no

#

they arent

#

lol

turbid solar
#

Load the user

prisma lantern
#

loadUser().get()?

#

or something else

turbid solar
#

Yes

nocturne elbow
#

also there's a getPrefix method that returns the final, calculated prefix

#

instead of getPrefixes which returns a map

prisma lantern
#

nah i have my own prefix system

#

i have 2 prefixes for players

#

their rank color

#

and their chat prefix

#

so thats what i use

nocturne elbow
#

riiiiiiiiiiiiiiight

prisma lantern
#

lol

#

does getPrimaryGroup() get the group with the highest weight

turbid solar
#

By default yes

wispy harness
#

is it possible to get the case sensitive username of an UUID with the LuckPerms API?

turbid solar
#

No

#

It'll always be lowercase

opal chasm
#

is there a way i can check if a group has a particular temporary permission node, and get how long until said node expires?

obtuse jolt
#

!Api yea, you can look into the Node object and how to query nodes

frank driftBOT
unkempt depot
#

How does LuckPerms get around the issue with Java 16 that restricts the appending of classes into memory through the addUrl method?

turbid solar
#

This i think

unkempt depot
#

Thanks!

queen rose
#

Will I experience issues if I don't run use a scheduler when using the LuckPerms API?

turbid solar
#

As long you dont block the main thread

queen rose
#

I'm unfamiliar with that.

#

Are there common ways people block the main thread without meaning too?

turbid solar
queen rose
#

Thanks!

nocturne elbow
#

!api @thin matrix check those pages, 1st on depending on LP and 2nd on loading data for offline players

frank driftBOT
nocturne elbow
#

Also the section "CachedData" -> "Performing permission checks" once you have the loaded user

thin matrix
#

alright so after I load the user I can access the cached data.

nocturne elbow
#

yep

solar plank
#

how do I get the group/rank name of the player

#

not the prefix

#

like Owner

#

not

#

&7[&4Owner&7]

obtuse jolt
#

Players can inherit multiple group

#

But a assume you can use getPrimaryGroup since it seems you only want the highest priority group

vale wren
#

you could cycle through players permissions to see if any node is an instance of Node.INHERITANCE

#

and then get that node

nocturne elbow
#

You can call PermissionHolder.getNodes(NodeType) to get owned nodes of a specific type

vale wren
#

you would get sth like "group.owner" from that, i believe

#

so you need to cut the group. out to get the actual group name

nocturne elbow
#

Which has a method that provides the actual group name they represent

#

getNodes does not return a collection of Strings

#

what are you trying to achieve?

wild whale
#

Please stop spamming channels. #support-1 for LP support.

hardy sedge
#

I just checked code I made some time ago, removing or adding LP groups (InheritanceNode) to a user. For some reason I remember that I did not implement a check against the LP cache if a user holds/misses the group before I perform the operation to add/remove. But at the moment I find no reason why I'm not checking before to save unnecessary operation.

#

Or did I miss smth

nocturne elbow
#

yeah there's no real reason to

#

adding and removing nodes returns a erm

#

something, that tells you if it succeeded or why it failed

#

d;lp nodemap#add(node)

slate deltaBOT
#
@NonNull
DataMutateResult add(@NonNull Node node)```
Description:

Adds a node.

Returns:

the result of the operation

Parameters:

node - the node to be add

nocturne elbow
#

DataMutateResult :^)

hardy sedge
#

Ohh I see thanks

steady glade
#

How would I be able to get a groups prefix and suffix?

nocturne elbow
#

From the CachedMetaData

#

!API check out the second page linked here, it goes over using them

frank driftBOT
steady glade
nocturne elbow
#

Check the methods in the GroupManager

#

getGroups or something, can't quite remember

steady glade
#

ok

steady glade
#

How would i get if a user has multiple groups?

steady glade
#

Is this good or is it weird? (Also don't mind the errors those are for a diffrent thing)

nocturne elbow
#

that is a bit weird uuh...

#

what are you trying to achieve?

steady glade
nocturne elbow
#

riiiiiiiiiight

#

uh

steady glade
#

Sorry if its a bit weird im tryna switch over from pex and thats what I did xD

nocturne elbow
#

i'm sorry i'm not trying to be rude or anything but what is going on?

steady glade
#

With the code or.?

#

With the Code its getting each group a user is in and saving it to an Object and then getting the prefix and suffix of the group.

nocturne elbow
#

Have you heard of "enhanced for loops"?

steady glade
#

no..

nocturne elbow
steady glade
#

ok

nocturne elbow
#

Okay so:

  • First off, UserManager.getUser(UUID) may (and most likely will) return null if the player is offline; you should definitely put that in a variable and null check, if it's null, handle the situation, if it isn't continue as normal. If on the other hand the player is guaranteed to be online then you can either ignore it or use the PlayerAdapter instead (see in the page linked above the section "Loading data for players")

  • Objects.requireNonNull(Object) purposely throws a NullPointerException if the object passed is null, please do proper null checks unless you actually want an NPE to be thrown

  • getInheritedGroups returns a Collection<Group>, you don't need to turn it into a group array, take advantage of that and use the enhanced for loop ("for each") to iterate through the groups one by one instead

The string builder part seems to be good

steady glade
#

Ah that makes sense but it runs when a player dose /(command) so they are guarenteed online, heres a test I came up with is it better?

#

Ill try to use the player adapter

nocturne elbow
#

that looks better, I still suggest you put the user itself in a variable but that works as well i suppose

steady glade
#

Ok thank you will do

sweet oak
#

Hello, I know I'm using the API wrong. Can anyone guide me how can i use API so I can use isPlayerInGroup method.

turbid solar
#

!api

frank driftBOT
turbid solar
#

Has a way to check

sweet oak
#

I'm on that wiki, I've imported dependencies.

turbid solar
#

Its an example method

sweet oak
#

That's right.

#

my bad.

turbid solar
#

NodeAddEvent

#

/ NodeRemoveEvent

#

!cookbook has example iirc

frank driftBOT
nocturne elbow
#

wat

nocturne elbow
#

getInheritedGroups

#

uh what about it doesn't work?

#

are you getting an error or..?

#

uh..

#

you're gonna need to share more code or more details about what "isn't working" and how it isn't, i simply cannot tell just by looking at that though

#

uh right

#

sharing the contextual code will surely help...

#

that does not even compile

hushed prawn
#

Hi, I'm trying to learn how to manipulate permissions programmatically, but a lot of the objects in the javadocs such as NodeBuilder return an access denied error when I try to view the page.
The wiki has a section for modifying user/group data:
DataMutateResult result = user.data().add(Node.builder("your.node.here").build());
but I'm not sure if the example would necessarily do what I'm trying to accomplish.
In case a user node already exists for the permission, will this code replace the existing node? I read that nodes are immutable, but I'm not quite sure how I would go about removing a specific node from a user. I was hoping that this particular method would just automatically remove an existing node, but I'm seeing that the DataMutateResult enum has a value called "FAIL_ALREADY_HAS", which I'm assuming would be the value that returns if I try to add a node that already exists. Any advice would be greatly appreciated! :)

nocturne elbow
#

Adding a node will not remove an existing one, it will simply add it if it does not exist and return DataMutateResult.SUCCESS.
DataMutateResult.FAIL_ALREADY_HAS is returned when the node "already exists", the attributes that are taken into consideration is node key (the "permission" itself), node value (true/false), the node's applicable contexts and if it has an expiry date (it ignores the expiry date itself, but it checks if it has one); so if there is one node matching those 4 attributes with the one you passed, it fails

To remove a node you can use NodeMap#remove(Node node), which only needs 3 of the 4 attributes: node key, node's context set and if it has an expiry (again the expiry value is ignored, and so is the node value (true/false)). If there is a node matching those 3 attributes, it's removed and DataMutateResult.SUCCESS returned, else DataMutateResult.FAIL_LACKS.

If you just want to remove a node regardless of context and expiry (i.e. key only) then you should probably use NodeMap#clear(Predicate<Node>) and pass a predicate created with NodeMatcher.key(String key).

hushed prawn
nocturne elbow
#

because java is stupid

#

will be fixed by the next api publishing

#

for now you can remove the /undefined from the URL or navigate by clicking the hyperlinks

hushed prawn
#

-.- I just realized that I overlooked the link to the source code ... lol

safe roost
#

wht to do

turbid solar
weary wyvern
#

Hello, if I check permissions from the Velocity it only accepts permissions which the player has global. Why not the permissions which the player has on the current server? And is there a way to change this?

turbid solar
#

Use the api to check for perms

#

Not velocity

#

!sync also this

frank driftBOT
weary wyvern
#

Yeah

#

Ive done this

turbid solar
#

Show code of where its not working

weary wyvern
#
if (user.getCachedData().getMetaData().getPrefix() != null) {
            prefix = user.getCachedData().getMetaData().getPrefix();
        }
#

Im using this

turbid solar
#

Screenshot /lpv info & /lp info

weary wyvern
#

It is capped on one server

#

wait

#

If I change this permission to global then it works as wanted.

turbid solar
#

Wait, are you doing that code on velocity?

weary wyvern
#

yes

#

exactly

turbid solar
#

Because of the context

weary wyvern
#

If im using this for example it works.

#

If I change it to this It wont work anymore

turbid solar
#

Yeah.m

#

Because context

weary wyvern
#

Yes I know

#

And How can I avoid this?

turbid solar
#

Not using the cacheddata ig?

#

Not sure

weary wyvern
nocturne elbow
#

CachedDataManager#getMetaData/getPermissionData can take a QueryOptions

#

you can build one with the context set you want with QueryOptions.builder()

#

If you use the method that does not take a QueryOptions it uses the user's active one

weary wyvern
#
user.getCachedData().getMetaData(QueryOptions.builder(QueryMode.NON_CONTEXTUAL).build()).getPrefix();
#

Right?

nocturne elbow
#

no

#

you do want to take contexts into consideration

#

and you do want to pass the context set to the builder

#

well, do you?

#

do you just want to take "any prefix" regardless of context?

#

or on a specific server context?

weary wyvern
#

I want the active Prefix -> Server Context?

#

Now im confused

nocturne elbow
#

you need to pass it the context

#

to the query options builder

#

and you don't want it to be non-contextual

#

because you want to query for context

#

the one you pass in

weary wyvern
#

I think this is completely wrong but this is my try:
user.getCachedData().getMetaData(QueryOptions.builder(QueryMode.CONTEXTUAL).flag(Flag.INCLUDE_NODES_WITHOUT_SERVER_CONTEXT, true).build()).getPrefix();

nocturne elbow
#

you are still not passing the context

#

give me a min

#

Hey guys, real noob here, sorry about that.

I'm trying to use LuckPerms API in my own plugin coding, but it seems I dont have access to its methods ( they dont appear after the dot) while the LuckPerms API do appears at 1st.

weary wyvern
#

Questions about using the LuckPerms Developer API - https://luckperms.net/wiki/Developer-API

#

There is a complete tutorial

nocturne elbow
#

The Luckperms API is installed the right way manually

nocturne elbow
weary wyvern
#

Dont use static injection

#

use this

turbid solar
#

Doesnt matter

weary wyvern
#

yes

turbid solar
#

Instead of the 2nd LuckPerms use api

nocturne elbow
# weary wyvern

oh okay thanks, and where in teh code should I add that ? below the imports ?

turbid solar
#

...

#

Nvm then

weary wyvern
#

and call it in onEnable

nocturne elbow
turbid solar
#

Yes

weary wyvern
turbid solar
#

Just make sure you're depending on LP ij your plugin.yml

wild whale
nocturne elbow
turbid solar
#

No

#

11 pls explain :p

nocturne elbow
#

sorry guys must be pain in the ass to explain noobs

wild whale
#

what am I explaining cas?

nocturne elbow
wild whale
#

oh plugin.yml crap ok

turbid solar
#

Dont feel like typing it on phone

weary wyvern
# nocturne elbow e.g.

the problem with this is that it uses all prefix on all Servers or not? Because if im on Server A i get the prefixes of Server B probably?

wild whale
nocturne elbow
#

is this a proof I have it ?

#

see below

wild whale
#

@stank

#

fk

nocturne elbow
#

:huh:

#

ah I dont have it in plugin.yml

weary wyvern
nocturne elbow
nocturne elbow
nocturne elbow
nocturne elbow
wild whale
nocturne elbow
weary wyvern
# nocturne elbow didn't you say you wanted to get the prefix for a context?

Im sorry. My english is not the best. I try it again.
I have 3 Servers

  • A, B, C
    I wanna get through Velocity the current prefix of the player the one with the context server=A und world=AWorld
    If i get it only shows GLOBAL prefixes -> it ignores everything with context.
    And is there a way to avoid that?

Hope its better now.

nocturne elbow
#

thanks for the help guys really appreciated

nocturne elbow
#

that's like the entire point of it

weary wyvern
nocturne elbow
#

?????????

weary wyvern
#

??????????

nocturne elbow
#

if you tell the query options to get the prefix for server A, it doesn't matter where you are or if the user is online at all, it will obey the query options and get the prefix for server A

weary wyvern
nocturne elbow
#

not sure if im supposed to do something else but it didnt fix the problem

weary wyvern
#

no

#

u dont have to do this

nocturne elbow
#

me ?

#

damn

weary wyvern
#

yes

nocturne elbow
#

I mean my problem is still not fixed, here the screen of my problems :

weary wyvern
#

U use api.

nocturne elbow
#

do you know what a variable is?

#

ah ye

weary wyvern
#

api.whatever you want

wild whale
#

this is basic java

nocturne elbow
#

but the luckperms methods doesnt appears in the list, si this normal ?

weary wyvern
#

congrats

nocturne elbow
#

??? they are right there

#

I dont think so

weary wyvern
#

....

nocturne elbow
#

for example, I dont se any of those

#

Those are packages

wild whale
#

those are packages

weary wyvern
#

Do you even know how to use Java?

nocturne elbow
#

shoudnt they be within the Luck Perms thing ?

#

not really

wild whale
#

If you're trying to use the LP api without knowing java (which it seems is the case), you are going to have a really hard time

nocturne elbow
#

im learning

#

oh jesus

weary wyvern
nocturne elbow
#

the LP API is not exactly beginner friendly

weary wyvern
#

Learn Java, then write Plugins

nocturne elbow
#

Hell, the spigot api isn't either

#

thing is my plan was to learn while experimenting those stuff u know

#

but the LP API is worse kek

wild whale
#

Learn java, then learn spigot, THEN learn LP api

nocturne elbow
#

I know python

wild whale
#

you shouldn't be touching spigot if you don't know java

weary wyvern
wild whale
#

python and java have literally nothing in common

#

(aside from the fact that they're both programming langauges)

nocturne elbow
#

yes but the programming logic is still there

#

anyway

weary wyvern
#

Yeah

#

But u dont know anything about java

nocturne elbow
#

the thought process yes

#

but packages have nothing to do with the thought process

#

sorry to bother u then, but where can I learn about packages and shit ?

weary wyvern
#

if you know python

nocturne elbow
#

I just want specific tutorials on those if that's possible

#

My plan is to learn java doing those stuff, I rather figuring projects out than follwoing boring tutorials

weary wyvern
nocturne elbow
#

and learn thing as I need them u know, I did that with python

wild whale
#

that may work with python, but with java there's a lot of base concepts you need to get down first

#

i.e. OOP isn't something you can just follow a tutorial on

nocturne elbow
#

"boring tutorials" are boring because you are not willing to spend the time on learning the language but okay

#

Online Courses:
Online courses are also great for learning java. Some websites that offer them are:

  • Coursera - Free unless you want a certificate
  • PluralSight - Great courses from what I've seen. Mostly Paid
  • Udemy - Never used them myself but they seem to all or at least most be paid.
    Coursera. - I can say it was pretty good at introducing me to the programming world as a whole not just java.

Oracle Docs:
Oracle docs can help a lot at learning and understanding java:

  • Start with this,
  • Breeze through this (skipping stuff that doesn't seem relevant like bitwise operators),
  • Hit this.
    They're the first three from this larger thing which you should definitely go through overall. But those three should be enough for slightly better understanding of what is happening here without feeling like a huge time sink.
    That one is a small part of this larger site wherein "Essential Java Classes" and "Collections" also have good useful stuff

Other services:
Some other cool services that will help you learn java are:

#

you can't expect to drive a semi-truck without knowing learning how to walk first

nocturne elbow
#

anyway

#

Thanks for the ressources and help guys

#

you will use most of the things you will learn

#

that's the thing

#

if you don't know what a variable is, what a class is and what a package is, if you keep insisting in "i don't need those", they are a requirement in java, you use them every single time you use JAva because java enforces their usage

#

yes but in python, I can really well try to do stuff once I got the basics, and just google what I dont know and learn it as i need it doing a projects u know. It's wayyy more fun to learn that way by doing actual projects

#

so you can do with java???

#

I know what a class and a variable is, not a package tho or how does it relates to the api thing

#

I guess i need to get those basics 1st then

#

If you want to see bukkit specific stuff I personally recommend the official bukkit wiki

#

okay will look into it, thanks!

weary wyvern
#

the prefix should look on the context and should watch if the player completes this context.

#

And if all matches then it should be used.

nocturne elbow
#

What??

weary wyvern
#

Fuck my English...

nocturne elbow
#

Regardless of where the player is in

weary wyvern
#

Yes

#

And i dont want this

nocturne elbow
#

Was that not what you told me you wanted??

#

Sorry I can't help you if I can't understand what you're wanting to do

weary wyvern
#

Yes

#

Next Try:
Im on the server A with the permission prefix.1000.Test with the context server=a world=test
If I now get the prefix of the player I dont get this prefix but the player is in the right world & server.

#

Better?

nocturne elbow
#

Okay let me see if I understand this time around

weary wyvern
#

^^

nocturne elbow
#

Okay I see what's going on

weary wyvern
#

Its maybe a bug?

nocturne elbow
#

Not a bug, it's intended behavior but let me explain

#

To put it shortly: when you get the getMetaData() (no query options, let's forget about the query options), it uses the user's active options based on the LP that processes the request. What does that mean? It means that, for a plugin on Velocity using the LP API on Velocity, it will use the contexts shown in /lpv user <user> info, because it's LPV processing said request. If the plugin using the API is on the backend server, then the contexts used are the ones shown in /lp user <user> info.

The server context does not mean "where the player is in", but "which LP is processing the request" (set in the config), so for LPV the server context will always be "proxy", in the LP on survival it will always be "survival", for the LP on creative it will always be "creative", etc. The server context is based on the setting in config, meaning it will always be the same "by default".

The world context does not necessarily mean "the world the player is in", but it means "where is the player located". For LP on a proxy, the world context is the name of the server (in the proxy settings) the player is in, the player is located in one of the servers, so for LPV that's the world context. For LP on the backend server, the world context is the Minecraft world the player is in, the player is located in one of those worlds so that is the world context

The thing is that each LP runs entirely independent and disconnected from the other LPs in the network, they don't really communicate with each other, they are "isolated", the only thing they share is a common database

#

"To put it shortly"

#

Lmao

#

So if you use getMetaData on a plugin on the server it will work as expected

weary wyvern
#

U mean that I have to write a plugin for the backend server to send the things to the proxy?

#

It was so clean without other plugins

#

Only a simpel Velocity Plugin :/

nocturne elbow
#

Yeah I know, the best you can do is get the user's world context and use it as server context for the query options, but you can't get the actual world without a plugin on the server that acts as a bridge to send that info

weary wyvern
#

that is really annoying...

nocturne elbow
#

Not really a bug, that's just how it works

weary wyvern
#

yeah

nocturne elbow
#

Each LP is its own, with its own set of contexts used to calculate the data

weary wyvern
#

makes sence

#

Thank you for your help.

nocturne elbow
gaunt hare
#

tysm 😄 yes those 2 links definitely help

#

guys what is Node#getPermission() in 5.0 api? is it #getKey()?

nocturne elbow
#

uh you should use 5.3 lol

gaunt hare
#

sry meant 5.0+ xD

#

as oppose to 4.0 lol

nocturne elbow
gaunt hare
#

im linkinf on latest rn

#

well im converting my code over to new api

#

and i have some Nodes that i get from event.getNode()

#

but then Node#getPermission() is gone 🤣

nocturne elbow
#

i c

gaunt hare
#

i figure its gotta b getKey() since it's the only string method... guess we'll kno when some1 dosent rank up lol

#

is there a javadocs? o.O

nocturne elbow
#

yeah but they are kinda broken right now, you can still navigate them though

#

!javadoc

frank driftBOT
nocturne elbow
#

third link

gaunt hare
#

ahh ty 😄

gaunt hare
#

o rip in pieces api#getNodeFactory()

#

i gotta say doe .-. a lot more hasnt changed then i thought

#

still got usermanger etc.

nocturne elbow
#

you use InheritanceNode.builder() or PrefixNode.builder(), PermissionNode.builder() etc

gaunt hare
#

ohh 😮 ty 😄

#
Plugin.Permissions.getUserManager().saveUser(user);```
is this all i need 2 do to set a node? .-.
nocturne elbow
#

yeah, that or

userManager.modifyUser(uuid, user -> user.data().add(node));
gaunt hare
#

oh thats evn better 😄 ty

gaunt hare
#

btw i know 4.0 api didnt support offline player perms, wat about modern api? .-.

nocturne elbow
#

The main API wiki page talks about that :d

#

You gotta load the user first

gaunt hare
#

oh 🤣 so the way i had it b4 then lol

#

i switched over to player.hasPermission()

merry scroll
#

Hello, I am using the latest LuckPerms API and tried to set a primary Group to a user. But ot doesnot work, and I am working for 2 hours with this problem, I need help. https://i.imgur.com/0n3yITq.png

turbid solar
#

!cookbook has examples @merry scroll

frank driftBOT
merry scroll
#

Thank you

native roost
#

how would I add permissions with my plugin to show on the website without registering a command for them

#

like I have a command with underlying commands but the underlying commands are built into the main command

nocturne elbow
#

LuckPerms will cache any permission that is checked

#

I believe you can add them with the API, I'm not sure, would need to check, or just trigger perm checks for players at random :^)

native roost
nocturne elbow
#

??

#

Wdym "check it in my code"?

native roost
#

like in my code I have this line

#

if (!player.hasPermission("amazing.vanish.list")) {

#

would that apply it

#

or is there a way I could change it so it did

nocturne elbow
#

LuckPerms will cache any permission that is checked

native roost
#

because the permission for the main command is amazing.vanish

#

ok

harsh radish
#

Hi, how can i get (and set) the players prefix, not the prefix of the players group?

obtuse jolt
#

@thorny echo ahh

thorny echo
#

boo

fiery tartan
#

Hi guys, i have a question. Can someone please tell me how can i remove permission from a player? Thx (Im new to api)

#

I tried this but its not working

#

Can someone please help me?

nocturne elbow
nocturne elbow
#

That's also explained in the first page of the two I linked above ^

nocturne elbow
#

For some reason user.getInheritedGroups can not be found, any idea if this has been changed or am I just a bit stupid?

nocturne elbow
#

nvm outdated version hihi
Now I am stuck at the following, I want to see the time left on a group that has been added to a player to determine when it will expire, how could you do that, I can not find anything related to this on the wiki besides getting a node with 1d as a time modifier.

fiery tartan
nocturne elbow
#

Should

nocturne elbow
tawdry estuary
#

||hi||

#

||how are you guys. im worried how this is going to go this is the first time that im using this and this thing||

nocturne elbow
#

do you have a question regarding the API ...?

scarlet aurora
#

this might sound really dumb (I'm not familiar with java at all, but I'm still trying to power through regardless)
what does possibleGroups mean in the API usage? how can I change this list to limit what it looks for?

nocturne elbow
#

huh?

#

oh

#

holy, i hate that example is there

#

basically that example does the following: you pass a player and an ordered collection of group names, ordered from "higher" to "lower" group priority, you define that yourself
(e.g. Arrays.asList("owner", "admin", "mod", "jr-mod", "helper", "vip+", "vip"))
and the method checks for each one of those strings, if the player has the group.<group> node, the first one found is returned, if none is found it returns null

#

it's a rather stupid example and i hate it's there lmao

#

because that is exactly not using the LP API

scarlet aurora
#

oh I see

#

alright thank you

stoic nest
#

LuckPerms luckPerms = LuckPermsProvider.get(); this would work on both sponge and spigot right?

#

someone is getting an error on a spigot (guessing magma/mohist) server

#

but it works fine on sponge

#

this is the error

#

not really sure what is causing the error

nocturne elbow
#

that looks like a problem with whatever hybrid they are running

#

LuckPermsProvider.get() works on every platform so long as it (the platform) does things properly (expose/bridge classes between both "modding universes")

stoic nest
#

any tips/idea on how to resolve the issue,

nocturne elbow
#

yeah tell the server software maintainers to fix it lol

#

or use an actually functional and stable modded platform

#

I would do the latter

stoic nest
#

rip alrighty, ty for the help

rain yarrow
#

helo

#

how can i have a rankup system in my server with luckperms ?

nocturne elbow
#

With the API?

steady glade
#

why wold this return null? look at line 96

nocturne elbow
#

Well what if there is no meta node for the key "land"? In that case getMetaValue will return null

#

Unless you're referring to something else

steady glade
nocturne elbow
#

?????????????????????

steady glade
#

hmm gimme a sec lemme just quick check my code

steady glade
#

Why would this return null?? Did I do something wrong? or is there a better way of getting a user's group and getting that groups prefix/Suffix? Same thing for the user

wild whale
#

if you're just trying to get their active prefix, I usually find the vault api to be easier than LP

obtuse jolt
#

User may not been loaded? Depends on what exactly is null

steady glade
#

Im trying to get there groups prefix and it seems that getting there prefix somehow returns null and I don't get why

turbid solar
#

does the prefix show in /lp user <user> info?

#

Is the user offline?

nocturne elbow
#

How can i get group int?
Something like when i do logger:
getLogger.info("Loaded" + LoadedGroupsHere + " Groups");

turbid solar
#

GroupManager#getLodedGroups?

#

ugh

nocturne elbow
nocturne elbow
#

It returns with [me.lucko.luckperms.common.api.implementation.ApiGroup@123455]

turbid solar
#

.size()

nocturne elbow
#

Thanks it's working!

nocturne elbow
#

Why i can't change rank for player?

#

What is wrong?

#

lp.getUserManager().getUser(target.getName()).setPrimaryGroup("VIP");

#

that's not really what setPrimaryGroup is for

#

!cookbook check out the cookbook for some examples

frank driftBOT
nocturne elbow
#

Can you show me an example to how i set a specific player to a specific rank?

#

I didn't find any good examples

turbid solar
bleak fulcrum
#

Hi guys! If I try to register the service in my Main class using RegisteredServiceProvider and do if (provider != null) {
LuckPerms api = provider.getProvider(); it just give me an error, if I try to start the server without this part, it just says that the API isn't loaded!

bleak fulcrum
#

Just fixed this, but how can i use the api in other classes?

nocturne elbow
#

By passing it around to the other classes, generally through their constructors

bleak fulcrum
#

That's my main onenable part:
private static Main plugin;

@Override
public void onEnable() {
    plugin = this;
    PluginManager pm = Bukkit.getPluginManager();
    RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
    LuckPerms api = provider.getProvider();
    pm.registerEvents(new Events(api), this);
}

but i get this error when loading the plugin java.lang.NullPointerException: Cannot invoke "org.bukkit.plugin.RegisteredServiceProvider.getProvider()" because "provider" is null

#

can't pastebin it because my pc is very slow

nocturne elbow
#

yeah you gotta check if provider is null

#

did you add LuckPerms as a depend in your plugin.yml?

bleak fulcrum
#

softdepend

nocturne elbow
#

how are you building your plugin?

bleak fulcrum
#

maven

nocturne elbow
#

send the pom.xml please

bleak fulcrum
#

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>

<repositories>
    <repository>
        <id>spigotmc-repo</id>
        <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
    </repository>
    <repository>
        <id>sonatype</id>
        <url>https://oss.sonatype.org/content/groups/public/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.spigotmc</groupId>
        <artifactId>spigot-api</artifactId>
        <version>1.16.4-R0.1-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>net.luckperms</groupId>
        <artifactId>api</artifactId>
        <version>5.2</version>
    </dependency>
</dependencies>

</project>

#

the important parts are these

#

and the java version is 15

nocturne elbow
#

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

bleak fulcrum
#

if (provider != null) { LuckPerms api = provider.getProvider(); }
pm.registerEvents(new Events(api), this);
why api is returned as unknown?

nocturne elbow
#

?

bleak fulcrum
#

fixed

#

it was returning an unknown variable in the new Events(api)

nocturne elbow
#

yeah because in there api is inside the if block, and you were trying to use it outside

bleak fulcrum
#

WORKS

#

TYSM

#

how can i check if a player is in one of 3 groups?

#

for (String VIPs : VIPs)
if (user.getPrimaryGroup().contains(VIPs)
something like that?

#

public final List<String> VIPs = Arrays.asList("Superior", "Legend", "Void");

#

that's the VIPs array

nocturne elbow
#

!API There's an example method you can use for that in the first or second API page linked here

frank driftBOT
bleak fulcrum
#

Can this works?
public final List<String> VIPs = Arrays.asList("Superior", "Legend", "Void");

for (String VIPs : VIPs)
if (p.hasPermission("group." + VIPs)) {

nocturne elbow
#

yeah that would do it

#

actually no

#

String VIPs : VIPs
the string variable can't be named the same as the list itself

#

name it vipGroup or something idk

bleak fulcrum
#

nope seems not working

nocturne elbow
#

How can I use LP api with bungeecord api?

#

The same way you'd use it on every other platform, the LP API is platform agnostic

#

!api in the first page you'll find lots of concepts you'll benefit from knowing, and the second one goes over the LP API itself and many things you will probably end up doing

frank driftBOT
nocturne elbow
#

How would I get a user instance tho?

#

That is explained in the dev api usage page

#

yes but in bungee there is no Player variable

#

ProxiedPlayer

#

Same thing

#

only ProxiedPlayer and I tried with that and it didnt work

#

What did you try exactly

#

or not

flint anvil
#

is GroupManager#getLoadedGroups() guranteed to have every group that is currently assigned to a player on the proxy? (velocity)

turbid solar
#

@thorny echo all channels

thorny echo
#

Thanks

flint anvil
nocturne elbow
nocturne elbow
flint anvil
nocturne elbow
#

Odds are all groups will be loaded at all times unless another plugin unloads them, it's not something I generally worry about

proud iron
#

How can i check permission time expire event or group/perm expire/remove event on a player?
UserDataRecalculateEvent isn't working. (I've tried debug no any responding)

nocturne elbow
#

NodeMutateEvent/NodeRemoveEvent

hardy sedge
#

Hi, I'm just porting a plugin to run on Bungee, can reuse the same API calls (and repos) or will it be different?

nocturne elbow
#

It's the same API anywhere you use it, entirely platform agnostic

hardy sedge
#

Perfect

#

ty

fathom terrace
#

how do i link my bungeecord lp to my servers?

nocturne elbow
#

With the API?

proud iron
nocturne elbow
#

getTarget()

#

And check if it's a User

paper burrow
#

Hello how to reset Prefix/Suffix by api?

#

<@&420243840985989121> 🙂

raven pelican
#

Hey how can I clear ALL Meta Data for a Player?

nocturne elbow
#

.data().clear(NodeType.META::matches)

mild shell
#

how i can put custom contexts here?

#

like essentialsx

obtuse jolt
#

!api

frank driftBOT
obtuse jolt
lyric tiger
#

I am trying to get how much time a player has a permission left. I am struggling to find where this is in the docs. Could any one point me in the right derection?

#

I need to get the amount of time before the permission node expires into a string

#

ok now i can not get the player info

nocturne elbow
#

yeah because Player is not a class in bungeecord

#

use the corresponding equivalent

lyric tiger
#

ok

#

that worked

#

it is still not liking

nocturne elbow
#

the example assumes you have a luckPerms variable

#

of type LuckPerms

#

which is the main API class you work with

modest token
frank driftBOT
#

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

nocturne elbow
#

no

modest token
#

well can you answer my question then ?

nocturne elbow
#

not here

modest token
#

k

nocturne elbow
#

i'm busy

lyric tiger
#

Ok i am not able to get any thing out of it

#

i got the player name but i can't get the Expiry

#

what would i have to uses to get the Expiry

nocturne elbow
#

Probably something like

user.getNodes().stream()
    .filter(Node::hasExpiry)
    .filter(NodeMatcher.key("some.permission"))
    .map(Node::getExpiryDuration)
    .findAny().orElse(null)
#

Or something similar

lyric tiger
#

Now i get a null pointer exception

#

23:36:43 [WARNING] Error dispatching event PostLoginEvent(player=ldash5) to listener me.dash.events.Events@778ca8ef
java.lang.NullPointerException
at me.dash.events.Events.postLoginEvent(Events.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.md_5.bungee.event.EventHandlerMethod.invoke(EventHandlerMethod.java:19)
at net.md_5.bungee.event.EventBus.post(EventBus.java:47)
at net.md_5.bungee.api.plugin.PluginManager.callEvent(PluginManager.java:412)
at net.md_5.bungee.connection.InitialHandler$6$1.run(InitialHandler.java:536)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.lang.Thread.run(Thread.java:748)

#

it looks like User user = luckPerms.getPlayerAdapter(ProxiedPlayer.class).getUser(player); is returning as null

nocturne elbow
#

Can't really tell with just a single line

#

Share the whole method up until that point

lyric tiger
#

import me.dash.send.Send;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.model.user.User;
import net.luckperms.api.node.Node;
import net.luckperms.api.node.NodeType;
import net.luckperms.api.node.matcher.NodeMatcher;
import net.luckperms.api.node.types.InheritanceNode;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;

import java.time.Duration;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

public class Events implements Listener {

    private Send plugin = Send.getInstance();
    @EventHandler
    public void postLoginEvent(PostLoginEvent event) {

        ProxiedPlayer playerr = event.getPlayer();

        if (playerr.hasPermission("send.1")) {


            LuckPerms luckPerms = null;
            User user = luckPerms.getPlayerAdapter(ProxiedPlayer.class).getUser(playerr);

          Duration test = user.getNodes().stream().filter(Node::hasExpiry).filter(NodeMatcher.key("some.permission")).map(Node::getExpiryDuration).findAny().orElse(null);

            playerr.sendMessage(new TextComponent(test.toString()));
            ProxyServer proxy = ProxyServer.getInstance();
            ServerInfo target = ProxyServer.getInstance().getServerInfo("hell");
            playerr.connect(target);
            //proxy.getPluginManager().dispatchCommand(proxy.getConsole(), "send " + player + " hub2");
        }



    }



}```
nocturne elbow
#

Well... You are setting luckPerms to null

#

Of course

#

You should definitely read this page, more specifically the section that says "getting a LuckPerms instance" or something https://luckperms.net/wiki/Developer-API

lyric tiger
#

it does not have one for bungee

nocturne elbow
#

Read the page

#

There is one that literally says "this will work on all platforms"

lyric tiger
#

same thing

#

i used LuckPerms luckPerms = LuckPermsProvider.get();

nocturne elbow
#

"same thing" meaning...? Does it still throw an exception? Are you getting a new error? Does it even compile?

lyric tiger
#

23:50:44 [WARNING] Error dispatching event PostLoginEvent(player=ldash5) to listener me.dash.events.Events@2bfeb1ef
java.lang.NullPointerException
at me.dash.events.Events.postLoginEvent(Events.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.md_5.bungee.event.EventHandlerMethod.invoke(EventHandlerMethod.java:19)
at net.md_5.bungee.event.EventBus.post(EventBus.java:47)
at net.md_5.bungee.api.plugin.PluginManager.callEvent(PluginManager.java:412)
at net.md_5.bungee.connection.InitialHandler$6$1.run(InitialHandler.java:536)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.lang.Thread.run(Thread.java:748)

#

that is what i am giting

#

and yes it compiled

nocturne elbow
#

Please use a paste site

#

!pasteit

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!

nocturne elbow
#

Looks horrible on mobile lol

lyric tiger
nocturne elbow
#

And share the code again too

lyric tiger
#

that is the code

turbid solar
#

test is null

nocturne elbow
#

Actually, you should really learn how to use Optional, it's a crucial class to handle nullability

lyric tiger
#

thank you for the help

#

how would i remove the Optional part in the start

turbid solar
#

check if its present then .get()

nocturne elbow
#

Hi ! is there a method I can call that creates a group as if it was in game command ?

nocturne elbow
#

closest thing I found but it wont work, cant have arg input apparently from there ?

turbid solar
#

d;lp GroupManager#createAndLoadGroup

slate deltaBOT
#
@NonNull
CompletableFuture<Group> createAndLoadGroup(@NonNull String name)
throws NullPointerException```
Description:

Creates a new group in the plugin's storage provider and then loads it into memory.

If a group by the same name already exists, it will be loaded.

Returns:

the resultant group

Parameters:

name - the name of the group

Throws:

NullPointerException - if the name is null

turbid solar
#

It returns a CompletableFuture

#

Look at pins

nocturne elbow
#

ugh

#

I guess i'll have to learn some more stuff before

#

thanks anyway

pastel quiver
#

!online

frank driftBOT
#

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

pastel quiver
#

!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

pastel quiver
#

!usage

frank driftBOT
nocturne elbow
#

d;lp GroupManager#createAndLoadGroup

slate deltaBOT
#
@NonNull
CompletableFuture<Group> createAndLoadGroup(@NonNull String name)
throws NullPointerException```
Description:

Creates a new group in the plugin's storage provider and then loads it into memory.

If a group by the same name already exists, it will be loaded.

Returns:

the resultant group

Parameters:

name - the name of the group

Throws:

NullPointerException - if the name is null

nocturne elbow
#

How do I use this in my code ? Nothing seems to work

#

Never encountered this syntax before so I looked up up what completable future is but it doesnt use this syntax either

#

Please help

turbid solar
#

!api

frank driftBOT
turbid solar
#

Also look at pins

nocturne elbow
nocturne elbow
#

I dont understand how it relates to this messaging service thing ? I thought i'd just have to call a method lol

#

ok thanks for link

#

The thing is none of their methods are being recognized in my code, even if I copy exactly what's in their example.

#

I seem to have imported the right things tho

#

I dont understand

#

I kind of get what's an completable future is now but nothing explains why this doesnt work

obtuse jolt
#

looks like you are very new to java itself?

nocturne elbow
#

Yes but I had no problem doing other things until now

#

I dont understand why those methods aren't recognized, I've tried every syntax possible

obtuse jolt
#

actionLogger is just an example variable, you need to actually use a variable that is present in your own class

#

CompletableFuture<ActionLog> getLog(); is a method in the log api interface, not something you use in your own code.

nocturne elbow
#

ah

#

Well that's why it seems weird to me I guess. My whole goal is to be able to create a group within my code and I got refered to this

#

d;lp GroupManager#createAndLoadGroup

slate deltaBOT
#
@NonNull
CompletableFuture<Group> createAndLoadGroup(@NonNull String name)
throws NullPointerException```
Description:

Creates a new group in the plugin's storage provider and then loads it into memory.

If a group by the same name already exists, it will be loaded.

Returns:

the resultant group

Parameters:

name - the name of the group

Throws:

NullPointerException - if the name is null

nocturne elbow
#

this isnt something we use in our code then ?

#

thought it was a kind of method that would call a "create group" command

obtuse jolt
#

the method is createAndLoadGroup in GroupManager class yea

#

so first you need the GroupManager instance variable

#

then assume its called manager, do manager.createAndLoadGroup("testname")

#

then from there, handle the completable future.

nocturne elbow
#

how can i remove all meta prefixed with defined weight?

obtuse jolt
#

From user or group?

#

d;lp UserManager#searchAll

slate deltaBOT
obtuse jolt
#

anyways both managers have a search all method

nocturne elbow
#

from user

nocturne elbow
nocturne elbow
obtuse jolt
#

yea you need to get an instance of a from the api

#

Basic oop design pattern for managers

obtuse jolt
# nocturne elbow from user

you can searchAll then filter NodeType and its weights. But note it may only return results of loaded users (i.e. offline users may not be loaded unless manually call loadUser, tho it will be a very expensive call)

nocturne elbow
#

i need it for just one user, i have the uuid

obtuse jolt
#

ah I assume you said all means everyone

nocturne elbow
#

is it a similar instance I need to get that is "specialized" for Group Manager ?

turbid solar
#

api.getGroupManager

obtuse jolt
#

yea ^^

nocturne elbow
#

ooooh

#

here it goes

obtuse jolt
nocturne elbow
#

thanks i will try it

#

Many thanks so far guys, so

#

this is used like any other method or does the Completable future type makes it deifferent ?

obtuse jolt
nocturne elbow
#

ok will do, thanks !

nocturne elbow
#

Figured lot of stuff out but I dont know what I'm doing wrong here

#

basically it's a command that create a group (supposedly)

#

I add prefix to check if it works well

#

the command work in game, the group is created, but the prefix doesnt add

#

seems like the player isnt assigned to the group

turbid solar
#

well for 1. you're not actually creating the group

#

and 2. look at the cookbook how to set someone's rank

#

!cookbook

frank driftBOT
nocturne elbow
nocturne elbow
#

Figured it out, just had to use join() method on the completablefuture to force the asynchronous return before processing next command.....

turbid solar
#

.join blocks the thread btw

nocturne elbow
#

yea I kinda understand now, but it's fine here it works instantly. I guess the problem was that the getGroup() command was processed one millisecond before the completablefuture was... lol

paper burrow
#

how can i get the user Weight!!!

#

<@&703975641728548874>

nocturne elbow
#
  1. Users don't have weight, groups do
  2. Stop trying to @ staff roles
paper burrow
#

ok

trail jungle
#

Hi, lpc is disabling essentials nicknames in 1.17?

#

Is there any way around it with papi not being updated yet?

nocturne elbow
#

wat

#

what does any of that have to do with the LP API

winged schooner
#

Hi guys! Is there any way to setup the server name programmatically through the API?

obtuse jolt
#

no

#

either in config, or i think you can use a java startup flag to define it

winged schooner
#

Eh would be great to can handle it, because I'm running my server instances in docker containers started from a template image

winged schooner
#

Thank you guys 🙂

round skiff
#

How do I get the time left on someones rank?

#

With api

round skiff
#

I can get the group but not the time left

round skiff
#

@thorny echo

frank driftBOT
#

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

round skiff
#

@rustic laurel

frank driftBOT
#

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

round skiff
#

@neat jackal

frank driftBOT
#

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

round skiff
#

@wild whale

frank driftBOT
#

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

round skiff
#

TwoTwovR is scamming

#

its a phishing link

#

you can see the link is mispelled

turbid solar
#

No need to tag every single mod/helpful btw

thorny echo
#

Uh I mean thanks but no need to tag all the mods 😄

#

Best is to pick one, wait 5 minutes, then ping another if the first doesn't see

round skiff
#

well didn't wnat someone to lose their steam account

#

cause if they did they could lose a lot of stuff

round skiff
#

so does anybody know the answer to my questions?

round skiff
#

I've been looking arouind and I can't find it

#

Halp

round skiff
#

HALp

#

hALp

#

this is why I hate using lesser used apis

#

no proper documentation

#

barely anybody to ask lol

round skiff
#

please someone, end my suffering

nocturne elbow
#

Can you stop whining and wait patiently like any self respectable human being?

#

Jesus Christ

#

Get the user's inheritance nodes, filter by those that have an expiry left and then get the expiry duration, you'll end up with a collection of Durations

nocturne elbow
nocturne elbow
#

I would go as far as saying that the LuckPerms API is more documented than Bukkit API, which is full of uncertainty, inconsistencies and straight up lies

violet jewel
round skiff
#

I'm sorry

#

I'll stop

round skiff
#

how do I search for specific node?

#
luckapi.getUserManager().getUser(player.getUniqueId()).getNodes().stream().filter(Node::hasExpiry).filter(NodeMatcher.key("group.test")).map(Node::getExpiryDuration).findAny().orElse(null)```
#

When I try this I get "PT730H14M57S"

#

The player has 4 weeks left

turbid solar
#

you can do your own thing to make that look nice

round skiff
#

thanks!

round skiff
#

How would I add a temporary rank?

nocturne elbow
#

!cookbook See the examples in this repo for how to give a parent group in general

frank driftBOT
nocturne elbow
#

The only thing you'd need to change is when building the inheritance node

round skiff
#

ok

#

I will try

round skiff
#

Is there an easy way to accumulate?

#

Or should I just get the time

#

time left

nocturne elbow
#

There is an add method in NodeMap that takes a TemporaryModifierMergeStrategy or some obnoxiously long-named enum class like that

round skiff
#

oh

#

um ok

#

I tried doing this

#

However it just stays

#

and even weirder

#

It becomes 29

nocturne elbow
#

TemporaryNodeMergeStrategy*

round skiff
#

I'm kinda a noob, how do I use it?

nocturne elbow
#

it's a method named add just like the one you're using

#

but instead of taking a single Node, it takes a Node and a TemporaryNodeMergeStrategy

round skiff
#

ah

#

thank you1

south hull
#

is it possible to add the luckperms bukkit as a dependency in maven? i tried this, but it said that it couldnt find the artifact.

  <groupId>net.luckperms</groupId>
  <artifactId>bukkit</artifactId>
  <version>5.2</version>
  <scope>provided</scope>
</dependency>```
nocturne elbow
#

there is no platform specific api, there is one universal api, entirely platform agnostic

#

!api

frank driftBOT
south hull
#

i already have the api one, i just want to be able to look at the code of the bukkit one in my ide

#

because it helps me understand what code does better when i look at the code

nocturne elbow
#

there is no "bukkit one", again it's completely platform independent; and you shouldn't have to worry about implementation details

#

as the definition of "API" implies, it is purely interfaces, the API jar contains no implementation

jaunty pecan
#

also

#

!cookbook

frank driftBOT
nocturne elbow
#

Does anyone know if it's safe to add nodes to a user's transient node map in events such as UserDataRecalculateEvent or UserCacheLoadEvent? it is not >:(

#

Anyone = @Luck 😩

jaunty pecan
#

should be fine

#

I don't see why not

#

but also idk why you'd want to

nocturne elbow
#

It isn't, adding a node invalidates caches which dispatches the data recalculate event

#

I'll end up with a nice and easy SOE lol

nocturne elbow
#

Hm I actually can handle this to not end up with a SOE

jaunty pecan
#

yes but why

#

what's the end goal

nocturne elbow
#

For a "cumulative/arithmetic" nodes extension, basically if I inherit meta griefdefender.bonus-blocks from two different groups with two different values, to add the values and put the node in the user's transient node map
Same would go for permissions, kinda like plots.plot.<value> (which is not a meta node for some reason >.>)

prisma trout
#

is there any reason i shouldn't use luckperm's meta API to store things like game statistics and stuff on a player

nocturne elbow
#

no

#

:)

jaunty pecan
#

just write a listener in such a way as to not trigger recursive updates

#

:>

#

i.e. don't try to add a node to the map if one is already there

nocturne elbow
#

lmao

#

yes

#

I think the best approach here is to tag the added nodes with metadata

dull rover
#

Got an interesting one. So I have a public project I designed back in the 2017 era. Part of the project involves adding and removing permissions from players. In the original implementation, and current that is, I just used the Vault permission API to add / remove permissions. When LuckPerms started getting attention and enforced the permissions async stuff with a config option, it started to break the implementation as this was running sync. So I figured an easy fix was throwing it async which worked fine until I found out a decent portion of the project users still uses PermissionsEx, and you know what happens when you async Vault permissions with PEX? It freaks out and doesn't allow it. So here we are, in 2021 and I have a janky module in my project that goes async / sync based on a config option.

So, given that entirely way too long context of a story. Now that we're in 2021, is there a better approach to designing this system to give / remove permissions in a way that would keep all permission plugins happy?

nocturne elbow
#

Additionally, UltraPermissions' Vault integration is broken :kekw: