#luckperms-api
1 messages · Page 36 of 1
Luckperms does not dispatch that operation in a way that lags the server
It will spin up a thread and use that, asynchronously, to remove the perms from the users
It's also not similar to running 500 commands at the same time, as it will just do what you ask
!bulk is a great example of this method being applied to its full extent
Quickly update a large amount of user and group permissions by using the bulkupdate command.
I have read your message more, and indeed believe that bulk or just running a loop to remove the perm using the LPAPI would be your best bet
!api
Learn how to use the LuckPerms API in your project.
alright. On a note unrelated to LuckPerms... is there a way I can code something like this easily and efficiently without using luckperms? My hope is that eventually I may be able to release my plugin to the public and if I can reduce the number of dependencies, that would help.
You can use Vault, which is a sane dependency
Then you'll have to arrange the async bit on your own, afaik
alright. I'll check it out. Thank you!
Hi, I'm reading everywhere the docs about Bukkit/Spigot API, but is that the same for BungeeCord?
I can't find anything about hooking into LP Bungee, I'd need it to get some prefixes
Oh - I've found them. Apologize.
how do you clear someones groups and add a new one
https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/commands/SetGroupCommand.java#L56L69 something like this is what you're looking for
How do i make it so a prefix for one of my groups doesn't get interupted by a prefix from another group which is a parent of it
!weight
LuckPerms allows you to set weights in order to determine the priority of certain nodes, like permissions and even prefixes. A higher weight number is a higher priority.
so my knowledge of completablefutures is surface level at best; and i'd like to know if this is the proper way of doing things
i have a DatabaseManager which returns a CompletableFuture<User> (this user is from my plugin, not LuckPerm's User, which might be a bit confusing but w/e)
return databaseManager.getUser(uuid, playerName)
.thenCombine(luckPerms.getUserManager().loadUser(uuid), (cryptoUser, user) -> {
cryptoUser.setLuckUser(user);
return cryptoUser;
});
is this proper?
basically i want to get the cryptolib User, load the LuckPerms User into it, and return the CryptolibUser in the cf
wait
if luckperms loads the user on join
why do i need to loadUser
if the user is already loaded, does this still re-query the database
oh wait
nvm
ignore me this is fine
lol okay
that code is only called when the user is offline anyways (playerdata needs to be prepared before the player joins)
wut
the proxy tells the server that a player is joining, the server loads the user data, tells the proxy it's ready, then the player connects
the proxy tells the server that a player is joining
I mean, you do know AsyncPlayerPreLoginEvent is a thing, right? 👀
remember
APPLE
i wrote this before i knew it was a thing :c
it might be better to switch over
aghh fuck it
you're right
lol
you and your apples
I suggest you set the event priority to MONITOR and ignoreCancelled true
already was on monitor, forgot about ignoreCancelled though
thanks
i assume APPLE#getName returns the username the player is trying to connect with?
(for any reason) if the event is cancelled, you don't want to load your user data so it won't be called, but if it isn't cancelled, LP will have the data loaded already by the MONITOR stage
so I think you could safely do getUser instead
lemme confirm
unless some stupid plugin would de-cancel the event (purest evil I have yet to see), yeah you're safe to use getUser
lol
and if i recall correctly from the documentations, LP is threadsafe?
Learn how to use the LuckPerms API in your project.
perfection
will User.getCachedData().getMetaData().getMetaValue("something that isn't set") return null?
or like an empty string
it's nullable
i assume null
it's nullable
then yes
but beware tho, things annotated as nonnull, if the passed value is invalid or there is no data, the method may throw an exception instead of returning something
no problem!
:^)
so, API-wise, the way to set meta would just be to get the meta map and put, yeah?
wait why is it a string list
ohh
wait
yeah
there's other stuff for that
user.data()
i might be a little slow but i get there in the end
yeah that's what i just found haha
modifyUser yes yes yes
not very familiar with this part but from what I know, the cached data is like a "mirror image" of the actual data, it's immutable from the api's pov and it's already "processed" (not the Node objects, but the string values)
yeah hence the whole cached thing
makes a lot of sense
this is a well structured API
LP as a whole is really nice to read and to work with :)
yeah honestly tho
this is great
so in Node.builder(String), is the string <key>.<value>
OHHH
i see
lol
no
you would use MetaNode.Builder
specify a key normally
and specify a value normally
OHHHH
LP will take care of escaping and formatting
i really am
i'm just excited to make this whole system here prepared for the future
is there a specific way to get a set of permissions with a certain "prefix"
i.e. all permissions that start with "cryptolib.chat_title"
oh wait
i can just iterate through the permission set
i'm an idiot lol
oh actually i could do this way better
i assume a Tristate.asBoolean() will return false if it's either false or unset, true if true?
thanks
wow
I have always joked about using Boolean as tristates
Because it can be true, false or null
that's literally what luck did xD
lol pog
i wonder why Boolean instead of boolean
also, to "update" a meta, i need to remove the MetaNode and then add the new one right?
yeah, since the node as a whole is a different one
you can should do something like user.data().clear(NodeMatcher.metaKey("whatever"))
Hey, I'm trying to use the API on Waterfall/BungeeCord, and even with depend: ["LuckPerms"] in my plugin, for some reason 1) my plugin loads before LP, and 2) another plugin (gChat, also from lucko) which loads after LP also says the API isn't loaded
ah, lemme try it
I even switched back to normal bungee from waterfall to see if that'd fix it, and no luck, but i'll try again lol
Yep, it's "depends"
yep, now i'm loading after
but, "The LuckPerms API is not loaded" still
lol
using LuckPermsProvider.get()
Are you trying to get the API on onLoad or onEnable?
Eeh not sure how bungee does it but the dependency tree dictates the enabling order, not load order
just tried w/ onEnable, still no luck (pun not intended)
Then you're most probably shading the API jar into your plugin, how are you building your jar?
w/ gradle, lemme check my build.gradle
Make sure it's compileOnly
Yeah no
Lol
Also, I suggest you update to 5.1 or 5.2 :d (ideally it would be the same version that the platform is running)
ayy, got LP api now
Neato
ah, yeah, lemme update it to 5.2
and now to hope my db code works lmfao
just out of curiosity, does LP use an ORM at all to handle it's DB stuff?
An what
p much it uh, handles stuff like fetching objects from a DB for you by generating SQL and mapping objects in the DB to fields in an object
(pretty much asking how LP handles database stuff, bc i want to try and have something as a fallback if my current thing doesn't work lol)
If I understood correctly, no, it makes all sql queries directly, fetching the data as it is stored basically (classic selects, inserts and updates :d) and builds the objects based on the query
Lemme
Sec lol
fair
so, pretty much what my fallback plan was already :p
i'm just using an orm rn bc im lazy, and it makes it easy to support multiple db backends
there is that HUGE list of pre-made query statements, so it's basically all clean when using them
fair
but yeah it's nothing more than classic connections, prepared statements and iterating through the result set
hello humans
if I wanted to get an integer value of a permission, like myplugin.numbers.10 should I use the stream API to find that value, or is there a better way?
Uh I feel like this might be a good use of meta
Perms are good and all, but meta is essentially a key: value map that respects inheritance
which sounds like exactly what you want
fucking hell fefo lol
fefo be
crazy
aye
how do I add Luckperms api on Bungee?
Learn how to use the LuckPerms API in your project.
@turbid solar so this is fine??
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.1</version>
<scope>provided</scope>
</dependency>
ah ok thanks buddy
Good evening, could someone tell me what event I should use when a player loses permission?
NodeRemoveEvent is what you're looking for
thx
huh?
Message got deleted
!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.
@nocturne elbow you can check api usage examples there 👆
thanks 🙂
among them, getting the prefix :d
i will save this repo in my browser favorites!
How can I get all user permissions? (only user permissions, no rank permissions)
!api
Learn how to use the LuckPerms API in your project.
Well, User extends PermissionHolder, so you can check the identifier (https://javadoc.io/static/net.luckperms/api/5.2/net/luckperms/api/model/PermissionHolder.html#getIdentifier--, https://javadoc.io/static/net.luckperms/api/5.2/net/luckperms/api/model/PermissionHolder.Identifier.html) to check if it's a User or a Group
And if it's an online player the one we are talking about and you want the player object, just get the uuid and Bukkit.getPlayer(uuid) lol
how do code html
?

how do i include lp api in my html project
wtf
??
I hope you're trolling
yes it is
- minecraft plugin have nothing to do with html
unless you are interfacing it with a website, but still
....................
No, really?
point taken, sorry
If you have legitimate questions about the LP java api, then here is fine.
im not having
luckAPI.getNodeFactory().makeGroupNode(group).build();
What am i doing wrong ?
Okay 😄
Is this correct ?
PermissionNode build = PermissionNode.builder().permission(groupName).build();
Correct ?
This is the one you want to use: https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/node/types/InheritanceNode.Builder.html
User user = this.luckPerms.getUserManager().getUser(player.getUniqueId());
is this the correct way to get a user ? and how can i apply the PermissionNode to the user ?
!cookbook You can check the "api-cookbook" repository for some "real world" examples on how to use the API
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Including but not limited to: loading user data and adding perms, groups, and other things
i did this like that but it wont work ...
So i got the groupnode and now i want to set it to the user
There is an example of exactly that in the cookbook repo..
can i do user.data().add()
And I don't quite get what you mean by "it wont work" either, how does it not work? Does it throw an error? What does it do/not do?
this.luckPerms.getUserManager().modifyUser(player.getUniqueId(), lpUser -> {
lpUser.data().clear(NodeType.INHERITANCE::matches);
PermissionNode build = PermissionNode.builder().permission(groupName).build();
lpUser.data().add(build);
});
did it like this ... checked with
lp user playername info nothing changed no rank ...
This is the one you want to use: https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/node/types/InheritanceNode.Builder.html
You use InheritanceNode.Builder to add parent groups to a user/group, not PermissionNode.Builder
okay i will try
Worked ^^ Thanks
Hello guys, how to solve this problem?
!errors
Here's a page with some common storage system errors.
I've already seen this, and I did everything according to the instructions, but the problem remained, so I came here
the entire server log?
Seeing a paste of the problem makes everything so much easier! Use https://bytebin.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!
uhm? #support-1 #support-2?
also this :d
Hello, i made a plugin which requires vault, and i didnt find any events, does luckperms has a parent group set event?
NodeAddEvent is what you're looking for
np
Is this the help channel
If you're looking for hekp with the LP api, yes. For general LP support, #support-1
This is where the cool devs hang out 😎
Oh I c
So I’m trying to make it so that an arena of my server is a kitpvp area and only in that area can you access certain kits. I have the region setup with worldgaurd and I installed extracontexts and set world guard to true
uuh #support-1 or #support-2 would have been more appropriate so I'm answering there
Ok
hi, I have such a problem, I don't know how to make every player lose the rank player
Dont post in 4 different channels
so, not exactly luckperms related but it's another one of lucko's plugins so i may as well ask here ig, is there a maven package for lucko's gchat plugin? found the source for it here but i'm wanting to use it's api for listening to chat events https://github.com/lucko/gChat
I mean you could... just... listen to Bungee's chat event?
And as far as I know it isn't up in any maven repo
Wouldn't be hard to clone, compile and install to maven local tho
why do u have an invisible name !+ avatar,
Yeah please nick yourself lol
It’s visible on mobile :)
Hey I was wondering if there was an event for when a node expires?
NodeRemoveEvent @shut ingot
Check that it had an expiry and that that instant is already in the past
Sweet I appreciate you a lot!
Lovely
hey @nocturne elbow the event doesn't fire at all? Is there something special i need to do to get the api event to fire or something haha
Hey Fatalmoment! Please don't tag helpful/staff members directly.
Hi i have a good questions
How are you subscribing the Listener to the event?
Anyone know how is call the methood that download the dependency? or where is the link?
Anyone know who is call the methood that download the dependency? or where is the link?
❓
You mean the dependencies repo?
I want to based on Luckperms dependency system
to download my custom dependency
Do i explained?
Well you can check LPs source for that, there are a couple of files dedicated to dependency downloading and checking
it's in a package called dependencies inside the common module of the project
I have just started with dependency magnamente
Oh, a owner of luckperms answer to me 😄
thanks
!clipy
Sorry! I do not understand the command !clipy
Type !help for a list of commands.
!Download luckperms sourcecode
You can download LuckPerms for Bukkit/Spigot, BungeeCord, Sponge, Nukkit and Velocity.
Thanks fefo I forgot to subscribe it
Sorry for the questions, but Luckperms, when enable it download dependency and when is down (when the plugin is off) it delete?
Because i wanna base on that system to make a plugin loader
Thanks fefo I forgot to subscribe it
hit that bell button
Sorry for the questions, but Luckperms, when enable it download dependency and when is down (when the plugin is off) it delete?
No, the downloaded dependencies are already downloaded into files, so unless someone manually deletes them (or the code manually deletes them), they will stay there
oh ok
thank
i wanna take ideas to make a plugin loader but i cant found anything
is there a way to unsubscribe on disable?
i use plugman and something strange happens xD
it starts to multiply the events
its happen something related to me
when i use Luckperms i cant use Plugman, its crash my network
is there a way to unsubscribe on disable?
When you subscribe to an event, you get an EventSubscription
Which you can close
Check out the javadocs for the methods and classes
!javadocs
Learn how to use the LuckPerms API in your project.
Bottom link
no?
LP bukkit legacy is the exact same as LP bukkit
it just includes gson with it
because 1.7.10 didn't have gson
@nocturne elbow why is your name so long but hi
Hey Conclure! Please don't tag helpful/staff members directly.
oops
KEK
okay so how do I use the luckperms api
!api :fingerguns:
Learn how to use the LuckPerms API in your project.
UserManager#loadUser
oh it's safe
and getUser is when the user is loaded right?
yessir
although loadUser returns a CompletableFuture<User>
so you can thenAccept/whenComplete
get() >:]
oh no
you should probably just take a look at the javadocs (instead of asking for every method)
okay so how do we get a user?
I mean that one is literally explained in the api usage page xD
oh also
and that as well ^
oh im blind, sry benUwU
!cookbook Check here for some real world api usage examples
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
a nice repo
also Eclipse IDE lol
yeah I mean Eclipse is good but it has ruined many projects
hwy how do I commands like /plugins and /info?
?
*disable
#luckperms-api is for support for those using the Luckperms API in their own plugins. I think you want to be in #support-1
my b
Lets say you need to get a specific server context and check if the player has a permission in that context. i.e. Hub server needs to check if a player has a permission in the 'factions' context How would you go about it?
This is probably a really dumb idea, but could I use the LuckPerms API without actual LuckPerms if I shaded the JAR in?
no
I basically want to have LuckPerms compatibility on a platform that doesn't have LuckPerms support yet
like what platform?
Minestom. It's a multithreaded server implementation designed to be used at scale.
No permissions system so I'm writing one.
well you need to do a lot more work than just shading luckperm's jar
probably beyond my scope of knowledge as well
I know that. But what I want with LuckPerms is for it to be able to write permissions to a LP database.
I thought maybe the API could help with that.
i mean how luckperm works is there is a common abstract api that does the main system, and the separately implement it to different platforms like nukki, bukkit, bungee etc
lmao
runs away
I hate Gradle as well.
I'm sure it does.
So basically what you're telling me is I can't use the API without the actual LP plugin installed?
Yes
You could make an issue on GH for support for that but its unlikely that it'll get added unless alot of people want it
Gradle > Maven
Well is Maven malevolent?
Lets say you need to get a specific server context and check if the player has a permission in that context. i.e. Hub server needs to check if a player has a permission in the 'factions' context How would you go about it?
!api
Learn how to use the LuckPerms API in your project.
I understand your point. I'm just a bit annoyed because all I want to do is database queries.
Make them yourself I guess?
Yeah I will but it's annoying because everything is buried in like a dozen layers of functions.
https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/context/ContextManager.html Doesn't say anything about getting specific contexts, only active contexts
I understand your point. I'm just a bit annoyed because all I want to do is database queries.
@mighty path well you must first get luckperms to actually work on the server platform first right...?
I suppose.
But since the databases are server-independent it seemed like something you could do without the server part.
yea so what if you have a database of permission? If luckperm is not working on your server means no permission checking will occur
suppporting a new server implementation with different api needs a lot more work than what you saying.
does the spigot API allow for using the ChatColor enum in a suffix/prefix
such as return this.getColor() + "[" + this.getName() + "]";
Yes
thanks
Hi, is there a way to integrate the BungeeCord version of LP with my spigot plugin ?
Learn how to use the LuckPerms API in your project.
yes but my plugin can't the .jar file because it's running on different server
what?
if your plugin has LuckPerms as a dependency, then you need luckperms on the server that the plugin is on
@subtle kelp you need luckperms on all server
so i can't use the bungee version ?
@subtle kelp you use lp-bungee for bungeecord server, lp-bukkit for bukkit based backend server
if you plugin is installed on your backend server, it should interact with LP-bukkit
then i need to install lp-bukkit on all servers that run my plugin and remove lp-bungee right ?
@subtle kelp you still need lp bungee for plugin on bungee and bungee perms like /server
ok i'll try that, thanks
!sync oh yea that this
To sync data between servers, you need to connect each LuckPerms plugin to the same database (for example MySQL) and set up a messaging service.
All working now, thank you
When coding a plugin for bungeecord, do you have to add support for luckperms for it to utilize it's permissions?
Nope, unless you will be working with LP directly through the API, there is no need to add exclusive support
Okay, let me grab my plugin code that I need help with.
if(args[0].equals("reload") && sender.hasPermission("discord.reload"))
Would this work with luckperms?
I have LP installed on bungee and spigot, the plugin code I showed is for a bungeecord plugin.
I do have both LP on bungee and spigot connected via a MySQL database.
Yes, that would work with LP
lol np
I literally added the LP api to add LP support but all-in-all I didn't follow the network installation instructions
// LuckPerms api = LuckPermsProvider.get();
ProxiedPlayer p = (ProxiedPlayer) sender;
if(args.length == 0) {
p.sendMessage(new ComponentBuilder(Discord.configuration.getString("text").replace("&","§")).create());
} else if(args[0].equals("reload") && sender.hasPermission("discord.reload")) {//|| api.getGroupManager().getGroup(api.getPlayerAdapter(ProxiedPlayer.class).getUser(p).getPrimaryGroup()).getNodes().toString().contains("key=discord.reload, value=true")) {
try {```
ROFL
I need some help with my code...
oh god... let me just pastebin it...
actually nvm forget it.
hm?
try {
Discord.reload();
p.sendMessage(new ComponentBuilder(Discord.configuration.getString("messages.pluginReloadSuccessful").replace("&","§")).create());
} catch (IOException e) {
p.sendMessage(new ComponentBuilder(Discord.configuration.getString("messages.pluginReloadUnsuccessful").replace("&","§")).create());
e.printStackTrace();
}
}```
I have this bit of code. when it errors for reloading the config. It doesn't drop a IO exception. but rather something completely different and i'm having a hard time seeing what that exception is, so I can catch it.
Let me grab the log.
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.
The config is INTENTIONALLY messed up so I can test the fail message.
btw instead of the .replace, ChatColor.translateAlternateCodes
What does Discord.reload() do? Share the code
do I spy static aboose
try {
Discord.reload();
p.sendMessage(new ComponentBuilder(Discord.configuration.getString("messages.pluginReloadSuccessful").replace("&","§")).create());
} catch (IOException e) {
p.sendMessage(new ComponentBuilder(Discord.configuration.getString("messages.pluginReloadUnsuccessful").replace("&","§")).create());
e.printStackTrace();
}
}```
@shy hill MY EYES
WHY YA HURTING MY EYES
with the .replace?
DSRV?
DiscordSRV, another plugin I'm support for
it's got a few legacy issues such as ReallyFreakingLongConfigOptions
Oh... wait, you haven't seen long yet.
I had setup networked LP wrong and didn't realize it so I instead did this to my plugin to check if a player has a permission...
api.getGroupManager().getGroup(api.getPlayerAdapter(ProxiedPlayer.class).getUser(p).getPrimaryGroup()).getNodes().toString().contains("key=discord.reload, value=true")) {```
🤣
burn it.
Yeah and that's not the way you check nodes btw lmao so brittle
🤣 It was my first time messing with bungeecord.
I assume md must have a platform-based way of checking if a player has a permission like bukkit's Player#hasPermission(String)
Yea, I fortunately didn't have to add "exclusive support" to my plugin to check if a player has a permission.
DiscordSRV really does have a really long config.
those key names are something though
MinecraftDiscordAccountLinkedAllowRelinkBySendingANewCode: false lol
the config itself really isn't that long, LP's is longer :)
I'm having a hard time reading that, let alone in a config file LMAO
posting this in #general one sec
Hello, I want get all USER permission (no group inherit permission), but I dont found how i can do it
With this code I get all permission, included permissions of groups
yeah that's uhm... no
Objects.requireNonNull will throw a NullPointerException on purpose if the object is null
That's just a suggestion tho
so you'll probably want to have something like if (user == null) return;
but you do you on that part
lemme
!javadocs
Learn how to use the LuckPerms API in your project.
"but I dont found how I can do it"
Are you saying that this should give me back the permission list from user?
#isWildCard = if permission is true or false, no?
looks good
this work fine, but is "isNegated()" the boolean for check if true or false, ty ^^
wut
yep, now Im trying to get Context server xD (getKey() and getPermission () return the same xd)
They return the same for PermissionNode, but getPermission does not exist for other type of nodes ;)
I too can send screenshots with an incredibly lacking amount of context
okey
I get this error
@modern thistle amazing error!!
Is this even related to the developer api?
Hey how do I connect my luckperm ranks with tebex store
please reply as soon as possible
with luckperms api? else #support-1 or #support-2
Hallo, what jar is the api of luckperms?
!api
Learn how to use the LuckPerms API in your project.
how do I set a players primary group?
User#setPrimaryGroup doesn't seem to be working for me, no error at all
i got luckperms to work with commands already in the game but couldnt figure out how to do it with commands outside like warps and stuff which i got from plugins
This might help you, Unturned: https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/commands/SetGroupCommand.java
Thanks
realized i used the wrong channel, apologies
shut i use the normal latest luckperms-bukkit.jar as api?
yeah....... no
in the main api usage page it tells you you should download the api jar instead (if you are not using a build system like maven or gradle)
use maven
Use Gradle
Gradle is more compact
Plus Daemon
Maven: ```xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>target/dependencies
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Gradle: ```gradle
apply plugin: 'java'
repositories {
mavenCentral()
}
jar {
baseName = 'gradleExample'
version = '0.0.1-SNAPSHOT'
}
dependencies {
testImplementation 'junit:junit:4.12'
}
Plus it’s easier for dependencies
where and how are you calling addPermission?
assuming permissions is basically getStringList?
exactly
I just realized, sorry xDDD
also, you can remove this part: if it's empty, there is nothing to iterate through in the for loop below :) i.e. the loop would be skipped
Hey, im noob at the api. This code works inconsistent. What is the correct way to add a list of permissions to player?
public void exec(Player player) {
ArrayList<String> permissions = new ArrayList<>();
permissions.add("hub.break");
permissions.add("hub.place");
permissions.add("hub.jump");
permissions.add("hub.run");
for (String string : permissions) {
addPerm(player, string);
}
}
public static void addPerm(Player player, String permission) {
Node node = Node.builder(permission).withContext(DefaultContextKeys.SERVER_KEY, "hub").build();
Main.luckPerms.getUserManager().modifyUser(player.getUniqueId(), (User user) -> user.data().add(node));
}
!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.
Make sure to save the user
https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/commands/AddPermissionCommand.java
I used this, and this doesnt save user
Does the code just not work?
Its inconsistent, sometimes it saves all 4, some times 3, sometimes none
Tried debugging it? By logging every thing u do
Yeah, sometimes my loop execute before the user.data().add has returned succesful...
I have no idea if that is a correct way to add a list of permissions
public static void giveMultiple(Player player, List<String> permissions) {
User user = Main.luckPerms.getUserManager().getUser(player.getUniqueId());
for (String permission : permissions) {
Node node = Node.builder(permission).build();
user.data().add(node);
}
Main.luckPerms.getUserManager().saveUser(user);
}
Found this if this helps someone with same problem!
Not to mention faster 👀
Yea owo
How can I add a permission to a player via api?
!cookbook you can read some "real world" api usage examples in this repo, among them how to add perms
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
ok
my plugin stopped working😫
ok?
Hey so I made a scoreboard using
Set<String> groups = main.loadUser(player).getNodes().stream()
.filter(NodeType.INHERITANCE::matches)
.map(NodeType.INHERITANCE::cast)
.map(InheritanceNode::getGroupName)
.collect(Collectors.toSet());
and with each group I displayed it on the scoreboard. Now how can I set up the default group so i can name it to say Member on 5.0+ Ive looked around a bit and found a solution for <5.0 but I couldnt figure it out. Can you guys help me out w this
You can just getNodes(NodeType.INHERITANCE) and it'll return a collection of InheritanceNodes btw
And I'm not sure what you mean by the rest tbh
I used this from the api website which is why like that
so basically u have a default group on startup and i dont know how to change the name post version 5.0
/lp group default setdisplayname Member?
Then you can Group#getFriendlyName() iirc
Coolio
wait so what u were saying b4 about getNodes(NodeType.INHERITANCE)
how would i use that in my situation
where i want the groups
Instead of getNodes().stream().filter(...).map(...) you can just getNodes(NodeType...).stream()
Hello, how to get ?
https://i.imgur.com/3qTjebv.png
so earlier we talked ab how u can change the displayname of the default group and that is good but my issue now is that the method I was using was grabbing the groups by name and not displayname so how would I be able to display the displayname of a group on the scoreboard? I can see there is a place for displaynames in the api online but it is pretty confusing
@barren parrot Node#getExpiry() iirc
Ok thank's I will look
@orchid cape not sure what you're looking for really
Yeah the display name
so how do i get that
cuz the groups variable with the getnodes etc etc gives me the group name not the displayname
the display name is Member
but the group name is default
Then get the group from the GroupManager from the resulting nodes
GroupManager#getGroup(String) or something
public static String getPlayerGroup(Player player, Collection<String> possibleGroups) {
for (String group : possibleGroups) {
if (player.hasPermission("group." + group)) {
return group;
}
}
return null;
}
that is the one i was using for geting the group of a player
now this is where i put in the groups variable that i used above and the player
Yeah... but that's with the groups names, not the display names
Get the player groups like you were doing earlier (with the stream) and get the Group from the resulting InheritanceNodes using the GroupManager
How to replace null to rank ?
https://i.imgur.com/xUkCIqJ.png
Set<Instant> group = user.getNodes().stream()
.map(NodeType.INHERITANCE::cast)
.map(Node::getExpiry)
.collect(Collectors.toSet());
If you just want to get the rank, Vault is usually the easiest
How to get rank and time at the same time ?
filter the nodes that do have an expiry
so you have all the InheritanceNodes that do expire (i.e. parent groups)
Ok thank's i will test
Can I use the API Outside from Spigot/BungeeCord/Nukkit etc. In an own Java Application
But why
To manage permissions etc?
permissions for what though
Is it possible or Not?
...
it's not that simple
if you're managing permissions for an entirely different java app, unrelated to minecraft, yes it's likely possible but you'd have to abstract things yourself
I want to implement LuckPerms as a module into CloudNet, i dont know If you know Englisch
Yes
cloudnet is an infrastructure for existing servers, if I'm reading this correctly
cloudnet helps you run, for example, a paper server, no?
anyhow, anything is possible if you have the skills to do it, but I'm not sure what your actual use case is tbh
Luckperms simply isn't made for that use case
you can modify it if you have the skills to do so, if not, it's not a cloudnet module natively
Yes i know
Which abstract classes i Must use to create an instance?
I think I have the Skills
then, read the code, and abstract it. It's not something anyone can guide you through without doing it all for you
Is there a way to get someones position on a track?
with API?
yeah
Was just trying to make some simple command that promote players below a rank under them in a track, but not to the same rank etc, and applied the correct server context, so they can only promote people for their respective context, and only to the rank below theirs.
Currently we have 2 lp dbs one on the proxy so everyone has global litebans and a second on the servers, so i am using plugin messaging channels and using the API to check tracks directly then send a response back to do the proxy database
was hoping i could just get their position in the track and then check if the next one is below the current position of the command sender, though if not i guess i'll have to do something a bit more tedious
did some reading up in general and i think i can do this using track promote commands if i set up the perms correctly, might just use the command as an alias to fire off the same command on bungee and the server and have the plugin make sure the servers context is set correctly for the tracks thing.
hello is there an api when the player has new permissions
example: group.test suddenly I can execute actions afterwards
sorry i'm belgian ^^
You add the relevant perms to the group??
Anyone there? I'm needing some help
!askl
Sorry! I do not understand the command !askl
Type !help for a list of commands.
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!
!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!
🤔
Wie heißt das Event, welches gecalled wird wenn ein User ein Gruppenupdate erhält?
wann wird das gecalled?
Hello, does someone know how I give the player his permission with the LuckPerms API
!cookbook there is an example for that in here 👇
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 can't find the code example, which index is it in exactly?
commands/AddPermissionCommand or something
Ok
I don't mean with a command but with the API
.. that entire repo is full of examples on how to use the api
take the AddPermissionCommand piece as example
and adapt it to your needs
Is there a possibility to get the highest group of a player?
User#getPrimaryGroup?
@nocturne elbow returns default. but i have admin and default
Hey Lvkas_ × Lukas! Please don't tag helpful/staff members directly.
sorry 
LuckPerms allows you to set weights in order to determine the priority of certain nodes, like permissions and even prefixes. A higher weight number is a higher priority.
Other than that, if you don't want to use that method you can getInheritedGroups(QueryOptions) to get an ordered collection of groups (https://javadoc.io/static/net.luckperms/api/5.2/net/luckperms/api/model/PermissionHolder.html#getInheritedGroups-net.luckperms.api.query.QueryOptions-)
Other than that, if you don't want to use that method you can
getInheritedGroups(QueryOptions)to get an ordered collection of groups (https://javadoc.io/static/net.luckperms/api/5.2/net/luckperms/api/model/PermissionHolder.html#getInheritedGroups-net.luckperms.api.query.QueryOptions-)
yes
first the highest?
How to remove a permission from a player?
through API
How to what
lol sorry
O
You should uuuh build a copy of the node you want to remove, UserManager#modifyUser and then User#data().clear(NodeEqualityPredicate) for that node (see https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/node/NodeEqualityPredicate.html)
oh ok got it
hey i use this to get the prefix of the player but i get this error:
PlaceholderAPI.setPlaceholders(po, "%luckperms_prefix%")
java.lang.IllegalArgumentException: Score '§l>> §lLylixn : %luckperms_prefix%' is longer than the limit of 40 characters
at org.apache.commons.lang.Validate.isTrue(Validate.java:136) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at org.bukkit.craftbukkit.v1_16_R2.scoreboard.CraftObjective.getScore(CraftObjective.java:121) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at io.github.kypdo.irithemccore.Main.lambda$scoreBase$0(Main.java:83) ~[?:?]
at org.bukkit.craftbukkit.v1_16_R2.scheduler.CraftTask.run(CraftTask.java:81) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at org.bukkit.craftbukkit.v1_16_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:400) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at net.minecraft.server.v1_16_R2.MinecraftServer.b(MinecraftServer.java:1059) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at net.minecraft.server.v1_16_R2.DedicatedServer.b(DedicatedServer.java:352) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at net.minecraft.server.v1_16_R2.MinecraftServer.a(MinecraftServer.java:1007) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at net.minecraft.server.v1_16_R2.MinecraftServer.w(MinecraftServer.java:846) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at net.minecraft.server.v1_16_R2.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_202]
How can I check if a group has permission to something?
I tried
group.getNodes().contains(Node.builder("my.node.test").build());
java.lang.IllegalArgumentException: Score '§l>> §lLylixn : %luckperms_prefix%' is longer than the limit of 40 characters
at org.apache.commons.lang.Validate.isTrue(Validate.java:136) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at org.bukkit.craftbukkit.v1_16_R2.scoreboard.CraftObjective.getScore(CraftObjective.java:121) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at io.github.kypdo.irithemccore.Main.lambda$scoreBase$0(Main.java:83) ~[?:?]
at org.bukkit.craftbukkit.v1_16_R2.scheduler.CraftTask.run(CraftTask.java:81) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at org.bukkit.craftbukkit.v1_16_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:400) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at net.minecraft.server.v1_16_R2.MinecraftServer.b(MinecraftServer.java:1059) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at net.minecraft.server.v1_16_R2.DedicatedServer.b(DedicatedServer.java:352) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at net.minecraft.server.v1_16_R2.MinecraftServer.a(MinecraftServer.java:1007) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at net.minecraft.server.v1_16_R2.MinecraftServer.w(MinecraftServer.java:846) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at net.minecraft.server.v1_16_R2.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[spigot-1.16.3.jar:git-Spigot-3a70bd9-bf3d720]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_202]
@nocturne elbow "is longer than the limit of 40 characters" - You are exceeding the character limit
but the prefix is : "&7&lJoueur"
I tried
group.getNodes().contains(Node.builder("my.node.test").build());
So I've made a work around, but I'd like to know anyways. I searched for messages containing this, but haven't found what I was looking for
but the prefix is : "&7&lJoueur"
@nocturne elbow Its not - its: §l>> §lLylixn : &7&lJoueur (at least maybe even more when chatting)
Because it might add suffixes or clan tags, idk what else you are doing...
How can i get the meta datas; meta key and meta value?
For a group
And not in the form string, stringlist
yes thanks
so i'm using this to set suffixes, but i'm curious how performant is it?
public void setSuffix(Player player, String suffix) {
LP.getUserManager().modifyUser(player.getUniqueId(), (User user) -> {
user.data().clear(NodeType.SUFFIX::matches);
Map<Integer, String> inheritedSuffixes = user.getCachedData().getMetaData(QueryOptions.nonContextual()).getSuffixes();
int priority = inheritedSuffixes.keySet().stream().mapToInt(i -> i + 10).max().orElse(10);
Node node = SuffixNode.builder(suffix, priority).build();
user.data().add(node);
});
}
in the end it'll be used fairly regularly on a server with 60+ players
and i'm pretty new to java so i have no idea how exactly completablefutures work
well, the loading/saving user data that modifyUser does for you are done asynchronously, so there is no performance penalty there
ah great
I'm not sure if the callback is done async, but it's all loaded and cached data anyway so it's gonna be fast
yeah from what I know completablefutures are basically promises in js
alright, thanks!
yeah the callback is done async too
so there will be absolutely no performance penalty whatsoever
that's great, thanks for the info
yeah from what I know completablefutures are basically promises in js
👍
Exactly the same idea
i promise to complete your future
yes
That wasn't--
i'm having this weird issue, i keep getting java.lang.NoClassDefFoundError: net/luckperms/api/node/Node BUT only sometimes
How are you building your plugin?
Well, i'm using this guide to hotreload my code https://www.spigotmc.org/threads/guide-windows-extremely-productive-development-environment.394754/ which I guess could introduce some issues
but, even if i use this and copy the jar to the plugins folder, i get the same error
Didn't really answer my question
uh that's really the best answer i have since i'm extremely new to this
by the looks of it you're using maven
yeah
!paste your pom.xml please
Seeing a paste of the problem makes everything so much easier! Use https://bytebin.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!
when i launch the server
yeah
i fix the issue by removing the imports, removing anywhere the imports are used, rebuild, relaunch, reimport and hotreload
then it's fine
uuuhh don't know what kind of fix is that lol
it's really hacky lol
got a server log with that error coming up on start up?
you need to put LuckPerms as a dependency in your plugin.yml
ah
the exception java.lang.NoClassDefFoundError usually shows up when either the class doesn't exists or the plugin associated with this class hasn't been initialized yet
NodeRemoveEvent, check that the node was of type INHERITANCE and that it had an expiry
might as well want to check the target too, depends on your needs
thanks i'm going to try that
BungeeCord dont found the api
The plugin said, that the api is not loaded
I have in my bungee.yml as depend LuckPerms
you are shading (including/compiling with) the API inside your plugin
most probably
you don't want to include the LP API inside your plugin
yes
it is provided by LP
yes ik
how do I access the lp groups (not lpb) from the API that I load using a Bungeecord plugin. Do I only have access to the lpb groups?
or do I have to use the message channel to fetch the groups I want
or do people using the bungee version only use lpb groups instead of lp groups. Because then I wouldn't need to do this
Assuming bungee is set up correctly, all groups and perm data should be globally accesible.
private static LuckPerms luckPermAPI = LuckPermsProvider.get();
^ this is what im using for my bungee plugin
and its only giving me the lpb groups. But your saying the lpb groups shoudl sync with the lp groups?
COrrect
if they are using the same db...
in theory, the commands should have no difference. Both /lpb and /lp should have the exact same effect
ok thats good to hear. makes my life a lot easier
thanks for the help. best permission plugin by far 🙂
!api
Learn how to use the LuckPerms API in your project.
RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager().getRegistration(Permission.class);
permissionProvider.getProvider().playerAdd(Bukkit.getPlayerExact(playerName), reward.getData());```
I'm using this to hook into luckperms and add a permission to a user, everything is working well except that the added permission has a world context and idk why
well you're hooking onto LP through vault
and by default, LP does not ignore world context on operations made through vault
you can explicitly give a world argument to vault tho, don't know the exact methods
ahm
hm?
you can explicitly give a world argument to vault tho, don't know the exact methods
in that case, you would passnullas world
read* ;)
thanks
well yes I need to use null as a world argument
without it, it takes the player current world
correct
thanks for helping me Fefo
😁 np
im my plugin has permissions, do I need to add lp as an external library and make it a (depend in plugin.yml) or does it not matter?
i would but ive been seeing way better progress when i actually grind out shit myself
its most likely a problem with my if else loops tbh lol
i have too many (!(sender) + (sender) loops
ight wtvr
thats the permission node okay?
like that it works while im opped (hence the default op)
yus
now it's default FALSE so you need the permission node regardless of opped status
public class SpeedMain implements CommandExecutor {
List<String> toggled = new ArrayList<String>();
public boolean onCommand(CommandSender sender, Command cmd, String commondLabel, String[] args) {
if (commondLabel.equalsIgnoreCase("speed")) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "YOU MUST BE A PLAYER TO USE THIS COMMAND!");
return false;
}
Player player = (Player) sender;
if (player.hasPermission("de.speed")) {
if (toggled.contains(player.getName())) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
player.sendMessage(ChatColor.AQUA + "SPEED" + "" + ChatColor.GREEN + "ENABLED!");
toggled.remove(player.getName());
return true;
}
player.removePotionEffect(PotionEffectType.SPEED);
player.sendMessage(ChatColor.AQUA + "SPEED" + "" + ChatColor.DARK_RED + "DISABLED!");
toggled.add(player.getName());
return true;
}
}
return false;
}
}
and thats the code for the permission node im trying to make
i think the issue is the if loops
what doesnt work about it?
even when you have the perm node it doesnt work
okay
okay
so
Stupid question
Are you absolutely sure you have the permission?
^
Sure
does the code look good though?
why are you returning false after this check?
Can't read nicely rn, on the phone lol
lol all g
should return true
then you wont have to cast sender to player
makes it simpler
so like ```java
public class SpeedMain implements CommandExecutor {
List<String> toggled = new ArrayList<String>();
public boolean onCommand(CommandSender sender, Command cmd, String commondLabel, String[] args) {
if (commondLabel.equalsIgnoreCase("speed")) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "YOU MUST BE A PLAYER TO USE THIS COMMAND!");
return true;
}
if (sender.hasPermission("de.speed")) {
if (toggled.contains(sender.getName())) {
sender.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
sender.sendMessage(ChatColor.AQUA + "SPEED" + "" + ChatColor.GREEN + "ENABLED!");
toggled.remove(sender.getName());
return true;
}
sender.removePotionEffect(PotionEffectType.SPEED);
sender.sendMessage(ChatColor.AQUA + "SPEED" + "" + ChatColor.DARK_RED + "DISABLED!");
toggled.add(sender.getName());
return true;
}
}
return true;
}
}```
how about printing the value of sender.hasPermission("de.speed")?
see what it actually gets
So the issue would be somewhere else
then this toggled.contains(sender.getName()) must be evaluating to false
the toggled is fine bc when im opped its working
that's what's left I guess?
yeah
the fuck
because the default is for op...
try just getting rid of the default: false all together
ok
what does /lp check <yourself> de.speed show when deopped (and having the node obv)?
I wonder if itll work lol
what does
/lp check <yourself> de.speedshow when deopped (and having the node obv)?
@nocturne elbow did that already
Hey TheShinyLizard! Please don't tag helpful/staff members directly.
im eventually gana make a parent thing for the perms so it will be 10x easier to manage
make children 😉
try just getting rid of the default: false all together
@nocturne elbow tf this worked...
ummmmmmmmmmmm
I just never add defaults to my perms
unless theyre admin perms then i add default: op
thats funny tho. glad it worked man
thats stupid as wtf
On a bad note however my wifi decided to crash...
ah no
10:24PM for me and I've got class tomorrow lol
enjoy
I'll try
tell ya what, life is at its peak when you get out of school
Factual
just finished 🙂
ciao
Given an InheritanceNode (group), what would be the proper method of finding the prefix granted to the player from that group?
metaData.getPrefix()
yeet
getMetaData on the InheritanceNode requires a NodeMetadataKey which doesn't appear to be documented on the api docs
MetaData metaData = cachedData.getMetaData(contexts);
String prefix = metaData.getPrefix();
please ignore me
just listen to fefo
Lol
Fefo is the profesh
You want to get the prefix/es coming from that group (and parents) specifically, and not any of the other inherited groups, right?
Correct
Well, you have the node, .getGroupName() will... well, give you the group name lol, from there you get the group instance from the GroupManager, getCachedData.getMetaData.getPrefix
Tim was sort of on the right path... but at the end of it lmao
Perfect, got it, thanks
For getPrefix you'll want to pass the user's queryOptions, so it applies for their contexts
big ol line of code
Users query options?
You have the user instance from where you got the node, right?
Yes
Doesn't it have a method like "getQueryOptions" or something? 🤔
Scroll down....?
What API version are you compiling against?
5.0
Aaaa



