#luckperms-api

1 messages · Page 46 of 1

nocturne elbow
#

What do you want to do?

flint vine
#

why when i use setPrimaryGroup(args[0]); nothing changed in the game and in the database ?

nocturne elbow
#

That's not what I asked, please re-read my messages

flint vine
#

i want to change the primary group

#

and there is a method in the api setPrimaryGroup

#

but it's not effect any thing

nocturne elbow
#

Do you want to change the user's parent groups?

flint vine
#

no primary group

nocturne elbow
#

By default the primary group is the parent group with highest weight

flint vine
#

i understand now sorry for misunderstanding.

nocturne elbow
#

If you want to change the user's parent groups (which will in effect change the primary group), there is an example in the cookbook repo for it

past patio
frank driftBOT
past patio
#

That is the code

nocturne elbow
#

Use equalsIgnoreCase and screenshot /lp listgroups

past patio
#

yes my server is crasht i cannot be started

nocturne elbow
#

welp

turbid solar
#

Setup weights

#

@past patio

past patio
turbid solar
#

!weights

frank driftBOT
#

LuckPerms allows you to set weights in order to determine the priority of certain nodes, like permissions and even prefixes. A higher weight number is a higher priority.

past patio
#

that work that

#

thanks

paper burrow
#

can i give Temp Group with API?

#

<@&301745567137136650>

nocturne elbow
#

bruh....

paper burrow
#

...

nocturne elbow
#

you're lucky role pings are disabled

paper burrow
#

sorry< but my question

nocturne elbow
#

yes

#

wait patiently

#

there are other people asking for help and I only have two hands and a single pair of eyes

paper burrow
#

xD!

nocturne elbow
#

what's so funny

paper burrow
#

nvm

flint vine
#

emilyy is the best

paper burrow
#

emilyy is the best

nocturne elbow
#

With a few modifications

paper burrow
#

ik that but how can i set time?

nocturne elbow
#

First: not clearing the inheritance nodes the user has
Second: adding an expiry to the node (see the method .expiry(Duration) in the node builder)

paper burrow
#

okay thank u

flint vine
#

i didn't found it

paper burrow
nocturne elbow
flint vine
nocturne elbow
#

the method is in the node builder, not after you built it

#

so like InheritanceNode.builder(group).expiry(...)

flint vine
#

i understand thank you emilyy

nocturne elbow
#

yw

paper burrow
#

emilyy the Duration is in seconds or millseconds or in timestamp

nocturne elbow
#

There are several expiry methods, you can use the one that takes expiry(long duration, TimeUnit unit) (TimeUnit is an enum I believe)

wide widget
#

How do i give permissions to people

#

so they can do /spawn

#

and come to spawn

turbid solar
#

With the api?

wide widget
#

i added LuckPerms

#

and EssentialsX

turbid solar
#

So no

wide widget
#

and the EssentialsSpawn

turbid solar
wide widget
#

oh

#

ok

steel gull
#

I codet a little plugin with luckperms and since i updatet the version of Luckperm on my 1.12.2 paperspigot server to the newest i got this error https://paste.lucko.me/IeqiutAsSZ. What could I do?

#

is it just a problem with the version? or is there a newer version of the api?

frank driftBOT
steel gull
#

changed nothing ... same error and i´m using in my plugin the latest version of the api

nocturne elbow
steel gull
#

yes i think so ...

#

but i need to look if i had done it

nocturne elbow
#

@steel gull if you're still having this issue please send the whole logs/latest.log + plugin.yml + the relevant code

steel gull
#

ok thanks but i didnt found time to test it yet but i think that was my problem

nocturne elbow
#

Oki

paper burrow
#

Hi, I have a problem that is a little complicated

Now I have 5 ranks
Owner

  • Admin
  • Builder
  • Member
  • default

I was given permission to the rank of Default and the inheritance to the rank of Member, after which the inheritance status from the rank of Member to Builder permissions The default does not come to the rank of Builder Why?

nocturne elbow
#

uh what is this to do with the api?

paper burrow
#

ahh wrong chat.

vale wren
#

Hello,
I am trying to make a levelling system. If a player gets enough XP, he levels up and that sets his prefix to Level (his new level).

Thats how I tried to do it using this method in one of my classes:
|| public static void setPrefix(String name, String string) {
Node node = Node.builder("prefix.0." + string).build();
api.getUserManager().getUser(name).getNodes().add(node);
api.getUserManager().saveUser(api.getUserManager().getUser(name));
} //usage in any other class is (class).setPrefix("examplePlayer1", "§8[§c§lLevel 2§8]");||
but it does not work. The player will not have any other prefixes on him (except the one in his primary group, but no prefixes on the user him/herself).

So.. how do I set a prefix using lpApi?

#

It does not add the permission "prefix.0.xxxx" at all.

obtuse jolt
#

!api

frank driftBOT
obtuse jolt
#

look into PrefixNode

#

also take note of the weight that you set, by default, only highest weight is shown

vale wren
#

PrefixNode node = PrefixNode.builder(100, "[Some Prefix]").build();
the args of the builder(int, string) seem to be incorrect as ide is marking the builder method as en error and wants me to leave the () empty

obtuse jolt
#

either your ide has some issues, or you are using an old version of lp api

#

oh wait its prefix first then priority lol

vale wren
#

yeah

#

vice versa

obtuse jolt
#

open a PR to fix that in the wiki, the dev will probably response in a few days

vale wren
#

alright

#

Oh, now it finally works.

#

The cause was that i was using api.getUserManager().getUser(user).getNodes().add(node);, but should be api.getUserManager().getUser(user).data().add(node);

#

thanks:)

vale wren
#

also, is there a way of removing all prefixes an user has on him/herself, when the users group.xxxx changes?

obtuse jolt
#

you can just query user for all prefix node and remove them

vale wren
#

well the problem is that I need to remove all prefixes when a group is changed by the DiscordSRV plugin, which synces groups between discord and minecraft

#

when a role is changed and replaced by an another one on discord, you get the new role ingame but it wont remove ur prefixes (if you have any)

obtuse jolt
#

honestly, why cant you just set prefix in the group?

obtuse jolt
vale wren
obtuse jolt
#

nickname?

vale wren
#

oh i just realised something, maybe i dont need to get the nickname from e.getTarget() (PermissionHolder)

obtuse jolt
#

yea you should do that

vale wren
#

havent tried that yet but ill better ask cuz it feels wrong to me, im new to the lp api

#

e.getNode().toString().contains("group")

#

will this work? check if the node is group.xxxx

obtuse jolt
nocturne elbow
#

lol

obtuse jolt
#

its like doing int x = 1, if (x.toString() == "1")

nocturne elbow
#

you should get the node and check if the type is of NodeType.INHERITANCE

vale wren
obtuse jolt
#

basically yea

vale wren
#

alright

obtuse jolt
#

its a more robust way of doing things

vale wren
#

well... i tried using NodeAddEvent with debug messages and it doesnt seem to be reacting to DiscordSRV's role syncing (which basically just adds group.xxxx if you get the xxxx role on discord

#

found UserDataRecalculateEvent on github, but i cant get the node from there (or maybe im just too blind)

obtuse jolt
#

issit like through an automated lp command?

#

Also how are you registering the event? its different from normal bukkit events btw

vale wren
#

I did not know about the registering.. imma try it rn

vale wren
#

alright so discordsrv uses Vault to add assign groups

molten fjord
#

wait what is that

vale wren
#

i dont know what am doing wrong, but the NodeAddEvent still doesnt work for me:

||public class LpListener {
private final Main main;
private final LuckPerms luckPerms;

public LpListener(Main main, LuckPerms luckPerms) {
    this.main = main;
    this.luckPerms = luckPerms;
}

public void register() {
    EventBus eventBus = luckPerms.getEventBus();
    eventBus.subscribe(this.main, NodeAddEvent.class, this::onNodeAdd);
}

private void onNodeAdd(NodeAddEvent e) {
    Bukkit.getPlayerExact("Vojtiisek").sendMessage("test message");
    if (!e.isUser())
        return;
    
    Bukkit.getPlayerExact("Vojtiisek").sendMessage("test message222");
    User target = (User) e.getTarget();
    
    this.main.getServer().getScheduler().runTask(this.main, () -> {
        if (e.getNode().getType().equals(NodeType.INHERITANCE)) {
            for (Node node : e.getTarget().getNodes()) {
                if (node.getType().equals(NodeType.PREFIX))             
                    e.getTarget().data().remove(node);
                }
            }
        }
    });
}

}
||
I dont even get the "test message" and "test message222" messages, when my group.xxxx changes (the old one gets removed and the new one is added)

vale wren
# molten fjord wait what is that

discordsrv is a plugin for integrating discord with a mc server, vault is a really popular api for doing stuff with permissions and economy i think

molten fjord
#

ah thx

vale wren
#

cuz it doesnt say so on the wiki

turbid solar
#

Send code

turbid solar
#

Are you initializing the class?

vale wren
#

well, at least im trying to

#

LpListener lpListener = new LpListener(this, api);
lpListener.register();

#

in onEnable

turbid solar
#

And?

vale wren
#

still nothing

turbid solar
#

Debug time

#

Add some loggers to the register method

vale wren
#

alright

turbid solar
#

!paste your code here

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!

turbid solar
#

Btw

vale wren
#

uuuuuuuuuuuuuuuh

#

ok it does not initialize the LpListener class at all

#

register() method does not work

#

none of the System.out.printlns work

turbid solar
#

So LpListener listener = new LpListener(...)

vale wren
#

how does that have effect

turbid solar
#

Then listener.register

vale wren
#

but alright

#

am i registering it correctly?

#

idk the lp api tbh

#

and im not a pro java programmer

#

did not do any

oak fjord
#

How can I remove prefix with specific weight?

#

I'm trying to create a custom prefix command, /prefix <prefix> will set the player prefix, and when they run /prefix only, the custom prefix will got removed.

obtuse jolt
#

you can just query user for prefix nodes and check its weight with PrefixNode#getPriority

oak fjord
#
user.data().clear(NodeType.PREFIX.predicate( prefixNode -> prefixNode.getPriority() == 2000));
``` like this?
nocturne elbow
#

if you can identify your custom prefix with priority 2000 yes

oak fjord
nocturne elbow
#

hm tbh all that async/futures/scheduler mixture is likely to not go very well

#

if you already have the User object, there is nothing to worry about in regards to doing things async

oak fjord
#

so it's okay not to run async if I already get the User object asynchronously?

nocturne elbow
#

Once you get the user object you don't really have to worry, unless you want to do something after calling UserManager#saveUser/modifyUser or delegate something to the server main thread, etc

oak fjord
#

alright yeah, i have that already.

#

thanks

nocturne elbow
#

yw

oak fjord
#

you need to save the user after adding/removing the prefix right?

nocturne elbow
#

Yes

oak fjord
#

aight, cool

fallow imp
#

Hello, If a player has not joined the server ever, would the UserManager.loadUser(hisUUID) return null? or just a user with the default group?

lament wraith
#

Hello! How can i remove custom player prefixes on group change?

nocturne elbow
frank driftBOT
lament wraith
#

Thank you very much!

vale wren
#

How do I get a full name of the permission node?

#

i mean, for example get "essentials.spawn" from a node

#

node.toString()?

obtuse jolt
#

if I am not wrong there is a getKey() method

vale wren
#

yeah there is, so this returns the node itself?

#

i mean, the permission name or how to call it

obtuse jolt
nocturne elbow
#

heyo

#

im playing with luckperms api atm

#

and i'd like for the permission updates to be instant but for some reason they are only applied upon relogging

#

i tried the solution in this issue to no avail

#

same problem occurs, only relogging applies the permission

#

here's my code

#
        Bukkit.broadcastMessage("added permission " + "hardcoregames." + kitInfo.getKitLowercase(kits));

        Node node = Node.builder("hardcoregames." + kitInfo.getKitLowercase(kits))
                .value(true)
                .expiry(Duration.ofHours(24))
                .build();
        user.data().add(node);
        HardcoreGames.getLuckPermsInstance().getUserManager().saveUser(user).thenRun(() -> {
            HardcoreGames.getLuckPermsInstance().getMessagingService().ifPresent(service -> {
                service.pushUserUpdate(user);
            });
        });```
nocturne elbow
#

Thanks for any help and if you do respond please ping me ^^

obtuse jolt
#

you are on a bungeecord network with permission stored on an sql database?

nocturne elbow
obtuse jolt
#

ok, right after adding that permision with your code, can you run /lp user USER permission check hardcoregames.kitnamehere

#

and send the screenshot

nocturne elbow
# obtuse jolt ok, right after adding that permision with your code, can you run `/lp user USER...

[08:26:24 INFO]: [LP] Permission information for hardcoregames.worm:
[08:26:24 INFO]: [LP] - clew2 has hardcoregames.worm set to true in context global.
[08:26:24 INFO]: [LP] - clew2 does not inherit hardcoregames.worm.
[08:26:24 INFO]: [LP]
[08:26:24 INFO]: [LP] Permission check for hardcoregames.worm:
[08:26:24 INFO]: [LP] Result: true
[08:26:24 INFO]: [LP] Processor: common.DirectProcessor
[08:26:24 INFO]: [LP] Cause: None
[08:26:24 INFO]: [LP] Context: (dimension-type=overworld) (gamemode=survival) (world=hungergames)

obtuse jolt
#

Result: true

#

means the permission has been set properly

nocturne elbow
#

yea, this is odd..

#

i just checked it and it gave me perm while online this time

obtuse jolt
#

probably your kits plugin isnt updating

nocturne elbow
#

but it took a second to update

#

maybe its cuz i typed that command above?

obtuse jolt
#

yea but definitely not relogin as you described

nocturne elbow
#

sorry wdym

obtuse jolt
#

same problem occurs, only relogging applies the permission

nocturne elbow
#

ohh

#

i see what u mean

#

ill give it a check, thank u

nocturne elbow
#

The lp check command

nocturne elbow
#

Do you reckon switching to User#hasPermission might fix it?

frank driftBOT
#

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

nocturne elbow
buoyant plaza
#

how do i recall the player's group (p1)?

nocturne elbow
#

Maybe

#

First read the rule #1 in #rules

nocturne elbow
nocturne elbow
buoyant plaza
#

I have to get the group with the highest priority of the player (p1)

nocturne elbow
#

!API
I suggest you read the 2 main general API usage pages, they contain useful information such as getting a User instance from a player etc

frank driftBOT
nocturne elbow
buoyant plaza
#

okay, thanks

nocturne elbow
#

emily, do u have any idea of how i can resolve this problem? my adding of perms to user wont work unless the player relogs

#
        Game game = Game.getSharedGame();
        if (game.getAllKitsFree()) {
            return true;
        }
        if (kits == Kits.NONE) { return true; }
        User user = HardcoreGames.getLuckPermsInstance().getUserManager().getUser(p.getUniqueId());
        if (user != null && hasPermission(user, "hardcoregames." + getKitLowercase(kits))) {
            Bukkit.broadcastMessage("has permission " + "hardcoregames." + getKitLowercase(kits));
        }
        if (user != null) {
            return hasPermission(user,
            "hardcoregames." + getKitLowercase(kits));
        }
        return false;
    }
    public boolean hasPermission(User user, String permission) {
        return user.getCachedData().getPermissionData().checkPermission(permission).asBoolean();
    }```
#

this is how i check for perms

#
        final LuckPerms api = LuckPermsProvider.get();

        KitInfo kitInfo = KitInfo.getSharedKitInfo();
        Bukkit.broadcastMessage("added permission " + "hardcoregames." + kitInfo.getKitLowercase(kits));

        Node node = Node.builder("hardcoregames." + kitInfo.getKitLowercase(kits))
                .value(true)
                .expiry(Duration.ofHours(24))
                .build();

        api.getUserManager().modifyUser(user.getUniqueId(), (User user1) -> {

                    user1.data().add(node);
                });


        api.getUserManager().saveUser(user).thenRun(() -> {
            HardcoreGames.getLuckPermsInstance().getMessagingService().ifPresent(service -> {
                service.pushUserUpdate(user);
            });
        });
        //HardcoreGames.getLuckPermsInstance().runUpdateTask();
    }```
#

this is how i give the perm

#

only works if offline upon login, or if online and perm given only works on relog

#

If you give me 10 minutes or so sure, can't read very comfortably from discord mobile

buoyant plaza
#

User rank = LuckPermsProvider.get().getPlayerAdapter().getUser(p1).getPrimaryGroup();

nocturne elbow
#

You need to pass the Player class to getPlayerAdater

#

Please lmk if u have any ideas

nocturne elbow
#

Player.class

buoyant plaza
#

Cannot resolve symbol 'Player'

#

User rank = LuckPermsProvider.get().getPlayerAdapter(Player.class).getUser(p1).getPrimaryGroup();

#

What dependency is Player.class?

nocturne elbow
#

I assume you're coding for Bukkit

buoyant plaza
#

no, bungeecord

nocturne elbow
#

Then pass the Class for whichever class you work with a player object

#

PlayerClassName.class

buoyant plaza
#

But I use bungeecord, I don't get that class

nocturne elbow
#

🤦‍♀️

#

Do you know what a Class object is?

buoyant plaza
#

😅

#

si

nocturne elbow
#

Which class do you use when working with player objects on bungeecord

buoyant plaza
#

ProxiedPlayer if I understand what you mean

nocturne elbow
#

Then you pass ProxiedPlayer.class, that will give you a Class object, which is what getPlayerAdater expects

#

You need a variable named group which you don't have.....

buoyant plaza
#

.getUser() what should i put inside?

nocturne elbow
#

The ProxiedPlayed object

#

Please read your own code

#

Your LuckPerms variable is named api

#

Not luckPerms

#

You also don't have a groupName variable

buoyant plaza
#

User user = LuckPermsProvider.get().getPlayerAdapter(ProxiedPlayer.class).getUser(p1).getPrimaryGroup();

#

so?

nocturne elbow
buoyant plaza
#

I shoot myself...

nocturne elbow
#

This is way beyond the LuckPerms API or the PEX API

#

This is basic Java knowledge

#

I can link you a few courses, guides and documentations for learning Java if you want me to

buoyant plaza
nocturne elbow
#

Can you people please disable reply pings?

nocturne elbow
#

hint hint, it returns a String

#

String groupName = "moderator"; idk, maybe it's in a command you get it as a command argument, there is no one singular way but you need a String groupName

buoyant plaza
#

String user = LuckPermsProvider.get().getPlayerAdapter(ProxiedPlayer.class).getUser(p1).getPrimaryGroup();

#

so?

nocturne elbow
#

sure

#

the variable name is a bit misleading but if that works for you

buoyant plaza
#

String rank = LuckPermsProvider.get().getPlayerAdapter(ProxiedPlayer.class).getUser(p1).getPrimaryGroup(); should the player's highest group return to me?

nocturne elbow
# nocturne elbow ```public void addKitFor24Hours(User user, Kits kits) { final LuckPerms ...

modifyUser already saves the data for you, you should call this:

...modifyUser(...
  // add node
).thenRun(() -> {
    HardcoreGames.getLuckPermsInstance().getMessagingService().ifPresent(service -> {
        service.pushUserUpdate(user);
    });
});

although since you already have the user object you can quite easily just

user.data().add(...);
...saveUser(user).thenRun(() -> {
    HardcoreGames.getLuckPermsInstance().getMessagingService().ifPresent(service -> {
        service.pushUserUpdate(user);
    });
});
buoyant plaza
#

when exporting the plugin with Maven this comes out

#

I uploaded this with Maven

#

package net.luckperms.api does not exist

#

.-.

nocturne elbow
#

I can't help you with the lack of Java knowledge and experience, this is not general development support, there are tons of servers out there you can get basic help with that, using the LuckPerms API requires some Java knowledge and so do we in any of these guilds:
The Coding Den: https://discord.gg/code
HelpChat: https://discord.gg/helpchat
Developer Den: https://discord.gg/Jbm4xXvC

buoyant plaza
#

in the code it goes, when exporto no

nocturne elbow
#

TecnoFra please paste your pom.xml in a paste site and send the link here

#

!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
#

And also describe step by step the way you are building your plugin too

buoyant plaza
nocturne elbow
#

you didn't add luckperms as a maven dependency

#

And you should also declare the bungeecord-chat dependency as <scope>provided</scope>, you probably don't want to shade that into your plugin, can lead to some nasty issues

buoyant plaza
nocturne elbow
#

looks good

steel gull
#

what need I to define as softdepend for luckperms ... the api name? the Filename of the Luckpermsversion?

nocturne elbow
#

What?

#

Just LuckPerms

steel gull
#

i try and get the same error just like without it as softdepend

nocturne elbow
#

Share your plugin.yml + the class in where you get the error

#

!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!

steel gull
#

first is the important thing of the plugin.yml the last the errormessage that the console shares

nocturne elbow
#

- LuckPerms, not -LuckPerms

steel gull
#

ok ..

nocturne elbow
#

yaml is a bitch but that's how lists work on it

steel gull
#

well ... im sorry i had to see that error

#

but thanks for your support

nocturne elbow
#

huh?

#

okay

nocturne elbow
# nocturne elbow `modifyUser` already saves the data for you, you should call this: ```java ...mo...

no such luck for me 😦 this is what i wrote ``` final LuckPerms api = LuckPermsProvider.get();

    KitInfo kitInfo = KitInfo.getSharedKitInfo();
    Bukkit.broadcastMessage("added permission " + "hardcoregames." + kitInfo.getKitLowercase(kits));

    Node node = Node.builder("hardcoregames." + kitInfo.getKitLowercase(kits))
            .value(true)
            .expiry(Duration.ofHours(24))
            .build();

    api.getUserManager().modifyUser(user.getUniqueId(), (User user1) -> {

                user1.data().add(node);
            }).thenRun(() -> {
                api.getUserManager().saveUser(user);

        HardcoreGames.getLuckPermsInstance().getMessagingService().ifPresent(service -> {
            service.pushUserUpdate(user);
        });
    });```
#

im assuming this is correct right? or did i miss something

#

also, typing /lp user (name) check permission (permission name here) updates the perms and it works in that case

#

but never from the command itself

#

you are not supposed to run saveUser and modifyUser together

#

modifyUser already saves the user

#

ah

#

either one or the other

#

perhaps soemthing like this?

#

        KitInfo kitInfo = KitInfo.getSharedKitInfo();
        Bukkit.broadcastMessage("added permission " + "hardcoregames." + kitInfo.getKitLowercase(kits));

        Node node = Node.builder("hardcoregames." + kitInfo.getKitLowercase(kits))
                .value(true)
                .expiry(Duration.ofHours(24))
                .build();

                    user.data().add(node);
                   api.getUserManager().saveUser(user).thenRun(() -> {
            HardcoreGames.getLuckPermsInstance().getMessagingService().ifPresent(service -> {
                service.pushUserUpdate(user);
            });
        });```
#

err

#

that saves it twice..

#

something like that instead maybe?

#

that doesn't save it twice?

#

that saves it once and it looks good

#

oh yeah just edited it, accidently put two save funcs xP

#

nope, didnt work :/ this is really confusing

#

still only works on relog

nocturne elbow
#

it runs on a certain command from console

#

with no errors or anything

#

on the server or on the proxy?

#

so on the server i believe

#

okay, screenshot /lp info please

#

sure thing

#

does luckperms have dev builds? maybe this is something fixed in more recent versions

#

there is no concept of "dev builds" really, each commit has its own build you can find at https://luckperms.net/download but keep in mind that yes, the "release" on spigotmc is not as updated as the one in the LP website

#

are you testing this on a network or in a single server only..?

#

i've tried on localhost and on my online server

#

same results

#

at least im pretty sure its luckperms fault because i think my plugin is handling the perms fault, but unsure of why

#

ill check my depends rq

nocturne elbow
#

everything's up to date and whatnot

#

gonna try a clean build on 5.3.37

#

no luck :/

#

wait

#

i just found something

#

if i run the command twice, it updates the previous perm but not the first one

#

can you show all of the relevant code? how you actually get to give the permission and where you check for it
https://paste.lucko.me/

#

sure thing

nocturne elbow
#

i apologize in advance for terrible formatting

#

i can fix that if its too much trouble to read

nocturne elbow
#

@nocturne elbow hate to bother you, but have you had a chance to look at my code yet?

frank driftBOT
#

Hey 🇨🇳中華人民共和国への栄光🇨🇳! Please don't tag helpful/staff members directly.

nocturne elbow
#

oop, sorry

sonic canopy
#

Hi guys, has anybody started working on an implementation of fabric-permission-api on top of vanilla commands ? (Please mention me in replies)

obtuse jolt
sonic canopy
#

I know but there still is a chance someone here has done it

obtuse jolt
nocturne elbow
nocturne elbow
sonic marsh
#

so I'm trying to create an addon for a skyblock plugin to allow for permissions to be granted to a specific set of people, but I don't want to actually add the permission to the player, since that is pretty janky, and if you revoke it could remove permissions gotten other ways.
is there an easy way to make another section like "groups"?

nocturne elbow
#

uh yeah that's literally what groups are for lol

sonic marsh
#

I'd prefer if it was a seperate section

#

since groups would make everything confusing af

nocturne elbow
#

I mean what you just described are groups

#

You could name it whatever you want, that is the definition of a group

#

Whether it's named "group" or "another section" sounds like you'd still need to use hundreds or thousands of them

#

What is this for exactly

#

Maybe granting the permissions to the players directly isn't as bad as you'd think, who knows

sonic marsh
#

thats why I don't want to add them to groups, since it would clog up everything

sonic marsh
#

now what

#

how do I know not to remove it

nocturne elbow
#

what?

sonic marsh
#

if someone has permission x, and then their island gets it, then it would just assign it twice.
then if they leave the island, they shouldn't lose the perm, since they had it beforehand

nocturne elbow
#

so you want to do like "island-granted" permissions or something?

#

or what do you mean by "a specific set of people"?

sonic marsh
#

well yeah, a team of people are on an island

#

maybe I could create something that luckperms checks on player login? and give it a list of permissions

#

but that are only temporary

nocturne elbow
#

temporary how? that are removed on logout?

#

or what?

sonic marsh
#

they're not located anywhere, luckperms just knows its there. kind of like there were 2 permission handlers

nocturne elbow
#

what??

sonic marsh
#

well I'm trying to make it not interfere with normal permissions at all

#

its just on top of normal perms

nocturne elbow
#

I'm having a hard time understanding what is it you're wanting to achieve in the first place

sonic marsh
#

basically make a way to grant a specific island an achievement, that Luckperms takes into account when deciding if someone has permission to do something, without granting it to the user themself, since that interferes with normal permissions

nocturne elbow
#

that sounds a whole lot like a group per island

#

is that what you're trying to avoid?

sonic marsh
#

yes

#

since think about how much that would be if you had 100 islands

#

and for example, my server has 800 islands registered.
I don't really want to make the web interface useless for example

nocturne elbow
#

i c

#

so in the end what you're trying to avoid is saving the data within LP's storage, right?

sonic marsh
#

well, not necessarily. idrc how its stored, but I'm willing to store it myself, if that makes things easier

nocturne elbow
#

Hm well I'm thinking of two possibilities

#

I take that back, I can think of one way only:

Use the transient node map; this is like the regular node map of the permission holder with the difference it is not saved to storage (see the documentation for PermissionHolder#transientData()). This would require for you to save the perms yourself and add them to the user's transient node map on UserLoadEvent.
Imagine a permission holder (group/user) has two permission maps, basically this

private final Map<String, Node> normalMap;    // this one is saved in storage
private final Map<String, Node> transientMap; // this one is not saved in storage

This has the advantage in your case that whatever you put in the transient node map does not directly interfere with the regular node map, but it is taken into account when calculating permissions.
The only disadvantage is what I said above:

This would require for you to save the perms yourself and add them to the user's transient node map on UserLoadEvent

sonic marsh
#

ok, cool. that was the idea I had, but I had no idea if it was possible

#

will it appear in the LP editor or anything?

nocturne elbow
#

I don't think it will, no

sonic marsh
#

good

#

thank you 🙂

nocturne elbow
#

yw

sonic marsh
#

actually, is it possible to add something to the UI?
like another section

#

I assume not, but idk I might as well ask

#

(The Web UI)

#

or a separate UI like the player only one

nocturne elbow
#

huh?

sonic marsh
#

like a web editor for islands. its a far-fetched idea, but idk

nocturne elbow
#

Well... you can kinda do something, but I don't think it mixes well with transient nodes, /lp editor <node prefix> will create an editor filtering users (not groups) that contain a node that starts with said prefix, so say for instance if I do something like /lp editor group.jr- that would bring up all users that have the group jr-moderator and jr-helper, just to put an example.
Again:

I don't think it mixes well with transient nodes
Since the data uploaded to the web editor is exclusively the one in storage

sonic marsh
#

ah, got it. maybe a web editor api at some point? :p

sonic marsh
#

;p ok

#

ty emily

nocturne elbow
#

yw

#

I'll add that to my endless "add to api" to-do list

#

or I'll just open an issue and do nothing about it :^)

sonic marsh
#

:p that works

nocturne elbow
#

(No pun intended) haha

nocturne elbow
# nocturne elbow https://paste.lucko.me/sG9Rds8Rgj

I'll have to read that some other day but this is the code I tested https://paste.lucko.me/R6xM7Cg1yu and these are the results for the following commands:

/testplugin givePermission some.permission
/testplugin checkPermissionPlayer some.permission
/testplugin checkPermissionUser some.permission

/testplugin removePermission some.permission
/testplugin checkPermissionPlayer some.permission
/testplugin checkPermissionUser some.permission
solar plank
#

hey so am adding a chat format system in my plugin and I was wondering on how to get a group prefix?

misty hinge
#

pretty easy

solar plank
#

never used luck perms api

#

so am confused

turbid solar
#

!api

frank driftBOT
turbid solar
#

!cookbook

frank driftBOT
misty hinge
#

cas smh

#

just do it with vault api

pine crow
#

Is there a way to check with luckperms api for all player ranks

#

So not only primary group

turbid solar
#

Yes

#

!cookbook has example

frank driftBOT
pine crow
#

alr thx

solar plank
#

is there a vault discord? I need help with the api of vault

turbid solar
#

No

misty hinge
rotund light
#

How do you use LP API to give a player temporary permission, not time limited. I mean it won't save?

#

Can't use Nukkit's internal permission system since installing LP messes that up

nocturne elbow
jaunty pecan
#

also, you can use the internal system too

#

PermissionAttachments

#

lp supports them just fine

rotund light
# jaunty pecan also, you can use the internal system too
        at java.util.Objects.requireNonNull(Objects.java:246) ~[?:?]
        at me.lucko.luckperms.nukkit.inject.permissible.LuckPermsPermissible.addAttachment(LuckPermsPermissible.java:247) ~[?:?]
        at cn.nukkit.Player.addAttachment(Player.java:533) ~[server.jar:?]
        at cn.nukkit.Player.addAttachment(Player.java:528) ~[server.jar:?]
        at zen.nukkit.permission.shop.Utils.Util.givePermissions(Util.java:63) ~[?:?]
        at zen.nukkit.permission.shop.Menu.User.UserMenu.lambda$userMenuWindow$3(UserMenu.java:75) ~[?:?]
        at zen.nukkit.permission.shop.Utils.MenuAPI.window.ModalWindow.triggerUpperClick(ModalWindow.java:87) ~[?:?]
        at zen.nukkit.permission.shop.NukkitEventListener.onDataPacket(NukkitEventListener.java:43) ~[?:?]
        at jdk.internal.reflect.GeneratedMethodAccessor17.invoke(Unknown Source) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
#

This happened when I tried to use internal system with LP installed

#

And my code was as simple as this

            PermissionAttachment attachment = player.addAttachment(Core.instance);

            command.getPermissions().forEach(permission -> attachment.setPermission(permission, true));

            player.recalculatePermissions();```
#

Not sure if I did something wrong or LP did something but that didn't work well

nocturne elbow
#

permission is null

#

like within the forEach

jaunty pecan
#

nah it's a dumb nukkit thing

#

one sec

rotund light
jaunty pecan
nocturne elbow
jaunty pecan
#

that's why ^ @nocturne elbow

#

code is from nukkit's Player class

nocturne elbow
#

oh

#

what the

#

that's stupid

rotund light
#

Oh boy

nocturne elbow
#

why is that even a thing... does that exist in Bukkit too?

jaunty pecan
#

no

rotund light
#

Pretty sure not.

jaunty pecan
#

just a random nukkit change

rotund light
#

Should I just use user.transientData().add(); then?

#

And how do you add add negative permission?

jaunty pecan
#

keep using your current code

#

to set negative permissions, use false instead of true for the value

rotund light
jaunty pecan
#

you might as well keep using permissionattachments, it's easier

#

(for what you're trying to do, anyway)

rotund light
#

Yeah. Thanks, you saved me

#

Using LP would be overkill

jaunty pecan
#

well, it depends :p

#

there are times where the permissionattachment API isn't enough

#

anyway, that build is live now

#

!download

frank driftBOT
rotund light
#

Thanks 🙏🏻

last grove
# jaunty pecan (for what you're trying to do, anyway)

Hey. Got time helping me? I am using Chatessentials and luckperms, ranks and prefixes are set up and done. And i have added myself to the group i want to be in. But the rank still does not show up ingame.. I got no clue how to solve this

nocturne elbow
frank driftBOT
#
LuckPerms does not perform any chat/tablist formatting of its own!

LuckPerms only acts as the source for prefixes / suffixes, it doesn't actually apply them. You need an appropriately configured chat/tablist formatting plugin for them to be displayed. If the values appear correctly when you run /lp user <user> info, LuckPerms is doing its job!

List of chat/tablist formatting plugins that work with LuckPerms
vital pewter
#

How can i clear player's specific MeteNode?

#

user.data().remove(xxx);
What should i write here

nocturne elbow
#

Take a look at the MetaNode.builder()

vital pewter
#

Should i build the same MetaNode to remove it?

#

Can i just remove it by key

nocturne elbow
#

If you want to use remove(Node) you need to pass the same one (key, value, expiry and contexts)

vital pewter
#

So i need to build exactly the same MetaNote to remove it?

nocturne elbow
#

If you want to remove by key you should use clear(NodeMatcher), take a look at NodeMatcher.metaKey(String) or .metaKey(MetaNode)

vital pewter
#

Ok thx

#

Uhmmm I can't access the JavaDocs

nocturne elbow
#

hm?

vital pewter
#

Bruh

nocturne elbow
#

Oh that yeah

#

Hopefully it will be fixed by v5.4 but as of now either navigate the javadoc "manually" instead of searching or remove that bit there from the URL

vital pewter
#

Ah thx

#

Hmmm it return a Matcher but not the note

nocturne elbow
#

Yes? That's what you need

vital pewter
#

So how can i get node by the matcher

#

Or how can i remove node by the matcher?

nocturne elbow
vital pewter
#

Uhmmm sorry

nocturne elbow
#

!api I suggest you read these two pages @nocturne elbow

frank driftBOT
nocturne elbow
#

!cookbook and here's an example plugin if you want to take a look at a "real" example

frank driftBOT
ocean citrus
#

Hello is there a way to get the prefix from a group?
I'm making my own plugin and I want to show the lp prefix in front of the name

something like this but instead of health I want to use the prefix and for that i need a ^part of the api I assume

ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard board = manager.getNewScoreboard();
 
Objective objective = board.registerNewObjective("showhealth", "health");
objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
objective.setDisplayName("/ 20");
 
for(Player online : Bukkit.getOnlinePlayers()){
  online.setScoreboard(board);
  online.setHealth(online.getHealth()); //Update their health
}
#

so that would be for example [member] Nauss

#

String prefix = metaData.getPrefix(); ?

jaunty pecan
#

Yes

ocean citrus
#

Well I'll try that

ocean citrus
#

What's the best way for obtaining an instance of the API for Bukkit?

craggy ember
#

Service provider

#

Services manager I mean

ocean citrus
#

So I would put that in the main class of my plugin?

craggy ember
#

Yes

#

Well, you can put it anywhere tbh

ocean citrus
#

oh

#

Well it seems that I have to import alot XD

craggy ember
#

Yeah that's fine

ocean citrus
obtuse jolt
#

did you like miss a semicolon on the previous line or smt

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

    }
obtuse jolt
#

wait

#

it looks like your are doing a if statement outside any method or constructor

#

which is not how java works

craggy ember
#

You can use anonymous labels as well, but those are weird

#

Should be able to initialise it in the constructor

#

Though because Bukkit, that is not recommended iirc

ocean citrus
#

so where would i put this?

#

RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);

obtuse jolt
#

you should just do RegisteredServiceProvider<LuckPerms> provider; in class field

ocean citrus
#

uhu

obtuse jolt
#

ifs your plugin's main class put setting the lp instance in the onEnable() method

#

or not you can put in the constructor of the class

#

if all these are very unfamiliar, then you probably want to look at java and oop fundamentals first

ocean citrus
#

Well yea i had some strange code and i was wondering where to place it

ocean citrus
#

And I'm looking for some code to add a lp prefix to minecraft nametag

coral prairie
#

I don't know if I'm completely dumb rn, but I have the following in my dependencies:

#

But still, I do not have anything LuckPerms-related being tab-completed

#

btw, mavenCentral() is in the repos

#

Okay, I just am dumb. restarted the ide, everything working

warm hazel
#

I was wondering if there's any reason why would luckperms api sometimes return null as user for players who are online, should I just add a null check and ignore it?

jaunty pecan
#

from what context are you calling getUser?

#

it should 100% always return a user for a player that is online

#

of course, it's possible that player objects stick around after the corresponding player disconnects, e.g. if stored in some collection and not cleaned up, among lots of other possibilities

warm hazel
#

i'm calling it in a repeating task and in join event, don't know which case was this

#

bukkit's Player#isOnline returned true

teal hill
#

I want to know when /lp user <player> parent set <group> is executed

What I tried: I tried using NodeAddEvent but i couldn't get enough information about event. (like user's uuid)``` luckperms.getEventBus().subscribe(this.plugin, NodeAddEvent.class, this::updateGroups);

turbid solar
#

I want to know when /lp user <player> parent set <group> is executed
what does this mean?

teal hill
#

Is there any event when user's parent changed.

turbid solar
#

yeah

teal hill
#

user's uuid would be enough

turbid solar
#

d;lp NodeAddEvent

slate deltaBOT
#
public interface NodeAddEvent
extends NodeMutateEvent```
NodeAddEvent has 2 super interfaces, 2 methods, and  1 extensions.
Description:

Called when a node is added to a holder

obtuse jolt
#

NodeAddEvent#getTarget

teal hill
#

Then theres no way to get uuid in Permission Holder ,_,

obtuse jolt
#

then i think you can cast to Player

teal hill
#

wow

#

wasn't know that

obtuse jolt
#

after checking its instance of Player ofc

teal hill
teal hill
#

using names gross

obtuse jolt
#

sorry not Player

#

its User

#

see this ^^ for code example

teal hill
#

ok will check rn ^^ thx

turbid solar
#

read the description of the java docs

teal hill
#

already done same thing 😹

turbid solar
#

if it's a user it'll return their UUID, if it's a group the groups name

teal hill
#

thx both ^^ this helped a lot

obtuse jolt
#

yea but probably better to use User#getUniqueId()

teal hill
obtuse jolt
#

since it returns a UUID object instead of string

wind moth
#

Which event is called if a user get a new group or the old group was removed?

teal hill
#

same question 😹

obtuse jolt
wind moth
wind moth
#

thx

candid vapor
#

How would I get a list of users whos primary group is xyz via the API?

turbid solar
#

!cookbook

frank driftBOT
candid vapor
#

perfect, thanks

turbid solar
#

For velocity, is it save to check a user's group on LoginEvent?

blissful sequoia
#

!sql

frank driftBOT
#

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

plucky beacon
#

Hi what's the API event for permission updates pls?

#

I'd like to update a player's display name when their permissions change

nocturne elbow
#

NodeMutateEvent

#

NodeAddEvent and NodeRemoveEvent if you want to do specific actions for those

#

But Mutate covers both

plucky beacon
#

Ah and silly question but can we subscribe to those using Bukkit listeners?

#

Ah

nocturne elbow
#

No

#

LP uses its own event system

#

!api

frank driftBOT
nocturne elbow
#

Explained in the first two links

plucky beacon
#

Ah ty

nocturne elbow
#

!cookbook There are also some usage examples in here:

frank driftBOT
plucky beacon
#

OOh UserDataRecalculateEvent

#

Perfect

#

This is the one

nocturne elbow
#

Eeh...

#

no

plucky beacon
#

yeye when their prefix changes

nocturne elbow
#

... okay

#

yeah ig that works actually

#

it's not necessarily related to permissions being added/removed

nocturne elbow
#

Hello. I need to simultaneously get the player and the group that is assigned to him through the command /lp <user> player parent set <group>. What event do I need to listen to for this?

I tried to do this using NodeAddEvent, but this event allows you to get only one thing - either the group or the player. Or I’m dumb and don’t know how to use it correctly. I tried:

public void onNodeAdd(NodeAddEvent event) {
        User user = null;
        Group group = null;
        if (event.getTarget() instanceof User) {
            user = (User) event.getTarget();
        }
        if (event.getTarget() instanceof Group) {
            group = (Group) event.getTarget();
        }
        System.out.println(user + " " + group);
}

but group is null. However, it was obvious, but I did not know what else to try. 😄

Anyway, who can help and tell me how to get the player and the group assigned to him at the same time?

#

The target is the User, and when setting a parent group you add an InheritanceNode, check if the event's Node is an InheritanceNode

#

And how can I get the group from this node?

#

InheritanceNode#getGroupName()

#

Then you can get the group from it with the GroupManager

#

oh, i've got it

#

thanks you very much!

#

@cedar dagger please don't misuse the channels

cedar dagger
#

not sure where to ask questions

nocturne elbow
#

general support goes in the support channels

#

not the api channel

cedar dagger
#

ok

rocky aurora
#

how can I get highest inherited group/parent of a player?

#

or is it always at the top of inherited group collection (User#.getInheritedGroups)

#

for ex. if a player has role C, which is a parent of role B, and B is parent of A

#

how do I get role C?

nocturne elbow
#

C in that case is the only direct parent group and if the config file is default it's also the primary group

candid vapor
#

how would i get the groups of an offline player? i see how to do it with an online player in cookbook, but PlayerAdapter does not work with OfflinePlayer.class

candid vapor
#

i know how to get an offline user, but the getInheritedGroups method takes QueryOptions. I don't know how to make that without PlayerAdapter

nocturne elbow
#

QueryOptions.builder(QueryMode)

#

then QueryOption.Builder#build()

#

or just PermissionHolder#getQueryOptions() if you don't want anything fancy (contexts etc)

candid vapor
#

ah, user.getQueryOptions, ty

turbid solar
#

d;lp User#getNodes

slate deltaBOT
#
@Unmodifiable @NonNull
default Collection<Node> getNodes()```
Description:

Gets a flattened view of the holders own Nodes.

This list is constructed using the values of both the normal and transient backing node maps.

It may contain duplicate entries if the same node is added to both the normal and transient node maps. You can use getDistinctNodes() for a view without duplicates.

This method does not resolve inheritance rules.

Returns:

a collection of the holders own nodes.

turbid solar
#

how can i check if someone has a certain meta (including inherited nodes?)

#

bc im very confused atm

#
public static @Nullable String getMetaValue(UUID uuid, String key) {
        User user = null;
        try {
            user = luckPerms.getUserManager().loadUser(uuid).get();
        } catch (Throwable thr) {
            thr.printStackTrace();
        }
        if (user == null) throw new IllegalStateException("user is null!");

        return user.resolveInheritedNodes(NodeType.META, user.getQueryOptions())
                .stream()
                .filter(NodeMatcher.metaKey(key))
                .findFirst()
                .orElse(null)
                .getMetaValue();
    }

how can I make it be null if the person doesn't have the meta key?

nocturne elbow
#

CachedMetaData?

#

Something like luckPerms.getPlayerAdapter(/* player class */).getMetaData(player).somethingSomething(metaKey)

turbid solar
#

works thank you

#

happy bday

nocturne elbow
#

yw :)

turbid solar
#

huh

#

OH

turbid solar
#

nothing i was being very stupid

turbid solar
#

d;lp getUserManager().getLoadedUsers()

slate deltaBOT
#
public interface Group
extends PermissionHolder```
Group has 1 super interfaces, 3 methods, and  1 extensions.
Description:

An inheritable holder of permission data.

turbid solar
#

d;lp UserManager#getLoadedUsers

slate deltaBOT
vagrant spruce
#

how do I add and remove a player's group?

nocturne elbow
#

!cookbook there's an example for that in here

frank driftBOT
nocturne elbow
#

not exactly that, but between the example repo and your IDE suggestions, that's more than enough of a hint to know what to do lol

fallow imp
#

How to get the player's temp group as a InherentsNode?

#

!meta

frank driftBOT
fallow imp
#

!temp

frank driftBOT
#

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

fallow imp
#

If you know how, please mention me

turbid solar
#

d;lp User#getInheritedGroups

slate deltaBOT
#
@Unmodifiable @NonNull
Collection<Group> getInheritedGroups(@NonNull QueryOptions queryOptions)```
Description:

Gets a collection of the Groups this holder inherits nodes from.

If Flag.RESOLVE_INHERITANCE is set, this will include holders inherited from both directly and indirectly (through directly inherited groups). It will effectively resolve the whole "inheritance tree".

If Flag.RESOLVE_INHERITANCE is not set, then the traversal will only go one level up the inheritance tree, and return only directly inherited groups.

The collection will be ordered according to the platforms inheritance rules. The groups which are inherited from first will appear earlier in the list.

The list will not contain the holder.

Returns:

a collection of the groups the holder inherits from

Parameters:

queryOptions - the query options

granite marlin
#

is querying for a permission via the luckperms api, several times a minute heavy?

#

or should i do that via the bukkit api

#

(please ping me when you reply)

turbid solar
#

Probably fast with LP? But I doubt it's a big difference @granite marlin

granite marlin
#

so it isnt heavier than bukkit api right?

turbid solar
#

Shouldn't be

granite marlin
#

ok

#

thanks

craggy bay
#

gibt es die möglichkeit sich den group suffix zu holen?

#

is it possible to get the group suffix?

turbid solar
#

Yes

#

!cookbook

frank driftBOT
turbid solar
#

!api

frank driftBOT
turbid solar
#

Load the user

turbid solar
#

Does User#getCachedData().getMetaData().getMetaValue(key); not get inherited meta?

nocturne elbow
#

afaik it returns whatever is shown in /lp user <user> info

#

I mean in reality it's the other way around, what's shown in user info is what it gets from the cached metadata

turbid solar
#

oh it works now weird

turbid solar
fallow imp
#

What's the supported ChronoField units in the Instant class of the Expiry?!
I tried NANO_OF_SECONDS and that returned 0. I just want the seconds duration of the temp group

#

(Please ping me when reply)

nocturne elbow
#

what?

#

context?

#

@fallow imp ig i should ping you

fallow imp
#

Yes, I just used ur method above to get the expiry of the inherted group of the player.

Instant expiry = user.getNodes(NodeType.INHERITANCE)
                                .stream()
                                .filter(Node::hasExpiry)
                                .map(Node::getExpiry).findFirst().orElse(null);```
I didn't put any contexts for the temp group, I set it by:
/lp user myName parent addtemp VIP 3d
nocturne elbow
#

by "context" I mean "what's the context of your question"

#

what do you want to get exactly?

fallow imp
#

I want to know how can I get the seconds from the instant duration because I want to calculate it to days

#

or how can I get the days directly

#

Instant.get(ChronoField.WHICH_ONE);

nocturne elbow
#

seconds relative to what?

#

seconds since epoch? seconds remaining since now?

fallow imp
#

seconds remaining since now

#

or the days remaining since now

nocturne elbow
#

I believe there is a Node#getDuration() method, returns a Duration between now and the expiry instant

#

getExpiryDuration

fallow imp
#

well, The Node#hasExpiry() will return true when the duration is set right?

nocturne elbow
#

That's probably better

#

mhm

fallow imp
#

nvm

#

I will try

#

Thanks

nocturne elbow
#

mhm = yes

fallow imp
#

oh thanks didn't know it

brave lion
#

ehm I guess Im here

languid walrus
#

You can just include mavenCentral() as a repository

#

It should include it then I believe

#

@brave lion

vapid hull
turbid solar
#

No need go add a repository

#

Only the dependency

brave lion
#

I am using code of luckperms to make a similar dependency manager

#

And it was there saying that maven didnt like we use maven central to CDN

#

And it also said there I shouls first ask for permission before using his repo so...

#

As I cant create my own mirror rn...

turbid solar
#

Iirc its fine to use luckos for yoir own use

#

But for bigger you need to contact him

brave lion
#

I mean its a public plugin

#

But its only in 100 servers rn...

#

So should I contact him or its fine?

turbid solar
#

I'd contact him

brave lion
#

Are DM open?

turbid solar
brave lion
#

Ok gonna try

nocturne elbow
#

how do i give a permission to a player with the api

#

!cookbook

frank driftBOT
turbid solar
#

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.

Returns:

the resultant user

Parameters:

uniqueId - the uuid of the user

Throws:

NullPointerException - if the uuid is null

turbid solar
#

Screenshot /lp info

#

Update

#

!latest

frank driftBOT
#
Latest version

5.3.42

turbid solar
#

!update

frank driftBOT
median galleon
#

Why this wont change the primary group?```

User user = api.getUserManager().getUser(p.getUniqueId());

user.setPrimaryGroup("rookie");
api.getUserManager().saveUser(user);```

nocturne elbow
#

Because by default the primary group is calculated based on your parent group list

vapid hull
#

getUserManager().getUser(player.getUniqueId()).getPrimaryGroup(); is the color of the group included in the returned string?

obtuse jolt
#

It returns the group name

vapid hull
#

how can i get the color of the group?

obtuse jolt
#

Where did you set the colour?

vapid hull
#

is that not possible with luckperms? Im just new to the API and the server admin configured the plugin... I think anywhere exists a config file with the data i'll ned

wild whale
#

LP doesn't have any sort of storage for a color for a group. Depending on how the admin set it up, it could be in the prefix, in the group name, stored in a meta, etc

obtuse jolt
#

You can use meta nodes

vapid hull
#

Okay thank you, that was helpful.

vapid hull
#

what plugin name shall i add if im using Luckperms on bungeecord in my plugin yml, just depend: ["LuckPerms"] ?

nocturne elbow
#

Yeah

umbral anchor
#
        manager.getAdvancements().forEach(adv -> {
            Group group = luckPerms.getGroupManager().getGroup(adv.getName().getKey());
            luckPerms.getUserManager().modifyUser(offlinePlayer.getUniqueId(), (user) -> {
                Node node = InheritanceNode.builder(group).build();
                user.data().remove(node);
            });
        });``` so i have this removing all related groups when i need to, but it only removes a portion of the groups for some reason (i assume because it's trying to remove them all asynchronously)
#

wondering if maybe this would do it more linearly and cause less problems java luckPerms.getUserManager().modifyUser(offlinePlayer.getUniqueId(), user -> { manager.getAdvancements().stream() .map(Advancement::getName) .map(NameKey::getKey) .map(luckPerms.getGroupManager()::getGroup) .map(InheritanceNode::builder) .map(Builder::build) .forEach(user.data()::remove); });

nocturne elbow
#

Yeah just put the forEach (and subsequently the getGroup etc) inside the modifyUser

#

That stream chain might be a bit overkill 😆

#

But it'll do the job

buoyant plaza
#

hi sorry, i can't understand the api written in the wiki. How can I do that if the player is in the "founder" group he does ...

wild whale
#

If you just want to see if a player has a group, using the vault api is probably easiest

buoyant plaza
#

I have to do that if the highest group of the player is "founder" he does things

#

"founder" is an example, then I have to do with other groups

raven pelican
#

whats the best way to get the highest value of a permission, lets say i have a permission (bank.create.x) where x is an Integer value, whats the best way to get the highest x val

nocturne elbow
#

None with LP, that is just a regular permission LP does not distinguish from others, of course you can use streams to filter map etc but that's not something LP will do

#

Although you should really be using meta nodes for that

#

Essentially a key-value pair actually optimized for those kinds of lookups, check out the MetaNode and MetaNode.Builder

#

You can also specify in the LP config how a certain set of meta keys will be sorted (by value, by inheritance, etc. I don't remember the exact setting name, you can probably just Ctrl F "meta")

raven pelican
#

could I not get all nodes (aka permissions) starting with bank.create?

#

do you mean this String metaValue = user.getCachedData().getMetaData().getMetaValue("some-key");

nocturne elbow
#

Yeah

nocturne elbow
raven pelican
#

ohh so I just save lets say 12 into a key and I can always get that? I am guessing that is persistant aka permanent?

nocturne elbow
#

Yeah meta nodes are like any others, with the difference LP optimizes for those lookups

raven pelican
#

does that just support Primitive data types?

#

aka String, integer and stuff?

nocturne elbow
#

I mean they are stored as strings

#

You can just Integer.parseInt, after all you know what to expect

raven pelican
#

so this is my method ```Java
public int getMetaDataInteger(UUID uuid, String key){
User user = luckPerms.getUserManager().getUser(uuid);
CachedMetaData metaData = user.getCachedData().getMetaData();

    return metaData.getMetaValue(key, Integer::parseInt).orElse(0);
}``` but I get `java.lang.NoSuchMethodError: 'java.util.Optional net.luckperms.api.cacheddata.CachedMetaData.getMetaValue(java.lang.String, java.util.function.Function)'`
#

the error is on the return metaData#...

nocturne elbow
#

Screenshot /lp info

raven pelican
#

Yea I just noticed I have a pretty old version, I just updated and will retry

steady glade
#

how would I return a specific meta type that a group or user has?

#

this is what I have from trying to read the javadocs but I feel like its wrong

nocturne elbow
#

Uh what are you trying to accomplish exactly?

steady glade
#

im trying to get a defined meta from a player

#

like when you add a meta type to a group im trying to get that meta and then do something to the players that have that meta if that makes any sense

nocturne elbow
#

So you're trying to get the value for that meta key, right?

steady glade
#

yes

nocturne elbow
#

Can I see how you're giving it in the first place?

steady glade
#

like ingame or code?

nocturne elbow
#

Code

steady glade
#

The issue with that is the idea is to predefine the meta ingame and then the code picks it up and dose the things its suppose to or would it be better to define it in code?

nocturne elbow
#

Uh I'm not exactly sure what you mean but I just want to see the part you add the node to the user and how it's being done

steady glade
#

ah ok

#

Its suppose to be called when a command is ran

#

though again I dont think I did it right either

nocturne elbow
#

Keep in mind that getMetaValue can return null in the case of no value being present for that key

#

(also remember to save the user when adding the node :d)

steady glade
#

thank you adding null checkers should fix that issue and ill remember : D

#

dose this work??

nocturne elbow
#

You should be able to not pass anything to getMetaData (not null, just nothing, no arguments)

#

If not make sure you're targeting an up-to-date API version, 5.3 is the current one

steady glade
#

ok

lyric ferry
#

hello everyone! I'm able to connect to the API and get the sender of a command's permissions. I want to see if a permission's value is true in the context of the world that the player is issuing the command. I'm not seeing an obvious solution, but I'm probably overlooking it. Any help is appreciated!

obtuse jolt
#

You could just use the bukkit CommandSender#hasPermssion method tho?

lyric ferry
#

again, I can grab the sender's permissions no problem. The issue is say I have a permission that in the context of a particular world is false, but in the context of another world is true. As I loop through and obtain the user's permission nodes, I also want to check to see if it is true or false in the context of the current world.

I'm sure I'll have to pass in the current world information for comparision, but how do I get that permission node's context information and value (true or false)?

nocturne elbow
#

Why do you need to check the specific permission for the world the player is currently in?

#

What's preventing you from doing player.hasPermission(perm)?

#

@lyric ferry

twilit jasper
#

how would I check if a user has or inherits a specific group?

#

I see examples for listing all of them etc but was hoping there was something direct

nocturne elbow
#

d;lp permissionholder#getinheritedgroups

slate deltaBOT
#
@Unmodifiable @NonNull
Collection<Group> getInheritedGroups(@NonNull QueryOptions queryOptions)```
Description:

Gets a collection of the Groups this holder inherits nodes from.

If Flag.RESOLVE_INHERITANCE is set, this will include holders inherited from both directly and indirectly (through directly inherited groups). It will effectively resolve the whole "inheritance tree".

If Flag.RESOLVE_INHERITANCE is not set, then the traversal will only go one level up the inheritance tree, and return only directly inherited groups.

The collection will be ordered according to the platforms inheritance rules. The groups which are inherited from first will appear earlier in the list.

The list will not contain the holder.

Returns:

a collection of the groups the holder inherits from

Parameters:

queryOptions - the query options

nocturne elbow
#

i suppose you can use this @twilit jasper ^

lyric ferry
#

@nocturne elbow nothing. I can do that easily. That's not the question, however. I'm looking for more than if they have the node, I'm also looking to see if the value is true for the current context

frank driftBOT
#

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

nocturne elbow
#

yeah but.. why?

#

what are you trying to achieve with that

obtuse jolt
#

Unless you are saying you want to get the context value or smt

lyric ferry
#

ok. So to put it in full context, I am creating a plugin that works with help files. As part of the plugin, I need to see what groups the sender belongs to. This part is very easy to accomplish. However, there may be group nodes that exist in the player's list but are false for the world that they are in (for example, the group Factions exists in their list but it is currently set to false because they are not currently in the Factions world - this prevents them from having the factions permissions in the current world). In my plugin I only want to display the help files for the commands that they have access to based on the world that they are in.

Right now I can see the .txt files that list the commands for Plot world and Factions world but they are in the Plot world and should not see the Factions. My question is if there is a method I can import that allows me to see if the group node is currently false so that way I can tell my plugin to not display that factions help file as an option for the user to choose from.

nocturne elbow
#

If the parent group has a world context, they will not inherit it if they are not in said world

#

Also group nodes set to false don't really have an effect

#

How are you currently checking all this?

wispy harness
#

How do I subscribe to offline user parent updates?

nocturne elbow
#

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

frosty fulcrum
#

How can I make a group in a code?

#

On the page isn’t it

#

Pls help

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

frosty fulcrum
#

Thx, if will be a problem, I will write 😉 Sry for my English

frosty fulcrum
#

Can I make in programming my permissions? Not in the game

turbid solar
#

!cookbook has examples

frank driftBOT
frosty fulcrum
#

Pls help

#

For me?

turbid solar
#

Well yeah.. who else?

frosty fulcrum
#

😄

#

Sry for the question

#

...

honest grotto
#

It seems Player#hasPermission() can't catch Luckperms temp permission..

#

How can I catch it?

nocturne elbow
#

I mean it does

#

How are you testing it exactly

honest grotto
#
if (!p.hasPermission("jobs.boost.all.all.1.2") || !p.hasPermission("jobs.boost.all.all.1.5")
                    || !p.hasPermission("jobs.boost.all.all.2")) {
                return ChatColor.GOLD + "Test" + ChatColor.WHITE + " : " + ChatColor.RED + ChatColor.BOLD + "✘";
            } else if (p.hasPermission("jobs.boost.all.all.1.2")) {
                return ChatColor.GOLD + "Test 1.2" + ChatColor.WHITE + " : " + jobs120pNode.getExpiryDuration().toMinutes();
            } else if (p.hasPermission("jobs.boost.all.all.1.5")) {
                return ChatColor.GOLD + "Test 1.5" + ChatColor.WHITE + " : " + jobs150pNode.getExpiryDuration().toMinutes();
            } else if (p.hasPermission("jobs.boost.all.all.2")) {
                return ChatColor.GOLD + "Test 2" + ChatColor.WHITE + " : " + jobs200pNode.getExpiryDuration().toMinutes();
            }
#

I tried

#

But It always return "✘"

nocturne elbow
#

Are you sure you have (or inherit) all of the 3 permissions?

honest grotto
#

Yep

#

I tried other forms of code, but it didn't work too.

#
if (p.hasPermission("jobs.boost.all.all.1.2")) {
                return ChatColor.GOLD + "Test 1.2" + ChatColor.WHITE + " : " + jobs120pNode.getExpiryDuration().toMinutes();
            } else if (p.hasPermission("jobs.boost.all.all.1.5")) {
                return ChatColor.GOLD + "Test 1.5" + ChatColor.WHITE + " : " + jobs150pNode.getExpiryDuration().toMinutes();
            } else if (p.hasPermission("jobs.boost.all.all.2")) {
                return ChatColor.GOLD + "Test 2" + ChatColor.WHITE + " : " + jobs200pNode.getExpiryDuration().toMinutes();
            } else {
                return "X";
nocturne elbow
#

Do you give the permissions to the users themselves or are they inherited?

honest grotto
#

I use /lp user (nickname) permission settemp (permission) true (time) command.

nocturne elbow
nocturne elbow
honest grotto
honest grotto
#

And variables from PermissionNode

#
            PermissionNode mc150pNode = PermissionNode.builder("mcmmo.perks.xp.50percentboost.*").build();
            PermissionNode mc200pNode = PermissionNode.builder("mcmmo.perks.xp.double.*").build();
            PermissionNode mc300pNode = PermissionNode.builder("mcmmo.perks.xp.triple.*").build();```
Like this
nocturne elbow
#

Uh I need the full output of the commands as well

honest grotto
frank driftBOT
honest grotto
#

It's placeholders

#

NPE occurred in the jobs code, so i tested it with mcMMO code.

nocturne elbow
honest grotto
#

I couldn't understand what kind of command you are saying because my English is not good. but, I brought the LP information command.

nocturne elbow
honest grotto
#

yes

nocturne elbow
#

I mean as far as I can see it's working as intended

#

You are checking for hasPermission("mcmmo.perks.xp.triple.*"), not "mcmmo.perks.xp.triple" which is what you have

honest grotto
#

..what the..

#

I'm so sorry for wasting your time...

nocturne elbow
#

No worries

frosty fulcrum
#

Can I make permission in my program?

turbid solar
#

Yes

#

!api

frank driftBOT
turbid solar
#

!cookbook

frank driftBOT
stable saffron
#

Guys how set player group in luckperms api i have this code:

api.getUserManager().loadUser(player.getUniqueId()).get().setPrimaryGroup("vip");                        api.getUserManager().saveUser(Objects.requireNonNull(api.getUserManager().getUser(player.getUniqueId())));
turbid solar
#

!cookbook has an example iirc

frank driftBOT
stable saffron
nocturne elbow
#

what about it doesn't work?

stable saffron
#

Player has primary group - default not deleted..

nocturne elbow
#

hm, screenshot /lp info

frosty fulcrum
#

Did you try at the editor?

#

Groups settings

#

...

nocturne elbow
#

the whole thing please

stable saffron
nocturne elbow
#

yeah you should definitely update, you're quite a bit outdated

#

!update

frank driftBOT
frosty fulcrum
nocturne elbow
#

I mean yes of course you can but maybe they are doing a plugin that automates some stuff, or gives ranks based on achievements or whatever

frosty fulcrum
#

Oke. It Doesn’t matter

#

For writing

nocturne elbow
#

hm?

frosty fulcrum
#

Do you understand?

#

Me?

nocturne elbow
#

I don't

frosty fulcrum
#

😦

#

It doesn’t important. That was it

stable saffron
wispy harness
lean crypt
nocturne elbow
#

it will only fire wherever it originated

#

if you want to detect it in other LP instances you should listen to LogReceiveEvent I believe and "manually" parse the contents of the logged action

nocturne elbow
wispy harness
#

Alrightyy

lean crypt
#

thank you! lastly, I am trying to perform a lookup of a meta value on a server context, how would I find meta values on a User that have the server context?

#
if(p.getSubjectData().getOptions(SubjectData.GLOBAL_CONTEXT).containsKey("my_meta_value")){

I want something like this but it takes in to account server context with LuckPerms.getServerName()

#

ok so i believe it is

user.getCachedData().getMetaData(QueryOptions.contextual(???));

but i'm unsure on how to get a ContextSet to go inside where i have marked ???

nocturne elbow
#

If you're only wanting to get a single ContextSet with a single key/value, check out ContextSetFactory.immutableOf(String key, String value)

thin turret
#

Hey guys so I'm trying to use the SuffixNode Node in the API, it all works fine and is adding the Suffix correctly. However, after restarting the server the suffixes disappear for some weird reason. Is there anyway to prevent this?

nocturne elbow
#

Are you saving the user?

thin turret
#

As soon as you typed that I saw it on the API, that's what I was missing. Let me try it now 😄

#

Yep works. Thank you!

lean crypt
#

Does User.getCachedData() only work if the User has logged in since server has been online? Even if they have logged in previously? I'm getting nullpointer when running .getCachedData().getMetaData() on a User that hasn't logged in yet since restart (but has previously).

How do I access the metadata for Users that haven't logged in yet to have their data cached, but have previously logged in so have records in LP database?

lean crypt
#
List<Node> metaNodes = user.data()
                .toCollection()
                .stream()
                .filter(node -> node instanceof MetaNode)
                .filter(node -> ((MetaNode) node).getMetaKey().equals("my_meta_key"))
                .collect(Collectors.toList());

am i missing an easier way 😄

nocturne elbow
#

Are you loading it first?

lean crypt
nocturne elbow
#

Just so you know, you don't store User instances in fields and variables indefinitely

#

You load the user, use it inside the relevant methods and then just forget about it (save changes if necessary)

#

Check out the 2 main API pages on how to load user data for offline players and all that

#

!api

frank driftBOT
nocturne elbow
#

Those first 2 links

#

!cookbook this repo has a few examples you might find useful for seeing "real life usages"

frank driftBOT
lean crypt
#

oh no...

#

CompletableFuture pepecry2

weary wyvern
#

How do I change parents of players? I can't find the Node for this?

turbid solar
#

!cookbook has examples

frank driftBOT
weary wyvern
lucid dagger
#

Anyone know why MAven wont grab my luckperms api

#

IntelliJ screwed up like twice. Its not grabbing Luckperms XD

rustic laurel
#

!api make sure you're going about this the right way- follow the steps on here

frank driftBOT
lucid dagger
#

yep