#luckperms-api
1 messages · Page 48 of 1
I don't think there is an easy "one size fits all" solution here; what I'm having in mind is:
-
keep the sync/async setting you have and hope for the best lmao
1.1) hard code some sync-only perms plugin list and ignore the setting? -
tell LP users to turn vault-unsafe-lookups to true in LP config to let it do the thing. it's not like it will actually lag the server unless they are using a remote database that is literally on the other side of the world
-
remake an internal Vault-like async-friendly interface and use plugin-specific implementations and APIs?
- lucko/synapse 😩
Hello. I'm having a bit of difficulty to promote a player in a track using luckperm API.
First, I think I don't understand ContextSet.
final static private LuckPerms lp = LuckPermsProvider.get();
User user = lp.getUserManager().getUser(player.getUniqueId());
Track track = lp.getTrackManager().getTrack("main");
ImmutableContextSet set = ImmutableContextSet.builder()
.add("world", "world")
.add("server", "survival")
.build();
track.promote(user, set);
this code gives me error of java.lang.NoClassDefFoundError: net/luckperms/api/context/ContextSet
can anyone give me some little code to promote a player in a track to help me understand a bit? thanks
!paste your pom.xml or build.gradle
Seeing a paste of the problem makes everything so much easier! Use https://paste.lucko.me/ for easy pasting!
Pastebin any relevant segments of the console log. If it's a startup error, this includes the entire startup log!
Pastebin the entire LuckPerms config file (passwords removed) as well as any other relevant files!
and also ensure you are using the latest version of lp on your mc server itself.
(unless you are not using any dependency manager then uh...)
the luckperm itself is working well as I got
//InheritanceNode node= InheritanceNode.builder("rank1").value(true).build();
//DataMutateResult result = user.data().add(node);
this working fine
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.3</version>
<scope>provided</scope>
</dependency>
is my dependency
screenshot /lp info
uh wait shit why luckperm is deleted -_-;.. one sec.. sorry. I think I accidently cleaned it or something
lol
(although not the current issue) using static for LuckPermsProvider.get(); is not a good idea. As it may be null since it only loads when lp loads.
ha. funny it works. oh is it
so instantiate it whenever using?
well not gonna be invoked that many times anyways
I'd just check if LP is enabled
How do I set the permission to false or true with
user.data().add(PermissionNode.builder("custom.music.toggle").build());
Yeah that might be valid, I just feel bad if I force people to toggle that config option to make it work. Thanks for the feedback. Maybe Luck has some input too 👀
there is a .value(boolean) method for the node builder.
Idk if this is the best place to ask but why did LuckPerms choose to use h2 as its default storage type? Just out of curiosity.
It’s faster compared to readable types like yaml or json.
And the point is to use commands or web editor instead of editing the data file itself. Reducing user error.
@nocturne elbow
Fair, although why h2 over sqlite? Speed?
Hey Textxre! Please don't tag helpful/staff members directly.
We have our ways 😄
if i wanna add someone to a group using the api do i just add the group.<group> node to them or is there a better way to do it
Jason didn't we go through this before?
InheritanceNode.builder(group)... or InheritanceNode.builder(groupName)...
never seen that before in my life ngl :p
lmao
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
ty
good?
user.data().add(InheritanceNode.builder(group).build());
luckPerms.getUserManager().saveUser(user);```
sure
Hello!
I'm trying to use luckperms api in a plugin but for some reason luckperms return in services manager is null.
Server version: 1.17
LuckPerms version: 5.3.48
API version: 5.3
LuckPerms logs:
>.... [23:35:29 INFO]: [LuckPerms] Enabling LuckPerms v5.3.48
>.... [23:35:30 INFO]: __
>.... [23:35:30 INFO]: | |__) LuckPerms v5.3.48
>.... [23:35:30 INFO]: |___ | Running on Bukkit - Paper
>.... [23:35:30 INFO]:
>.... [23:35:30 INFO]: [LuckPerms] Loading configuration...
>.... [23:35:30 INFO]: [LuckPerms] Loading storage provider... [H2]
>.... [23:35:30 INFO]: [LuckPerms] Loading internal permission managers...
>.... [23:35:30 INFO]: [LuckPerms] Performing initial data load...
>.... [23:35:30 INFO]: [LuckPerms] Successfully enabled. (took 965ms)
>.... [23:35:30 INFO]: [LuckPerms] Registered Vault permission & chat hook.
My code:
public void onEnable() {
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
api = provider.getProvider();
}
}
I've already tried using "LuckPermsProvider#get()" too (Give me "The LuckPerms API isn't loaded yet!")
luckperms is defined as a dependency in plugin.yml^
@candid fjord please paste your plugin.yml and your pom.xml/build.gradle please
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pardon the delay, got caught up in something
implementation "net.luckperms:api:5.3"
Don't do that
You're shading the API, it's already provided, use compileOnly

I didn't realize that, thanks
How expensive is it to save metadata back into luckperms
Like, should I only save once in a while or not worry about it
also how can i get all nodes under another node
basically i want to sum everything under "fishing.catch"
meta are always strings, so you will need to get, convert to int and add them yourself.
Thank u, so basically just user.data().add(InheritanceNode.builder("groupname").build()); to add a parent and user.data().remove(InheritanceNode.builder("groupname").build()); to remove a parent, right?
Okay thank you! I'm using this for my use case rn for adding one group and removing a bunch of other groups
yea that works
awesome!
thank you, but is there a way i can like iterate over every node under fishing.catch?
because the keys might not be known before hand (the part that says "fish_stingray" could be anything, it's based off of the caught item's id)
Hey, is there an api for bungeecord plugin ?
It's the same API regardless of the platform you're using
!api The first page linked has all you need to include it in your project
Learn how to use the LuckPerms API in your project.
I have already api on spigot
Yeah it's still the same API everywhere else
How would I update a player's group using the API (in a different plugin)?
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
I feel like there is another way to do this java UUID uuid = UUID.fromString(nodeMutateEvent.getTarget().getIdentifier().getName());
Cast nodeMutateEvent.getTarget() to a User object
e.g. User user = (User) e.getTarget();
then there is this method https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/model/user/User.html#getUniqueId()
hi, how can i get which permission do i need to execute command?
!verbose
LuckPerms provides a verbose command to help you find out what permissions a command/plugin is checking.
Or just look in the wikis for all plugins you are using. Permission nodes are usually listed there.
is there api for verbose?
no
so is there other way to get needed permission witch api?
i want to get needed permission to execute command and if player doesnt have show which rank he need to use this command
right that isn't quite possible, or not with the LP API just by itself; what platform is this for? Bukkit, bungee, fabric...
paper/purpur
right so bukkit
yea
problem is that permission for commands can be checked at any time, not only when you run them (e.g. when changing worlds, when tab completing, when joining)
i know but i need this only when player run command
your best bet would be to listen to something like PlayerCommandPreprocessEvent, get the command, get the permission for it, and check against the LP API
i use PlayerCommandPreprocessEvent but i dont know how to get permission
spigot doesnt have any method to get this
it very much does
you can get the command with Bukkit.getPluginCommand(String)
But again, without doing some injecting reflection shit that is most likely your best bet
Because of that, there is no way to distinguish between any of those for a permission check source
Even verbose itself doesn't, even if there was an API for it it does not tell the difference, a permission check is just a permission check as far as it can tell
When i use /anvil this doesnt work but if i use /cmi:anvil its work
That seems unrelated to LuckPerms and permission checking, the error is very descriptive
Is it possible to get players permissions from groups it doesn’t have on global context?
Without having to define the context the group is in, because that’d be for all gamemodes
uh you can probably use PermissionHolder#resolveInheritedNodes(QueryOptions) with non-contextual query options, then stream the resulting collection and remove those nodes that have an empty context set
I may be doing this completely wrong but how would you guys go about mapping group names to their corresponding prefixes/suffixes? (I know you can do .getPrefixes(), but I'm looking to map the group and prefix together somehow) This is how I'm doing it now and it does not like me at all (getPlayerGroups just gets a collection of all inheritance nodes a user has)
Yeah that is not how you do it at all lmao
Noooooooo lmao I figured
resolveInheritedGroups and get the prefix from the CachedMetaData of each, that's how I would do it
I need help
!ask
Please ask the question you have. Don't ask to ask, or ask to DM someone. There are people here to help you, but we need to know what to help you with, so please just ask the question you want to in as much detail as possible!
How do i add luckperms groups to discordsrv
Example i want the Owner prefix to show up on discord chat
There is a format listed in discordsrv. You can try displaying the placeholder for ranks there.
Ahh
What does it look like
Is it the red one?
this channel is for Developer API
Thank you, will give it a shot
So adding a permission to a group with context global doesn’t really affect anything as far as I know now, that’d only work if the group is global as well, just in case someone runs in to that as well
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
How does this work?
CompletableFuture<Void> loadGroups = getApi().getGroupManager().loadAllGroups();
loadGroups.thenAcceptAsync((Void group) -> {
// what can I do now?
});
not much, it just loads all groups so you can ensure getGroup(@NonNull String name) isnt null or you dont have to do isLoaded(@NonNull String name)
yea
ok
I get an error when I try to use this method here: https://github.com/lucko/LuckPerms/issues/2949
you can call getLoadedGroups() to basically get all the groups you just loaded if you need https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/model/group/GroupManager.html#getLoadedGroups()
Maybe this is becoming the 'xy problem' thing
Okay
I'm doing a chat pings and I want to be able to ping groups, so I need to:
#1) know if it is a valid group name, if yes get the group
#2) get all online players in that group
the Function interface cant define the var types correctly for some reason....
Idk if I should query everytime or maybe cache the entire group/users?
yeah
Hey guys, is there a way to get the weight of the players group?
@NonNull
OptionalInt getWeight()```
Gets the weight of this group, if present.
the group weight
ah I see, thanks man!
Hey @jaunty pecan why do you return Optional in your api?
Hey Mqzn! Please don't tag helpful/staff members directly.
Because a rank can have no weight set
apologies
then -1
or just keep the optionalint
what if i actually want to set my group's weight to -1?
then just simply disallow that
lol no
throw a custom exception, i would do that
that sounds like bad plugin design ngl
what made you think about that
it's like "oh you can do all of this except when this happens"
you give freedom to your users but constrain them with that just because you want to api return -1
Then what does OptionalInt return
it's the classic example of "Oh this works wonderfully except on Tuesdays when it's raining", that is not good design (neither it's a good experience for the end consumer, they should have all the freedom they want within reason)
🤡 "throws an Exception"
Yea?
that's why you check if it's present first
or use orElse
or whatever
it's only good on the side of logic
you can't call getAsInt if there is nothing to get
no more advantages
not really a bad design tbh
using OptionalInt for this use case fits perfectly really
a group may not have a weight in which case the optional will contain nothing, but if it does then the group's weight can be any value within the int range, and the optional will contain it
weird thing to argue about :p
but yes, OptionalInt is definitely the correct choice there imo
no, it very much is the correct choice
an Optional represents a value that can respresent null, and it doesn't mean something went wrong
that's exactly what it's being used for
How do i retrieve the goup metadata for one specific player.
to be more clear i know i can do
luckPerms.getPlayerAdapter(Player.class).getMetaData(source);
and then stuff like getPrefix/getSuffix/getValue which returns metadata value from groups having highest priority, but is there an easy way to get values from all groups in somewhat sorted order? not just from the group with highest priority
also is there any way to add transient metadata to an user that will be cleared when a player disconnects the server?
those doesnt seems to be able to set meta prefix and suffix
public interface SuffixNode
extends Builder>```
SuffixNode has 2 methods, 1 extensions, and 5 super interfaces.
A sub-type of Node used to store suffix assignments.
how i can check if user group is permanent or temporary?
Find the InheritanceNode for the group you're wanting to check (from PermissionHolder#getNodes(NodeType) and check if it hasExpiry
is there an alternative to checking if a player has the group.<group> permission to check if a player is in a group? since this is ineffective for opped players
Hm PermissionHolder#getInheritedGroups(QueryOptions) probably
Hi :D! Sorry for the trouble, but i'm having issues with specifying the User (User user = ...)
Eclipse can't find "luckPerms"
(I did already the registering of luckperms in onEnable())
How can i resolve that?
Hey the prefix wont show up ive used stylist chatx and others ive changed the weigh and nothing
Wrong channel
There is anyone who can solve that?? If anyone helps me, ping please 😄
means that the variable just doesnt exist...? check your code, doesnt sound like luckperms APi related
Thanks. Later i will try
Ben wait a momeng
Moment*
Yeah
yea its just an example code snippet
You need to get an instance of LuckPerms
you need to get the instance of LuckPerms and store in a variable named luckPerms
!api
Learn how to use the LuckPerms API in your project.
Another thing... for adding a user in a group i need to add the permission "group." And the name of the group?
the name is up to you
its based on what you created in luckperms for your server
Hi, i have another problem
when i try to do a command of my plugin, my console print a NullPointerExpection error in this line:
User user = luckPerms.getPlayerAdapter(Player.class).getUser(player);
How can i solve that?
Seeing a paste of the problem makes everything so much easier! Use https://paste.lucko.me/ for easy pasting!
Pastebin any relevant segments of the console log. If it's a startup error, this includes the entire startup log!
Pastebin the entire LuckPerms config file (passwords removed) as well as any other relevant files!
Hey MaxPlay066! Please don't tag helpful/staff members directly.
yes, the player is online
Luckperms is null
wait a moment
now the console print another error
java.lang.IllegalArgumentException: Attempting to build non-permission node with PermissionNode.Builder. permission = 'group.market', correct builder type = me.lucko.luckperms.co
oh okay
about that?
Not sure
Send code again
Above onEnable
LuckPerms luckPerms;
Then in onEnable
luckPerms = provider.getProvider()
oh okay
does luckperms usermanager reset on restart
I have a weird issue where I do /ignore list and it shows the correct formatting, then I restart the server and it shows gray until the player rejoins
and its not to do with the player not being online
public String getPrefixFromName(String name) {
if (TwistBungeecore.getAPI().getUserManager().getUser(name) == null) return "&7";
else return Objects.requireNonNull(TwistBungeecore.getAPI().getUserManager().getUser(name)).getCachedData().getMetaData().getPrefix();
}```
thats my method
but if they've joined and then they leave, it still shows formatting after their name
its only after a restart
Btw i swear getUser takes an uuid?
It can take a name
Because users are loaded for up to a minute after they leave
If you run that code 2 or 5 minutes after they have left, the user will be unloaded and getUser will return null
ah right, so how do I load the player when they're offline?
!api The second page linked goes over that
Learn how to use the LuckPerms API in your project.
Thanks!
Main.luckPerms.getPlayerAdapter(Player.class).getUser(p)
.getNodes(NodeType.PERMISSION).stream()
.filter(Node -> Node.getPermission().equals("group.vip"))
.filter(permissionNode -> !permissionNode.getValue()).count();```
I want check whether the player is in or inherited from any group
this code can check if a player belongs to a group but cannot check if he inherits from it
a and I need expiry but a know how get this with permission but idk how get this with group
What would be the most efficient way to get a list of UUIDs that have a specific permission? It also needs to query offline players.
maybe this?
public CompletableFuture<Set<UUID>> getUsersWithOfflinePerm(String perm) {
return luckPerms.getUserManager().searchAll(NodeMatcher.key(PermissionNode.builder(perm).build())).thenApply(Map::keySet);
}
Yep, that's how you'd do it (although you can skip the node building and just pass the perm string)
PERMISSION nodes are precisely not inheritance nodes
For that you would getNodes INHERITANCE and filter for group name (InheritanceNode has a grtGroupName method or something similar)
Collection<InheritanceNode> nodes = user.getNodes(NodeType.INHERITANCE);
getTime(nodes);``` ```java
public static long getTime(Collection<InheritanceNode> nodes) {
long time = -1;
for (InheritanceNode node : nodes) {
if (node.getGroupName().equals("vip")) {
if (node.hasExpiry()) {
time = node.getExpiryDuration().getSeconds();
} else {
time = 0;
}
}
}
return time;
}```
I have this source
but I have one problem
how I check player with vip+ (with extends vip) this return -1
-1 player haven't rank
0 player have rank on unlimited time
more how 0 player have rank on time X
Hm then you may have to use resolveInheritedNodes or getInheritedNodes (I don't remember the exact name) instead of getNodes(...)
Hi! sorry for the trouble, but i'm having problems with luckperms api
Here the error
and here the code (wait)
marketl.add(player);
market.remove(player);
user.data().add(PermissionNode.builder("group.market").build());
player.sendMessage(ChatColor.BLUE + "Hai appena accettato il contratto lavorativo per il market");
luckPerms.getUserManager().saveUser(user);
thanks in advance
@frail quest you wanna add permission to the player?
oh thanks realy you are the best 😉
Collection<InheritanceNode> nodes = user.resolveInheritedNodes(NodeType.INHERITANCE, QueryOptions.defaultContextualOptions());
long time = getTime(nodes);```
public static long getTime(Collection<InheritanceNode> nodes) {
long time = -1;
for (InheritanceNode node : nodes) {
if (node.getGroupName().equals("vip")) {
if (node.hasExpiry()) {
time = node.getExpiryDuration().getSeconds();
} else {
time = 0;
}
}
}
return time;
}```
but I have one problem
how I have vip+ on 2 week program return 0 (unlimited time vip) (return expiry with vip+)
Hey !
I have a question ? How to add a permission to a player with LuckPerms ?
With the api?
Yes ! ^^
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
!api
Learn how to use the LuckPerms API in your project.
guys, is it possible to get an api from luckperms bungee? looking for the provider, (which is obvious) has to have the spigot jar on the server.
Learn how to use the LuckPerms API in your project.
private void registerLuckPerms() {
final RegisteredServiceProvider<LuckPerms>registeredServiceProvider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (registeredServiceProvider == null) {
throw new NotFoundException("LuckPerms is not present");
}
luckPerms = registeredServiceProvider.getProvider();
}
looking for the provider, it can't find the luckperms api.
do we have to fetch the provider that way?
LuckPermsProvider
Yes
oh, ok.
Exception
Caused by: java.lang.ClassNotFoundException: net.luckperms.api.LuckPermsProvider
//
private void registerLuckPerms() {
try {
luckPerms = LuckPermsProvider.get();
} catch (IllegalStateException exception) {
Bukkit.getConsoleSender().sendMessage("§cLuckPermsAPI not found");
}
}
Soft depend on LuckPerms
Also make sure LP is installed
And make sure you dont shade LPApi in
is installed only on the bungee
It needs to be installed ok the server you want LP to work on
Bungee LP is not a replacement for the whole network
You still need to install it on each server
a ok, is there any jar that only registers the api? without literally being luckperms?
No
That's not a thing
How would the API work without LuckPerms
Doesn't make any sense
!network
If you run a BungeeCord network, learn how to correctly setup LuckPerms on all server instances (including Bungee).
Syncing data between servers
!database
Sorry! I do not understand the command database
Type !help for a list of commands
!help
!advanced
!api
!argumentbased
!ask
!bulkupdate
!bungee
!bungeecheck
!cauldron
!colours
!commandequivalents
!commands
!config
!context
!cookbook
!default
!downloads
!editor
!editorsafety
!errors
!essentials
!extensions
!extracontexts
!faq
!formatting
!helpchat
!inheritance
!install
!libsdir
!locale
!meta
!migration
!notworking
!nowildcard
!pasteit
!permissions
!placeholders
!selfhosting
!stacking
!storage
!suggestions
!switchstorage
!sync
!testingperms
!tracks
!translationprogress
!translations
!upgrade
!usage
!userinfo
!verbose
!version
!weight
!whyluckperms
!wiki
!api
Learn how to use the LuckPerms API in your project.
If I wanted to set a permission to a player on only "this" server using the API, is this the proper approach?
fun EntityPlayerMP.setServerPermission(permission: String, allowed: Boolean = true, expirySeconds: Long = -1L, mergeStrategy: TemporaryNodeMergeStrategy = TemporaryNodeMergeStrategy.NONE) {
val api = LuckPermsProvider.get()
api.userManager.modifyUser(uniqueID) { user ->
val node = PermissionNode.builder(permission)
.withContext("server", api.serverName)
.value(allowed)
if (expirySeconds != -1L) {
node.expiry(expirySeconds)
}
user.data().add(node.build(), mergeStrategy)
}
}```
Essentially using `LuckPermsProvider.get().serverName` to set the `server` context on a node
That's one way yeah
Is there another one that'd be better?
Eh probably not
alright, thanks ^^
!downloads
You can download LuckPerms for Bukkit/Spigot/Paper, BungeeCord, Sponge, Fabric, Nukkit and Velocity.
!version
5.3.51
!notworking
We really would absolutely love to help you out! However, telling us that it isn't working wastes everyone's time. Please, just describe the issue you're having clearly and with as much detail as possible, and send any relevant screenshots of whatever problems you're having.
please use #general for bot spam
For BungeeCord, Am I going to use skeleton method?
The what??
Oops it was my auto correct, I meant singleton
kk!
What is the suitable event for Listening User Group Update?
"group update" as in "update parent group" or "added node to a group"?
Well whichever the case is, the cookbook has an example for those and more
!cookook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Is there any way to retrieve the user's previous primary group directly from a NodeAddEvent?
I think there's a getDataBefore/After methods
You would need to compare those
d;methods LP NodeMutateEvent
net.luckperms.api.event.node.NodeMutateEvent#getDataAfter
net.luckperms.api.event.node.NodeMutateEvent#getDataType
net.luckperms.api.event.node.NodeMutateEvent#getTarget
net.luckperms.api.event.node.NodeMutateEvent#isUser
net.luckperms.api.event.node.NodeMutateEvent#isGroup
net.luckperms.api.event.node.NodeMutateEvent#getDataBefore```
Yep
I'm trying to alert users with a staff rank if they are using a permission which non-staff lack. How would I check if a permission node is part of a group (or its children) while using the same context as a User object?
For example, the rank default may inherit smpdefault if server=smp.
I tried to create a User object and use setPrimaryGroup("default") and then check user.resolveInheritedNodes but it didn't take into account the group change. I also tried using a Group object to do group.resolveInheritedNodes but I would need the player's context. Thank you!
How would I check if a permission node is part of a group (or its children) while using the same context as a User object?
I mean in reality using the platform's permission API (e.g. Bukkitplayer.hasPermission("permission")) should suffice, but if you need the tristate value (true/false/unset) then you need to do this: see in here the section about cached data and performing permission checks with it https://luckperms.net/wiki/Developer-API-Usage
Both of those options take the user's active contexts into consideration (in fact, LP's platform permission checks are backed by the cached data)
Thanks! Would it be possible to do something like hasPermission given a User and if the user's primary group was default?
I tried to create a User object and use setPrimaryGroup("default")
Despite the method name, it does not do what you might believe it does, if you want to change a player's parent groups, see here for an example https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/commands/SetGroupCommand.java
i mean sure you can getPrimaryGroup and check against "default"
Ok I think a better question to ask would be whether there is a method to get a query option representing a user context that way I could check against "default" using the user's server and world. Or would I have to build the user context and convert it to QueryOptions myself?
i have no idea what you're asking exactly
the primary group is also calculated with the active contexts taken into consideration
I want to check if given a player with a non-default rank, a permission node is coming from any of their ranks besides default (or children of default)
okay there is probably an easier way of doing that
give me a minute
Thanks! 😄
You can probably use a mixture of these things:
https://javadoc.io/static/net.luckperms/api/5.3/net/luckperms/api/node/metadata/types/InheritanceOriginMetadata.html (if you aren't familiar with the concept of metadata, see https://luckperms.net/wiki/Developer-API-Usage#store-and-query-custom-metadata)
Maybe this is appropriate? https://javadoc.io/static/net.luckperms/api/5.3/net/luckperms/api/model/PermissionHolder.html#resolveDistinctInheritedNodes(net.luckperms.api.query.QueryOptions)
And to get the user's active query options well, just this tbh, nothing else https://javadoc.io/static/net.luckperms/api/5.3/net/luckperms/api/model/PermissionHolder.html#getQueryOptions()
Then from the resulting Set, check each node's origin with the metadata key from above
This is great thank you so much!
My plugin works now. 😄 I used all the links you sent me. Only problem I had was I couldn't use getQueryOptions because in Bungee, server=bungee and world=serverName.
uh, I'm lost.. I'm trying to check when a user has a group added or removed
im trying to use nodeaddevent
but im sadly failing
My code is,
private void onNodeAddEvent(NodeAddEvent e) {
if((e.isUser() && e.getNode().getType() == NodeType.INHERITANCE) || (e.isUser() && e.getNode().hasExpired())){
System.out.println(e.getTarget().getFriendlyName());
RankSyncer.syncRanks(e.getTarget().getFriendlyName(), Objects.requireNonNull(lp.getUserManager().getUser(e.getTarget().getFriendlyName())).getPrimaryGroup());
}
}
and Yes I've registered everything properly
lp.getUserManager().getUser(e.getTarget().getFriendlyName())
uh.. you can just.. use the event target?
you can cast it to a User if it's a user
anyway, what about that doesn't work?
Also, chances are this e.getNode().hasExpired() will be false in NodeAddEvent :d a node is being added, it won't be added when it's already expired, it makes no sense
How to check, the expiry of a MetaNode?
yes
returns an Instant, or a getExpiryDuration that returns a Duration if you need it like that
so you want to retrieve a meta node to check its expiry date
yes
uh probably something like
Set<MetaNode> temporaryMetaNodes = user.getNodes(NodeType.META)
.stream()
.filter(Node::hasExpiry)
.filter(NodeMatcher.metaKey("meta-node-key"))
.collect(Collectors.toSet());
that will result in all temporary meta nodes for that meta key
or if you only want the "first" one (if any) then .findFirst() instead of .collect(...)
Thanks!
How can I display the expiraty in a dd.MM.yyyy HH:mm format?
never worked with that before
same logic but extended for months and years i guess
actually this thing exists
exist a event to check if the rank of the player was changed?
private void onNodeAdd(NodeAddEvent e) {
if (!e.isUser())
return;
User target = (User) e.getTarget();
this.main.getServer().getScheduler().runTask(this.main, () -> {
if (e.getNode().getType().equals(NodeType.INHERITANCE)) {
}
});
}
NodeType.INHERITANCE are basically group. nodes
thanks
Hello, I need some help.
Is it possible for user.getPrimaryGroup() to return null, even though 1) the user is an online player (its me) and 2) the role is not null?
?
for the maven or gradle buildtool
so you dont use a build tool?
if they actually are not in a group, yes
java, 1.12.2 spigot api
can you show me your code
lol both not understanding each other, but how will dependency manager be relevant for the above questions anyways?
Thats if you shade luckperms into your jar, so its prevent to communicate to the real plugin
public static boolean methodName(String playerName) {
API.sendDebugMsg(playerName); //this returns my nickname, which is correct and not null
User user = api.getUserManager().getUser(playerName);
String role = user.getPrimaryGroup().toString(); //this returns null
}
and i am in a role
your plugin will probably not even start
thats too 😄
But when you fail its start and returns an error or null
ahh
wait i send you the right code
yea but still unrelated, the null is not at api instance
ensure you are using the latest version of lp on your server
!update
You can download LuckPerms for Bukkit/Spigot/Paper, BungeeCord, Sponge, Fabric, Nukkit and Velocity.
alright
LuckPerms api = LuckPermsProvider.get();
User user = api.getUserManager().getUser(e.getPlayer().getUUID());
Group group = api.getGroupManager().getGroup(user.getPrimaryGroup());
// returns the group object
return group;
// returns the group name
return group.getName();
well, my whole plugin works with the code i sent and literally just this one method does not work
user.getprimarygroup returns only the name of the group, so you have to get the group over the groupmanager
all the other methods do work
actually, user.getPrimaryGroup() is alr a string, why are you doing a .toString() again
ik
the tostring wasnt there originally
also if getPrimaryGroup is null, .toString() will fail with NPE
yeah
so thats what is happening?
it was not there before, i just tried to add it cuz sometimes it fixes stuff
yes because getprimarygroup is a string - its the name of the primary group of the player, but its not a group object, so if you want to get the group object, you have to get it with the api
i need to get the name, not the group
cuz my code works with the name
then i cant help you, the string should return the name of the group
that's fine tho
OOOOOOOOOOOOOOh, now i realised its even more messed up
nothing about the group object, its about what getPrimaryGroup returns
player.getName() (which is playerName) returns...... uh
maybe the user is not loaded yet
whats that
public static boolean methodName(String playerName) {
API.sendDebugMsg("1" + playerName);
sendDebugMsg is just a msg that is sent just to me
playerName is player.getName
but it sends name and role on the other line
but its executed just once so idk why 2 lines
and then the role is null
is the player online in the server?
screenshot /lp user USER info and /lp info
yes but... it shouldnt
why not?
??????
this thing
Where are you called methodName
playerName is player.getName() which returns Vojtiisek as thats my name
Right click to check usages
99% chance its a different log code
^
means your code logic elsewhere is wrong, and you are passing groupname as playerName into the method
how do i do that in eclipse? never used that thing
Oh idk
I use intelliJ lol
that is how i call the method: roleHasLevel(player.getName())
player is commandsender
i mean
player is player
that is commandsender
well then it has to called twice
Thats a different method?
for it to log twice
its the same
code aint magic
find the other instance that method is called
unless this line is in a loop
no way its a lp issue, if it logs twice with one log message and you dont even know why
I am a dumbass
sorry for wasting yall times im just blind
the method was used once and then the second time through an another method
and in the another method there were wrong args there
but thanks for helping me, you were right, ben
this.
french guy can mention me ?
How do I get all the Groups/Parents of a user is there a API method OR Do I've to make a filter loop.
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Hss examples iirc
perms.getUserManager().getUser(username).getInheritedGroups(QueryOptions.defaultContextualOptions()).forEach((e) -> {
if(!e.getName().equalsIgnoreCase(group)) {
if(!config.getStringList("donoroles").contains(e.getName())) {
manager.setDono(username, false, SQLManager.AccountType.UUID);
}
}
});
will this work?
I know this old but someone can help me?
Learn how to use the LuckPerms API in your project.
Ay
I have downloaded grant+ but don't know how to add ranks any advice?
with lukcperms
I'm trying to pool the information I need into one event but am failing because 'NodeMutateEvent' throws twice with each time providing half the information
public void onGroupChange(NodeMutateEvent e) {
if (e.isUser() && e.getDataType().equals(DataType.NORMAL)) {
Player player = Bukkit.getPlayer(e.getTarget().getFriendlyName());
Node[] before = e.getDataBefore().toArray(new Node[0]);
Node[] after = e.getDataAfter().toArray(new Node[0]);
String originalGroup = before[0].getKey();
String updatedGroup = after[0].getKey();
Bukkit.getPluginManager().callEvent(new LuckPermsGroupUpdateEvent(player, originalGroup, updatedGroup));
}
}```
Could anyone advise?
Node#getContexts()
then see the methods in the ContextSet interface
I uh..
First, NodeMutateEvent is not a Bukkit Event, you don't register it as an EventHandler
Secondly, this...
String originalGroup = before[0].getKey();
String updatedGroup = after[0].getKey();
this is so unreliable
what are you trying to achieve exactly
RE the second point, I threw that together to try and show the information I'm attempting to retrieve
The outcome I would like is an event where I can get: The Player who has had their group changed, the name of the original group they had, and the name of the new group they have
@rustic laurel
ty
wdym by "throws twice with each time providing half the information"?
and what are you doing exactly that dispatches the event?
NodeMutateEvent throws once when the group is added and another when the old group is cleared - My issue is figuring out a way to get both of these into the same place
Triggering nodemutateevent in the first place is me changing the primary group of a player - /lp user * group set *
Well it triggers twice because parent set are two actions really
First NodeAdd and then NodeClear
Understandable, do you know of a different event I could utilise that would allow me to get the before/after groups at the same time?
hm
well there is no single "node clear and add" or whatever event
I guess your best bet is to just listen to NodeAddEvent and check if the node that was added is a node of nodetype INHERITANCE
if i do chat.getplayerprefix() will that return the luckperms prefix? (chat is the vault chat)
Yea
and is there also a way to get all prefixes in a list or something
i want to use the length
Is there a temporary permission expiration event?
:/
trying to get the length of all the groups of that players and that way create a gui with the corresponding amount of slots
remove the for loop and use the .length value
smh what was i doing iterating over an int
now i'm trying to get all the group prefixes
private static void loadGroups() {
groups.clear();
Set<Group> groupsSet = luckPerms.getGroupManager().getLoadedGroups();
for (Group group : groupsSet) {
groups.add(group.getName());
}
}
public static HashMap<String, String> prefixes = new HashMap<>(); //group, prefix
private static void loadPrefixes() {
prefixes.clear();
for (String groupName : groups) {
String prefix = luckPerms.getGroupManager().getGroup(groupName).getCachedData().getMetaData().getPrefix();
if (prefix == null || prefix.equalsIgnoreCase("null")) {
prefix = "&7";
}
prefixes.put(groupName, prefix);
}
}```
this is how I do it
how do i get all groups of a offline proxiedplayer
ow thank you very much
is there also a way to check if a player is in a specific group?
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
:D
now i'm trying to get all groups of a player :/
lol good luck
something like this?
public static Set<String> getPlayerGroups(Player player) {
Set<String> groups = new HashSet<>();
for (Group g : Main.getApi().getGroupManager().getLoadedGroups()) {
if (player.hasPermission("group." + g)) {
groups.add(g.toString());
}
}
return groups;
}
ah ki
and i changed it to a list
i'm creating a gui where players can choose their prefix :/
Why no use deluxetags :P
uhh never used
Is quite easy. Lmk if you'd consider it, I could give you a crash course on it
So I can add permissions via the API, but what about adding permissions as false? Otherwise known as negating them?
Basically negating scoreboard permissions for my users on Bedrock, since the scoreboard is messed up on Bedrock
I was able to do this with a custom command to set the prefix, custom file to store the user's prefix (pre-set prefix) and then a menu from DeluxeMenu to set/choose the prefix, and to store permissions
Basically: Created a file for storing user data, made a custom command /setprefix <player> <prefix> (set the prefix options in the code) and then made it only runnable through console, and then created a GUI in DeluxeMenus to let the players choose it, and also made my own placeholder for the prefix as well via PlaceholderAPI
With this they don't create their own prefixes, but they can if you do it differently, kinda like how I made custom join messages, but that's a different story
I was also able to do it using DeluxeTags and a custom GUI via DeluxeMenus (just to change the look of it)
Also changed the alias in DeluxeTag's plugin.yml to "/prefix" and then in commands.yml for spigot set "/tags" to a different tags plugin (ImmortalTags) but honestly that's more complicated (and requires a different tags plugin ImmortalTags for example if you also want to use tags as suffixes
Anyways does anyone know about this lol
set the value to false
the Node object should have a method setValue(boolean)
So I have this, Node scoreboardOffNode = Node.builder(scoreboardOff).build();
do I just add ".setValue(false); after .build()?
I believe its before
or just do scoreboardOffNode.setValue ..
second example should show something similar
i want to have a single permission group, but the prefix changes depending on the player's gamemode, is it possible to make a group like this with the api? or is there some easier solution?
You don't even need the API for that really, you can use contexts since LP provides a gamemode context
You can set a permission or group on a per-world/per-server basis, through what we call "contexts".
cool ty
How can i Import thr api to my maven Spigot project
!cookbook Isn't that covered somewhere here? Not sure
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Haha. No
how can i add permission to player
With the api?
yes
!api
Learn how to use the LuckPerms API in your project.
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
what is "luckPerms"
it doesnt add permission "hihihihihi" to me
Use userr instead of user
?
- is the first if condition on args even satisfied?
- Is provider null?
Log to console
PluginInstance#getLogger().info("LP not null");
I was wondering about that...
it work perfectly now thx a lot 
is there a way to get arbitrary permissions starting with a prefix through the API?
as in, say you had a claims plugin, you had a permission like claim.10 and that permission would indicate that user/group could claim up to 10 chunks
d;lp UserManager#searchAll
@Unmodifiable @NonNull
<T extends Node> CompletableFuture<Map<UUID,Collection<T>>> searchAll(@NonNull NodeMatcher matcher)```
Searches the normal node maps of all known Users for Node entries matching the given matcher.
5.1
matcher - the matcher
the entries which matched
iirc it has a atartsWith method
Hey, we want to rewrite a plugin from bukkit to bungeecord so I have just a question about how to get the luckperms provider in bungeecord
For bukkit we used
But what is it in bungeecord
!API I believe the second page linked explains how to get the API instance
Learn how to use the LuckPerms API in your project.
Hello, I'm new to using LuckPerm's API and would like your help in a matter:
I want to reset a player's group in a specific Track using the API. I found Track#demote and decided to just use it until the player can no longer be demoted, but I have 4 questions:
- The
demotefunction requires a User and a ContextSet - I understand how to get the player as a User (#getPlayerAdapter(Player.class)#getUser), but what is the ContextSet and how do I get it? (I want to demote everywhere, not in a specific situation/place) - How do I know I reached the first group in the chain so I don't end up kicking them out of the Track? Meaning: do I just need to check their current group in said Track after each demotion or is there an easier way?
- How do I get a player's current group (or index at least) in a Track?
- Do I need to save the data after I finish demoting them or does
demotedo it automatically?
Thx in advance!
- You can pass an
ImmutableContextSet.empty()/.emptySet()/something like that - Yes, you'd have to check that "manually"
- Get the user's direct parent groups and filter those that are on the track; ideally you would end up with either one group or none
- I forgot lol
Thx!
But how do I get the player's parent groups? There's only a function to get their primary group
There's a resolveInheritedGroups method or smth
You should end up with something like user.resolveInheritedGroups(user.queryOptions().toBuilder().flag(Flag.INHERITANCE, false).build(), can't remember off the top of my head, play around with it
found it, thx!
Last question for now: how do I add a permission to a Group? Do I just get its data with #data, add a new Node and save it, or something else?
no, nothing else, it's pretty much just like a user
is there a UserManager#searchAll alternative that takes into account the user's groups?
.
eh you should definitely use meta nodes for that
also like you want to get every user with a claim.* perm?
How do I get the players rank?
Hey, I'm not sure if this is right channel but let's try. I'm creating plugin which utilizes luckperm's group. Currently something like that happens:
can I get already formatted group using legacy color codes?
uh is this to do with the API?
in general terms User#getPrimaryGroup() is sufficient enough, but keep in mind users can have more than a single parent group (and may inherit from others too)
What's your goal?
ohhh, I was using event.getPlayer().getGroupName()
its javascript
events.on('AsyncPlayerChatEvent', event => {
const name = event.getPlayer().getDisplayName()
event.setFormat(event.getPlayer().getGroupName() + name + c(" &7» &f") + event.getMessage());
});```
yeah idk what getGroupName() is, neither the event nor that method are from LP
depending on your environment it may be correct or not, wouldn't know
I got it off some spigot thread
I mean getGroupName doesn't exist in spigot either
Looks like it was from "groupmanager"
no clue
another perms manager iirc
not really a quesion with the api but does luckperms store what permissions each user has or is it done by bukkit?
LP
Since it also is implemented for other platforms (Sponge, Bungee, Fabric, ... Nukkit?) something like storage is pretty much just abstracted away from the platform LP is running on
okay thanks
how is it actually stored in the db? is it a table for each player? or are is tehre a table for each player or something
As far as database storage is concerned, pick your poison
https://github.com/lucko/LuckPerms/tree/master/common/src/main/resources/me/lucko/luckperms/schema
thanks
Hey guys! I am making a bungeecord plugin along side luckperms, and I have put the luckperms developer API into my bungee project. However after reading through all the documentation and researching online, I'm afraid I'm still very confused on how everything works. Are luckperms permissions and groups completely separate from bungeecord permissions and groups? If so, how can I check if a player is part of a group, or has a permission etc..
Thanks in advance, sorry if this an extremely basic question I can't wrap my head around :P
!api
Learn how to use the LuckPerms API in your project.
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Between all those you should get the hang of it, the API itself is the same everywhere (and yes, BungeeCord groups are separate from LP groups)
Perfect, thanks! Will take a look at all of those
How can i obtain an instance of the LP API in Velocity 3.X.X
!api
Learn how to use the LuckPerms API in your project.
This only tells you how to obtain it in Bukkit, Sponge & Singleton access
I only tried the singleton access method but it doesn't work: https://haste.nycode.de/efupojusij.vhdl
Have you read a, b & c?
a)
Bukkit, Sponge, Singleton
b)
What you can do when you got it
c)
The Javadocs
No the errors
oh
Have you stated luckperms as a dependency in @Plugin?
ohhhh thanks i'd guess thats the error
Is there a Luckperms event when a user gets a new rank or something like this?
here you can see an example of a listener listening to permission changes. you can do a similar thing and check if node.getType() == NodeType.INHERITANCE
JavaDoc for NodeType: https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/node/NodeType.html
Example listener I was talking about: https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/listener/PlayerGivenPermissionListener.java
If I add those 2 permission nodes into single user.
luckPerms.userManager.modifyUser(player.uniqueId) { user ->
user.data().add(Node.builder("foo.bar").expiry(Duration.ofDays(1L)).build())
user.data().add(Node.builder("foo.bar").expiry(Duration.ofDays(2L)).build())
}
the expiry duration will be merge to 3 days?
I'm not sure whats wrong
I copied it exactly
wait nvm
How do I add the repository? I'm a noob
I have no idea what I'm doing
ok wll
I restarted
and for some reason its fine now
thanks
Its a dependency now, but it still throws me an exception https://haste.nycode.de/otowamuras.vhdl
Do the LuckPermsUtil(LuckPermsProvider...) in the proxy enable event or something
Whenever LP loads
ohhh thanks <3
I need to add this code on onEnable() to use the api?
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
LuckPerms api = provider.getProvider();
}
Yes
and if I plugin in onload
it will work too?
Well, in the class make a LuckPerms api;
Then in there do api = LuckPermsProvider.get()
Dont think so
Its onEnable iirc
I mean that my plugin is starting before most of the plugins bcz I have a world generation class there
load: STARTUP
It will work if the plugin is like that or I need to do it after the plugins loads?
Make sure you softdepend on LuckPerms
yeah of course
so just put that in the onenable?
and then I need to access this api varible if I want to use the api?
Yea
how I can get the player prefix?
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
How do i get the prefix of a group
Check this
This is really good
HI, how to settemp perms with Api?
NodeBuilder#expiry(long duration, TimeUnit unit)
thx
why null?
"net.luckperms.api.LuckPerms.getUserManager()" because "me.mateo.Hooks.LuckPermsAPI.luckPerms" is null
Well, it says why
java.lang.NullPointerException: Cannot invoke "net.luckperms.api.LuckPerms.getUserManager()" because "me.mateo.Hooks.LuckPermsAPI.luckPerms" is null
I'm trying to make a method to add temporary permissions, but it marks me empty
Seeing a paste of the problem makes everything so much easier! Use https://paste.lucko.me/ for easy pasting!
Pastebin any relevant segments of the console log. If it's a startup error, this includes the entire startup log!
Pastebin the entire LuckPerms config file (passwords removed) as well as any other relevant files!
Somewhere you need to do luckPerms = LuckPermsProvider.get()
/lp editor
java.lang.NoClassDefFoundError: net.luckperms.api.LuckPermsProvider
at net.pixelplays.extendedsurvival.ExtendedSurvival.onEnable(ExtendedSurvival.java:50) ~[?:?]
im getting this error when using the luckperms api
luckPerms = LuckPermsProvider.get();
that is line 50
private LuckPerms luckPerms;
and here for "luckPerms"
can someone explain what the problem is
is this on bukkit/bungee/..?
Is LuckPerms installed on the server..?
yes
Also is it in your (soft-)depend in the plugin.yml?
no but before changing to 1.17.1 it wasnt still a problem
well it should be there, there are no guarantees about Bukkit's plugin loading order unless you define it yourself (loadbefore/depend/soft-depend)
hello world
pls help
how can I trigger a group (parent) change event for a player
and get a player name
pretty much this with a few tweaks https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/listener/PlayerNodeChangeListener.java
!api if you are unfamiliar with the API as a whole you should definitely read these wiki pages
Learn how to use the LuckPerms API in your project.
ohh, yeah, i mb should read or filter first thanks
what java.pkg do i need to use to get luckperms ranks (I have vault vtw, so if theres a way I can use their hooks that would be great)
This example plugin will probably help and guide you in the right direction too https://github.com/LuckPerms/api-cookbook
See I'm writing in javascript
and all the plugin suports is importing pkgs (I assume that means packages), so would I do something like this?
const { net.luckperms.api.LuckPerms } = Java.pkg("me.lucko.lpcookbook.listener"}
``` or...
Java !== Javascript
I know
the "lpcookbook" package is just the package of the example plugin
not the actual LP API
you can find the LP packages here https://javadoc.io/doc/net.luckperms/api/latest/index.html
how can I get a user's group in a specific track
Unfortunately the user can be on many groups on a track (without using promote/demote/parent settrack but rather parent add directly)
You'll have to manually loop the user's (direct) parent groups (PermissionHolder::getInheritedGroups and turn off the Flag.RESOLVE_INHERITANCE) and check which one(s) are on said track with Track::containsGroup
ok thanks
Which event would be the best to listen to for when a player is added/removed from a group
NodeMutateEvent
and look for group.xxxx i assume?
check event.getNode() instanceof InheritanceNode
ah okay and then I can do InheritanceNode#getGroupName, perfect thanks
yep exactly, np
I'm trying to add a context for rank progression
Every time a player would promote themselves it would cost money
I got as far as downloading ExtraContexts
i want get group list
I hooked luckperms and ess with papi
what?
why are you here?
GroupManager#getLoadedGroups
that was to minjae-
Few questions
- Can this easily be used on BungeeCord
- Is there an easy way to see how long is left of a player’s temp rank.
-> I’m thinking of making a bungeecord command for/rankwhich returns what rank the player has and (if applicable) how long is left.
thanks
not sure what you mean/imply by "easily on BungeeCord"?
The API is the exact same on every platform
so if you find the API hard to use on Fabric you'll find it just as hard to use on Bungee lmao
Well that is number 1 answered. Just wanted to make sure it would work the same on bungee as it would bukkit
Is there an easy way to see how long is left of a player’s temp rank
pretty much just:
- get the player's own INHERITANCE nodes
- filter those that have an expiry
- map the group name to the expiry (both of which you can get from the InheritanceNode)
done ig?
I’ll play around with that, thanks.
private static net.luckperms.api.LuckPerms luckPerms;
public static void createTeam(String team){
luckPerms.getGroupManager().createAndLoadGroup(team);
}
is NullPointerException
Do you ever initialize the luckPerms field?
This is my first time using the api from luckperms
You should probably read the main api usage guides:
- General concepts and things you'll use and eventually have to know: https://luckperms.net/wiki/Developer-API
- Overall elements of the LP API you'll most likely use: https://luckperms.net/wiki/Developer-API-Usage
- And here's example plugin that makes use of several aspects of the API, you can use this to guide yourself too https://github.com/LuckPerms/api-cookbook
Add depends: [LuckPerms] to your plugin.yml
How often does UserDataRecalculateEvent fire?
There isn’t an interval for that, it based on whether someone add/remove a perm, a player joins the server, or a manual cache invalidation is called
alright thank you 🙂
Listen to the NodeRemoveEvent, check that the node is an InheritanceNode with an expiry and that the event target is a User
do this
this other person had the exact same request hahah
no problem
Hello guys! Who know, why sometimes UserManager#getUser(UUID) returns null? Player is also on server (Example)
Code
@Override
public @NotNull String resolvePrefix(@NotNull UUID uuid) {
final User user = luckPerms.getUserManager()
.getUser(uuid);
if (user == null) {
return "";
}
final String prefix = user
.getCachedData()
.getMetaData()
.getPrefix();
return prefix == null ? "" : prefix;
}
just excluded NPE but it's annoying a bit
or is there any other way which is null-safe?
d;lp UserManager#loadUser#join
@NonNull
default CompletableFuture<User> loadUser(@NonNull UUID uniqueId)
throws NullPointerException```
Loads a user from the plugin's storage provider into memory.
uniqueId - the uuid of the user
NullPointerException - if the uuid is null
the resultant user
Maybe that helps?
I mean if the player is actually on the server, getUser won't (or at least it seriously shouldn't) return null
ye, that's strange
If I were you I'd rather fix the underlying issue instead of working around it :d
But if you're wanting to work with offline players too then loadUser is the way to go (although you should work with the CompletableFuture continuation design (whenComplete/thenAccept) rather than calling join/get blocking the current thread (unless you're already async in which case it won't really matter to the main thread))
ye, i mean like, i should also load if player is offline, it's displays just top player
did the luckperms API change in 1.17?
user.data().add(Node.builder(test.permission).withContext("server","testserver").build())
used to work fine but now it has no output or anything
what's there to output?
giving them the permission
using the API gives no feedback to any person unless you do that yourself
here's the full method (kotlin)
private fun addPerkPerms(userUUID: UUID, perkPerms: List<String>) {
luckPerms.userManager.modifyUser(userUUID) { user: User ->
perkPerms.forEach {
user.data().add(Node.builder(test.permission).withContext("server","testserver").build())
println("test")
}
}
}
by "or anything", i meant that it wasn't giving them permissions
where's test even coming from lol
also with kotlin you dont need to explicity state the type of the consumer, nor in java really
anyway to answer your initial question: no
^ perkPerms could be empty, and in that case it wouldn't run
nah it's running according to debug
user.data().add(Node.builder(test.permission).withContext("server","testserver").build()) is just not doing anything
println(test) gave output in multiple different test scenarios as expected
thats so odd since modifyUser should also handle saving
testing with an older build of luckperms
can you tell us what test.permission is?
it's a permission node
i misstyped it, it is a string
sorry
it was println(it) but that wasn't descriptive so I just replaced it with a string in what i sent you
ah ok I was wondering why you weren't using it in a for loop
all right then 🤔
honestly thats very odd
private fun addPerkPerms(userUUID: UUID, perkPerms: List<String>) {
luckPerms.userManager.modifyUser(userUUID) { user: User ->
perkPerms.forEach {
user.data().add(Node.builder(it).withContext("server","earth").build())
println(it)
}
}
}
that's the copied code
hmm now it's working on my test server, gonna see if it just randomly starts working on my prod server too
does anyone know why im getting this error?
[14:21:52 ERROR]: [BentoBox] BentoBox v1.17.3-SNAPSHOT-LOCAL attempted to register an invalid EventHandler method signature "public void world.bentobox.bentobox.listeners.LuckPermsListener.onNodeAdd(net.luckperms.api.event.node.NodeAddEvent)" in class world.bentobox.bentobox.listeners.LuckPermsListener
here's my method signature
public void onNodeAdd(NodeAddEvent e) {
there is no @EventHandler anotation
how and where are you trying to register it?
are you sure?
the error kinda contradicts that statement lol
can you share the class? https://paste.lucko.me/
hm all I can think of is bukkit is dumb
are you sure the jar in the plugins dir is updated to that of the code?
yep
well idrk what to tell you lol that straight up cannot happen without an annotation
final EventHandler eh = method.getAnnotation(EventHandler.class);
if (eh == null) continue;
// ...
if (method.getParameterTypes().length != 1 || !Event.class.isAssignableFrom(checkClass = method.getParameterTypes()[0])) {
plugin.getLogger().severe(plugin.getDescription().getFullName() + " attempted to register an invalid EventHandler method signature \"" + method.toGenericString() + "\" in " + listener.getClass());
continue;
}
why are you registering it in the bukkit plugin manager in the first place lmao
😬 thanks im stupid
When I'm using the NodeAdd event on a server when the event got called something changes, but when I'm changing the rank of someone one for example lobby and the player is in Freebuild the changes don't change is it possible that this happens?
So you mean, the permissions are not synced across multiple servers?
the permissions are synced the admins on freebuild receive the message that the rank changes, but for example the scoreboard does not update, but when I'm on freebuild and change the rank of a player on freebuild the scoreboard update
events do not propagate throughout the network, your best bet is to subscribe to events from these packages
https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/event/log/package-summary.html
https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/event/sync/package-summary.html
and "manually" parse the received log messages, there is no way for other LPs to know which data exactly to update
Hello, is there a way using the developer API to get the remaining time of a temporary permission?
I have a luckperms event listener right now on velocity, but it only detects the event from /lpv command and not /lp. Is there any way to detect both? Or did I just set it up wrong? (Where plug-in is the instance of the velocity plug-in)
public void register() {
EventBus eventBus = plugin.getLuckPerms().getEventBus();
eventBus.subscribe(plugin, NodeAddEvent.class, this::onUserPromote);
eventBus.subscribe(plugin, NodeRemoveEvent.class, this::onUserDemote);
}
you can just read Emily above message lol, answers the exact same thing
^^
Oop thank you I am illiterate (much appreciated <3)
@uncut temple
->
I'm having an issue getting my plugin to load after LuckPerms. I do have it as a dependency & I am loading it on the onEnable.
I am just getting the normal error:
net.luckperms.api.LuckPermsProvider$NotLoadedException: The LuckPerms API isn't loaded yet!
This could be because:
a) the LuckPerms plugin is not installed or it failed to enable
b) the plugin in the stacktrace does not declare a dependency on LuckPerms
c) the plugin in the stacktrace is retrieving the API before the plugin 'enable' phase
(call the #get method in onEnable, not the constructor!)
& luck perms loads directly after it throws that error.
This is how I have it added as a dependency.
Depends: [LuckPerms]
This is a Bungee Plugin.
I am also running the bungee version of luck perms.
I would like to output in a string how long the player is still in the primary group. Is there any API there?
Try lowercase depends
Likely not the issue
First check your logs if lp is enabled before you plugin properly, then also ensure that you are setting the dependency scope of lpapi as provided (if you use maven) gradle should be similar
You mean temp permission node?
@obtuse jolt can you give me an example?
Hey MELONEODERSO! Please don't tag helpful/staff members directly.
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
definitely the issue!
# not the same!
Depends: [LuckPerms]
depends: [LuckPerms]
yaml bad terrible disgusting yuck
yes I know it isn't yaml's fault
:)
we'll blame you then. :D
:(
I thought he meant luckperms lowercase
But yea checking the logs would have discover teh issues anyways
@obtuse jolt try
Hey TheGamerYT! Please don't tag helpful/staff members directly.
fuck u 🙂
Lol
I want to set a player with the Api in the primary group for 5 days and I don't understand how I do that
what have you tried?
LuckPermsProvider.get().getUserManager().getUser(player.getName()).setPrimaryGroup("premium");
!cookbook There are examples here that happen to also show what you're wanting to do
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
But I can't find anything like I only give a rank for five days.
Add the expiry in the node builder
what should you do in "some.node.key"
??
Also please read my nickname thank you
Care to elaborate on "what should you do in "?
What should I use to get the API in maven? Specifically for bungeecord
Okay well I ended up with
<repository>
<id>luckperms-repo</id>
<url>https://mvnrepository.com/artifact/net.luckperms/api</url>
</repository>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.3</version>
<scope>provided</scope>
</dependency>
Is this right?
Dont need that repo
Oh neat. I'm new to maven so I was a bit confused
How do I make this message silent?
With the api?(
that message shows up in chat but i dont want it too
What is this to do with the API?
I think there is a command to silence the logs
Hi, there is a way to:
- ADD parent group with API
- GET all permission of a given player with API?
I mean it would be pretty useless if you couldn't
lmao
!api You should read over these wiki pages: the first one contains overall info about adding and using the API in your project + important info about the API's design you will most definitely want to have in mind when using it
Learn how to use the LuckPerms API in your project.
the second page is just a whole bunch of things you will use in your journey throughout the LP API
Oook I hadn't seen this page, thank you! 🙂
in addition to that you can also use the api cookbook to take as guide/"real life" example
