#luckperms-api

1 messages · Page 6 of 1

subtle sleet
main dagger
#

you shouldnt interact with the database directly. if you need to interact with luckperms data from something not running directly on a minecraft server, you should use the rest api

night pier
#

Not to mention, it’s h2, not SQLite.

quasi viper
#

Hi there

#

Very quick question

#

To add a group to a user we use this right?

  api.getUserManager().modifyUser(p.getUniqueId(), u -> {
                            InheritanceNode node = InheritanceNode.builder(group).value(true).build();
                            u.data().add(node);
                        });```

But how about removal?
#
 api.getUserManager().modifyUser(p.getUniqueId(), u -> {
                            InheritanceNode node = InheritanceNode.builder(group).value(true).build();
                            u.data().remove(node);
                        });```

Tried this but apparently it completely removes the user
fast delta
#

if that node is the only node the user has, then it would be a "default user", default users are removed from storage (as there is nothing special to save)

quasi viper
gray glen
fast delta
#

modifyUser saves the user after running your action

#

that looks good

upbeat spire
#

I recently learned that I can't use the character . in meta keys if I want to find them like GroupManager.searchAll(NodeMatcher.metaKey("foo.bar")). Are there any other characters I need to avoid using, or maybe the other way around where only certain characters work everywhere? Same question for group IDs, permissions, etc. I can't find anything about what characters are or aren't allowed on the API documentation, and I didn't get any errors trying to set this sort of thing.

fast delta
#

uh you can use them, the plugin will just escape them for storage

#

maybe NodeMatcher doesn't account for that? if so then that's a bug

upbeat spire
#

Judging by the latest documentation not matching the APIs I have access to, I suspect I'm on an older version - so with luck it's a bug that has since been fixed.

upbeat spire
timber ravine
#

NodeAddEvent what happens if multiples are added at once such as from editor?

#

does it just fire the event multiple times or not at all?

modest socket
#

hiya, im in Fabric and I dont have the usual player.hasPermission from bukkit. How may I do that with Luckperms? I want to detect certain permissions like example.foo permission node

spring geyser
#

hey, im trying to promote a User within a Track. I get my track object using lp.getTrackManager().getTrack("division");, where division is the name of my track. How can i promote or demote a user within this group? I see that there is Track#promote(User user, ContextSet context) but i dont really understand where i could get a corresponding ContextSet object. What do i do here?

fast delta
fast delta
# spring geyser hey, im trying to promote a User within a Track. I get my track object using ```...

Contexts tell the plugin when and where a stored node should be applied to the user/group, contexts are things like current world/server/game mode/etc that a user/group "is in" , and they can change over time
https://luckperms.net/wiki/Context
When promoting a user on a track, the context you provide is the context the new inheritancenode will have (and the plugin will apply it when it is satisfied), if you just want it to be applied (potentially) anytime just pass an empty context https://javadoc.io/static/net.luckperms/api/5.4/net/luckperms/api/context/ImmutableContextSet.html#empty()

nocturne elbow
#

Hello, I'm trying to remove /server command for default user joining my server.
I'm using Velocity as Proxy and Spigot 1.8.8.

Velocity documentation: If the user has the velocity.command.server permission (by default, this is granted to all users), players can use this command to view and switch to another server.

So, when the player joins I try to remove the permission.

Here's my code:

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        event.setJoinMessage(null);
        
        Player player = event.getPlayer();

        LuckPerms api = LuckPermsProvider.get();
        User user = api.getUserManager().getUser(player.getUniqueId());

        user.data().remove(Node.builder("velocity.command.server").build());
        api.getUserManager().saveUser(user);

But I can still run the command, while having absolutely no permission. (attached screenshot, prints all permission attached to a user when he logs on)

spring geyser
fast delta
#

the user

modest socket
fast delta
nocturne elbow
#

Thank you tho

#

What if I'm using MySQL as remote storage?

fast delta
#

you can just have the permission set to false on the default group, keep in mind that having LP on the proxy is not a replacement for LP on the servers, LP on the proxy takes care of proxy permissions, LP on the server takes care of the server's permissions

#

you can have multiple LPs connected to the same database with no problems, obviously they will share the permissions, but you can filter that with the "server" context https://luckperms.net/wiki/Context

nocturne elbow
#

I turned on MySQL for remote storage on proxy side, should I disable it and just use file configuration?

fast delta
#

¯_(ツ)_/¯

#

that solely depends on your setup needs

nocturne elbow
#

I just want to disable /server everywhere tbh

#
        LuckPerms api = LuckPermsProvider.get();
        User user = api.getUserManager().getUser(player.getUniqueId());

        user.data().add(Node.builder("velocity.command.server").value(false).build());
        api.getUserManager().saveUser(user);
fast delta
#

you don't need that code

nocturne elbow
#

Both server and proxy use MySQL for storage

wild whale
#

...why not just add that node to a group all users inherit i.e. default?

nocturne elbow
#

I'm really new to Java etc

wild whale
#

No, this isn't something java needs, this is just simple LP configuration

nocturne elbow
#

yea I know

wild whale
#

Add that node to default with a value of false

nocturne elbow
#

I'm new to permissions

#

Everything

#

It's the first time I'm making a minecraft server

nocturne elbow
#

ty

spring geyser
#

i "accidentally" promoted myself within a track using the promote command whilst my plugin does other stuff with promoting and demoting me, and now i am part of multiple types of the same tracks it appears. how can i fix this? (both global context i believe)

#

this is what i now get when trying to promte / demote myself

#

(clearning track using /lp user USERNAME parent settrack TRACK GROUP global worked

nocturne elbow
wild whale
#

/lp group default permission set <permission> false

#

This is an admin problem, not a programming problem

nocturne elbow
timber ravine
#

and do these events fire if a temporary permission expires?

wary mason
#

I have depend: [ LuckPerms ] but LP looks like load after plugin where depend is

wild whale
#

@wary mason could I see the full class, and the full startup logs please?

#

!paste

frank driftBOT
#
Please use pastebin!

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

wary mason
#

It works like 4 hours back... 😄 but last 4 hours I cannot find where is problem

wild whale
#

....yeah no it's not your code, I'd forgotten about this problem. Basically it seems you've created a race condition. LP initializes async, if it connects to a DB quickly then by the time your plugin is initialized, the API is initialized. If the DB connection is a bit slower, then the API might not yet be initialized and your plugin cannot access the API if it's the first thing it does

#

LP's database connection, not yours

wary mason
#

oh

#

Alr so what I can do to fix this?

wild whale
#

Uh in your code, the easiest way would be to delay the accessing of the LP api instance.
I'm going to verify this is indeed the problem, and open an issue for LP, so that we can fix this in some way on our end

wary mason
#

so put get to later task right?

wary mason
#

Woo
Its really weird.. When I have init plugin like static in different class from Main it throw error about net/luckperms/api/node/Node but when I move public static Plugin pl to main it works but still loaded before LuckPerms

wary mason
delicate vessel
#

hello guys this is my old code but i will change to luckperms but i dont understand the api i will check if player is in group

wary mason
#

Hello @wild whale (Sorry for ping ^^)
You find something what can fix my problem?

frank driftBOT
#

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

fast delta
#

clippy can't read

cobalt rapids
#

Yep :/

harsh garden
#

Node.builder(oldPermission).build() what will happen if this doesn't exists. will it make one, or what?

#

do I make null checks for them?

fathom sigil
#
            // Remove previous suffix
            user.data().remove(Node.builder("suffix.0.*").build());

            // Add the new badge-related permission (based on the active badge name)
            user.data().add(Node.builder("suffix.0." + activeBadgeName).build());

            // Set the player's display name suffix
            user.data().add(Node.builder("suffix").build());

            // Save changes to LuckPerms
            luckPerms.getUserManager().saveUser(user);
        }```

This is adding the suffix just fine, but it's not removing it.
Any idea why?
turbid solar
#

don’t think l that supports regex

fathom sigil
turbid solar
#

!cookbook

frank driftBOT
fathom sigil
spring geyser
#

how can i set someones "rank" within a track to something without using Track#promote or Track#demote

frank driftBOT
sterile pike
#

hullo - i just wanted to ask if the common module is published to a maven repo? i'm looking to make an implementation for Geyser-Standalone.

jaunty pecan
#

common isn't published

#

your best bet is probably to fork the LP repo and add a new submodule

sterile pike
#

frankly thats really unfortunate considering i would have to sync my fork to pull changes, rather than 5.4 just being updated with breakages to common but not the api

#

and i would just target using a timestamp and update that single version whenever necessary

#

ngl i might just bundle the common jar into git as unfortunate as that is

viral turret
#

how can i get the offline representation of a luckperms User?

#

i just want to check if an offline player (offline user) has a permission. I know it's possible because luckperms is able to set and check permissions for players if it's directly set through lp

#

nevermind, got it. Incase anyone needs this in the future here it is:

val user: User = luckPerms.userManager.loadUser(offlinePlayer.uniqueId).join() // kotlin
User user = luckperms.getUserManager.loadUser(offlinePlayer.uniqueId).join() // java
wild whale
#

Keep in mind using .join on a CompletableFuture will block the calling thread until the Future completes (the User loads), so don't do that on the main thread unless you like lag.

viral turret
#

so should i use an asynchronous task or is there anyway to not use #join?

untold tiger
#

hello

#

im new in using the luckperms api

#

and if i try to get a prefix of an user

#

i get null

#

can you tell me why?

#

im in the owner group and a prefix is set

wild whale
#

For starters, where are you getting null from? is the return value of that line null, or are you getting a NPE somewhere?

#

Also XY problem, why are you splitting the prefix? I'm getting the vibes you're trying to do something you probably shouldn't be

untold tiger
#

no the return of getPrefix is null

untold tiger
#

the return should be „§8[§4Owner§8] §4“

#

thats why i split the String at the space

#

and get the color

wild whale
#

Are you trying to remove the color, or use it seperately from the prefix?

untold tiger
#

to use it

#

like „color + player.getName()“

#

that the player color is from his group but without the prefix itself

wild whale
#

This sounds like a good use for LP's meta system, a key:value store on LP PermissionHolders accessible to admins. You can set for instance meta.namecolor.&4, then get the meta value for namecolor for a user (or use our PAPI expansion, %luckperms_meta_namecolor%). That way, no parsing required, and you easily get stuff like user overrides for name colors for free

#

!meta

frank driftBOT
untold tiger
#

so generally i can not get the prefix like that

wild whale
#

Well something to that effect should function, it's just clunky and fragile

untold tiger
#

Okay, so i need to use Vault or something

carmine zodiac
#

when me.lucko.luckperms.api.LuckPermsApi was changed to me.lucko.luckperms.api.LuckPerms?

#

i mean version

turbid solar
#

4 -> 5 i believe

#

nvm

#

right now it's net.luckperms.api

night pier
#

It sent from me.lucko to net.luckperms in 5, but I don’t remember it being LuckPermsAPI the entire time I’ve been here

coarse bluff
#

We are currently using plugin.luckPerms.getUserManager().modifyUser(p.getUniqueId(), user -> user.data().add(Node.builder("group.temp").expiry(Duration.ofDays(months * 30L)).build())); to add X months of a group to a user. How can we use accumulate here?

main dagger
#

look at the source code for LP addtemp command and see how it does it

wild whale
#

It'll probably just search for an existing node and modify it's expiry if present

#

(The LP source won't be very helpful since it's not using the API, you'd have to figure out how to convert it to API methods and classes_

coarse bluff
#

Found TemporaryNodeMergeStrategy.ADD_NEW_DURATION_TO_EXISTING. Trying it now with the node add
EDIT: That was it! 🙂

jaunty pecan
#

!javadoc

frank driftBOT
jaunty pecan
#

:]

fiery jacinth
#

I'm currently creating an authentication plugin. I want to add authentication status to context. I'm a beginner when it comes to creating plugins, so I don't know. I don't really understand when I look at Developer API Usage. I can't speek english.so If you don't mind speek japanese.

wary mountain
#

What is the ID and URL of the repository of LuckPerms? I'm using maven

wild whale
#

!api

frank driftBOT
mellow iron
#

Player has text for the action bar, which stores as meta value in LuckPerms User. When this text needs to be changed, the following code is played:

userManager.modifyUser(target.uniqueId) { it ->
  val node = MetaNode.builder(actionBarTextKey, str).build()

  it.data().clear(NodeType.META.predicate { it.key == node.key })

  val result: DataMutateResult = it.data().add(node)
}

It doesn't work. Another node with the same key appears in the meta, but the text is different.
actionbar.message.text = 'test test test test test'.
actionbar.message.text = 'Tklthmwkthlth'
actionbar.message.text = 'You are live!'

maybe Im doing something wrong

#

I need the value to change, not create a new meta

fiery jacinth
#

Is there a way to give players new context?

fiery jacinth
#

How should I deal with this? Cannot invoke "net.luckperms.api.LuckPerms.getContextManager()" because "this.luckPerms" is null

mellow iron
fiery jacinth
fiery jacinth
mellow iron
#

show your code

fiery jacinth
#

luckPerms.getContextManager().registerCalculator(new CustomCalculator());

wild whale
#

and how are you initializing luckPerms?

fiery jacinth
#

LuckPerms luckPerms = null;

wild whale
#

Cannot invoke "net.luckperms.api.LuckPerms.getContextManager()" because "this.luckPerms" is null

#

Well that might be related

fiery jacinth
#

What should I do?

wild whale
#

!api

frank driftBOT
fiery jacinth
#

You will see something like this: NotLoadedException: The LuckPerms API isn't loaded yet!
↓I am writing code like this↓

wild whale
#

a) why are you using 2 different methods to get an API instance at the same time? Pick one.
b) if you're getting API not loaded errors, then either LP isn't installed, or you didn't declare it as a dependency in your plugin.yml

fiery jacinth
#

What should I do if it becomes null?

elder tundra
#

Why is the LuckPerms dependency red?

turbid solar
#

restart your intellij

elder tundra
#

thx

spring geyser
#

is there some convenient way of modifying a suffix of a prefix of a player?

main dagger
#

find the one you want to alter, remove it, add your new modified one. boom, done

mellow iron
#

Player has some text for action bar message, which stores as meta value in LuckPerms User. When this text needs to be changed, the following code is played:

userManager.modifyUser(target.uniqueId) { it -> /* it = user */
  val node = MetaNode.builder(actionBarTextKey, str).build()

  it.data().clear(NodeType.META.predicate { it.key == node.key })  /* somenode.key == node.key ig */

  val result: DataMutateResult = it.data().add(node)
}

It doesn't work. Another node with the same key appears in meta, but text is different.
actionbar.message.text = 'test test test test test'.
actionbar.message.text = 'Tklthmwkthlth'
actionbar.message.text = 'You are live!'

how can i fix this?

nocturne elbow
#

Is there any plugin message or something I can use to check if a player has a permission on a specific server?

#

Each server has its own permission stuff and my goal is to check if a player has a permission on a specific server from my proxy

upper nacelle
#

You need a centralized database for them all to point to

#

You can then issue permissions with a scope if you need to

#

and check scoped nodes on any server

nocturne elbow
nocturne elbow
#

how do I check if a player has a permission

left geyser
#

!api

frank driftBOT
left geyser
#

!cookbook

frank driftBOT
jovial jacinth
#

How can I get a users nodes that start with x using User#getNodes()? Or if there is there a better way?

An example of what I am trying to do, I could have three perms x.x, x.y, x.z. How can I figure out which of the three an user has?

wild whale
#

Sounds like LP's meta system might be what you want. It's a key:value store tied to LP PermissionHolders that admins can configure through permissions like prefixes etc using node meta.KEY.VALUE i.e. meta.x.y (or the meta set <key> <value> command etc). You can then access the current meta value for a given key for a player using PlaceholderAPI, Vault, or LP's api manually

brave lion
#

I am currently using forge permissions API to work with permissions with my mod. This should also work with luckperms right?

main dagger
#

yes

wicked beacon
#

how can i get all groups that are on the server and add it to a List in String

mellow iron
#

(kotlin)

wicked beacon
real juniper
#

Hello guys, can someone help me plz? I dont know why it does not working(

main dagger
#

where exactly is the first screenshot from?

#

actually, you assign the variable as api in the second screenshot, but try accessing it as luckperms in the second

#

also i dont know java all that well but that looks like your assigning it to a local variable which will be lost outside the context of "the plugin is currently enabling"

chilly aspen
#

Is there a way to access a players active meta data via the bukkit api, similar to sponge how you can do player.option("meta key) to get a Optional<String>?

upper nacelle
chilly aspen
#

Yup. perfect. thanks!

upper nacelle
frank driftBOT
chilly aspen
#

I didnt expect it to be built into LP tbh with you - although i did do many searches for it. After the using sponge the past 4 years, I became accustomed to their own platform designing around LP tying into it.

dense otter
#

Hello guys i use a app to make a discord bot BotGhost and i like to now how i contect a rank to my LP database to diacord bot

wild whale
#

!api

frank driftBOT
wild whale
#

No idea what you mean by "connect". If you've got more specific questions, we're happy to help

dense otter
#

aka syn somranks that are only in 1 track

wild whale
#

There's off-the-shelf plugins that exist to do that fyi i.e. DiscordSRV

dense otter
#

Ye i now but i what to make a custom pluging for it

#

Bot i mean

#

I need 2 tracks 1 for Players MC to discord

#

andere 1 for staff discord to mc

night pier
#

Why do you need tracks for this? Why don’t you just clear old groups within a list, and add the new one.

dense otter
#

We have som rank that we dont what in discord or other way in mc

wary knoll
#

Is there a way to serialize a Node object to store in a db?

wary knoll
celest oriole
#

Short question:
I saw you could import the LP API via maven.
In the docs it said that I have to obtain an Instance of the API.
Where can I get one, if not utilizing Bungee/Bukkit etc?

For context: Working on a library that will be used in various systems, including Bungee/Spigot etc., and I would like to implement Luckperms in there.
However, the library itself is not a plugin and is meant to be utilized inside of other plugins.

Can I use the LP API for "custom" purposes or do I need to obtain a Instance through Bukkit/Sponge as displayed on your website?

wild whale
#

!api
There's also a generic way of accessing a LP instance assuming it's loaded

frank driftBOT
celest oriole
#

I have seen the page, but I am unsure if the LP API will be loaded in every use-case.
As noted there, it will throw an IllegalStateException if the API is not loaded.

Can I load it myself?
Does that involve creating a own ServicesManager similar to Bungee/Sponge?

fast delta
#

No, LP needs to be implemented for the platform, then there is the standalone version which, just like the plugin distributions, load additional extensions which you can make your own (kinda like an LP plugin)

celest oriole
fast delta
#

main function?

celest oriole
#

There might be a misunderstanding...
If I need a Bungee/Sponge ServiceManager to get a LP instance, the docker container must need some kind of way of creating an instance aswell?!
So I am confused to why the container can get one (seemingly) without running bungee/spigot, but I cant

fast delta
#

it's a standalone program

#

LP creates itself, you don't

celest oriole
#

correct

fast delta
#

you get the already created instance

#

in a plugin environment, your plugin is loaded alongside LP, this is not the case in a standalone program as there is a single entry point; LP lets you create extensions which are loaded by LP which are useful in situations like running something with LP in the standalone env

nocturne elbow
#

emily can u help me

#

look support 1

celest oriole
#

I think I see your point...

when used as a plugin, ofc the LP plugins has to be loaded to use the lp perms system, and the LP instance is shared between all plugins if Im not mistaken

in this case, the library is a standalone program with a single entry point, isnt it?
in my library I have my init function, and it isnt run by any plugin directly (e.g. the library is not loaded by bungee/spigot)

so doesnt make that a standalone program with single entry point?

fast delta
#

LP standalone is not a plugin you load

#

it is the main program

celest oriole
#

right

#

ohhhhh

#

but it utilizes the api module right?

#

just looked it up, it uses common lol

fast delta
#

it implements it

#

yes

#

because extensions need to use the api

#

you can make your "standalone" version of your library an extension that LP will load

celest oriole
#

ah no, that wont work.
the library is meant to be an allrounder for our network, it currently handles player uptime, stats, bans and more when utilized in plugins (e.g. spigot) and maintenances and motd through our proxies

i wanted to use luckperms since it will become standard throughout our network, and I wanted to use it in possibly even backend solutions to check permissions (via UUIDs), where no mc servers exist.
I assume i could use the REST-API by the standalone version? I am afraid that this would result in more latency than doing queries manually

fast delta
#

eh, if it runs on the same host machine latency is likely not an issue

#

evne if it's within a same LAN

celest oriole
#

kk, was wondering since I already have around 50ms "login times" while using redis and sql in a bungee plugin

fast delta
#

that's faster than a blink duration :p

celest oriole
#

sure, but bungee marks it as a slow login, while everything is on the same network :/

#

maybe I was just unlucky

spring geyser
#

is there some way of overwriting how names are sorted in tab? Like i want luckperms weight stuff to still group people, e.G: people with the admin role above people without it, but when multiple people have admin id like to modify in what order they appear on tab, is that possibly easily?

night pier
#

Doesn’t seem like this has anything to do with the API, or LuckPerms in general.

#

Lp doesn’t control how names are sorted in the tablist

silk star
wild whale
#

The only obvious issue I'm seeing is you're using getUser only without any method that loads users, meaning your code will throw "unknown user" if a valid UUID is offline (whether this is a problem or not for your application, I don't know). Otherwise, please state what you mean by "not working"

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

    at net.luckperms.api.LuckPermsProvider.get(LuckPermsProvider.java:53) ~[?:?]
    at net.lymox.coresystem.StaticCommonClass.commonLoad(StaticCommonClass.java:60) ~[?:?]
    at net.lymox.coresystem.CoreSystemPlugin.onLoad(CoreSystemPlugin.java:40) ~[?:?]
    at net.md_5.bungee.api.plugin.PluginManager.enablePlugin(PluginManager.java:399) ~[server.jar:git:Waterfall-Bootstrap:1.20-R0.1-SNAPSHOT:ec41547:536]
    at net.md_5.bungee.api.plugin.PluginManager.loadPlugins(PluginManager.java:301) ~[server.jar:git:Waterfall-Bootstrap:1.20-R0.1-SNAPSHOT:ec41547:536]
    at net.md_5.bungee.BungeeCord.start(BungeeCord.java:287) ~[server.jar:git:Waterfall-Bootstrap:1.20-R0.1-SNAPSHOT:ec41547:536]
    at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67) ~[server.jar:git:Waterfall-Bootstrap:1.20-R0.1-SNAPSHOT:ec41547:536]
    at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15) ~[server.jar:git:Waterfall-Bootstrap:1.20-R0.1-SNAPSHOT:ec41547:536]

#
#Interface class for my Provider

package net.lymox.coresystem.permission;

import net.luckperms.api.cacheddata.CachedMetaData;
import net.luckperms.api.model.group.Group;
import net.luckperms.api.model.user.User;
import net.lymox.coresystem.service.IServiceProvider;

import java.util.Map;
import java.util.UUID;

public interface ILuckPermsProvider extends IServiceProvider {

    User getLuckPermsUser(UUID uniqueId);

    Group getGroup(String groupName);

    CachedMetaData getCachedGroupMetaData(Group group);

    Group getPlayerGroup(UUID uniqueId);

    Map<String, Boolean> getGroupPermissions(Group group);

    Map<String, Boolean> getPlayerPermissions(UUID uniqueId);

    boolean hasPermission(UUID uniqueId, String permission);

    boolean hasHigherRank(UUID uniqueId, UUID targetUniqueId);
}

#Provider class for LuckPerms Inferface
package net.lymox.coresystem.permission;

import net.luckperms.api.LuckPerms;
import net.luckperms.api.cacheddata.CachedMetaData;
import net.luckperms.api.model.group.Group;
import net.luckperms.api.model.user.User;
import net.lymox.coresystem.service.ServiceCloseable;
import net.lymox.coresystem.service.enums.EnumClosePriority;

import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;

public class LuckPermsProvider implements ILuckPermsProvider {

    private LuckPerms luckPerms;

    public LuckPermsProvider(LuckPerms luckPerms) {
        this.luckPerms = luckPerms;
    }

    public LuckPerms getLuckPerms() {return luckPerms;}

    @Override
    public User getLuckPermsUser(UUID uniqueId) {
        if (!this.luckPerms.getUserManager().isLoaded(uniqueId)) {
            try {
                return this.luckPerms.getUserManager().loadUser(uniqueId).get();
            } catch (InterruptedException | ExecutionException e) {
                e.printStackTrace();
            }
        }
        return this.luckPerms.getUserManager().getUser(uniqueId);
    }

    @Override
    public Group getGroup(String groupName) {
        return this.luckPerms.getGroupManager().getGroup(groupName);
    }

    @Override
    public CachedMetaData getCachedGroupMetaData(Group group) {
        return group.getCachedData().getMetaData(this.luckPerms.getContextManager().getStaticQueryOptions());
    }

    @Override
    public Group getPlayerGroup(UUID uniqueId) {
        return this.getGroup(this.getLuckPermsUser(uniqueId).getPrimaryGroup());
    }

    @Override
    public Map<String, Boolean> getGroupPermissions(Group group) {
        return group.getCachedData().getPermissionData(this.luckPerms.getContextManager().getStaticQueryOptions()).getPermissionMap();
    }

    @Override
    public Map<String, Boolean> getPlayerPermissions(UUID uniqueId) {
        return this.getLuckPermsUser(uniqueId).getCachedData().getPermissionData(this.luckPerms.getContextManager().getStaticQueryOptions()).getPermissionMap();
    }

    @Override
    public boolean hasPermission(UUID uniqueId, String permission) {
        if (this.getGroupPermissions(this.getPlayerGroup(uniqueId)).keySet().stream().anyMatch(s -> s.equalsIgnoreCase(permission))) {
            return true;
        }
        return this.getPlayerPermissions(uniqueId).keySet().stream().anyMatch(s -> s.equalsIgnoreCase(permission));
    }

    @Override
    public boolean hasHigherRank(UUID uniqueId, UUID targetUniqueId) {
        return this.getPlayerGroup(uniqueId).getWeight().orElse(-1) <= this.getPlayerGroup(targetUniqueId).getWeight().orElse(-1);
    }

    @Override
    public ServiceCloseable getServiceCloseable() {
        return new ServiceCloseable(EnumClosePriority.LAST);
    }
}


#Register
        ServiceProvider.registerProvider(ILuckPermsProvider.class, new LuckPermsProvider(net.luckperms.api.LuckPermsProvider.get()));

#

Sorry for lo´ng message

fast delta
coral beacon
#

Thanks it Worms

silk star
nocturne elbow
#

hello

silk star
fast delta
#

you need to save the user via UserManager#saveUser, and also need to push update messages yourself (see the pinned message with example)

robust owl
#

does the api have any methods to list out active permission nodes? trying to retrieve the list of nodes that are present when doing something like /lp user x permission set _ so that i can have tab completion for a permission argument in my own plugin

fast delta
#

Yeah, there's a getKnownPermissions method somewhere

wild whale
#

Platform#getKnownPermissions

fast delta
#

that

wild whale
#

Note that it's a bit hacky and will most likely not include everything. LP attempts to find permissions by scraping plugin.ymls and any defined permissions in the LP permission setup, but it's far from perfect.

A pretty common question we get in support channels is "why doesn't the editor prompt permissions for X", since it's the same data

fast delta
#

(no it doesn't do it like that)

wild whale
#

Well it's something along those lines. Point is if plugins don't declare the permissions, LP won't find it for suggestions

fast delta
#

also not 😛

#

any permission check will add it to the set, that's all that happens

wild whale
#

Did luck change it or something? as far as I knew it didn't cache permission checks for suggestions, and just got what it could from plugin manifests

#

into the code I go

fast delta
#

idk about ≤v4 but v5 does that, it doesn't go out of its way to scrape things

wild whale
#

Ok went down a 15 minute rabbithole, and still don't have a solid answer. LP does indeed log permission checks for the known permissions list, it also overrides Bukkit's permission map to save any permissions added there. However, after 15 minutes of file reading and ripgrepping, I cannot answer the seemingly simple quesstion of "does plugin.yml permissions get added to that list", and I don't want to wait another 15 minutes to open WSL IJ and wait for it to update paper

fast delta
#

they do but for the wrong reasons

#

bukkit does some very aggressive permission checking on login for like every registered permission (plugin.yml and PluginManager.whatever) so they end up going through LP

wild whale
#

kek ok so yes but no

dense otter
#

is there a way to link 1 track for players to discord [op players do not get all rank]

#

please ping me

fast delta
dense otter
frank driftBOT
#

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

left geyser
#

Helpfuls do not any extra permissions. Await while one of the moderators handle the situation. bee_happy

celest oriole
#

Question: Can I utilize the NodeMatcher?
Is there any doc about those?
I would imagine to copy the necessary classes into my own project and use them to lookup perms.

buoyant plaza
#

Hi, how do I get CachedMetaData of an offline player?

fast delta
marble lichen
#

Hello, is there an efficient way to get the player's prefix with the higher weight ?

I went with that but it says that CachedMetaData#getPrefixes shouldn't really be used for querying

nimble dust
#

Can somone help me i dont know why this is not working i tried to get an instance in onEnable and in a Constructer in PlayerListener Class

main dagger
nimble dust
forest crown
#

Why are you doing LuckPermsProvider direct in event?
Call it in onEnable as it says.

#

And then get it from your main class instance and get the user.

#

Something like this (I always get all the api like this)

    private LuckPerms _luckPermsApi;
    public LuckPerms getLuckPerms(){
        return _luckPermsApi;
    }

    @Override
    public void onEnable() {
        _luckPermsApi = LuckPermsProvider.get();
    }
nimble dust
#

i cant check it right now

nimble dust
winter niche
nimble dust
balmy knoll
#

Hey !

I am currently trying to remove a permission from a user in my BungeeCord plugin, but this doesnt do anything. The code i made looks like the one i use to add the permission.
My permission is "isMuted", so maybe it comes from the format ?
Here is the code i use:

public static void removeTemporaryPermission(UUID id, String permission){
        LuckPerms luckPerms = LuckPermsProvider.get();
        CompletableFuture<User> userFuture = luckPerms.getUserManager().loadUser(id);

        userFuture.thenAcceptAsync(user -> {
            NodeBuilder<?, ?> nodeBuilder = PermissionNode.builder(permission);
            Node node = nodeBuilder.build();
            user.data().remove(node);
            luckPerms.getUserManager().saveUser(user);
        }).join();
    }
#

Whenever i call that, the permission stays in place

#

Its supposed to expire in some time, but i'd like to remove it manually using a command

turbid solar
#

where are you checking if it’s removed

#

also don’t .join it that’s blocking

balmy knoll
#

Its a BungeeCord so it should be removed on the Proxy

#

Also, im pretty sure its a misconfiguration from my part but Spigot perms and Proxy perms arent synced

#

Even though all Spigot servers are synced successfully

#

And even without the .join() the permission stay there

fast delta
#

what's the result of the remove call?

fast delta
balmy knoll
balmy knoll
fast delta
#

yeah it's not going to throw any errors

#

but it returns a Result or something

balmy knoll
#

I'll add a Console.log

#

Oh ok, i get a FAIL_LACKS when i data.remove

fast delta
#

hm yeah, does the permission you want to remove have any context applied? server/world context etc

balmy knoll
#

I dont think so

#

I'll check that

#

Well, in theory it shouldnt

#

Doesnt seem to have one

fast delta
#

expiry time should be ignored

#

i wonder if the capital M is the problem, hm

balmy knoll
#

i'll try without it

#

Nah, still FAIL_LACKS

night pier
#

could it have anything to do with it not being an actual permission node? I’ve seen something act weird with permission checks when it’s not in a foo.bar format.

fast delta
#

that shouldn't really matter

balmy knoll
#

if i try to remove isMuted, even i have isMuted and ismuted, it will FAIL_LACKS, but if i try to remove ismuted, it works

fast delta
balmy knoll
#

Thanks for your help !

wild whale
#

@calm monolith No advertising

calm monolith
#

😦

viral plume
#

How can i get a specific meta on a group?

granite harness
#

How would I add Luckperms to Maven if it's in Maven Central? Like do I have to do something else besides add the maven dependency? 0.o

night pier
#

You just add the LuckPerms dependency. No repository is needed if you’re using maven

granite harness
#

Oh so that's it, so no need to go into Project Structure and add the jar file there?

#

(Sorry new to plugin development)

night pier
#

No, god no. If you’re using a build tool, do not add a jar directly to your project with intellijs project structure.
There are ways of defining all of that in the pom.

granite harness
#

That is awesome! I love how simple Minecraft plugin making is to all this!!

#

Actually amazing haha

outer schooner
#

help me please, I don’t understand how I can implement receiving a group to send a message when joining/quiting player

fast delta
#

the server context is just based on the server configuration option in the LuckPerms config, it isn't really to do with the name in the serverinfo on bungeecord, although ideally they'd match but it isn't necessary

fast delta
#

so if they do match you can just use the one from the ServerInfo object itself

#

if not you'd have to fetch that from the server somehow, either with a plugin on the server and some request/response messages or somehow else

marble lichen
#

Hello, i'm trying to remove all ranks from a player that are in a track. Is it possible ? I didn't see any example on the wiki.
Currently stuck with :
user.getNodes(NodeType.INHERITANCE).stream().filter(node -> node.???)
-> Trying to test if a node is in a track

balmy knoll
#

Is there a specific way to remove a temporary permission from a user ? Because i cant seem to make it work with just building a node and user.date().remove(node)

fast delta
fast delta
balmy knoll
sly stream
#

doseluckpemrs support monkodebi

turbid solar
#

what

left geyser
#

I'd translate that to "does LuckPerms support MongoDB" in which case it does but has nothing to do with this channel.

sly stream
#

myeskuel

main dagger
elfin skiff
#

eskulait

(sorry, could not resist)

left geyser
#

Let's stay on topic folks. This channel's for LuckPerms API related questions & support only.

monkodebi, myeskuel, eskulait and that sort of stuff can go to #general.

(You can always use #support-1 / #support-2 for general LuckPerms support.)

spring geyser
#

are luckperms chat prefix and tab prefix stored seperately? I want to temporarily remove the tab prefix of a player

#

but keep it in chat

wild whale
#

LP has no concept of chat vs tab, LP isn't responsible for display whatsoever. The typical setup involves just one prefix being used for both, but one could set up a second set of prefixes using meta under a tab-prefix key or something. However, not sure what this has to do with the API

spring geyser
main dagger
#

yes, but still has nothing to do with the api

surreal pecan
#

Trying to run /lp user <UUID> parent add clog server through LP API. From my understanding, is the way to do this
user.data().add(Node.builder("parent.clog").build());?

fast delta
#

uh no, it'd be "group.clog" but the safe way is user.data().add(InheritanceNode.builder("clog").build())

surreal pecan
#

/lp user/group <user|group> parent add <group> [context...]
/lp user <UUID> parent add clog server
Being the command

wild whale
#

fyi assert doesn't do anything without a startup flag

surreal pecan
wild whale
#

No, that won't affect this, just a heads up so you know to change that to something i.e. if (user == null) throw new NullPointerException("Null user");

surreal pecan
surreal pecan
#
                    User user = luckPerms.getUserManager().getUser(target.getUuid());
                    if (user == null) throw new NullPointerException("Null user");
                    user.data().add(InheritanceNode.builder("clog").build());
                    luckPerms.getUserManager().saveUser(user);
                    Group group = luckPerms.getGroupManager().getGroup("clog");
                    if (group == null) throw new NullPointerException("Null group");
                    luckPerms.getGroupManager().saveGroup(group);```
Still not adding to group, unsure why. Updated code here
wild whale
#

Inheritance is saved on the user, not on the group, so the group saving is unneccesary

#

How are you determining whether or not the user is being added to the group?

surreal pecan
surreal pecan
#

Had an issue with my if statement 😭 thanks for the help

elder marlin
#

Is there a way to make the username different from the prefix?

copper bloom
marble lichen
#

Hello, is there a way to save some Nodes to a .yml file ?
I would like to store them so that players could be able to remove them et "equip" them later

#

And by Node, i mean PermissionNode

main dagger
#

there is no api for it, but you can (de)serialize to/from whatever format you want

slate canopy
#

Can I get list of permissions set on x player and remove all the player should not have any more?

brave saffron
#

Using luckperms API how can I get a group expiration date?
Currently I have:

    @Override
    public void create(Inventory inv, Player p, String... args) {
        AtomicInteger i = new AtomicInteger();

        LuckPerms api = LuckPermsProvider.get();
        UserManager userManager = api.getUserManager();
        CompletableFuture<User> userFuture = userManager.loadUser(p.getUniqueId());

        userFuture.thenAcceptAsync(user -> {
            Data.getServices("Privilegijos").forEach(service -> {
                PermissionNode group = user.getNodes(NodeType.PERMISSION).stream().filter(node -> node.getKey().equalsIgnoreCase("group."+Config.getServer()+"-"+service)).findFirst().orElse(null);

                if (group != null) {
                    Instant expiryDate = group.getExpiry();
                    if (expiryDate != null) {
                        inv.setItem(i.getAndIncrement(), CItem.b(Data.getMaterial("Privilegijos", service), 1, "&6" + service,
                                List.of(
                                        expiryDate.toString()
                                )).create());
                    }
                }
            });
        });
    }```
brave saffron
#

Solved it

fast delta
#

epic

stark jasper
#

Is there a better event to listen to than NodeMutateEvent for group updates for players?

#

I really don't want to do a set diff on the nodes to see what changed

night pier
#

could listen to NodeAddEvent / NodeRemoveEvent and use getNode() to see what's added/removed.

stark jasper
#

does that fire on promotions/demotions?

night pier
#

i cannot answer that honestly - i'd imagine so?

stark jasper
#

I'll try it out, thanks

stark jasper
#

What's the easiest way to check if a player has a permission in a given world?

stark jasper
#

Does this look correct? This seems... verbose

    public static boolean hasPermissionInWorld(Player player, String permission, String worldName) {
        PlayerAdapter<Player> playerAdapter = LuckPermsProvider.get().getPlayerAdapter(Player.class);
        QueryOptions query = QueryOptions.contextual(ImmutableContextSet.of(WORLD_KEY, worldName));
        User user = playerAdapter.getUser(player);
        PermissionNode targetNode = PermissionNode.builder(permission).build();
        return user.resolveDistinctInheritedNodes(query).stream().anyMatch(
                node -> node.getType().equals(NodeType.PERMISSION)
                        && ((PermissionNode) node).getPermission().equals(targetNode.getPermission()));
    }
fast delta
nocturne elbow
#

Hi

#

I just have a question

#

I noticed in the interface storage implementation that Exception thrown

#

Is that good or bad practice

true hound
#

Hello I have an issue with code I am writing:

@EventHandler
  public void onPlayerWorldChange(PlayerChangedWorldEvent e) {
    Player player = e.getPlayer();
    if (e.getFrom().getName().startsWith("copy")) {
      Bukkit.getLogger().info(player.getName() + "test");
      if (player.hasPermission("zodra.war.map")) {
        Bukkit.getLogger().info(player.getName() + "test2");
        LuckPerms luckPerms = LuckPermsProvider.get();
        User user = luckPerms.getUserManager().getUser(player.getUniqueId());
        Node permissionNode = Node.builder("zodra.war.map").build();
        user.data().remove(permissionNode);
        luckPerms.getUserManager().saveUser(user);
      }
    }
  }```


The PlayerChangedWorldEvent works.
both if statements work. (I get test2 in my logs)

However removing the permission "zodra.war.map" seems to fail.
Any idea why that would be?

This is how the permission was given way before (which works):
```java
                    user.data().add(Node.builder("zodra.war.map")
                            .expiry(Duration.ofSeconds(75 * timeMultipier))
                            .build());```
main dagger
#

i think you have to add an expiry to the node you are trying to remove

true hound
#

Ayayay

#

Good to know!

#

🫡

#

Let's try that

#

Lol it can not be 'any' as 0 will not work, however

     Node permissionNode = Node.builder("zodra.war.map").expiry(1).build();```
Works haha
Ty you :D
main dagger
#

i presume 0 is just no expiry

true hound
#

yap but it's still a number ;^)

#

makes sense, but I'd see people struggle over it when debugging

stark jasper
tawny silo
#

Does anyone know why the api isn't recognised?

night pier
#

can you show where you defined your dependency for LuckPerms in your pom please

tawny silo
#

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.23</version>
</dependency>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.4</version> <!-- Use the version matching your server's LuckPerms version -->
<scope>provided</scope>
</dependency>
</dependencies>

#

been trying different versions as well and no luck

night pier
#

try invalidating caches and restarting

tawny silo
#

Just tried and no luck

#

remade the project and it's fine now

terse meteor
#

I am writing a plugin to protect a streamer from banned words, and I need to interact with user permissions. What is the best way to correctly determine which users on the entire server, as well as online, have a specific permission?

I tried the following approach, but I encountered errors. How can I fix them?

        for (Player onlinePlayer : event.getRecipients()) {
            if (filterEnabled && luckPerms.getUserManager().getUser(onlinePlayer.getName()) != null &&
                    luckPerms.getUserManager().getUser(onlinePlayer.getName())
                            .data()
                            .toBuilder()
                            .build()
                            .asSet()
                            .stream()
                            .anyMatch(node -> node.getKey().equals("nbw.filter") && node.getValue() && !node.hasExpired())) {} ...
```|
#

Other code:

#

        boolean filterEnabled = event.getRecipients().stream()
                .anyMatch(onlinePlayer -> luckPerms.getUserManager().getUser(onlinePlayer.getName()) != null &&
                        luckPerms.getUserManager().getUser(onlinePlayer.getName())
                                .data()
                                .toBuilder()
                                .build()
                                .asSet()
                                .stream()
                                .anyMatch(node -> node.getKey().equals("nbw.filter") && node.getValue() && !node.hasExpired()));

fast delta
#

why not just do player.hasPermission("nbw.filter") instead?

terse meteor
#

As I mentioned, I need to check if anyone has a specific permission on the server and find out who exactly has it. Therefore, player.hasPermission("nbw.filter") does not suit my needs.

fast delta
terse meteor
#

When a user issues a command (in my case, /nbw or /nobanwords), they are granted the permission nbw.filter. After that, when another player writes a message in chat containing a blocked word, the plugin should find users who have enabled this mode, using the permissions for synchronization between servers.

#

And after that, it adds censorship to the message for those who have used the command.

fast delta
#

If this is gonna work on some cross-server chat, I strongly recommend you keep a redis cache for users who have the permission active and query that cache instead. The searchAll method will search for the permission in the storage which already happens on another thread, and doing that in something like chat events can incur some very undesired overhead

terse meteor
#

Are you talking about conflicts with plugins like Chatty?

fast delta
#

No, I'm talking about the time spent performing that searchAll query on every chat message

terse meteor
#

Ah, thank you for the information. Unfortunately, I'm quite new to Java; I've only managed to write a simple plugin, so I don't know much about proper plugin development. I struggled to import LuckPerms into the project due to some error.

fast delta
#

mm yeah, the "problem" with searchAll is that it looks up in storage for all and every user that matches the matcher, so it can be somewhat slow depending on the situation, I would be worried about running that too frequently (and the nature of "someone sends a chat message" you can't exactly pinpoint how often it'll run)
redis is an in-memory cache that you can use between multiple servers, and already having the players that run the command in there can greatly reduce that overhead

i don't wanna say it's an ambitious project but it sure isn't something i would start with 😅

terse meteor
#

Thank you for the advice.

fast delta
#

remind me i need to watch senko san lol

terse meteor
turbid solar
#

do not spam

magic comet
#

how do i get a player's group using api and i normal skript? not java?

like set {_group} to %luckperms_groups%

turbid solar
#

wrong channel

#

well for the api part

#

!cookbook

frank driftBOT
turbid solar
#

the skript part, wrong channel

magic comet
#

ok

marble lichen
#

Hello, is it possible to get the weight of a prefix from a group ?

unreal mantle
scarlet drum
#

Hello! How can I get an offline user only with player name?

unreal mantle
#

Use the players UUID, then get name from that

scarlet drum
#

but I have only player name stored

unreal mantle
#

All players have a UUID if you're running an online mode server. So you can still use the players UUID

#

LP stores player data via UUID not name

scarlet drum
#

is an offline mode server

unreal mantle
#

!offline

frank driftBOT
#
Offline mode/cracked servers

Running a Minecraft server in offline mode can cause a lot of issues, particularly with UUIDs and security vulnerabilities. Some people also view it as unethical (piracy). We understand that some people need to run their servers in offline mode. However, due to the reasons mentioned, some users will choose to not support those running a server in offline mode (this does not apply to those running in a Bungeecord network). Please respect their decision, you may continue to seek help for your issue but in most cases, it can be resolved by setting online-mode=true in server.properties.

timber ravine
#

why am i getting multiple events of NodeMutateEvent when i use web editor? i am supposed to get only one..

fast delta
#

it depends exactly on what was done

#

can't really say anything without seeing the changes

turbid solar
#

okay

timber ravine
main dagger
#

well i would expect to get one event for each addition, removal, and change

timber ravine
#

(this is basically event -> discord)

main dagger
#

is that not one event for every addition, removal, or change?

night pier
#

That’s what it seems like to me.

timber ravine
#

i was expecting one event, so i can send an embed listing all changes, added.. removed or modifies

#

but i can't do that if each addition/removal/modification fires it's own Mutate event

main dagger
#

the docs say that the event is fired "when a node is added to/removed from a user/group"

#

node being singular

timber ravine
coral owl
#

Is there a way to get the prefix of an offline player through skript-reflect?
Since using placeholders for skript, with an offline player returns null

wild whale
#

Uh if skript can run stuff off the main thread, you can request the prefix through Vault. If not, you'd need to load the user as outlined in our API docs, and I don't know if skript is capable of handling Futures

#

I just want to make sure you're careful to not do anything that will result in loading user data on the main thread, since that will result in a large lag spike. LP will automatically block Vault requests that would require a data load by default, but any manual loads require you to ensure you do so safely

coral owl
#

I tried doing this, but I have no clue if it works, idk if the return values are something skript can print

import:
    net.luckperms.api.LuckPerms
        
command /test <offline player>:
    trigger:
        if arg-1 is not online:
            send "Not Online"
            set {_n} to name of arg-1
            set {_uuid} to uuid of arg-1
            
            set {_um} to LuckPerms.getUserManager()
            set {_uf} to {_um}.loadUser({_uuid})
            set {_nodes} to {_uf}.getNodes()
            send {_nodes}
wild whale
#

And here's where those futures I was mentioning come into play, loadUser returns a CompletableFuture<User>, not a User. I don't know how your skript thing handles that.

coral owl
#

Well I could try putting it all into 1 line and not set it to anything,
Im not the most advanced when it comes to skript-reflect. As there is very low documentation on it.
But I want to say skript allows anything or type of value to be inserted into a variable, but I believe doing this should work the same

LuckPerms.getUserManager().loadUser({_uuid})

without setting it to a variable

#

granted if I knew the full path after loadUser to get to the part to retrieve data from an offline player, I could tell if it works or not

#

There's only 2 "data" I use from players, which is prefixes, and weight.

wild whale
#

Well if you just loadUser without storing the result, then you loose easy access to the user and have no idea when the data load is complete. Data loads are async, so you can't just loadUser(uuid); <next line> getUser(uuid). I'll be honest, unless Skript has explicit support for async programming, or the reflections thing can support Futures, I suspect this method will never work.
If you only need the prefix, you can get that from Vault slightly easier, but that still requires the request be async, which again, I don't know if skript supports

coral owl
#

Im doing some more reserach on skript-reflect right now. I had the "data" sent to console and it was saying

  [Thu 19:24:07 INFO ] [Skript]     No matching static method: UserManager.loadUser called without arguments
  [Thu 19:24:07 INFO ] [Skript]     Did you misspell the method? You may have meant to type one of the following:
  [Thu 19:24:07 INFO ] [Skript]     * %UserManager%.loadUser

So just teeter tottering between I can or cant use functions / methods

coral beacon
#

I have a problem, the permission of Luckperms does not work I have written a PermissionProvider allerdiongs I ask in the LoginEvent of Bungeecord if he has this permission so that he can join in maintenance but he can not because he has no rights, but I have * permission

coral owl
#

_11, so after getting some help, I am now successfully able to get the LoadUser data, now where to go after is still a bit more to go

#

What would be the best course of action to get the player data, more specifically prefix and weight from the User
Nodes? Data?

coral owl
#

@wild whale Sorry for the ping, just wanted to let you know that it is done!!!!
Finished Product:

import:
    net.luckperms.api.LuckPermsProvider
        
command /test <offline player>:
    trigger:
        if arg-1 is not online:
            set {_t} to arg-1
            
            set {_luckperms} to LuckPermsProvider.get()
            set {_um} to {_luckperms}.getUserManager()
            set {_uuid} to {_t}.getUniqueId()
            set {_load} to {_um}.loadUser({_uuid})
            while {_load}.isDone() is false:
                wait 1 tick
            set {_now} to {_load}.get()
            set {_data} to {_now}.getCachedData()
            set {_md} to {_data}.getMetaData()
            set {_getprefix} to {_md}.getPrefix()
            set {_weight} to {_md}.getMetaValue("weight")
            set {_prefix} to LPFixer({_getprefix})
            send formatted {_prefix}
            send {_weight}
frank driftBOT
#

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

coral owl
#

Yes Clippy

turbid solar
#

what in the everliving fuck

coral owl
main dagger
#

that uh

#

might work i guess

coral owl
#

It does, its for skript so

turbid solar
#

not really the right channe@for skript though

coral owl
signal maple
#

Hello (again), I'm working with LP API, but I dont know how to get the old rank with UserDataRecalculateEvent

turbid solar
#

what are you trying to do

signal maple
#

I want to sync discord ranks with lp ranks. But, I have to remove old rank. So I need to get the new rank and the old rank

turbid solar
#

nodemutateevent

signal maple
#

Ok I'm going to try

turbid solar
#

probably the one you want

signal maple
#

WTF

#

When I want to get the Player name, is not really the name of the player:

turbid solar
#

luckperms stores the name lowercase

signal maple
#

So how can I get the player ?

turbid solar
#

what are you trying to do

signal maple
#

I want to get the previous role and the next role

turbid solar
#

and why do you need the player name for that

signal maple
#

Because with the player name I can get his Discord ID

#

So that's what I need

❌ Before parent
check New parent
check Player Name

turbid solar
#

what

night pier
signal maple
turbid solar
#

get the uuid

#

check if it's a user

signal maple
#

I added if(user == null) return;

turbid solar
#

then cast and .getUniqueId

#

no

#

if (event.isUser()

signal maple
#

So what did I need to cast ?

turbid solar
#

to User

#

get uuid

signal maple
#

Hmm. I didn't understand sorry 😅

turbid solar
#

if (!event.isUser()){ return } // not a user

User user = (User) event.getTarget()

signal maple
#

Ok done

#

So now what did I need to do to get the previous rank ?

#

Because I am here but I don't know what I am supposed to do

#

I did this

rough hollow
#

how do you send a message to a specific group?

signal maple
#

You can do Bukkit.getOnlinePlayers().foreach(player -> if(player.haspermission("group.yourgroup")) player.sendMessage("message")

turbid solar
#

parse it

signal maple
#

How can I do it ?

turbid solar
signal maple
signal maple
#

pls anyone ?

signal maple
radiant plover
#

Hi, is it possible to get the "possible command list" for each group via the API?

turbid solar
#

wdym

#

like what commands they can do?

pure kraken
turbid solar
#

don’t crosspost

radiant plover
turbid solar
#

not possible

main dagger
bitter tiger
#

Hey how do i use the LuckPerms api to set a server specific group on a player?

#

Im running it on a velocity proxy

main dagger
#

add the inheritance node with a context

bitter tiger
#

Thanks

bitter tiger
#

So im supposed to say something like ".getNodes()" then find the one node that is attached to my server?

#

Cause i dont really see the inheritance node with a server contextg

main dagger
#

you have to add a context to the node when you add the node to the player

vestal violet
#

How get all player groups? I find only primary group

#

Or luck perms dont support more one group per player?

#

I've used this method for now, but if someone offers a better one, I'll be grateful.
return luckPerms.getGroupManager().getLoadedGroups().stream().map(Group::getName).filter(it -> hasPermission(player, "group." + it)).distinct().toArray(String[]::new);

wild whale
#

PermissionHolder#getInheritedGroups(QueryOptions) i.e. user.getInheritedGroups(user.getQueryOptions())

copper bloom
#

Bro _11 your so smart

tough hamlet
#

Hi, how I could put in my PlayerJoinEvent class to detect when a player connects what rank he has in order to perform certain actions when a player with a rank such as "VIP" connects to the server.

signal maple
#

Anyone know can I parse a group ?

main dagger
#

parse in what way

tough hamlet
main dagger
#

thats a variable name that you probably havent declared

main dagger
signal maple
oblique lodge
#

Any clue? here's my pom.xml

        <dependency>
            <groupId>net.luckperms</groupId>
            <artifactId>api</artifactId>
            <version>5.4</version>
            <scope>provided</scope>
        </dependency>
this.luckPerms = this.instance.getServer().getServicesManager().load(LuckPerms.class);

Also tried this,

    RegisteredServiceProvider<LuckPerms> provider = this.instance.getServer().getServicesManager().getRegistration(LuckPerms.class);
    if (provider != null) {
      this.luckPerms = provider.getProvider();
    }
#

I'm not shading it either, here's my shade plugin config,

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
                    <relocations>
                        <relocation>
                            <pattern>dev.dejvokep.boostedyaml</pattern>
                            <shadedPattern>in.arcadelabs.shaded.libs</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>co.aikar.commands</pattern>
                            <shadedPattern>in.arcadelabs.shaded.libs.acf</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>co.aikar.locales</pattern>
                            <shadedPattern>in.arcadelabs.shaded.libs.locales</shadedPattern>
                        </relocation>
                    </relocations>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
turbid solar
#

!paste

frank driftBOT
#
Please use pastebin!

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

oblique lodge
turbid solar
#

send the event teams class

oblique lodge
#

Away from pc rn, I'll send in a few hours

#

EventTeams is not extending JavaPlugin btw, I'm just instantiating the LP API in its constructor and then calling that constructor in onEnable of EventTeamsPlugin class

acoustic wren
#

yo wassup

#

im making a plugin with permissions

#

so in /lp editor doesnt appear

#

how can i add all the permissions so it appears on the editor?

night pier
#

permissions are known by the server when there is a permission check made for them.

acoustic wren
lunar cloak
#

how would i call for a meta value?

#

as a placeholder for a skript

oblique lodge
#

Also, check the tree view to see if it's showing all your plugin's permissions there

oblique lodge
# turbid solar send the event teams class
public class EventTeams {

  private final EventTeamsPlugin instance;
  private LuckPerms luckPerms;

  public EventTeams(EventTeamsPlugin instance) {
    this.instance = instance;
    this.initLP();
  }

  private void initLP() {
//    RegisteredServiceProvider<LuckPerms> provider = this.instance.getServer().getServicesManager().getRegistration(LuckPerms.class);
//    if (provider != null) {
//      this.luckPerms = provider.getProvider();
    this.luckPerms = this.instance.getServer().getServicesManager().load(LuckPerms.class);
//    }
  }

  public LuckPerms getLuckPerms() {
    return this.luckPerms;
  }
}
oblique lodge
main dagger
oblique lodge
#

I tried both methods, haven't tried the singelton method yet but I guess that's irrelevant as it can't find the class

oblique lodge
main dagger
#

it doesnt

#

luckperms tells the server that it will handle permission checks, so any time a plugin does CommandSender#hasPermission(), the server asks luckperms if that sender has permission. luckperms adds the checked permission to a list of known permissions, and that list is what is used for suggestions

#

it never loads any permission data from plugins

oblique lodge
#

Oh, but how does it suggest permissions from plugins like worldguard, essentials etc even when that command has not been ran even once

main dagger
#

it wont

oblique lodge
#

This is on a fresh installation, I've not opened a portal or even made any sign or placed em

main dagger
#

it might suggest the base command permissions since those are checked for in-game command completion

oblique lodge
#

Server and LP version:

ver
[05:47:11 INFO]: Checking version, please wait...
[05:47:11 INFO]: Current: git-Purpur-1985 (MC: 1.19.4)*

  • You are running the latest version
    lp version
    [05:47:13 INFO]: [LP] Running LuckPerms v5.4.111.
copper bloom
#

You guys can probably take over the world with this knowledge, very smart people

oblique lodge
wild whale
#

Your issue is a NoClassDef for the main LP api class right?

oblique lodge
#

Yep

wild whale
#

If so, have you added a dependency on LP in your plugin.yml?

oblique lodge
#

I have added it in my paper-plugin.yml,

dependencies:
  server:
    LuckPerms:
      load: BEFORE
      required: true
terse forge
wild whale
#

?

terse forge
# wild whale ?

why are mods unlucky just because they get disturbed for, people being continuously asking questions from them?

#

xD

copper bloom
terse forge
#

sorry for the ping

shut tapir
#

So uh if people could help me out

private boolean setupLuckPerms() {
        RegisteredServiceProvider<LuckPerms> provider = getServer().getServicesManager().getRegistration(LuckPerms.class);
        if (provider != null) {
            luckPerms = provider.getProvider();
            return true;
        }
        return false;
    }

doesnt seem to work

#

i already did mostly what had to do to hook it to the plugin to say it needs it

#

like the plugin.yml adding it to the depend list

#

still says it isnt there

#

just coding tablist plugin to get the prefix and suffix for on the username

wheat lake
shut tapir
#

I did not know that i thought vault was mostly use for like say econ stuff

#

as you can see i am still new at coding

wheat lake
#

Vault is a basic for Permissions, Economy but also prefixes and that stuff.
If you don't use any advanced stuff I do recommend you to use Vault. It's easier to hook into and more code examples available

shut tapir
#

ah okay but i saw i was able to get it work but it doesnt update the ranks whenever i change them

upper nacelle
#

@night pier @main dagger ^

frank driftBOT
#

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

left geyser
left geyser
# upper nacelle

Uh, my bad. Seems like the Mod role is only mentionable for Helpful+ users. No worries. Thanks for notifying us anyways. 🤝

ornate solstice
#

Possible to get the uuid of a player that never played?

#

from their username

#

if not at least have the uuid from username if they have played before

night pier
#

oh this is the api channel

ornate solstice
#

yes it is

turbid solar
#

1st no clue

#

depends on if the api asks the bukkit server

#

2nd yes

#

lookupUsername or something

ornate solstice
#

So basically i am trying to promote a user along a track when they vote, but there is the chance that they are not online then.

    public void onVote(VotifierEvent event){
        String suggestedUsername = event.getVote().getUsername();
        CompletableFuture<UUID> futureUUID = lpApi.getUserManager().lookupUniqueId(suggestedUsername);
        futureUUID.thenAccept(uuid -> {
            User lpUser = lpApi.getUserManager().getUser(uuid);
            Track voterTrack = lpApi.getTrackManager().getTrack("voter");
            if (voterTrack != null && lpUser != null) {
                if (event.getVote().getServiceName().equals("minestatus.net test vote")) {
                    voterTrack.promote(lpUser, ImmutableContextSet.empty());
                    Bukkit.broadcast(Component.text(lpUser.getUsername()+" has voted for the server!"));
                }
            }
        });
        Bukkit.getConsoleSender().sendMessage("vote received from "+event.getVote().getUsername()+" from "+event.getVote().getServiceName());
    }```

I can see the broadcast message but weirdly the user never actually get promoted, if anyone would have a look and maybe tell me if i did something wrong.
fast delta
#

if the player is offline you need to load the user, although in either case i suggest you simply just use UserManager#modifyUser, it will load the user (even if offline), run your action, and then save the user to the db again

acoustic wren
#

hello, so im making a plugin with this permission check:

String str = event.getBlock().getType().toString().toLowerCase();
                if (event.getPlayer().hasPermission("unbreakable."+str)){
                    event.setCancelled(false);
                }```
and i wanna make appear all unbreakable.{block}, being block all the materials poissible, appear in the editor. how?
acoustic wren
#

nvm, solved

cosmic sorrel
#

Does Luckperms support PlaceholderAPI for the groups? like %luckgroup% or something?

#

And Ive tried to import the api... it like broke my entire project in intellji and remove bukkit from it 😭

main dagger
#

!placeholders

frank driftBOT
main dagger
#

this isnt the place to advertise random discord servers

outer schooner
#

How can I implement getting privilege prefixes for player login/logout messages?

hexed agate
#

Is there a way to get the real name of a group, not the display name, from an placeholder? all the ones I have tried have just given me the alias i set with set displayname

wild whale
#

No - that's the entire point of the display name. It overrides the group name, for cases where renaming it is impractical. 99% of people who use it are doing so incorrectly, and should be using prefixes, suffixes, or custom meta to do whatever

hexed agate
#

Ok

#

Thank you

unkempt sun
#

I want a regular player to be able to use the /pokeheal command what is wrong with this

left geyser
iron panther
#

Can I somehow ask LuckPerms to not handle my custom player on join?

User <uuid> - A doesn't have data pre-loaded, they have never been processed during pre-login in this session. - denying login.
hexed agate
#

is there a placeholder to take the highest prefix from a certain track?

main dagger
#

!placeholders

frank driftBOT
main dagger
#

not really an api question

hexed agate
#

I did not find it there

main dagger
#

highest_on_track_<track>?

hexed agate
#

will that return my prefix? When I used it previously I only saw it returning my actual name of the group

#

I'll give it another try

main dagger
hexed agate
#

Ah ok

#

thank you

#

For future refernse is this just a general support question?

#

I was under the impression it was an API thing

main dagger
#

are you making a plugin?

hexed agate
#

Ah good point

pliant vector
#

How can I implement LuckPerms API into my Velocity plugin? Since it doesnt use the RegisteredServiceProvider that the LP docs say to use

turbid solar
#

there are 2 ways the docs say

#

the RSP and other thing

pliant vector
#

Oh, the reason the singleton access wasnt working is because Velocity requires me to put @NonNull since it could return null

outer schooner
#

How i can use LuckPerms here

#

package me.plugs.nukkit;

import cn.nukkit.Player;
import cn.nukkit.event.EventHandler;
import cn.nukkit.event.Listener;
import cn.nukkit.event.player.PlayerJoinEvent;
import cn.nukkit.event.player.PlayerQuitEvent;
import cn.nukkit.plugin.PluginBase;
import cn.nukkit.utils.Config;
import cn.nukkit.utils.TextFormat;
import java.io.File;
import ru.nukkit.multipass.Multipass;

public class JoinMessageDonaters extends PluginBase implements Listener {
public void onEnable() {
this.getServer().getPluginManager().registerEvents(this, this);
this.getDataFolder().mkdirs();
this.saveResource("msgjoin.yml");
this.saveResource("msgquit.yml");
}

@EventHandler
public void PlayerJoinEvent(PlayerJoinEvent event) {
Config join = new Config(new File(this.getDataFolder(), "msgjoin.yml"));
Player player = event.getPlayer();
String nick = player.getName();
String donate = Multipass.getGroup(nick);
if (join.getString(donate) != null) {
this.getServer().broadcastMessage(TextFormat.colorize(join.getString(donate).replace("{nick}", nick)));
}

}

@EventHandler
public void PlayerQuitEvent(PlayerQuitEvent event) {
Config quit = new Config(new File(this.getDataFolder(), "msgquit.yml"));
Player player = event.getPlayer();
String nick = player.getName();
String donate = Multipass.getGroup(nick);
if (quit.getString(donate) != null) {
this.getServer().broadcastMessage(TextFormat.colorize(quit.getString(donate).replace("{nick}", nick)));
}

}
}

wild scarab
#

OK, let's go. I made a plugin using the skript code in which, when the "/adm" command was used, the person would join the ADM group, the code worked perfectly. However, I need to make an update for the person to stay in this group within the game, can anyone tell me if /lp applyedits can be disabled?

night pier
#

what?

wild scarab
# night pier what?

I made a plugin that puts me in a group, but for me to stay in the group within the game I need to use the command /lp apply edits <codigo>, and basically I wanted to know if there is a way for me to disable this thing of having to send the command /lp apply edits <code>

night pier
#

What are you doing that requires you to even touch the applyedits command?

wild scarab
#

Forget it, is there any way for me to set the value of a group that is false?

#

I want to do that, but on the game, with some command

#

@night pier

frank driftBOT
#

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

wild scarab
#

srry

brisk nexus
#

using the luckperms api, what event would i use to detect when someone is added/removed from a group? I tried using the UserDataRecalculateEvent but that didn't seem to get called when i updated someones group, I've also tried NodeMutateEvent, but that's also kind of confusing me as I'm not sure how to get a user instance from that

brisk nexus
#

(Using the velocity luckperms api btw)

fast delta
#

NodeMutateEvent has getTarget(), it returns a PermissionHolder but you can ofc do instanceof User

brisk nexus
# fast delta NodeMutateEvent has getTarget(), it returns a PermissionHolder but you can ofc d...

I'm attempting to use

private void luckpermsUpdateEvent(NodeMutateEvent e){

    if(!(e.getTarget() instanceof User)) return;
    User user = (User) e.getTarget();

    System.out.println("Updating: " + user.getUsername());

as a test, but it's not executing.
I'm registering it like this in the ProxyInitializeEvent

        luckPerms.getEventBus().subscribe(this, NodeMutateEvent.class, this::luckpermsUpdateEvent);
languid briar
#

Hello! I'm listening to UserTrackEvent to update the player's nametag and scoreboard when their primary group (or rank) changes.
But this is not printing or working, any clue why this could be?

#

I assume plugin in the subscribe function can be a normal paper JavaPlugin right? (that's instance in my case)

#

I'm using NodeMutateEvent now and it works, is this UserTrackEvent for something else, did I misunderstood it?

wild whale
languid briar
wild whale
#

Correct, because those aren't track commands. parent settrack is iirc the only track-related command under the parent section. Not all parent commands modify tracks

languid briar
#

Oh sorry I read parent settrack as two different subcommands

#

Yeah this works then, thanks! 🙂

wild whale
#

all good, I figured that's what happened. Glad it's working 👍

placid bobcat
#

is there a way to "register" permissions (for them to show up in tab completion), outside of bukkit? (specifically on velocity, in my case)
or should I just do some pseudo check against them or similar on startup?

main dagger
#

they show up in tab completions after luckperms handles a permission check for that permission

#

bukkit or otherwise

placid bobcat
#

so making a pseudo check on startup would be the most proper way to have them show up, if you don't want to rely on it being checked in normal usage?

robust yacht
#

how do i get the expiry date of a player's group?

bitter tiger
#

I have the luckperms plugin on my proxy and im using the luckperms api on one of my servers, however, it gives me a NoClassDefFound error when trying to use the api. Can someone help me?

main dagger
#

you cant import a class that only exists in another process

#

so you need to install LP on the backend too

atomic hill
#

How would I get the Bukkit Player object from the LuckPerms PermissionHolder object (from an event)?

I have tried```java
Player player = Bukkit.getPlayer(event.getTarget().getFriendlyName());

main dagger
#

get the uuid

#

and i think getPlayer() only works for online players anyways

brisk nexus
#

hey @main dagger, seen you helping a lot of people, would you mind helpin me out with this?

i am trying to make my own tab system, and on tab entries I need to display the players rank which works fine, as I'm just getting the primary group of a user and then finding the prefix for that group, but I've noticed that if I update my rank in game, my primary group doesn't change? I'm assuming this is because I'm using the velocity API of luckperms, is there anything i can do to fix this?

frank driftBOT
#

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

main dagger
#

primary group is an arbitrary concept. just get the users prefix directly

brisk nexus
#

how do i do that?

slate lagoon
#

Hello,

I've been intrigued by how the player.hasPermission() function automatically invokes the logic of LuckPerms when used. From my research, it seems that registering a service through the ServiceManager allows for integration into Bukkit's system. The advice I received was that creating a class inheriting Bukkit's Permissible interface and registering it as a service would achieve this.

Upon inspecting the LuckPerms Bukkit plugin code here(https://github.com/LuckPerms/LuckPerms/blob/754283c053493bfa1cbc5df05987ba46f7fde388/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java#L254), it appeared to confirm that service registration was the correct approach. However, the LuckPerms interface does not inherit from Permissible, and its internal functions also seemed unrelated to hasPermission.

I am curious about the mechanism behind how LuckPerms registers its service and replaces the existing Permission functionality. Although I anticipate that it involves inheriting Permissible and registering it, I'm puzzled about how the service registration integrates and replaces the class simultaneously.

I've tried to understand the code, but it's challenging to find the connection. Any detailed advice or clarification on this would be greatly appreciated.

Thank you.

GitHub

A permissions plugin for Minecraft servers. Contribute to LuckPerms/LuckPerms development by creating an account on GitHub.

slate lagoon
# fast delta LP injects its own Permissible implementation into the CraftPlayer's Permissible...

Thanks to your advice, I've gained a significant understanding of how LuckPerms interacts with the Bukkit's permission system. It was enlightening to discover how LuckPerms replaces the standard PermissibleBase with its own implementation in LuckPermsPermissible.

LuckPerms effectively substitutes the default PermissibleBase in Bukkit by utilizing its custom class, LuckPermsPermissible. This process involves accessing the internal Permissible field of the Player object using reflection and replacing it with LuckPerms' permission management logic. The injection and uninjection processes during player login and logout ensure that LuckPerms maintains compatibility with the existing system while offering its unique permission management capabilities.

Without your advice, understanding this intricate mechanism would have taken much longer. I sincerely appreciate the help you've provided in gaining this insight. This deeper understanding will undoubtedly aid in better plugin development.

Thank you very much!!!!

night pier
#

TLDR “thanks”

brisk nexus
rustic galleon
#

The prefix is ​​updated in bungee's luck perms but does not take effect on other servers unless a command like "/lp user info" is executed or the player relogs from the server.

brisk nexus
fast delta
mild token
#

I want to make a Forge mod that shows me the rank prefix in the tablist because that wasn't there from the start, so I downloaded the mod and threw it into the library folder as a Jar Library and added it to Grade.build program is bound and when I join a world this error occurs in the console/crashlog: [21:11:22] [Server thread/ERROR] [minecraft/ServerLoginPacketListenerImpl]: Couldn't place player in world
net.luckperms.api.LuckPermsProvider$NotLoadedException: The LuckPerms API isn't loaded yet!
This could be because:
a) the LuckPerms plugin is not installed or it failed to enable
b) the plugin in the stacktrace does not declare a dependency on LuckPerms
c) the plugin in the stacktrace is retrieving the API before the plugin 'enable' phase
(call the #get method in onEnable, not the constructor!)

umbral bough
#

I'm actually getting that same error ^ but in a velocity plugin.

  • I have made sure to list luckperms as a dependency in the plugin annotation:
@Plugin(
// ...
    dependencies = [Dependency(id = "luckperms")],
)
  • I schedule a task which uses the LuckPerms API:
    private fun registerTasks() {
        logger.info("Registering tasks...")
        timer.scheduleAtFixedRate(0L, 60_000L) {
            runBlocking {
                luckPermsSyncTaskService.sync()
            }
        }
        logger.info("Finished registering tasks.")
    }
private suspend fun syncPlayer(player: Player) {
    val luckperms = LuckPermsProvider.get()
    val user = luckperms.userManager.getUser(player.id)
// ...
}

And yet, this error is thrown: Exception in thread "OnTimeSyncTimer" net.luckperms.api.LuckPermsProvider$NotLoadedException: The LuckPerms API isn't loaded yet!.
I'm not sure what else to check

#

if I change the dependency to luckperms1, the plugin fails to load... so it's definitely finding the dependency

#

okay... I figured it out - I was accidentally shading the luckperms api

#

@mild token This might also be your problem. Change implementation -> compileOnly for the LP dependency

fringe jasper
#

Does exist a Waterdog version of LuckPerms?

bold plume
#

i.e. no, but try the Nukkit version and see if it works

main dagger
#

also wrong channel

clever tapir
#

I need help with a custom plugin my server has ordered from SaberFactions, that is going to allow us to have temporary ranks with custom faction power. However the dev of SaberFactions says his commands that are supposed to work with Luckperms Api isnt working.

night pier
#

we have no information what so ever. Have the developer of the plugin come here and ask, since it’s a plugin he made that’s not working as expected. 🤷‍♂️

thick silo
#

You should not have accepted the plugin that is not working and let the dev figure out what is wrong on the API part

obtuse halo
#

I am getting net.luckperms.api.LuckPermsProvider$NotLoadedException: The LuckPerms API isn't loaded yet! while using velocity api

#

where should I use luckPerms = LuckPermsProvider.get();

#

Wait same happening on waterfall too now, I think I changed something and now this is happening

night pier
#

make sure you’re not shading LuckPerms.

obtuse halo
#

Oh, I am probably shading luckperms

obtuse halo
stiff merlin
#

Can I use the API in a BungeeCord plugin?
If so, how can I check if a player has a certain permission?

main dagger
#

for simple permission checks, you dont need the api

#

just use the platforms method of checking permissions

stiff merlin
main dagger
#

seems right

#

ive never used bungeecord though

stiff merlin
#

Okay I will try it

#

Thanks a lot

toxic mortar
#

does Player#hasPermission("group.{name}") check if a player has a group named {name}?

#

why there is no something like User#hasGroup() or Group#getUsers()?

wild whale
#

All data aside from the UUID <-> username cache is stored as permissions. hasPermission("group.<name>") is a quick and easy way to check without the LP api, with the API you check for an InheritanceNode with the desired group.

timber ravine
#

What's the most efficient way to get the prefix of a player who may be online or offline

#

With some caching

turbid solar
#

check if the user is online else load

robust yacht
#

whats the best way to get all users in a group

merry latch
#

Forge 1.20.1

turbid solar
#

ok

sly oxide
#

This method doesn't work.

  private void addGroup(ProxiedPlayer player, String group) {
        LuckPerms luckPerms = LuckPermsProvider.get();

        luckPerms.getUserManager().modifyUser(player.getUniqueId(), (user) -> user.setPrimaryGroup(group));
    }```
timber ravine
#

You have to save the changes

turbid solar
#

!cookbook

frank driftBOT
crystal whale
#

How do I put permissions in the luckperms web using a other plugin of a scr

floral steeple
#

does the luckperms api support offline players?

#

what is a contextSet

#
public class VipJoin implements Listener {

    private Node vipNode = Node.builder("iransky.vip").withContext(DefaultContextKeys.SERVER_KEY, "smp").build();

    @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
    public void onPlayerPreLogin(AsyncPlayerPreLoginEvent e){
        User player = LuckpermsAPI.api.getUserManager().getUser(e.getUniqueId());
        if(!player.getNodes().contains(vipNode)){
            e.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_FULL);
            e.setKickMessage("The Server Is Full! You Need SkyGod Or Higher To Join");
            return;
        }

        for (Player p : Bukkit.getOnlinePlayers()) {
            if(p.hasPermission("iransky.vip")) continue;
            p.kickPlayer("You Were Kicked Due To A VIP Player Join!");
            e.setLoginResult(AsyncPlayerPreLoginEvent.Result.ALLOWED);
            break;
        }
    }

}```
is there anything i need to improve?
main dagger
copper bloom
#

Crazy

solemn widget
#

does anyone know how to make a range with luckperms on sternalboard?

main dagger
#

wrong channel

#

and dont crosspost

shut zodiac
#

I want to get the uuid of a player by name and when i run it i get [16:01:36 INFO]: Chucky3920 null

System.out.println(mcName + " " + uuid);```
main dagger
#

doesnt the server provide a way to look up that info?

shut zodiac
#

but i want to make it able to get offline players too (im on velocity)

robust yacht
#

How do i get all perms in the right capitalization

main dagger
#

"get" in what way?

#

if you want a list of all permissions from all plugins on the server, thats not really something you can do

robust yacht
#

sry for ping

shut zodiac
#

Yea

turbid solar
#

try not joining it

#

.join()^

shut zodiac
#

Will have to try tmrw

toxic mortar
#

what is the easiest way to get all users that are in a certain group?

turbid solar
#

searchAll probably

limpid tide
#

Hello!

I need some help:

I've been trying to create a plugin that uses LuckPerms to get permissions and other related stuff, but I've been running into the same issue and I've tried everything I found either on the GitHub issues page or other places:

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

In this gist is the source-code (That's calling the LuckPerms API), latest log from the server, build.gradle and plugin.yml file:

https://gist.github.com/tockawaffle/39a195f17e79af7dc22dd2d500d18666

I am using:
Paper 1.20.2
LuckPerms 5.4.102 (Any version would give me the same result.)
Java 17

I don't really know what else to do, lol

fast delta
#
libraries:
  - net.luckperms:api:5.4

you do not want to do that, the api is provided by the plugin already

limpid tide
#

Yep, that did it
Thanks!

copper fossil
#

Hello, I'm having issues initializing the LuckPerms API on BungeeCord. I have the same error as the person above me (NotLoadedException). This is my onEnable Method:

public static LuckPermsConnector luckPermsConnector;
@Override
public void onEnable() {
    MongoManager.connect();
    luckPermsConnector = new LuckPermsConnector(LuckPermsProvider.get());
    ProxyServer.getInstance().getPluginManager().registerCommand(this, new BanCommand());
    ProxyServer.getInstance().getPluginManager().registerCommand(this, new MuteCommand());
    ProxyServer.getInstance().getPluginManager().registerCommand(this, new UnbanCommand());
    ProxyServer.getInstance().getPluginManager().registerListener(this, new ChatListener());
    ProxyServer.getInstance().getPluginManager().registerListener(this, new LoginListener());
    ProxyServer.getInstance().getPluginManager().registerListener(this, new PostLoginListener());
}

and this is the relevant part of my LuckPermsConnector class:

private final LuckPerms api;
public LuckPermsConnector(LuckPerms api){
    this.api = api;
}

For reference, here is the relavant part of the server logs: https://hastebin.com/share/ligagibeca.makefile

LuckPerms is installed and configured on my proxy and can be used normally. It's also loaded before my plugin.

main dagger
#

did you shade luckperms into your project?

#

if you did: dont

copper fossil
royal locust
#

It doesn't work luckperms, what can I do, I can't even create a group, can you help me?

fiery bridge
#

is there a api for the lpb?

royal locust
royal locust
# fiery bridge is there a api for the lpb?

I want to go to the luckperms editor's page and it doesn't go to me, it says Another command is being executed, I'm waiting for it to finish and it's been 5 days, as it says the same thing, I restarted but it doesn't help

fiery bridge
copper fossil
main dagger
# fiery bridge is there a api for the lpb?

there is no api specifically for any version of luckperms. the api is shared between all platforms and works the same way on all of them, the only difference being what types are used as permission holders (eg the player class)

brisk venture
#
luckPerms.userManager.uniqueUsers.thenAcceptAsync { users ->

            for(user in users)
            {
                luckPerms.userManager.loadUser(user).thenAcceptAsync { user ->
                    val rank = AbstractRankService.getRank(user.primaryGroup)

                    if(rank == null) {
                        failedUsers[user.uniqueId] = user.primaryGroup
                        return@thenAcceptAsync
                    }

                }
            }```

I'm aware of `user.primaryGroup`, but how would I retrieve the remaining duration of their group?
main dagger
#

well players can have many groups

brisk venture
steady mist
#

these 2 lines literally do nothing, doesnt set the parent group at all.

#

or add the user to the group

main dagger
#

setting the primary group like that wont do anything

#

you need to actually add an inheritance node for the group

#

!cookbook probably has an example

frank driftBOT
prime scaffold
#

Hello, please tell me how can I install donation if I get user and then and then use Method setPrimary But it gives the result Fail

turbid solar
#

1 message above yours

prime scaffold
turbid solar
#

read 1 message above your initial message

prime scaffold
#

я исправил и мне пишет ето Loaded class net.luckperms.api.LuckPerms from LuckPerms v5.4.116 which is not a depend, softdepend or loadbefore of this plugin.

wild whale
#

Add LP as a depend (or a softdepend if LP is an optional dependency) of your plugin in your plugin.yml

prime scaffold
#

And now it says FAIL_ALREADY_HAS

wild whale
#

That's not a LP error, where does it say that and if it's in the logs then what's the full logger line?

prime scaffold
#

this is after the player has executed the command but

#

everything is fine in the magazine

prime scaffold
#

Тут код для решения моей проблемы

tough cypress
#

Hey Fellas, would anyone know if there is an efficient way to check what numerical value is set after a permission node? Like checking someones max claim size in permissions claims.size.100 all the way to claims.size.400999 without check recursively?

main dagger
#

use meta instead, as it was made for that

#

!meta

frank driftBOT
main dagger
#

its basically just a key -> value map

tough cypress
#

ah ya mean I would need to do one myself, I'd assume just thought it would be nice to do it on the fly

spring mesa
#

I'm working on a leaderboard plugin utilizes player's prefixs, what I'm doing is loading the users one by one to get the displayname but this is not very efficient, especially if I have everything stored in a database. Is there a way to do this without loading one by one? like fetch a group of users?

opal rover
#

java.lang.NullPointerException: Cannot invoke "net.luckperms.api.model.user.User.data()" because "user" is null

Why user is null?

 public void add(UUID resident) {
        User user;
        if (TownyPermissions.getUserManager().isLoaded(uniqueID)) {
            user = TownyPermissions.getUserManager().getUser(resident);
        } else {
            user = TownyPermissions.getUserManager().loadUser(uniqueID).join();
        }
        residents.add(resident);
        for (String permission : perms) {
            user.data().add(Node.builder(permission).build());
        }
        TownyPermissions.getUserManager().saveUser(user);
    } ```
night pier
#

Add some loggers to verify the user isnt actually null before trying to do anything with it in LP

opal rover
fast delta
#

you are checking if the UUID uniqueId is loaded, but getting the user for resident which is the method param

spring mesa
#

I'm working on a leaderboard plugin utilizes player's prefixs, what I'm doing is loading the users one by one to get the displayname but this is not very efficient, especially if I have everything stored in a database. Is there a way to do this without loading one by one? like fetch a group of users?

worthy adder
#

Hello, is there a version for WaterDogPE?

main dagger
worthy adder
#

and I'm sorry for speaking on the wrong channel

noble relic
#

Hello guys, is it possible to listen to luckperm events through Velocity at all?

turbid solar
#

yes

#

luckperm's uses it's own event stuff

#

not the platform

noble relic
#

Hmm, it doesn't seem to work.

   public RankChangeListener(LuckPerms luckPerms){
            EventBus eventBus = luckPerms.getEventBus();

            eventBus.subscribe(DataTracker.getInstance(), UserDataRecalculateEvent.class, this::onUserDataRecalc);
        }

        private void onUserDataRecalc(UserDataRecalculateEvent event){
            System.out.println(event.getUser().getPrimaryGroup());

        }

This is my listener and then on my main

onProxyInitialize:
luckPerms = LuckPermsProvider.get();
new RankChangeListener(luckPerms);

#

But the command runs in the backend server so I don't see how velocity could listen to it

#

Not that I've looked into luckperms I suppose there will be some plugin messaging

main dagger
#

events will only fire on the instance a change occurs on

worldly lagoon
#

There is an way to only node expiry when the player is online?

night pier
#

I'm not sure that this is an API question, but no. the expiry is a timestamp

worldly lagoon
#

Sadly, I believe I should save each player's time and add/remove the equivalent timestamp when they leave/join

noble relic
daring sand
#

Hello U have a quqestion how can i can make the luckperms api in my plugin

frank driftBOT
daring sand
#

i cant see anything abaut velocity

wild whale
#

The singleton method works on every platform

daring sand
#

oh ok thx

vivid ermine
#

If a player has never joined the server, is it possible to add him (the nickname) a permission and then check for it?

turbid solar
#

use the uuid

bronze loom
#

and who i can set them?

bronze loom
scarlet forge
#

!meta

frank driftBOT
bronze loom
#

💀

brazen kettle
#

Possible to get how long is left on a temp group?

chilly swallow
#

how i can create a custom command that allows to set temporary groups to players? like /tempgroup

chilly swallow
#

i have discovered already

#

thanks

fast delta
#

epic

chilly swallow
# fast delta epic

i just created a command with 3 arguments and make a Integer parse the 3 argument in a luckperms /lp user parent addtemp command

#

/tempgroup <Nick> <Rank> <Time in Days>

tawdry perch
#

Hi, how should I use the luckperms api? dependency alone is not enough for me

noble relic
#
  1. Try reloading maven project

  2. Try Invalidating Cache Data and Restarting IDE

  3. Try right clicking pom.xml Maven > Unlink Maven Projects then right click pom.xml again and Add As Maven Project

#

(Assuming you're using maven)

fast delta
#

well, hiding debugging information is one way to hinder the ability of getting help, because that one line you hid is pretty important to see where the issue is caused exactly and that could give one or two hints :p
other than that, make sure that your bungee.yml/plugin.yml is formatted correctly for the plugin dependency thing with LuckPerms

fast delta
#

yes and that line provides extra information that can help us help you

#

would need to see either a) that line and/or b) your plugin yml to see what could be wrong

storm goblet
#

Can I loop through all players that are in a certain group?

#

All offline players

strong gull
#

Hey why does the LuckPermsProvider.get().getUserManager().getUniqueUsers().join() not return all the users in the db?

wild whale
#

It'll only return the users who have data saved. If a user's only data is group.default, LP doesn't save anything about them to save space

strong gull
#

and it returns 0

lyric hollow
#

i understand that the method "getLoadedUsers()" only loads the online players right? is there a way to get all the offline players as well ?

#

sorry if im asking something blatantly obvious

fast delta
#

monkahmm what are you trying to do exactly? there might be a more efficient way of doing whatever you want to achieve

lyric hollow
fast delta
#

I mean, there's UserManager#searchAll, but it might not exactly fit all of your criteria

#

loading all users to fetch that info seems a bit.. not good designed lol

#

why can't you just wait until the player logs out, then save the remaining time, and then when they log in again you add the difference?

lyric hollow
#

omg that is soo much more efficient

#

🤣

#

i will do exactly that, thank you

lyric hollow
flat imp
#

hey
how i can get my server players info (group and ....) and show them in my discord bot ?

limber cypress
#

How to listen to network sync through LuckPerms API

flat imp
turbid solar
#

!rest

frank driftBOT
#

Sorry! I do not understand the command rest Did you mean latest?
Type !help for a list of commands

turbid solar
#

there’s a rest api you could use

raw agate
#

how

#

i can set parent to player with api?

#

and, option of timer

raw agate
#

@jaunty pecan

frank driftBOT
#

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

left geyser
raw agate
left geyser
#

!api

frank driftBOT
flint cobalt
#

hi

#

how can i fix this?

fast delta
# flint cobalt

as it shows, there is no method named "getApplicableContexts" in the ContextManager
but for that you can just call getMetaData(), without passing any parameters to it

flint cobalt
#

and this?

fast delta
#

hm?

#

what does it say

flint cobalt
#

its good?

fast delta
#

that will work, yes, but it will not get the LP configured prefix, for that you'd use getMetaData().getPrefix()

flint cobalt
#

ready

#

thanks

flint cobalt
#

anyone can help me?

raw agate
#

i try to set a group to player with time

#

but the api not set in the luckperms

limber cypress
fast delta
fast delta
raw agate
fast delta
#

you aren't adding a group tho? you're adding a meta node

raw agate
#

So how do you add a temporary group?

fast delta
#

with an InheritanceNode

#

not a MetaNode, an Inheritance represents a parent group, a MetaNode represents an arbitrary key-value pair

raw agate
#

you can send me one example pls?

fast delta
#

!cookbook

frank driftBOT
raw agate
fast delta
#

it's a timestamp

raw agate
#

timestamp is in seconds right?

#

i can get the seconds and + with timestamp now?

fast delta
muted shuttle
#

I have an issue with this where when removing multiple permission nodes sometimes it's resetting the player's ranks

#

the function im using ```java
public static void removePermission(Player player, String... permission) {
luckPerms.getUserManager().modifyUser(player.getUniqueId(), user -> {
for (String s : permission) {
user.data().add(Node.builder(s).value(false).build());
}
});
}

#

is there a reason why that might be happening? this is the implementation

#

i assume that it's due to me modifying the user multiple times, rather than doing it all at once.

ionic seal
#

What's the event that gets fired when user's group/parent changes whether the group is on track or not. i.e. /lp user X parent set Y. Which event would fire? Currently I have UserTrackEvent, but not what I'm looking for. Thanks in advance!

fast delta
#

NodeAddEvent, NodeRemoveEvent and maybe NodeClearEvent (stuff like parent set will clear the InheritanceNodes and add the one you're setting)

#

check that the holder is a user, the node being added is an InheritanceNode

fast delta
muted shuttle
#

Yeah i realized what i was doing midway through sending that message, haven't pushed to prod yet so i cannot tell you for sure that was the reason but it most likely was

muted shuttle
#

I did that as soon as i noticed

flint cobalt
#

how can i fix this?

flint cobalt
#

anyone can help me??

fast delta
#

uh, I wonder where you got that code from, but:

  • Node.getExpiry does not return a long, it returns a java.time.Instant, you can see that if you check the method return type or if you hover your cursor over the squiggly red line
  • user.getQueryOptions() already gives you a QueryOptions, you can call .contexts() on that
  • if you want to turn the user's node map into a Stream<Node>, you can do user.getNodes().stream()
  • you can't use a ContextSet as a Predicate<Node> filter as it is, but you can do a lambda like node -> node.getContexts().isSatisfiedBy(contextSet
static jasper
#
  • don't use chatgpt if you don't understand what the code does
lapis breach
#

It said there is a data error occurred while loading permissions, do someone know how to fix it?

wild whale
brittle crypt
#

Hello
On my server, players periodically lose permissions. I would like to make an debugger plugin that would tell me when a player has lost a permit and what caused it, so that I can track which plugin is taking a permission from a player. is it possible to do this? I found NodeRemoveEvent in the documentation, but unfortunately, it does not provide information about which plugin removed the permission.

main dagger
#

im not super familiar with java or how the lp event system works but you might be able to look at the call stack

#

if you can access that, and lp doesnt delay handling the event

brittle crypt