#luckperms-api
1 messages · Page 21 of 1
It's literally the second link of that page. Are you sure you read it?
I think I got it
Hello! What am I doing wrong? https://paste.lucko.me/l453RkqUzA
it always returns Tristate.UNDEFINED
(my goal is to check an offline player's permission node value)
@ripe thorn
Hey Gabriele C.! Please don't tag staff members.
@night phoenix that looks correct to me
@jaunty pecan are the flags on by default?
errrr no they're not!
good point
so yeah instead of
QueryOptions.builder(QueryMode.NON_CONTEXTUAL).build()
you should instead use
QueryOptions.nonContextual()
That should be in the Javadocs btw
yeah gonna change that
👍🏻
I'm updating my plugins to 5.0 api, and you used to be able to do this for getting all permissions, what is the equivalent?
this?
I'm a little confused about the context part, how does that work
hmm, i'm jumping to 5.0 API however I used user cached data and contexts to retrieve prefixes from metadeta
how would I do this now?
this new api is foreign to me
How i do get the prefix in new api?
@vague obsidian
for(Node node : u.getPermissions())
if(node instanceof PermissionNode)
strings.add(((PermissionNode) node).getPermission());
@austere furnace @open pendant to get group prefixes, I use the following code
QueryOptions queryOptions = api.getContextManager().getQueryOptions(p);
String name api.getGroupManager().getGroup(group).getCachedData().getMetaData(queryOptions).getPrefix();
where group is a string
and p is a Player
@raven mason i did that as i seen javadoc but it doesn't return with colors it just returnes in chat like this &cAdmin
ChatColor.translateAlternateColorCodes('&', prefix);
or if you want
ChatColor.stripColor(prefix) after translating
thanks.
[19:20:43 WARN]: [PlaceholderAPI] Task #20 for PlaceholderAPI v2.10.4 generated an exception java.lang.NoClassDefFoundError: net/luckperms/api/LuckPerms at me.lucko.luckperms.placeholders.LuckPermsExpansion.canRegister(LuckPermsExpansion.java:48) ~[?:?] at me.clip.placeholderapi.expansion.ExpansionManager.registerExpansion(ExpansionManager.java:102) ~[?:?] at me.clip.placeholderapi.expansion.ExpansionManager.registerAllExpansions(ExpansionManager.java:154) ~[?:?] at me.clip.placeholderapi.PlaceholderAPIPlugin.lambda$onEnable$0(PlaceholderAPIPlugin.java:145) ~[?:?] at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) ~[server.jar:git-Spigot-21fe707-e1ebe52] at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [server.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:723) [server.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [server.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [server.jar:git-Spigot-21fe707-e1ebe52] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [server.jar:git-Spigot-21fe707-e1ebe52] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222] Caused by: java.lang.ClassNotFoundException: net.luckperms.api.LuckPerms at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_222] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_222] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_222]
Can someone help me ? I don't know what I can try next. - > Manual Install, Papi ecloud install. I asked a lot of people but nobody understand 😦
@raven mason nope, thats not how it shows up for me
Hi, I'm using maven to resolve LuckPerms as dependency but it's import's don't work? (the pom itself doesn't give any errors, but my classes do)
@languid socket the new API uses a different package than the old one
Also it’s very different
yes, i've got it to work now
in 4.x this was the way to get prefix:
public static String getPrefix(Player p) {
User user = loadUser(p);
ContextManager contextManager = Main.getLuckpermsApi().getContextManager();
Contexts contexts = contextManager.lookupApplicableContexts(user).orElseGet(contextManager::getStaticContexts);
MetaData metaData = user.getCachedData().getMetaData(contexts);
return ChatColor.translateAlternateColorCodes('&', metaData.getPrefix());
}```
Now since ``5.x`` this doesn't work anymore? So what to change tot get it back working?
Anyone?
can someone help me with this error i'm receiving while using the api?
error: https://hasteb.in/emowuxar.lua
code: https://hasteb.in/pilajeru.java
@languid socket hope that helps: https://github.com/AuraDevelopmentTeam/BungeeChat2/blob/master/src/main/java/dev/aura/bungeechat/hook/LuckPerms5Hook.java
hey brainstone could you help me?
Are you trying to work with offline players?
no online
You also seem to be using the old API
like what i'm doing is that if they inherit a group like Developer it would show an item in the Inventory?
oh
where's the new API?
Groups need to be lowercase
@crystal sonnet so there is no option to use LuckPerms itself to retrieve prefixes?
Hey Horizons! Please don't tag staff members.
Oops
Oh, will check it out, thanks
!api
Learn how to use the LuckPerms API in your project.
thanks
BrainStone
how do you check if a user is in a group?
if true then run something if false then run something else?
Hey I used Maven to add LuckPerms as a dependencies but it's showing red in my pom.xml? pls help
how do I make it so people are able to use disposal essentials signs?
and also the ```RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
LuckPerms api = provider.getProvider();
}``` shows lots of errors?
@crystal sonnet
Hey Lightning225! Please don't tag staff members.
@opaque sparrow that's not an Api thingy (at least if you provide more info) #general or #support-1
@glass vector could you show me your pom.xml? And what kind of errors does it give (the snippet)?
And what is it?
how do i do this part? it says to do in the wiki page
if (provider != null) {
LuckPerms api = provider.getProvider();
}```
idk where to put it n stuff
or how do i initialize luckperms? in the main class?
I would rather suggest to use the instance method using: LuckPerms api = LuckPermsProvider.get();
You can put it in any class you want but I suggest in your Main class.
Just as I said it.
That gives you an instance of the API
If you don't know what you can use that for or how to handle that, then I'd say learn Java and programming first before you get back here. Because those things are basics you must know before using that API @glass vector
nice
How can I query whether a user is a group with LuckPerms v5?
You don’t need to. A user is never a group
Unless of course you mean if a user is in a group.
Then check this:
!api
Learn how to use the LuckPerms API in your project.
Hey, how do you check if a user inherits a specific group and if they do it shows an item In a GUI for example. But if they don’t inherit that specific group then it doesn’t show that item? I don’t want the group. + permission thing because most of my players have op and it would should all the groups as they have it even though they are only apart of one. Like for example an Admin would have a operator but it would show that they are a part of owner group, developer group and admin group. But they are only an admin so how do I check if a player inherits a group without the permission as in the wiki?
@glass vector even if they have OP those group checks only succeed if they actually have the group
For real? I thought on the wiki it said if players with ‘op’ or ‘*’ will have the permissions?
!api
Learn how to use the LuckPerms API in your project.
The group permissions are an exception
?
Sorry, I'm new y'all. Trying to implement luckperms into an unmaintained Bungeecord plugin, but I'm struggling to register it. Obviously Bukkit class isn't available in Bungee's API, anyone able to help?
https://i.imgur.com/H19L80x.png
I imported import net.luckperms.api.LuckPerms;
Again, sorry for the noobish questions. I've taken a look at the API usage but cannot find bungee reference maybe I'm missing something.
Right below that line it tells you how to get it without that
@slate forum
@glass vector group. and other internal permissions are unaffected by * and OP
Try it
BrainStone, I'm a little confused which line you're referring too, the "Create type parameter"? The if statement or the line on the API where I C&P'd this from?
Thanks for your help btw 🙂
!api
Learn how to use the LuckPerms API in your project.
Brain stone
Yes?
So If i do the group. Plus permission on the wiki op and star wouldn’t affect it?
Yes. As mentioned several times now
Are you sure
Okay, thank you Brain. I've found it. 🙂
Slightly offtopic, in the JavaDocs what do the italicised classes mean? Deprecated?
it still shows while i'm opped even though i'm not in the group?
What method can I call to list all permissions the user has? I see player.hasPermission(); but I need to iterate over permissions beginning with, not a specific permission.
player.getPermissions() is only reading from bungee's config fine and not LuckPerms, however player.hasPermission() is reading correctly from Luckperms.
I'm a little bit lost by this one...
You naturally need to use the API and the user objects of LP, not the player objects of Bungee
@glass vector what's your code?
public static boolean isPlayerInGroup(Player player, String group) {
return player.hasPermission("group." + group);
}
if (isPlayerInGroup(target, "developer")){
grantsMenu.addItem(dev);
}else {
}```
Okay I will take a better luck at the API, is there a public version of the API? I'm using the .jar locally but I can't search for stuff.
it's a bukkit inventory, so if they are in group developer it would show the developer block in the inventory
Learn how to use the LuckPerms API in your project.
oh ya thank you
@glass vector weird. I could have sworn that works
In that case it's a fair bit more compilcated
is it still possible?
can you do this?
public static boolean isPlayerInGroup(Player player, String group) {
if (!player.isOp()){
return player.hasPermission("group." + group);
}
}```
but wait
probably not
oh
do you know how to do it? because i'm out of ideas
🤣
because that's the only thing i see in the wiki about if a user is in a group
I know it roughly
anything would help xD
In essence iterate over the player's nodes and find all the group nodes and find if it's the right one
🤔
Ugh... I'm looking at getDistinctNodes() but I can't figure out how to filter out all permissions, or at least iterate over each permission.
I see ways to check a specific permission, but for getting all perms I ain't quite sure what to do here
So far I'm getting this as an output ImmutableNode(key=group.admin, value=true, expireAt=0, contexts=ImmutableContextSet(contexts={}))
Code I'm using...
LuckPerms api = LuckPermsProvider.get();
public User loadUser(ProxiedPlayer player) {
return api.getUserManager().getUser(player.getUniqueId());
}
[....]
for (Object ob : loadUser(player).getDistinctNodes().toArray()) {
System.out.println("List Nodes: " + ob);
}
If I use Stream, I get https://i.imgur.com/8DQzOGR.png
I'm gonna take a break for a bit, I'm struggling to understand how to get a list of permissions from LuckPerm. Spent over 1 hour trying to do this now lmao... :l
Does anyone know where I can find in the javadocs reference to use getDistinctNodes()? Cheers.
https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/model/PermissionHolder.html#getDistinctNodes-- this doesn't really help ;l
Neither does this... (for me at least) https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#reading-usergroup-data
@versed dagger ask here
ik
for some reason my events does not trigger im checking for usertrackupdate event and im using eventbus and subscribing thru lambda and my code just does not want to run i tried in class that was suppose to handle all those events and in main to subscribe but it doesn't trigger at all not even a debug console output i added to see if event triggers. Im using luckperms v5, also here is the code: https://paste.chinesemarc.tech/toyutayapi.kotlin
A fork of Hastebin that looks better and supports more languages.
hey is there a way to find the temporary time of a parent using the luckperms nodes? on the wiki it showed temporary times for prefixes but i was wondering what about for groups?
Since LuckPerms api changed, how I set and unset a player permission/group?
Before I used User.setPermission and User.unsetPermission
Does anyone have any example code where you list ALL the users permissions when they join?
Did I got a ghost ping?
I got confused bc this: https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#checking-if-a-player-is-in-a-group
uses perms as example, so I assimilated with perms
That's the correct node
But as the error tells you, you're not supposed to create these nodes with the PermissionNode.Builder class
Tanks
Hey brianstone what is the node for a temporary group time?
?
So I said hey is there a way to find the temporary time of a parent using the luckperms nodes? on the wiki it showed temporary times for prefixes but i was wondering what about for groups?
Earlier and you said there is a node for everything so I was wondering what the node was?
Hummm
BrainStone, you know whats happening so I'm getting the error?
Its weird, bc it says nullable, and I can't get what is wrong......
Hey Awakened Redstone! Please don't tag staff members.
Humm, oops, did wrong, sorry
@glass vector you can either look javadocs or look on the wiki, or look on the code.
In LuckPerms 4 after I saved a User using api.userManager.saveUser(user), I usually also did a user.refreshCachedData(). I don't know if this was even required, but should I still do this in LuckPerms 5 using user.cachedData.invalidate(), or does this happen automatically?
Also, when doing something like user.data().contains(node, EXACT).asBoolean(), it triggers a NodeMutateEvent, but afaik this just does a lookup, so is it supposed to broadcast a the NodeMutateEvent or is this a bug?
Don't invalidate the cache
Everything that needs to be updated/invalidated gets updated/invalidated
If you do that you force the plugin to load everything from the database
ah I see
How can I check if version is 4 <? Maybe class check?
Exactly that
So I said hey is there a way to find the temporary time of a parent using the luckperms nodes? on the wiki it showed temporary times for prefixes but i was wondering what about for groups?
Earlier and you said there is a node for everything so I was wondering what the node was?
Like what do I type in the program
*ignored*
Hummm, my issue just got ignored....
BrainStone you said there is a node for everything so what is the node?
What do I type cause I can’t find it anywhere??
Is there a way to check if x user has x permission in a plugin?
@surreal comet you're not getting ignored
It's just that nobody that's on knows
@glass vector I said everything LP stores is a node
@covert jacinth just check for the permission...?
Like with the platform method
Oh my ducking god
I’m so done
WHAT IS THE NODE!!!!???????!?
Wtf
I’ve said this so many ducking times
What is the node
What is the node
What is the node
?????
@crystal sonnet
Hey Lightning225! Please don't tag staff members.
The node for what?
So I said hey is there a way to find the temporary time of a parent using the luckperms nodes? on the wiki it showed temporary times for prefixes but i was wondering what about for groups?
So I said hey is there a way to find the temporary time of a parent using the luckperms nodes? on the wiki it showed temporary times for prefixes but i was wondering what about for groups?
I said it works the same way
Find the parent node and use the same method
What method??!!!?
The same as on the wiki
🤦♀️
And second I’m not throwing around code
I know how it works.
Just not the the method names
Cut that shit. That’s your first warning
danm
What an irresponsible idiot lol
Hopefully he will regret that in the future when he is mature enough to see his mistake and he wont be able to get support
Hahaha good one XD
do u know anything about using mongoDB with luckperms?
Nope. That goes in #support-1 anyways
yeah I already posted there sorry
Wait so how i installed the API into the libraries (java plugin not Maven) but idk how to procceed...
if( LuckPerms.){}
Learn how to use the LuckPerms API in your project.
Hello, how can I add the permission to user that will persist only on the server command was called on without knowing name of the server? (Bungee server network). Do I have to get name of the server manually by calling Bungee messaging channel?
Hello!
Is there a way that I can automate the ranks that players by from the store in to the game
example:
I buy a rank on my webpage
And i want to use that rank at the moment
Can i automated ?
Help Please !
Lol
Didn’t even ask in the right channel
@tardy bramble you should be able to get the server name through the API
So, the group manager is returning null on my api, when I try tu use it I get a NullPointerException
Seams that happens the same for userManager
Is weird because there is a method that uses user and group manager and doen't get error
What's the way of finding out if a player inherits a group?
API doesnt have luckpermsUser.inheritsGroup(group)
anymore
in v5
You can just check if he has the "group" + group permission
Using the normal permission check method of your platform
Yes
okay
thats magic
and how do I get the suffix of a group?
group.getCachedData().getMetaData(); doesnt want my context anymore
but some queryoption
!api
Learn how to use the LuckPerms API in your project.
This page should answer this (hopefully)
Thanks
Weird, the GroupManager is returning null [NullPoiterException], but I have a class that uses it and doesn't return null, only on my sub commands it happens
Same for UserManager
nvm
@surreal comet if that happens you're accessing the API too early
Yeah, I was literally setting the AdminCommand before the onEnable.
Hey, how do I check the whether a a user has inherited a group with the 5.0 api?
!api
Learn how to use the LuckPerms API in your project.
Optional<? extends Node> nodeOpt = permission.getUserManager().getUser(player.getUniqueId()).getPermissions().stream() .filter(n -> n.getPermission().equalsIgnoreCase(clearedPermission)) .filter(n -> n.getValue() == clearedIsTrue) .findAny();
Whats the repplacement for getPermissions?
getNodes isn't enough, as I need inherited nodes
resolveInheritedNodes is what you're after
Okay good, would this be the 1:1 replacement?
User user = permission.getUserManager().getUser(player.getUniqueId()); Optional<? extends Node> nodeOpt = user.resolveInheritedNodes(permission.getContextManager().getQueryOptions(user).get()).stream() .filter(n -> n.getType() == NodeType.PERMISSION) .filter(n -> ((PermissionNode)n).getPermission().equalsIgnoreCase(clearedPermission)) .filter(n -> n.getValue() == clearedIsTrue) .findAny();
Before I really didn't touch Context stuff besides adding server etc. Thanks for your help
Instead of passing permission.getContextManager().getQueryOptions(user).get()
You can just use QueryOptions.nonContextual()
okay thanks
How to get user group prefix in api?
I'm getting a java.lang.NoClassDefFoundError when I call LuckPerms.getApi();, why is this?
oh wait - has it been changed..?
kk thanks, is this equivalent to using the Bukkit ServicesManager?
yes
coolio, thanks. I'm guessing this is a popular issue lol
The API got updated
I'm guessing I'll have to update my code too then
/papi ecloud download LuckPerms
And it just make my server messed up
Wat the heck bruhm
how can i get the weight from a player?
Okay. How can i get the hightest group from the player
That’s the primary group
Yes
You need to add an inheritance node in order to set groups
how do i set Primary Group and Parents of a user?
The primary group is calculated automatically
Parents are added through inheritance nodes
this is what i have```
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null)
{
LuckPerms api = provider.getProvider();
String primGroup = api.getUserManager().getUser(uuid).getPrimaryGroup();
if (hours >= 150)
{
//Set Primary group to legend
}
}
how would i do that?
https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage
has relevant information
I'd suggest reading through it as most of what you'll need is in there
ah ty
i dont get the nodes pls help
InheritanceNode node = InheritanceNode.builder(group).build();
is what i use to set primary group for players?
No. This generates a node
You now need to add that to a player and remove the others
how do i do that?
!api
Learn how to use the LuckPerms API in your project.
i am reading there
Good
okey
this is so confusing for me :(
.filter(NodeType.INHERITANCE::matches)
.map(NodeType.INHERITANCE::cast)
.map(InheritanceNode::getGroupName)
.collect(Collectors.toSet());
``` doesnt work for me
user, NodeType & Collectors get red
what should they be?
and what does .filter, .map & .collect do?
Those are Java (8) stream functions
Make sure you imported the classes
And that you’re using the v5 API
It’s a User object
from your snippet from earlier:
String primGroup = api.getUserManager().getUser(uuid).getPrimaryGroup();
it's the result form getUser in this line
Using this API assumes you know basic Java
And so does MC plugin programming btw
That’s not beginner level stuff
ik im still learning on the go
MC is not suited to learn Java basics
And using this API doubly not
And I’m not saying this to bring you down. I’m really just trying to help you by making sure you learn the basics before you dive into the harder stuff
i get that
Good
I wish I could recommend you good resources to learn
But I don’t have any. My apologies on that
well how do i know if i have basic java knowledge
Kinda a subjective thing tbh
Javadoc and information gathering knowledge is a pretty good thing to have since it makes learning things easier
Hi.. wow the API changed
How can I get a player's prefix? :)
I managed to do the java RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class); if (provider != null) { LuckPerms api = provider.getProvider(); following the online documentation.
edit found the usage page, was hiding :>
Uh
Is PermissionData not a thing?
Ya, it's just called CachedPermissionData now
I'm trying to get a LuckPerms api instence but I get a class not found exception
@ripe thorn
Hey Oscar! Please don't tag staff members.
@nocturne elbow you’re using the v5 API on a v4 instance. Update your LP
I've downloaded the recent LP
@crystal sonnet the only ne avaliable on spigotmc is v4
Hey Oscar! Please don't tag staff members.
!downloads
You can download LuckPerms for Spigot/Paper, BungeeCord, Sponge, Nukkit or Velocity.
You’re welcome
@nocturne elbow you wanted to ask something?
Okay, so I'm trying to loop through the loaded groups but it returns a null pointer exception
Find out what returns null
Are you sure loadAllGroups() returns null?
Any idea on how I can list all groups a player has and list out their prefixes? e.g "Admin, DonorRank, etc".
String group = api.getGroupManager().getGroup(player.getName()).getCachedData().getMetaData(queryOptions).getPrefix();```
I know that's a thing but I don't know how to get going with this. Any ideas?
Not it does not @nocturne elbow
Look
getLuckPerms() return null
Because you're loading it too early
so when should I load it?
You can't get the API instance before onEnable
And make sure your plugiin depends on LP in the plugin.yml
It does 🙂
@loud marsh why are you not getting the prefix from the user itself?
And I'm pretty sure on the metadata object is a method to list all prefixes
And getting all groups is done by iterating over all nodes of a player and looking for group nodes
Oh, sorry. Wrong line, I didn't mean to get the group one
I'm using the
String group = api.getUserManager().getUser(player.getName()).getCachedData().getMetaData(queryOptions).getPrefix();
Edited the line, ignore the group :P
Only seems to list out the current prefix tho
so i need help with rank prefixes
What about getting all groups a player has and displaying their prefix?
But as I said on the object returned by getMetaData should be a method that gives you all prefixes
ah
Are you even reading what I'm saying?
still null
for(Group g : Essence.getLuckPerms().getGroupManager().getLoadedGroups()){```
Yes, I understand now
this line returns null
Which part of that call does?
Please get the returns of each function and print them
@nocturne elbow is your question API related?
(if you don't know what an API is, then no)
ig
i have essentials chat and i ran the command and there is a suffix and a prefix on the rank i am currently and it isnt popping up in chat'
I did not mean to come across ignoring you or anything, sorry if that's what you thought lol
You said the getMetaData should give me all prefixes but it's only giving me one prefix
System.out.println(Essence.getLuckPerms());
System.out.println(Essence.getLuckPerms().getGroupManager());
System.out.println(Essence.getLuckPerms().getGroupManager().getLoadedGroups());
Basic debugging @nocturne elbow
oh right that's what you ment
No @loud marsh.
And I'm pretty sure on the metadata object is a method to list all prefixes
okay
You still here?
Essence.getLuckPerms();```
returns null
okay fixed it but
for(Group g : Essence.getLuckPerms().getGroupManager().getLoadedGroups()){
if(event.getPlayer().hasPermission("group." + g.getName().toLowerCase())){
if(section.getString(g.getName().toLowerCase()) == null) throw new NullPointerException("Group " + g.getName().toLowerCase() + " doesn't have a chat format in the config");
event.setFormat(Chat.coloured(section.getString(g.getName().toLowerCase())
.replace("{PLAYER}", event.getPlayer().getName())
.replace("{MESSAGE}", event.getMessage())));
}
}```
why isn't this working?
the group exists
and I have it on my test server
Alrighty, I managed to list out the ranks. But they include a weight attached to them (weight#=rank)
?
so i want to set a players chat format from the config
and it's a different one per group
How can I replace the weight? Sorry
Yeah, replace it with an empty string - or just generally remove it so it just keeps the rank and not the weight attachment
@nocturne elbow that's what you want to do. Not what's not working...
@loud marsh ?
You do get a map
so it returns the group name like I wanted
I'm debugging it
Alright.
I'm gonna say it outright to both of you
If you're not comfortable with programming Java, Minecraft plugins are not for you
Learn Java first
I appreciate the concern, and I am still learning Java while I use the Spigot API
The only somewhat exeception to this is if you are very eperienced with another OOP lamguage
@loud marsh don't
MC is not the place to learn Java
Yeah, that's a no no
of course it's not
You just said you did
misinterpretation. I'm learning Java but also using Spigot. i.e in my free-time
not with using spigot with learning java, sorry
👍
You don't need to learn any frameworks really
Spigot is essentially just one
The pure basics are what's needed here
Like knowing what a map is
And how you get the values out of it
Yeah I never learnt how to use one lol
Yeah that's basic stuff
And the LP API requires an even higher level
okay so
for(Group g : Essence.getLuckPerms().getGroupManager().getLoadedGroups()){
System.out.println("1" + event.getPlayer().hasPermission("group." + g.getName().toLowerCase()));
if(event.getPlayer().hasPermission("group." + g.getName().toLowerCase())){
if(Essence.getInstance().getConfig().getString("chat-format." + g.getName().toLowerCase()) == null) throw new NullPointerException("Group " + g.getName().toLowerCase() + " doesn't have a chat format in the config");
event.setFormat(Chat.coloured(Essence.getInstance().getConfig().getString("chat-format." + g.getName().toLowerCase()))
.replace("{PLAYER}", event.getPlayer().getName())
.replace("{MESSAGE}", event.getMessage()));
}
}```
Especially in terms of data models
did some debugging and i have the permission
but it still doesn't set the correct formar?
format*
it sets to default instead of the one it is ment to
well the permission check is true for all groups the player has
Including inherited ones
And thank for finally telling me what the issue is
In other words that your code always detects the player as being in default
Was that really that hard?
No 😄
Then why didn't you tell me 10 minutes ago?
I was debugging it
You you were very clearly seeing that before, didn't you?
Anyways if you just want to "the group" a player is in, get the primary group
There's a simple method on the user object
You really need to work on being concise
You're welcome
@nocturne elbow for future referece
If someone asks what you issue is, they want to know the symptoms of your problem
Ok, sorry again
I was using api.getStorage().loadUser(offlinePlayer.getUniqueId()) to obtain a User for an OfflinePlayer. Is something similar still applicable? I saw in the docs there's a CompletableFuture which will block a thread until they're obtained but this could block an indefinite number of threads..?
The old method also returned a completable future
So I’m not sure what you’re talking about @wet veldt
ah, it was implemented in that way?
Yes
All database interactions have returned a CompletableFuture
In v4 as they do in v5 @wet veldt
Okay thanks, just never directly interfaced with a CompletableFuture in the past so didn't realise, apologies.
No problem
How do you guys manage dependencies?
LuckPerms deffinately does not include H2 and redis drivers in it's 1.3MB jar file
Are you using some classloader trickery?
It's really clever whatever it is
They are downloaded and injected into the class loader
I’ve created a system that is even better and uses a custom class loader that isolates the loaded classes from the rest
@astral thicket
Thats really cool. And it doesn't conflict with java 11+?
Hey N3G4T1V3! Please don't tag staff members.
nothing nothing... I just solved my problem
Im updating my plugin to the last version of the api and I don't know if this is the way to make this:
In the version 4.4 I had this:
public static boolean existsGroup(String group) {
return API.getGroupSafe(group).isPresent();
}
And in the version 5.0 I don't know if there is an method or this is the way:
public static boolean existsGroup(String group) {
return API.getGroupManager().getLoadedGroups().stream().anyMatch(g -> g.getName().equals(group));
}
Just check if getGroup returns null
By the way, 2 questions
Does the later API update safe to update? will it effect the database structure at all?
Secondly, How do the node mutate (add) events work on a network? Is there some wizardry that sends the event to another server sharing the db, or just the server that issued the command?
Yes there is some wizardry. Namely the messaging services
And I don’t know what you mean with the first question at all
i mean, has there been any db schema changes recently or should all versions be compatable with the same db?
No changes at all in that department
Shiny, 4 and 5 are working with the same db, but messaging service changed, so that will error out when tryong to use 4 and 5 on the same network. So you have to update all servers at once
ah ok
So I am relatively new at this and I am trying to make a plugin for doing /rankup and I need to check if they are in a specific group on a specific track. I pasted this in but i'm not too sure how to use it
public static String getPlayerGroup(Player player, Collection<String> possibleGroups) {
for (String group : possibleGroups) {
if (player.hasPermission("group." + group)) {
return group;
}
}
return null;
}
I have that put in.. How would I make an if statement to say like..
if(sender.getPlayerGroup().equals("moderator", "staff")) { //Checks if player group equals moderator on staff track
sender.promote("staff") //Promotes on Staff Track
}
Learn how to use the LuckPerms API in your project.
@sharp timber
Yes I did, sorry. That’s where I got that first example method
I'm not really asking about the LuckPerms api, but more general permission API here, so sorry if this is in the wrong section. I was using Player#hasPermission and it was returning true when I'd set it to False in their permission data.
Has anyone had this problem before?
like I'd run lp user <name> permission checkinherits and it'd say False in game
but the permission would work for the action
You most likely have some type of logic error
Hey I've got a question.. I'm using the API and when invoking the java api.getUserManager().getUser(target.getName()).setPrimaryGroup(rank); the primary group is not being altered.
@hardy badge that's because setting the primary group is not equivalent to the parent set command.
How might I be able to simulate that?
All it does is change which of the groups already applied to the user are the primary. One
In addition by default this does absoutely nothing because the primary group is being calculated automatically
Have a look here:
!api
Learn how to use the LuckPerms API in your project.
how does the nodes work? im reading the docs but im not getting it 😦
In what context. There’s a fair bit to them.
how do i make it so normal players can do /spawn it works for me people who arent opped cant do it
@past ivy that question belongs in #support-1
!install
You can install LuckPerms on Spigot/Paper, Sponge, BungeeCord/Waterfall, Velocity and others. Check the installation guide for more info on setting up LuckPerms.
!downloads
You can download LuckPerms for Spigot/Paper, BungeeCord, Sponge, Nukkit or Velocity.
!advanced
!api
!argumentbased
!bulkupdate
!bungee
!commands
!context
!default
!downloads
!editor
!errors
!faq
!install
!meta
!migration
!permissions
!placeholders
!stacking
!storage
!switchstorage
!sync
!tracks
!usage
!verbose
!wiki
@nocturne elbow what do you need help with? This is the channel for plugin devs
General LP support is in #support-1
!permissions
A list of permissions used by LuckPerms commands.
!placeholders
Display data such as user prefixes and groups from LuckPerms in other plugins.
I need some help with using the API to add permissions to a user in code
!api
Learn how to use the LuckPerms API in your project.
if you listen to an event such as UserPromoteEvent on a bukkit server attached to a bungeecord proxy will the event still fire if the command that fired the event was ran on a different server?
Does Vault support LuckPerms API v5 now?
Vault supports nothing
Everything else supports vault
LP5 was supporting Vault from day one @wet veldt
As in, if I used Vault to query permissions and prefixes, and the server had LuckPerms v5+, would it work..?
Of course
Great, thanks
Why wouldn’t it?
I was thinking Vault would need to update to the new API version of LP
unless it doesn't work like that
ah I thought it was the other way round haha
The support is always coming from the plugin itself
It’s the same for all plugins supporting vault
Exactly
Small query regarding the implementation LP provides to Vault...
Are Vault queries for OfflinePlayers blocking? because LP uses those CompletableFuture things, would it block the thread until the data is obtained?
Yes it does
It's blocked until the player comes online..?
No...
It’s blocked until the data is loaded
Or not at all if it’s already loaded
@wet veldt
okay thanks, I'm just worried using that because I don't want a potential huge block
is there an upper bound on the time it'll block for? sorry
Just work with it async @wet veldt
How do I change the weight of a group using the api?
are all groups represented as weightnodes? e.g. if my group was "admin" then the node would be a WeightNode with key "group.admin"?
or can I just add any weightnode to the group's NodeMap, and delete the existing weightnodes? should I use any specific key for my weightnode?
How I get a User of a offline player based on it name?
User user = userManager.getUser(username);
return user != null
? CompletableFuture.completedFuture(user)
: userManager.lookupUniqueId(username).thenCompose(this::loadUser);
}
CompletableFuture<User> loadUser(UUID player) {
User user = userManager.getUser(player);
return user != null
? CompletableFuture.completedFuture(user)
: userManager.loadUser(player);
}```
you get the userManager instance using LuckPermsProvider.get().getUserManager();
is it possible to put a user on a specific position in a track using the api ? Dont see an option in the track manager unless im missing it 😛
if you're not on the main server thread you can use CompletableFuture#get (you'd have to change the return type in the signature)
otherwise you can use CompletionStage#thenAccept, CompletionStage#thenApply or CompletionStage#thenCompose
note that obtaining a user can fail - if you want to 'catch' the exception you can use CompletionStage#handle or CompletionStage#handleAsync
if you're not familiar with the CompletionStage and CompletableFuture api's, I'd recomment that you read their javadoc pages first
loadUser(args[0]).thenAccept(user -> {lpUser = user;});
User lp_target = lpUser;
if(lp_target == null) throw new CommandException("invalid player");
OfflinePlayer target = Bukkit.getOfflinePlayer(lp_target.getUniqueId());
database.createPlayer(lp_target.getUniqueId(), target.getPlayer());
Group group = luckPerms.getGroupManager().getGroup(args[1]);
if(group == null) throw new CommandException("invalid group");
database.setLevel(lp_target.getUniqueId(), args[1]);
lp_target.data().add(PermissionNode.builder("stafflog.commands.staff-mode").build());
sender.sendMessage("§7Defined §b" + target.getName() + "§7 as §b" + args[1]);
luckPerms.getUserManager().saveUser(lp_target);
}```
I'm not sure if this will work...
it won't, because the Consumer that accepts the user is invoked when the user is retreived, that is after the command completes.
you need to do everything inside the body of the lambda
the exception doen't work if I do so
you can return a new CompletableFuture from your 'execute' method
and make the completablefuture complete exceptionally with a CommandException using https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html#completeExceptionally-java.lang.Throwable-
Humm, the examples use CompletableFuture but the code u sent use CompletableStage, and I can't understand right what to do to use the CompletableFuture...
just change the return types of my methods to CompletableFuture<User> (I updated the example code)
I don't think my IDE acceted the completeExceptionaly
@ornate silo I can't get it, is it right or I should do something else?
public CompletableFuture<Void> execute(CommandSender, String label, String[] args) {
return loadUser(args[0]).thenCompose(user -> {
if (user == null) {
return CompletableFuture.failedFuture(new CommandExcetpion("invalid player"));
} else {
//ideally createPlayer returns a CompletableFuture as well, such that we can cantinue after the row was created.
database.createPlayer(user.getUniqueId, user.getName());
Group group = luckPerms.getGroupManager().getGroup(args[1]);
if (group == null) {
return CompletableFuture.failedFuture(new CommandException("invalid group"));
} else {
database.setLevel(user.getUniqueId(), args[1]);
user.data().add(PermissionNode.builder("stafflog.commands.staff-mode").build());
sender.sendMessage("§7Defined §b" + target.getName() + "§7 as §b" + args[1]);
return luckPerms.getUserManager().saveUser(user);
}
}
});
}```
if you must still use java 8 then instead of return CompleteableFuture#failedFuture(new CommandException(…)); you can use CompletableFuture<Void> cf = new CompletableFuture<>(); cf.completeExceptionally(new CommandException(…)); return cf;
is there any problem changing the return type of the base method to CompletableFuture<Void>?
there's more 3 classes that use the base method, and I think that they won't like this change, neither me, bc I would need to recode all again, and it was a pain to do 1st time.
return String idea == badLevel ? "bad" : "are u serious?";
this will perform very poor for players that are offline
anybody got an answer for me yet? https://discordapp.com/channels/241667244927483904/420538367986499585/662322374968082483
https://discordapp.com/channels/241667244927483904/420538367986499585/662388579279962122 I disagree tho, that is means you only need to add 2 extra return statements.
hmm trying to add support for luckperms to my plugin, but the user has perm check works only if the perms are in a group and the user has that group.
I have my plugins perms as a non op but I still cannot use my commands
I have a proper permissions tree in the plugin.yml
I'm an experienced java programmer btw
I think it has to do with context?
@ornate silo yes this is correct
or can I just add any weightnode to the group's NodeMap, and delete the existing weightnodes
public void setWeight(Group group, int weight) {
group.data().clear(NodeType.WEIGHT::matches);
group.data().add(WeightNode.builder(weight).build());
}
@languid granite I don't really understand your question
if you're defining your permissions in plugin.yml as non-op, then players will only have access to them if you explicitly grant them that permission
So
op: true?
By default only op has access
But I just want to perform a simple check if a specific player has the permission via luckperms
Ie just like
Player.hasPermission(...)
But through luckperms
Ty!
@languid granite if the player is online you don't need anything other than Player#hasPermission - LuckPerms will take care that the permissions are set correctly.
So the bukkit one is fine?
yup
But I've had reports that my plugin doesn't work properly with luckperms
that is.. interesting. Are you sure that the server admins who filed the reports had their permissions set up correctly? can you reproduce their problems?
Yes
And yes
For whatever reason some perms work and others don't
If you'd like to try yourself my plugin is called UberEnchant
It works flawlessly with essentials GroupManager
Oh I think they may also be using paper spigot
I think there is a mistake in your plugin.yml
when you define children, you define whether to 'enable'/'disable' a child permission.
you don't set their truth values
never mind what I just said
?
I don't think there was a mistake in your plugin.yml
Hmm
It has to be how LP handles perms
when do you check for permissions? only in command executors?
Pretty much
https://discordapp.com/channels/241667244927483904/420538367986499585/662447700964278283 try setting the defaults as op instead of false
yoo
how can I get a groups prefix?
I know how to get the group but there doesnt seem to be a getPrefix() method
group.getNodes().stream().filter(PrefixNode.class::isInstance).map(PrefixNode.class::cast).max(Comparator.comparing(PrefixNode::getPriority)).map(PrefixNode::getMetaValue);
ty
this sample code does not take inheritance into account
can someone help me please?
don't know until you tell us what's up.
how do i make it where when someone joins the server they automatically get a rank so i dont have to manually add them to a group
@ornate silo how would I do it to get the prefix from the group itself rather than all the inherited prefixes?
with the sample code I pasted @wheat veldt
@lilac shoal LuckPerms already provides a default group that by default is called "default" :)
ok ty
yes
okay tysm!
@ornate silo the .stream method isnt available in the Node class
that is correct. in api version 5 Group#getNodes returns a Collection<Node>, Collection has the stream method.
Weird that i cant seem to find the .Stream method
it's available in Java 8 and newer verions
getNodes returns ImmutableSetMultimap<ImmutableContextSet>
I think you're using LuckPerms api 4 then
to get the collection of nodes you can use group.getOwnNodes()
I haven't worked out the last parts yet, there is no #getPriority method on Node.
you can omit the cast, and the final call in the chain can be .map(node -> node.getPrefix().getValue())
then only the comparator needs to be fixed still..
a dirty fix would be to just call .findFirst instead of .max, but that is probably incorrect if a group has multiple prefixes.
oh, turns out the key in the entry is the priority
.filter(Node::isPrefix)
.map(Node::getPrefix)
.max(Comparator.comparing(Map.Entry::getKey)))
.map(Map.Entry::getValue);```
you can get the prefix string using Optional#get but be sure to check Optional#isPresent first!
if (prefix.isPresent()) { String pre = prefix.get(); /* code that is executed when the group has a prefix */}
(forgive me for forgetting parentheses sometimes, I am used to writing Scala lately instead of Java.. :3)
the code I pasted does not consider child/parent groups. It just computes the prefix with the most priority that is set on that group specifically.
maybe you need to replace max by min. Don't know whether higher priorities also mean that they come first..
are lower prefixes higher priority?
like the prefix with meta value of "1"
will be higher priority
then 2
thats weird
its attaching two prefixes together...
in that case you can just join them
String prefix = group.getOwnNodes().stream().filter(Node::isPrefix).map(Node::getPrefix).sort(Comparator.comparing(Map.Entry::getKey)).map(Map.Entry::getValue).collect(Collectors.joining(ChatColor.RESET.toString()))
So, when I get the group diplay name it shows right, but if I chahnge my plugin doen't get the new name, it get every time I open the GUI, but I have to reload the server to get the new display name
you can subscribe to NodeRemoveEvent and NodeMutateEvent to get notified of changes to nodes. luckPerms.getEventBus().subScribe(NodeMutateEvent.class, event -> { Set<Node> newNodes = event.getDataAfter(); /*TODO check for DisplayNameNodes*/ };
It does query the name every time I open the GUI, but it get the same result unless I reload for some reason
did you save the user data with userManager#saveUser?
there is also UserDataRecalculateEvent by the way.
How could I change the suffix of a user using the api?
user.data().clear(NodeType.SUFFIX::matches); user.data().add(SuffixNode.builder(suffix, priority).build());
How do you add a parent to a user? This is the command to do it:
/luckperms user WiebeHero parent add admin
But i can't find it anywhere on how to do this with the api...
And for some context, this is ADDING, not setting. It would also be appericiated if you could show me on how to remove a parent from the player
just add an InheritanceNode to the user
public void addParent(User user, Group /*can also use String*/ group) {
user.data().add(InheritanceNode.builder(group).build());
}
public void removeParent(User user, String group) {
user.data().clear(node -> NodeType.INHERITANCE.matches(node) && NodeType.INHERITANCE.cast(node).getGroupName().equals(group));
}
InheritanceNode cannot be resolved
@ornate silo
Il try to get the newest version
Alright many thanks koekenpan
hey @ornate silo sorry to disturb you again, but would this be good to see if a User has a specific parrent?
public void containsParrent(User user, String group) {
user.data().contains(InheritanceNode.builder(group).build(), NodeEqualityPredicate.EXACT);
}
Im very new to Nodes, sorry
that expression will only evaluate to true if the group that the player is in does not expire, and has no contexts
(and of course the user has to be in a a group with the same name)
and your version does not take grandparent groups into account
With no contexts meaning, no permissions @ornate silo
no I mean ContextSet
a node can be 'server-specific' or 'world-specific', that is done through contexts
the EXACT predicate tests key equality, value equality as well as context equality and expiry equality
Alrighty, got it ty 😄
np, yw :)
@ornate silo does a player need to be online for that query to work?
Oki
no
Hi all, I am just checking. Should this add/remove groups from players? Does remove a node remove the permission from the player?
/**
* Add a group to the user
* @param user User instance
* @param group group to add
*/
public static void addGroup(User user, String group) {
Node node = luckPermsApi.getNodeBuilderRegistry().forInheritance().group(group).build();
user.data().add(node);
luckPermsApi.getUserManager().saveUser(user);
}
/**
* Add a group to the user
* @param user User instance
* @param group group to remove
*/
public static void removeGroup(User user, String group) {
Node node = luckPermsApi.getNodeBuilderRegistry().forInheritance().group(group).build();
user.data().remove(node);
luckPermsApi.getUserManager().saveUser(user);
}
for example
LuckPermsHelper.removePermission(luckPermsUser, "group.oldgroup");
LuckPermsHelper.addPermission(luckPermsUser, "group.newgroup");
Will it just remove the group if the user has it?
oh! I just realised
i need to remove the "group." from the front
adds it automatically
it will only in some cases. Keep in mind that UserManager#saveUser returns a CompletableFuture - meaning that after you call one of these methods changes to the user aren't guaranteed to be propagated to the storage back-end yet. If you call both methods in sequence then there is a race condition, only one of the users states will be saved in the end because one user state will be overwritten by the other.
I'd recommend returning that CompletableFuture - callers of these methods can choose to ignore the return value anyway.
https://discordapp.com/channels/241667244927483904/420538367986499585/662833555239600129
If you're returning the CompletableFutures it will become:
LuckPermsHelper.removeGroup(luckPermsUser, "oldgroup")
.thenCompose(v -> LuckPermsHelper.addGroup(luckPermsUser, "newgroup"));
(your examples called [add/remove]Permission)
even better would be to do the add and remove operation for the User in one method, and save only once
Node remove = InheritanceNode.builder(oldGroup).build();
Node add = InheritanceNode.builder(newGroup).build();
user.data().remove(remove);
user.data().add(node);
return luckPermsApi.getUserManager().saveUser(user);
}```
I will implement the change group. Thank you kindly.
Nvm i already got it, sorry for the tag
Is there a part on tha api that allow me to bridge with bungee lp?
Hi, might be being a bit thick here, but I'm having trouble getting a group prefix using v5 of the api
Learn how to use the LuckPerms API in your project.
any example of getPrefix in version 5.x?
ah I didn't see those usage pages, i'll check them out now, thanks!
My plugin chnage the player group on bukkit luckperms, but not on bungee lp, and I'm not considering making a bungee version of the plugin as a option...
oh nvm
the chat plugin just didn't updated
Is it possible to obtain anyone uuid from luckperms db?
UserManager#lookupUniqueId
gChat (Bungeecord) doesn't show my prefix, does anyone know, what i did wrong?
Are there any code examples of finding a User, getting its nodes and setting Metadata for the User?
https://discordapp.com/channels/241667244927483904/420538367986499585/663125681772822572 in api 5 Node has subclasses. PrefixNode is one of them, so you need to check and cast, and then call #getMetaValue
@lofty orbit the wiki should get you started, check the section on readon and modifying user/group data https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#reading-usergroup-data
finding a user is as simple as LuckPermsProvider.get().getUserManager().getUser(String/UUID) if the user is online, otherwise use UserManager#loadUser
I can get the users, and got it to pull the Metadata from a player, both prefix and custom. but I set the custom meta with the plugins commands. I would like to add custom metadata with the API and that is definitely not as clear as how to go about it.
oh when you create the node use NodeBuilder#withMetaData
you'd have to define the metadatakeys as constants in your own plugin
do you have an example of doing this?
private static final NodeMetadataKey<Integer> NUM_KILLS_KEY = NodeMetadataKey.of("#kills", Integer.class);
public CompletableFuture<Void> setKills(UUID player, int kills) {
UserManager userManager = LuckPermsProvider.get().getUserManager();
User user = userManager.getUser(player);
CompletableFuture<User> userFuture = user == null ? userManager.loadUser(player) : CompletableFuture.completedFuture(user);
return userFuture.thenCompose(user -> {
Node killsNode = Node.builder("myplugin.kills")
.withMetadata(NUM_KILLS_KEY, kills)
.build();
user.data().add(killsNode);
return userManager.saveUser(user);
});
}``` something like this should do the trick
though I am not sure whether the implementation supports user-defined types for metadata values, the type signature of #withMetaData suggests it does.
awesome thank you! I will give this a try.
i'm reading through the source code now - it looks like node metadata does support every reference type imaginable, but it isn't ever saved to the database
so you'll need to handle saving/loading that in your own plugin.
Yeah, that's what I am seeing. The code appears to work (doesn't error) but the meta is never added to the database.
Maybe I will turn this data into a permission. Now to try turning this code into Add permission to user instead of Add metadata.
that's a possibility too
ah it was adding the key as a permission. So I can do it this way. yay
yeah. only works if your custom data is convertable from and to a string though.
yeah, in my case it is plugin.key.value will work fine.
Sorry I'm late to reply here
You want MetaNode
there are examples here
@lofty orbit ^
which event is triggered when someone gets a rank?
@idle seal Pretty sure it's just a Node Add event
The node in question would just begin with group.
ok
You can also check if the Node is an instance of InheritanceNode iirc
and how can i get the player from this node?
you check event.isUser() and if so you cast event.getTarget() to User
the event will not run if i give someone a parent
and which event do I have to use now?
the event will not run if i give someone a parent
Any errors? And what did you try to check it? @idle seal
No there are no errors. I am getting a message in the event
hello?
What's the message?
When permissions are updated by the API changes don't replicate to all servers instantly unless the player relogs or a query on the player is performed
this is said code to update perms
/**
* Add a permission to the user
* @param user User instance
* @param permission permission to add
*/
public static void addPermission(User user, String permission) {
Node node = luckPermsApi.getNodeBuilderRegistry().forPermission().permission(permission).build();
user.data().add(node);
luckPermsApi.getUserManager().saveUser(user);
}
@tardy quail what LP version are you using?
LuckPerms v5.0.50
on Waterfall as well
I also have an issue here: https://github.com/lucko/LuckPerms/issues/1917#issuecomment-573315508
@tardy quail I replied on github
Thank you kindly
Hi, I'm actully using LP v4 and I want to know if there is a way to add several permissions in one time.
I have a list of permissions that I want to apply on both online and offline players. Currently I want to apply 4 permissions but sometimes I have 2 of them apply, next 3 one of them... But never the four.
If someone have the solution...
for(String permission : currentReward.getPermissionsList()) {
futureUser = LuckPerms.getApi().getUserManager().loadUser(player.getUUID());
futureUser.thenApplyAsync(user -> user.setPermission(LuckPerms.getApi().getNodeFactory().newBuilder(permission).build()));
futureUser.thenApplyAsync(user -> LuckPerms.getApi().getUserManager().saveUser(user));
}
Thanks in advance
Why are you using v4 instead of v5?
@robust trellis highly recommend upgrading to v5 - once you've done that, this code will work for what you want to do
private LuckPerms luckPerms = Bukkit.getServicesManager().load(LuckPerms.class);
public void giveMultiple(Player player, List<String> permissions) {
User user = this.luckPerms.getUserManager().getUser(player.getUniqueId());
for (String permission : permissions) {
Node node = Node.builder(permission).build();
user.data().add(node);
}
this.luckPerms.getUserManager().saveUser(user);
}
@nocturne elbow are you asking about the API? or is this a general question
question
oh shit yeah
Thank you for your response
How do I add a rank to a player if the player stands on a pressureplate on a exact location while holding an item (the pressureplate and item part is already set, but I have no clue about adding the rank to a player)
Since we noticed many of you are struggling with using the API, we've opened a discussion on how to fix that: https://github.com/lucko/LuckPerms/issues/1926
Please provide us your feedback.
Hi, can someone help me with some code? I'm using lp API v5.0
I set the prefix of players with the LP API, but it looks like lp doesn't save this prefix. This is my code:
void setPrefix(User user, String prefix){
PrefixNode prefixNode = PrefixNode.builder(prefix, main.nodeWeight).build();
loadUser(user).getData(DataType.TRANSIENT).add(prefixNode);
api.getUserManager().saveUser(user);
api.getUserManager().saveUser(user).thenRun(() -> api.getMessagingService().ifPresent(service -> service.pushUserUpdate(user)));
}```
@wheat lake that's because you're setting transient data
Transient are temporary overrides that don't get stored to data
Just call data()
@wheat lake
Thanks! It worked
Hello, i try to update my plugin with luckperms 5 but i don't know how i can retrieve an group prefix and suffix.
Currently i have that (on bungee) :
try {
final LuckPerms api = LuckPermsProvider.get();
final User user = api.getUserManager().getUser(getUniqueId());
final Optional<Group> group = getGroup().flatMap(s -> Optional.ofNullable(api.getGroupManager().getGroup(s)));
if (user != null && group.isPresent()) {
final CachedMetaData data = group.get().getCachedData().getMetaData(api.getContextManager().getQueryOptions(user).orElse(api.getContextManager().getStaticQueryOptions()));
String prefix = (data.getPrefix() != null) ? MFString.colorize(data.getPrefix().trim()) : "";
String suffix = (data.getSuffix() != null) ? MFString.colorize(data.getSuffix().trim()) : "";
// Add space if is not only color
if (!ChatColor.stripColor(prefix).isEmpty()) {
prefix = prefix + " ";
}
if (!ChatColor.stripColor(suffix).isEmpty()) {
suffix = " " + suffix;
}
proxiedPlayer.setDisplayName(prefix + getName() + suffix + ChatColor.RESET);
}
} catch (IllegalStateException ignored) {
}
But with that my prefix and suffix is doesn't retrieved but i doesn't have error.
Thanks for your help
User's prefix includes the group's prefix
I have found my problem, its just because i doesn't have update my spigot plugin (for manage the tab list name) 😄
👍
Hi, why i have this error on Maven?
That’s not an error...? @rare rapids
Okey, so why don't you want it to work?
Do you mean “why doesn’t it want to work”?
And you’ve not shown any error whatsoever
Is it highlighted in red, can it work?
try refreshing the maven project
So I understand that setting the primary group doesn't change their parent group, but I've still got an itch to see if I can change users parent groups using the API. Any luck? (No pun indended)
Of course you can
You can do anything with the API that you can do with commands
And more @hardy badge
How might that be acomplished?
Adding is just adding an inheritance node to the player
Setting is just removing all existing inheritance nodes before adding the new one
There should be plenty of examples in this channel @hardy badge
And I think this page is getting better too
!api
Learn how to use the LuckPerms API in your project.
Would that mean the note like group.<group>?
Yes and no
There are builders for all kinds of node types
@deep wigeon how are you loading it right now?
You told me to put it in /config/luckperms/extensions and that's what I did. I believe I might also have it in the main luckperms folder, though.
It's just in my mods folder
I don't know the code :(
Then tell the dev to fix it
Rip. I'll just try to get a different one made that works or something
Insist on getting the code when you get a custom plugin made
I typically do, but this is one of the only ones that I don't have.
Any dev not offering that is not worth their salt
That sucks
It can be partially recovered through decompiling
Though that’s not an ideal solution
I'll either get someone to decompile it or try to get a new one made. Thanks for the help :)
How can i change the name of a group?
you don't, but you can create a new group with a different name and add the same nodes to it
and you'll have to make sure that all other permissionholder that inherited from the old group now will inherit from the new group
How to set a permission. What has to be in brackets?
LuckPerms.getApi().getUser(pp.getUniqueId()).setTransientPermission(HERE)
First off, you don’t want to set a transient permission
Second, search this channel. I think several snippets have been posted
And third have a look here
!api @haughty solar
Learn how to use the LuckPerms API in your project.
That is for luckperms, right?
Help meeee
This is my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.lumengaming</groupId>
<artifactId>Skillsaw3</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<build>
<finalName>Skillsaw3</finalName>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<!-- <repository>
<id>parallelblock-public</id>
<name>ParallelBlock Public Repository</name>
<url>https://repo.parallelblock.com/repository/maven-public/</url>
</repository>-->
<repository>
<!-- NuVotifier -->
<id>bintray-repo</id>
<url>https://dl.bintray.com/ichbinjoe/public/</url>
</repository>
</repositories>
<dependencies><dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-translate</artifactId>
<version>1.64.0</version>
</dependency>
<!-- https://hub.spigotmc.org/versions/ -->
<dependency>
<!-- https://oss.sonatype.org/content/repositories/snapshots/net/md-5/bungeecord-api/maven-metadata.xml -->
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.15-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.15-SNAPSHOT</version>
<type>javadoc</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15.1-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15.1-R0.1-SNAPSHOT</version>
<type>javadoc</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vexsoftware</groupId>
<artifactId>nuvotifier-universal</artifactId>
<version>2.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Alright, just going to remove luckperms from the project for now then...
!api
Learn how to use the LuckPerms API in your project.
@hollow zodiac
can a german(it doesnt matter )player help me on my Server .. I have Luckperms on in and i dont can edit it because when i use the command /lp creategroup (group) that doesnt work ...
#support-1 as it seems like it is a question about LuckPerms in general and not the developer API.
Please explain in that channel what exactly doesn't works
#support-1 @empty stag
