#luckperms-api
1 messages ยท Page 2 of 1
I don't think there's a single method to grab that (check the JDs just in case, link in prior message), so you'll have to loop over all groups the player has and find the one with the highest weight yourself
I know... I tried, but still absolutely no idea how to ...
What part about that do you not know how to do?
get highest group from this
Collection<Group> groups = user.getInheritedGroups(luckPerms.getPlayerAdapter(Player.class).getQueryOptions(player));
by weight of course
I mean it's not too hard, rough pseudocode would look something like ```
var highestGroup, highestGroupWeight
for group in groups
var weight = getWeight(group)
if (weight > highestGroupWeight)
highestGroup = group
highestGroupWeight = weight
and iirc there's a method on groups to get the weight, if not can get all nodes of type Weight and take the highest weight from the nodes
I don't remember any of the exact methods, but that's roughly what you need to do
you can also sort collection by method reference to group weight
ok I wasn't sure if that was something easy to do on JVM or not. If this was kt I would have done .sort { getWeight(it) }.first(), but I can't remember what all of that has JVM equivilences
so please give me example, I've already tried to do this ...
what have you tried exactly
I've try to comparing, sorting
for each
i want just get the one group, what have highest weight
.stream().sorted(Comparator.comparingInt(Group::getWeight)).findFirst()
dont think that'll work bc iirc its an OptionalInt
mutters about slow streams
i will try.
oh yes 
gr -> gr.getWeight().orElse(0) ?
that made me want to die writing that
๐ค untrue
someone have luckperms for 1.12.2 pls
doesnt luckperms work with all versions
I have a question,
is there a way to get the players prefix with the api
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
I have a question i use the luckperms-api for my citybuild plugin to get the ranks and update it correctly. Now i use ItemsAdder and there i can make placeholder rank badges like this:
In chat works but in the tablist it wont work does anyone know how to do that?
my code for luckperms is this:
https://hastebin.com/oqozuparok.properties
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
well its up to you to correctly add it to the tablist
if its working in chat, you are correctly getting it from luckperms, so the issue is likely with how you are setting it in the tablist
Ah ok thanks and do you maybe know whats the problem in my code? ^^'
Bc never used placeholders in combination with luckperms.
i dont see anything about placeholders in that snippet
So do i need the placeholdersapi too for it right?
you only need to use it if you want to use papi stuff
theres no reason you need to use it though
Ok. But then how can i get placeholders in it? Bc now i only get the rank from the rank on luckperms. But the tablist cannot "convert" it to the badge.
Like this
well papi doesnt use : for placeholders so im not sure what plugin is doing that
either way, its not something for luckperms to handle
Its a addon from itemsadder and the use as placeholders :admin: or :mod: etc.
you should talk to them then
Ok but thanks i will ask on the itemsadder devs directly thanks!
Hey-
I'm working on a plugin that requires access to offline (and potentially offline-mode) user's usernames from their UUID. It seemed rather silly to setup a database when LuckPerms already keeps that data. When getting the username from LuckPerms, I noticed that the name returned as lowercase. I understand that it's like that for standardisation in the database; however it seems wrong to not have some source for the proper name.
Is there a reason there is not a column for a capitalised name (aside from adding an extra 16 bytes to playerdata entries)? And if not, would a pull request be in order?
Edit: I plan to use the metadata API to save a capitalised name as a temporary measure, however this seems like a relatively important feature to have built in.
So I'm using the api to change user groups is there a way to get these changes to log? Right now they are not logging?
Bukkit.getOfflinePlayer(uuid).getName()?
a) That requires the player to have joined the specific instance, and be in the instance's UUID cache (The application I have does not necessarily have that for every player, plus I'm building for a proxy anyway)
b) If the player was online-mode, we could use the Mojang API; however the latency induced by that is not acceptable in my application (and some users are offline-mode)
whenever they join set a meta called username?
nvm thats what you said
https://github.com/LuckPerms/LuckPerms/issues/2595#issuecomment-688404289 there's your answer
and for another column that seems a bit useless for the 2% that needs it
Hey DMK! Please don't tag helpful/staff members directly.
But im using this method to get all groups user:```
User user = luckPerms.getUserManager().getUser(player);
if (user == null) {
return Optional.empty();
}
Collection<Group> groups = user.getInheritedGroups(luckPerms.getPlayerAdapter(Player.class).getQueryOptions(player));
i want to get groups, when player is offline.
okay thank you
my bad.
Keep in mind that .join() calls will return the user, however they are blocking; so only use them in async threads, or use thenAcceptAsync's callback
Thank you. I will apply thenApplyAsync.
I'm having a weird issue with the LP-api. I'm using it to remove an old rank and add a new one. It seems to remove the old rank but then applies the new one but it does not take effect until I do something /lp user name parent info?
This was working fine in previous versions and we just updated luck perms and the server. Only other change was we changed the server name from global to carrot which has been working just fine.
Hello again, i have small question about this code:
public static CompletableFuture<User> loadUser(UUID uuid) {
return luckPerms.getUserManager().loadUser(uuid);
}
public synchronized static Optional<Group> getHighestGroup(UUID uuid) {
return loadUser(uuid)
.thenApplyAsync(user -> {
Collection<Group> groups = user.getInheritedGroups(user.getQueryOptions());
return groups.stream().max(Comparator.comparingInt(g -> g.getWeight().orElse(0)));
}).join();
}
Is this code efficient?
You're using thenApplyAsync and join; use one or the other
I tried without join but I have no idea how to do it.
I need to get a group collection in this method
public static CompletableFuture<User> loadUser(UUID uuid) {
return luckPerms.getUserManager().loadUser(uuid);
}
public synchronized static Optional<Group> getHighestGroup(UUID uuid) {
User user = loadUser(uuid).join();
Collection<Group> groups = user.getInheritedGroups(user.getQueryOptions());
return groups.stream().max(Comparator.comparingInt(g -> g.getWeight().orElse(0)));
}
I have not tested this, but assuming all the types are correct, this would be more in line with what you are looking for.
Just keep in mind that calling getHighestGroup is blocking, and should only be used on an async thread.
Yes, the only problem is that I am calling it on a non-synchronous thread.
Do you mean the primary bukkit thread?
that's fine
no the main server thread is "sync", async in the MC sphere means any other thread generally
Yes.
And i have a command to control a group from luckperms.
ok so for the reference the main thread is generally the "sync" thread, so everything else is async in relation to it
Is the user online?
Assuming the user is offline to start with and you actually need to load data; a few options:
- Make your own CompletableFuture that you complete when LP's is done
- Call in your command executor: Bukkit.getScheduler().runTaskAsynchronously(()=>{ // the lookup and all execution after })
(Spawning threads is a little costly, so not ideal)
@obsidian forum
- Make your own CompletableFuture that you complete when LP's is done
And I have to do it synchronously? I have no idea how to do it.
That would be not be blocking to the thread; let me draft it up
propably no
CompleteableFutures are by definition async unless you .join() it or similar
Well that's not quite accurate but for this case it is
XY, what's your end goal?
I just want to get the highest user group. The command is made to open the player's head gui, where it shows what the highest group is and how much it expires.
Ok yeah sometimes you can get away with just vault but that'll require the LP api
yeah you can't get expiry
you can get group name / prefix but that's gotta be async since it still needs to do a data load
To get the expiry time I am using this code:
public static synchronized List<InheritanceNode> getTemponaryGroups(UUID uuid) {
return loadUser(uuid)
.thenApplyAsync(user -> user.getNodes(NodeType.INHERITANCE)
.stream()
.filter(Node::hasExpiry)
.filter(node -> !node.hasExpired())
.collect(Collectors.toList()))
.exceptionallyAsync(throwable -> Collections.emptyList())
.join();
}
that being said Vault is much easier to work with
that shouldn't be synchronized, that doesn't do what you think it does
And that will lag the server sincce you're doing a sync load
public static CompletableFuture<Optional<Group>> getHighestGroup(UUID uuid) {
CompletableFuture<Optional<Group>> futureGroup = new CompletableFuture<>();
loadUser(uuid).thenApplyAsync(user -> {
// do whatever with the user
futureGroup.complete(<whatever data you want to pass down>)
});
return futureGroup;
}
have your command logic be like getHighestGroup(uuid).thenApplyAsync(group - > {//do whatever});
once again, not tested; but shouuuld work
again though, shouldn't be synchronized. That will cause issues
yea if you call .join() anywhere from the primary thread you will sync everything up and halt the primary thread until it's done
so, add to the method synchronized?
Honestly don't screw with futures though, just run it all on an async task and .join it, much easier
The one above
no it shouldn't be synchronized
The times you need that keyword is extremely rare
Okay guys. Thank you very much i will try to do this...
good luck lol; I know you're getting a lot of info dumped on you xd
?
basically roughly what you should do is make an async task, inside you can load a user with .join, grab the group off of that like normal, then call another sync task to update the info wherever
Quadratic's method with chaining futures would work too, but it's a bit more complex
either way this ends with .joining on a async task and updating info on a sync task
Modify your group checker to just call .join() the loadUser method you made, do your checking, and return the straight data (Optional<Group> or whatever you want to pass down)
In your command handler: Bukkit.getScheduler().runTaskAsynchronously(()=>{ just call your getgroup method })
The other method I gave you was the optimal way to do it, as it prevents spawning new threads, (which is a little costly to the main thread); but since you're only doing it every time a command is run, it's not anything to worry about
No, I just don't know what to do next. Are you kidding me for what it is wtf
Where are you stuck
I think we dumped too much info on him lol
also think it needs mentioning, if you're trying to use the LP API with limited java experience, this will be a difficult process, the LP API assumes you have knowledge of futures and such
For your information, I wouldn't come if I knew what to do right.
I only asked if I was doing it well and if it would not cause lag on the server.
@wild whale thank you for your help. I'm not doing anything serious, I just want to do for myself to learn java.
Yeah all good, you're not the first person in this situation, and you won't be the last.
hello, why don't you find the dependency of lp?
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.4</version>
<scope>provided</scope>
</dependency>
i have an error on groupID, artifactId and versions
I've had a bunch of issues with jitpack.io today, are you attempting to use that repo?
Luckperms should be avalible through central, however you can also try paper's public repo:
Put this at the top of the <repositories> section:
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
so
<repository>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.4</version>
<scope>provided</scope>
</repository>
no
that needs to stay dependency
i do that
try refreshing maven
thanks bro
Error occurred while enabling ParadiseMC v1.0-SNAPSHOT (Is it up to date?)
java.lang.NoClassDefFoundError: net/luckperms/api/LuckPerms
Player subber = Bukkit.getPlayer(args[0]);
User user = LuckPermsProvider.get().getPlayerAdapter(Player.class).getUser(subber);
user.setPrimaryGroup("sub");
why is the error?
!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.
thanks
anyone know is Vault able to attach permissions to user through LuckPerms?
anyone know why it says the dependency isnt found in my pom.xml. other dependencies for plugins are working fine
refresh maven
Can you elaborate more?
Not actual, already fixed all my problems
hi
if (inheritedGroups.equals("helper")) {
globalFormat = Util.translateHexColorCodes(Config.CHAT_FORMAT_HELPER);
}
will this method work?
or so?
if (inheritedGroups.stream().anyMatch(g -> g.getName().equals("helper"))) {
2nd
Use filter
ta
does anyone know how to grant a player permissions within code (idea) in luckperms version 5.4
ty
how is .getGroup() defined? if i just put ,getGroup("name") then it returns null
Show the code you're using
public static void addPermission(UUID uuid) {
// Add the permission
// Load, modify & save the user in LuckPerms.
LuckPermsProvider.get().getUserManager().modifyUser(uuid, (User user) -> {
Group group = LuckPermsProvider.get().getGroupManager().getGroup("spawntag");
// Try to add the node to the user.
user.data().clear(NodeType.INHERITANCE::matches);
// Create a node to add to the player.
Node node = InheritanceNode.builder(group).build();
// Add the node to the user.
user.data().add(node);
// Tell the sender.
Bukkit.getPlayer(uuid).sendMessage(ChatColor.RED + user.getUsername() + " is now in group " + group.getDisplayName());
});
}
its copy pasted from github
and spawntag is my group for people who are tagged in spawn, obviously lol
oh and dont mind the add permission i forgot to change that lol
Don't copy paste code unless you know what it does
Group group = LuckPermsProvider.get().getGroupManager().getGroup("spawntag") It just simply getting the Group spawntag from the group manager and storing it in group
i get the node to add it to the player so hes in no?
it adds me to the group, what doesnt work tho is the nametagedit prefix somehow
i had to reload nametagedit to make it work somehow
i think nametagedit is the problem
i just removed me out of the group and my name still has the prefix
Hello, guys. How can i sort my list of players? Example: i have a list: ADMIN TEST, DEFAULT LOL, EMERALD MEGA, DEFAULT ROFL
I want: ADMIN: test
DEFAULT: lol, rofl
EMERALD: mega
dont cross post
๐ Hello, does anybody know how to add LuckPerms in a Forge development environment using gradle? The wiki says to use compileOnly but Forge does not load the mod. If I use CurseMaven to get the file directly, I get a NoSuchMethodError
Log:
https://paste.gg/p/anonymous/6f3d7d96c19b4205a4907aac7b05a54b
java.lang.NoSuchMethodError: 'com.mojang.brigadier.builder.LiteralArgumentBuilder net.minecraft.commands.Commands.m_82127_(java.lang.String)'
at me.lucko.luckperms.forge.ForgeCommandExecutor.onRegisterCommands(ForgeCommandExecutor.java:59)
It looks like some part of the mod is using SRG names even though I use implementation fg.deobf
(please ping me if you have any ideas)
This is my build.gradle: https://paste.gg/p/anonymous/f56a9b1af7204375af063eeafc2d55a3
you shouldn't depend on the internals, use the api?
If I use the API, Forge does not detect the mod and fails to load it
which results in API NotLoadedException
also, I'm not calling internal methods anywhere, the error above happens during mod construction
did you add luckperms as a dependancy?
Yes, using the gradle posted above. Also added in mods.toml as a required mod
Hi, I am making a plugin to ban other players. I would like the admin to not be able to ban other people with a given permissions. I have a problem with getting the permissions of an offline player using LP, how to do it? Thanks in advance for your help!
is my code so far: User user = LuckPermsProvider.get().getUserManager().getUser(args[0]); -> args[0]: player name
java.lang.NullPointerException: Cannot invoke "net.luckperms.api.model.user.User.getCachedData()" because "user" is null
Learn how to use the LuckPerms API in your project.
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
i need help pls
i gaved my group rank
work perfectly
work perfectly in chat
but it dont work in tab
and i also have /gts command
and i tried everything to make it work
but still the rank still cant do /gts
only work for op
oh ok
Why it is alwyays false?
public static boolean hasPermission(OfflinePlayer p, String permission) {
final boolean[] bool = {Boolean.FALSE};
CompletableFuture<User> userLoadTask = LuckPermsProvider.get().getUserManager().loadUser(p.getUniqueId());
userLoadTask.thenAccept((User user) -> {
CachedPermissionData permissionData = user.getCachedData().getPermissionData();
if (permissionData.checkPermission(permission).asBoolean()) {
new BukkitRunnable() {
@Override
public void run() {
bool[0] = true;
}
}.runTask(ServerPlugin.getInstance());
return;
}
});
return bool[0];
}
return a CompletableFuture
You declare your bool as final and initialize it with False. Therefore it will always return false at the end
Also, why would you create a temp bool array of 1?
because the regular boll didn't work and an error was popping up
something like that?
public static CompletableFuture<User> hasPermission(OfflinePlayer p, String permission) {
final boolean[] bool = {Boolean.FALSE};
CompletableFuture<User> userLoadTask = LuckPermsProvider.get().getUserManager().loadUser(p.getUniqueId());
userLoadTask.thenAccept((User user) -> {
CachedPermissionData permissionData = user.getCachedData().getPermissionData();
if (permissionData.checkPermission(permission).asBoolean()) {
new BukkitRunnable() {
@Override
public void run() {
bool[0] = true;
}
}.runTask(ServerPlugin.getInstance());
return;
}
});
return userLoadTask;
}
omitting the boolean in the middle
no
Boolean competeanlefutire
can you send me snippet of code, I have no idea how to do it

do anyone know how to remove perms from a player
User u = api.getUserManager().getUser(<uuid>);
for(Node n:u.getNodes()){
if(!n.getKey().equals("your.permission")) continue;
u.data().remove(n);
}
api.getUserManager().saveUser(u);
Not tested, but should work; replace "<uuid>" with the player UUID
Thanks
Will this return true if the user is in any of the groups passed to the method by name?
/**
* Queries the LuckPerms group (including inherited groups) of the given player.
* @param player the player ID
* @param groups one or more groups
* @return true if the player is in any of the given groups
*/
public static boolean hasAnyGroup(final UUID player, final String... groups) {
// query API
LuckPerms api = LuckPermsProvider.get();
// query user
User user = api.getUserManager().getUser(player);
// validate user
if(null == user) {
LOGGER.error("[LuckPermsHandler#hasAnyGroup] Failed to load API for unknown user '" + player + "' ");
return false;
}
// query primary group
final String primaryGroup = user.getPrimaryGroup();
// query inherited groups
final List<String> inheritedGroups = user.getInheritedGroups(QueryOptions.builder(QueryMode.NON_CONTEXTUAL).build())
.stream().map(Group::getName).toList();
// check each group to see if the user belongs to that group
for(String g : groups) {
// check primary group
if(g.equals(primaryGroup)) {
return true;
}
// check inherited groups
if(inheritedGroups.contains(g)) {
return true;
}
}
// no checks passed
return false;
}
I can't test in my IDE bc I'm using the Forge version and it won't import correctly (see my earlier post) so I need somebody to sanity check for me please ๐
it should
hello, can you help me how to show prefix in chat. I have set the prefix, I don't see the rank
Hi! I use LuckPerms Api in my backend and have a question about players UUIDs.
My case: user registers in my backend, then i wanna create player within luckperms-api to support group changing and etc. But i don't know user's uuid before they connected to the minecraft-server and it retreives in luckperms' player table in db. How i can fix this?
If i create user with generated UUID, add some perms to it, but after connect to minecraft server - they UUID will rewrite to mojang UUID
you can use the mojang api to get the uuid for a given username
@jaunty pecan so, sounds cool, but if i set online-mode to false - uuid will generates once only on my minecraft server?
Hey fania! Please don't tag helpful/staff members directly.
don't set online-mode false then :]
Thank you so much, will dive deep, i plan to use custom minecraft-server auth, will ask their devs how retreive UUID, good day!
isn't there a config setting for this? use-server-uuid-cache = false
# - When this is set to 'false', commands using a player's username will not work unless the player
# has joined since LuckPerms was first installed.
# - To get around this, you can use a player's uuid directly in the command, or enable this option.
Chances are I'm being a dumbass and missing it on the wiki, but how do I get my plugins permission nodes to show up as suggestions for the commands and in the web gui?
The suggestions will only show if the permissions are registered correctly and they have been checked since last restart
A permission check needs to be made for LP to recognize it
Registered correctly as in permissions.yml or...?
In your plugins plugin.yml
I'll need to Google how then, ty for telling me what file atleast, and then for the check, would it work if I did it on an empty player object?
Honestly, it doesn't matter if it shows in the suggestion list or not. you can still manually type the permission in and it will work
Ik, im trying to make it populate to make it eaiser to know it exists and its exact spelling and everything
Regardless ty
doesnt even need to be in the plugin.yml
Hello. I have this warning, how can i remove him?
EventSubscription<NodeAddEvent>' used without 'try'-with-resources statement```
eventBus.subscribe(this.corePlugin, NodeAddEvent.class, this::onNodeAdd);
should be to just ignore it
Hi there, is there an API version of this?
Setting temporary permissions with API for a time, and setting it to prolong, so if the player purchase the VIP twice, it will just get prolonged
Yes, check the various NodeBuilder::expiry methods, and the add method in NodeMap that takes a node merge strategy
how to get the prefix of the group in which the player is located?
thx
this is corectly?
(sorry for my eng)
how to corectly use ?
should be yes
use this instance
or LuckPermsProvider.get
Im tring to check if a user has a permission but it gives me a error
here is the code
User user = luckPerms.getUserManager().getUser(playerUUID);
return user.getCachedData().getPermissionData().checkPermission(permission).asBoolean();
}```
```if (CompanyCore.getInstance().hasPermission(player.getUniqueId(), "group." + args[0] + "-vicedirettore")) {```
Here is the error
Please use https://pastes.dev to send files in the future. I have automatically uploaded message.txt for you: https://pastes.dev/vBI23toGrD
is the player online
Yes it is
why not just use hasPermission() on the player directly?
load the user
Hi, can I change player's display name (which showing above their head) using Luckperms API?
Nope. LP isn't responsible for anything relating to display, that's entirely the responsibility of other plugins. All LP does is provide the prefix/suffix for users
Okay, thanks for information
If you have source for whatever nametag plugin you are using, you can modify it to integrate with the LuckPerms API and use LuckPerms' meta tag system to store info like that; however all the display stuff would be done outside of LP
I tried HaoNick, NickNamer, NickAPI, NameTagEdit plugins but any of them is not working. Have you a plugin recommend for this(version 1.8.8)?
You would need to modify the source of which ever one you chose to use. I used to use NameTagEdit back in the 1.8 days, however I ended up designing a custom nametag system for 1.16+
NameTagEdit requires using the config file for configuring each potential prefix and suffix, and does not support changing the player's name. You would not be able to do what you are trying to do.
HaoNick has worked in the past for me if the goal is to /nick a player; maybe play a bit more with that.
I use TAB as a plug and play formatter for tab and nametags, configs powerful enough and with papi support you can do just about anything within the vanilla limitations
I wanna give a fake name and a rank to the player for a limited time. So I need eternal API. NametagEdit API is (I guess) shut downed and I guess TAB don't have an API.
I don't think it has an API but it has PlaceholderAPI support which can easily do those
(don't even need anything custom for display for a temporary group, LP supports temp groups so can easily just do that with the LP api)
What does do DisplayNameNode
sets the display name for a group (allows users to override a group name in commands and what other plugins see through vault etc while keeping the group name the same internally)
That's stupid question but how I can create and give to player for that process (wtih LP API)
LuckPerms API is not going to help you unless your nametag plugin pulls from Vault or Luckperms' API to load prefixes & suffixes already.
LuckPerms is a permissions plugin that supports STORING player "meta", which includes prefixes, suffixes, and custom data; not displaying nametags.
Whatever plugin you use that handles displaying nametags has a source for data, some plugins have config files, some of those support PlaceholderAPI (PAPI has placeholders for prefix and suffix); some plugins have APIs that you could access from your own plugin.
Potential ways to use LuckPerms as a data source for prefixes:
A) Find a nametag plugin that already supports pulling from LuckPerms
B) Find a nametag plugin that supports Vault prefixes
C) Modify a nametag plugin that already exists, redesign the data loading portion to use LP's metadata API to load prefixes and suffixes.
In my experience, I have not found a working plugin that already has LP integration. I ended up designing my own nametag system that supports loading from LuckPerms.
TL;DR: Your best route would be to find some nametag plugin that already works without LP integration, and then modify it to integrate.
@plush narwhal
Best solve is make new nametag system working with LP, thanks for information :) 
Not necessarily, as I outlined, it should not be too complex to modify an existing plugin
How does LuckPerms handle SQL on Velocity without shading the MySQL driver?
i think luckperms remaps all of its dependancies to prevent conflicts
hey, guys. I have mongoDb in lp. If i get prefix of offline user i get him?
How can I get offline player prefix via luckperms api. I have a database.
how I can get weight player?
LuckPerms#getUserManager().loadUser(<UUID>).join().getCachedData().getMetaData().getPrefix()
Note that .join() is blocking, do not use on the primary thread
!api
Learn how to use the LuckPerms API in your project.
what does that have to do with the luckperms api?
but its probably something to do with doing it from a different thread
probably has something to do with it saying api in the code. just a wild guess
just because someone is using the luckperms api does not mean every issue they have is caused by luckperms
wherever you would ask questions about the bukkit api
I provided the API because the question he asked is super basic and covered in the API usage docs
i was responding to someone who has deleted their messages for whatever reason
ah
Hey, I use following code but it returns "null"
UserManager userManager = luckPerms.getUserManager();
nameColor = userManager.loadUser(uuid).join().getCachedData().getMetaData().getMetaValue("nameColor");```
What have I to change that it is working?
Hello everyone, can anyone tell me which event should i listen for to know when a user gets / lose a permission group?
(if there is one)
Check if user is loaded
User user = userManager.getUser(uuid);
if (user != null) {
//Do something
} else {
User u = userManager.loadUser(uuid).join();
//Do something
}
use NodeAddEvent and NodeRemoveEvent
Hi I can use Common as API?
I want testing a few things and maybe use it in my plugin
that doesn't answer what common does that you can't do with API though
I want check how working field "weight" from class MetaCache
You can get weight from the API
hmm how?
!api
Learn how to use the LuckPerms API in your project.
I know I can get weight from group but I think how read weight from user?
it is 50% true 50% false
I know that this is not what this system is for, but I think to base the rank hierarchy on it
better than typing all the group names by hand in my opinion
No, users never have weights.
I tested it java for (Node node : user.getNodes()) { if (node instanceof WeightNode weightNode) { if (weightNode.getValue()) { weight = Math.max(weight, weightNode.getWeight()); } } return Math.max(weight, luckPerms.getGroupManager().getGroup(user.getPrimaryGroup()).getWeight().orElse(-1)); } but I thinking better use one method for it
A User can have a WeightNode (it's just another Node in a PermissionHolder), but it does not do or affect anything in regards to permission calculation
If you want just a number for a user and you're hard depending on LP api anyways, use meta. It's basically a key:value store in nodes, so inheritance etc is respected
interesting idea but key:value must be safe to permission I can't do it to group or user?
It's stored as normal nodes, (meta.KEY.VALUE)
I just know more wondering if it is set value and if I could use this value to create a user hierarchy ๐ค
Luckperms gets them from the plugin that creates those permissions
The reason I'm asking is because I want to know if I can add my own there
That is also just the suggestion list, which is filled in when permission checks are made.
It looks like it shows up there once a permission is accessed
Yeah ^
Is it cached?
Or would it clear every restart
Every restart
But if permissions don't show in that list you can still manually type them in.
True, but it's easier when they are in that list. Especially if I'm going to be making a bunch of stuff and then adding permissions later on
So the only way to programmatically add a suggestion to that list is to call hasPermission?
Yes, permissions will only go into the suggestions list when a permission check is made.
I don't think you can manually add them to the suggestions list with the API. That would be a question for @proud crypt . But I'm pretty sure you cant.
just do a permission check onEnable
That is not working
!nw
We really would absolutely love to help you out! However, telling us that it isn't working wastes everyone's time. Please, just describe the issue you're having clearly and with as much detail as possible, and send any relevant screenshots of whatever problems you're having.
If I use the following code it returns "null"
User user = luckPerms.getUserManager().getUser(uuid);
if (user != null) {
nameColor = user.getCachedData().getMetaData().getMetaValue("nameColor");
} else {
User user1 = luckPerms.getUserManager().loadUser(uuid).join();
nameColor = user1.getCachedData().getMetaData().getMetaValue("nameColor");
}```
it is a String default value "Error"
you're checking for "nameColor" and "namecolor" is set
Lower/Upper case is a problem?
nah
thats not the problem
For only players it is working
now screenshot /lp user Lion_King287 meta info
start debugging, print stuff to console etc
Hi how I can get all online users from Group
I want read all users what permission change in NodeMutateEvent
I need do it ```java
luckPerms.getUserManager().getLoadedUsers().stream().filter(user -> {
Collection<Group> groups = user.getInheritedGroups(QueryOptions.builder(QueryMode.CONTEXTUAL).build());
});``` or exists method for it?
Hey HEROOSTECH! Please don't tag helpful/staff members directly.
no need to ping when i'm already talking to you
you should check what works the best w/ minestom and not just copy it
ยฏ_(ใ)_/ยฏ
should probably look into it more before your pr lol
Can you tell me why issuing groups does not work?
theres an pr for minestom already i think
hey guys, if i add a group my plugin cant recognize it... how can i force update the group list?
LuckPerms luckPerms = LuckPermsProvider.get();
luckPerms.getGroupManager().getLoadedGroups()
nevermind
its my bad
Anyone know how I could get user specific permissions? Like I found how to access the CachedPermissionData. But I don't want it to return every permission node from every group they have. I'm only trying to get user specific permissions
if you're interested in considering active contexts, temporary permissions etc I believe there's a getCachedData/getPermissionData that takes a QueryOptions, you'd build one with the Flag.RESOLVE_INHERITANCE disabled
https://javadoc.io/static/net.luckperms/api/5.4/net/luckperms/api/query/QueryOptions.Builder.html#flag(net.luckperms.api.query.Flag,boolean)
Got it, thx
ร
ร
why is this basically the only thing youve sent in this server?
hi
I am trying to give perms and kits in prison ranks x... although the groups have the items allowed, and the ladders are built, and all seems to function correctly, I still cant access the kits that lp allows per group. What am I doing wrong, been stuck on this for days
Use #support-1 or #support-2 for this in the future, this channel is for questions about the API. From what I can see from the screenshots you have given a wrong permission to the group
Change essentials.kits.agate to essentials.kits.jade (which is the kit you are trying to give)
ร
Do it
ร?
Hey LEN! Please don't tag helpful/staff members directly.
how to get the settemp by the api
intellij is giving me a warning here, but it doesnt say how to fix it.. what do i do to fix it?
You can ignore this warning.
ok
Is there any sort of guides for how to use the LuckPerms API in node.js?
you cannot use the LuckPerms API with node as it is literally part of the plugin/mod jar file. the REST api that you could interact with from node works just like any other REST api and should be documented somewhere
Thank you, I was referring to the REST API but I should have specified it.
Learn how to use LuckPerms and all of its features by reading the wiki.
I already looked there and couldn't find any node.js info but I guess -
sometimes i feel stupid lol
like i said, it works like any other rest api
im not familar with rest apis yet so i'll go check that out, thanks :))
there is almost certainly plenty of info out there about using rest apis with nodejs
yep
it wasn't that what i was looking for was undocumented, i was looking for the wrong information
have a look at https://codingjwilliams.gitlab.io/luckperms-rest/ :)
Documentation for luckperms-rest - v1.0.11

Thank you, I did see that I just didn't know where the API Key/url came from
there's probably something im missing that i didnt realize
what url do I use?
yes i just love that package, it's very well documented /s
either that or im too stupid to understand
The url is wherever you have the web server with the REST API hosted in
The API key is whatever you set in LUCKPERMS_REST_AUTH_KEYS for the REST API to accept
Might want to take a look at the readme of the rest-api repo to take a look at how it's configured https://github.com/LuckPerms/rest-api
Hey Guys, How Can I change the parent groups with luckperm api?
Ex:) Rank UP Just only default without guide
I need help, so I made the settings and then I hit apply, after that I reloaded the plugins and then I tested to see if it works (whitout op) and it worked, after I exited and entered, it didn't work any more the command I set
What command?
Can't find vault online can someone please send vault\
Send me which group you put the perms into
Open default group once
and?
And check if the commands you are trying to use are set to true if it is not there or set to false, it won't be working.
If it's not there just select the permission in and set it to true
all its true
Go to users and check if it's disabled only for you
no ,same its true
Hm, strange
it works until I rejoin the server
@south kayak what its Bungeecord?
It's a plugin used to connect multiple servers like by pixel by pixel bedwars server and skywars, they are different servers and are connected through plugins like bungeecord.
ohh
in the future, please use #support-1 or #support-2 for normal problems. adding permissions in the editor has nothing to do with using the api
how do i get the expiry time of a userโs rank
so im trying to add a prefix node to a player however, if i open the web editor instantly after it doesnt appear to save and it removes it from them
it doesnt clear for everyone just some users
sorry me confused
what goes in the ....
wait but that says to other servers... this is one server
and furthermore its only for some players.
so tried this... and same result
ah. so is there a limit to a prefix?
so there never was an issue with saving, it was saving with a long permission node
h2 has a limit iirc?
The database schema definitely has a max node length, yeah
200 characters comes to mind, but not sure
How can i get a player groups?
!api
Learn how to use the LuckPerms API in your project.
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Can somebody tell me how to fix this.
org.bukkit.plugin.InvalidPluginException: java.lang.ExceptionInInitializerError
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:149) ~[server.jar:3284a-Spigot-3892929-0ab8487]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:394) ~[server.jar:3284a-Spigot-3892929-0ab8487]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:301) ~[server.jar:3284a-Spigot-3892929-0ab8487]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:409) ~[server.jar:3284a-Spigot-3892929-0ab8487]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:233) ~[server.jar:3284a-Spigot-3892929-0ab8487]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1010) ~[server.jar:3284a-Spigot-3892929-0ab8487]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[server.jar:3284a-Spigot-3892929-0ab8487]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:467) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:67) ~[server.jar:3284a-Spigot-3892929-0ab8487]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:145) ~[server.jar:3284a-Spigot-3892929-0ab8487]
... 7 more
Caused by: net.luckperms.api.LuckPermsProvider$NotLoadedException: The LuckPerms API isn't loaded yet!
This could be because:
a) the LuckPerms plugin is not installed or it failed to enable
b) the plugin in the stacktrace does not declare a dependency on LuckPerms
c) the plugin in the stacktrace is retrieving the API before the plugin 'enable' phase
(call the #get method in onEnable, not the constructor!)
at net.luckperms.api.LuckPermsProvider.get(LuckPermsProvider.java:53) ~[?:?]
at com.foxdev.ranks.Ranks.<clinit>(Ranks.java:10) ~[?:?]
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:467) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:67) ~[server.jar:3284a-Spigot-3892929-0ab8487]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:145) ~[server.jar:3284a-Spigot-3892929-0ab8487]
... 7 more```
did you read it
!paste Ranks.java
Seeing a paste of the problem makes everything so much easier! Use https://pastes.dev/ 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!
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
User user = (User) api.getUserManager();
dont do that
How should i do it?
?
Hello,
How can I retrieve the highest group on a specifique track for a player ?
Thank you very much ๐
For the moment this is my code:
LuckPerms luckPerms = LuckPermsProvider.get();
Set<String> groups = Collections.singleton(luckPerms.getPlayerAdapter(Player.class).getUser(player).getNodes(NodeType.INHERITANCE).stream()
.map(InheritanceNode::getGroupName)
.map(n -> luckPerms.getGroupManager().getGroup(n))
.filter(Objects::nonNull)
.max(Comparator.comparingInt(g -> g.getWeight().orElse(0)))
.map(Group::getName)
.orElse(""));
I only get the highest rank
But I want the highest rank of a specific track, thank you very much ๐
filter it being on that track?
i'm the dude earlier making the forge chat mod, pretty much done but can't get the luckyperms API to work, clientside has no problems but the server crashes with the following stack trace: java.lang.NoSuchMethodError: 'com.mojang.brigadier.builder.LiteralArgumentBuilder net.minecraft.commands.Commands.m_82127_(java.lang.String)' at me.lucko.luckperms.forge.ForgeCommandExecutor.onRegisterCommands(ForgeCommandExecutor.java:59) at MC-BOOTSTRAP/eventbus@5.0.7/net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:247) at MC-BOOTSTRAP/eventbus@5.0.7/net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:239) at MC-BOOTSTRAP/eventbus@5.0.7/net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) at MC-BOOTSTRAP/eventbus@5.0.7/net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ...
Hey tim! Please don't tag helpful/staff members directly.
sorry for tagging, any idea what mightr be causing this though?
my code just uses the singleton API below: ```java
private void loadComplete(final FMLLoadCompleteEvent e) {
// Register server chat event
//MinecraftForge.EVENT_BUS.register(chatEvent);
LOGGER.info("LuckPermsChat - Mod is loaded (c) Name 2022 - 2023!");
// Load luckperms
LOGGER.info("LuckPermsChat - Attempting to load LuckPerms API!");
boolean failed = true;
try {
LuckPerms perms = null;
perms = LuckPermsProvider.get();
if(perms != null) {
//chatEvent.setLuckyPerms(perms);
failed = false;
}
} catch(Exception e2) { }
//
LOGGER.info("LuckPermsChat - " + (failed ? "LuckPerms API not found, is LuckPerms installed?" : "LuckPerms API found!"));
if(failed) LOGGER.warn("LuckPermsChat warning - LuckPerms API wasn't found, mod won't use it!");
}
"LuckPermsChat" 
if you use luckperms in the name, please make it very clear that its not officially affiliated with luckperms
will do
any ideas what may be causing my issue? here are some thing's i've tried: ```
- Using gradle dependencies for version 5.4
- Manually including API JAR file "api-5.4.jar" into build path
- Manually including entire mod (version 5.4.26) into build path
- Including mod in both mods folder and build path
- Including mod in mods folder, with gradle dependencies
- Including mod in mods folder, with API in build path
...
the name doesn't matter its for a server I'm hosting for some friends, if I put it on curseforge or anything it will be under a completely different name probably like "ForgeColoredChatUtils" and it will say that is is "LuckPerms" compatiable in the description
the chat formatting and everything works perfectly but the goal is to the the prefix and suffixes from user metadata and include them in the chat formatting - this will be the only way to do this on modded 1.18.2 packs since there are no luckperms compatible mods for 1.18.2 (and SpongeForge doesn't exist for MC 1.18.2 either)
Can somebody tell me whats wrong?
the API isn't loaded yet.
Make sure the provider is actually set, you're reaching before its loaded
How to load it ๐
// Set up LuckPerms
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) luckPerms = provider.getProvider();
Seeing a paste of the problem makes everything so much easier! Use https://pastes.dev/ 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!
First time i touch the luckperms api ๐
Currently, this is my setup and it works fine https://pastes.dev/ihfkn64kUS
Maybe you have to actually initialize it in the onEnable?
No problem!
How to set someone in a group?
@solid sable Do you mind if i tag you everytime or dont you want that?
You can set the primary group with getUserManager().getUser(name).setPrimaryGroup(groupName) or add a node to the user
I'm also new to the API so just ask here without tag, and if I have time i'll respond ๐
Ey if you need something (Dont ask for money) I fix it ๐
Hmm few hundered bucks? Jk
Make sure your LuckPerms is already initialized when you pass it through, or maybe even better, get it directly from your main class at execution
Its says this
Could not pass event PlayerInteractEvent to Ranks v1.0-
org.bukkit.event.EventException: null
Caused by: java.lang.NullPointerException: Cannot invoke "net.luckperms.api.LuckPerms.getUserManager()" because "this.luckPerms" is null
๐
It might be because you pass through the LuckPerms instance within your onEnable
No sorry I can't rn, however try reaching LuckPerms like I did in the Something class
Yeah but it doesnt succeed to set the player on that group.
does it give any output/errors?
Yes I do
I send you something in dm.
Cached Data:
You can use user.getCachedData().getPermissionData() to get a users permission data
Nodes:
You can use user.getNodes(NodeType.PERMISSION) to get all permissions
You can use user.getNodes(NodeType.INHERITANCE) to get all groups
Does anyone know how to download PlaceholderAPI from luckperms on mohist? /papi dont works.
Are luckperms load methods built-in async? Talking about the Spigot one, just wanna make sure everything related to the database runs async.
API calls are not, but internal luckperms handling is
Most API calls that would be blocking will return a CompleteableFuture, .join() is blocking
So do I have to do it myself? I don't use CompletableFuture#join at all. I'm fine with consumers
Also, sorry for the mention, didn't mean to bother you
If you use #thenAcceptAsync callbacks then you will be fine
examples from the docs
!api
Learn how to use the LuckPerms API in your project.
what I'm asking is do LuckPerms's API lookups use async loading process as it is in the commands? For example, I'm using UserManager#lookupUuid, does it work async?
I'm not looking for this, I know what CompletableFuture#join does, I just want to make sure the API's functions run async, and if not, why are they using CompletableFuture at all? doesn't make sense
when you make the API call, nothing has been done
Are you familiar with futures and promises?
nothing will happen unless you either
A) Join onto the thread you are on
B) Request a callback
Yes a little bit
I'm using option B
Then it will be non blocking
and will it be async? (THE LOADING PROCESS)
yes
alright thanks
Things that return a CompletableFuture run on another thread
Because.. it runs on another thread?
They have to- otherwise it WOULD be blocking
(Sorry for the mention)
it was a joke, nvm


๐คฏ
incorrect unfortunately ๐
old classpath 
!api
Learn how to use the LuckPerms API in your project.
the AI is only trained up to 2021 sadly
okay, i try it
very good, i save this link, thanks
If I am trying to retrieve the prefixes but I want prefixes from two different tracks (main and staff) how do I get both?
Display multiple prefixes/suffixes alongside a player's name.
why does this happen?
getrank: https://hastebin.com/anoyadajos.kotlin
chat: https://hastebin.com/soqovilido.csharp
even so happens on the discord
(i had the same result with getPrimaryGroup)
mmmm i love toolbar that cant be hidden and covers content (hastebin sucks on mobile)
your iterating over the users group nodes to try to get the prefix, instead of just getting the prefix of the user (which will inherit from groups)?
trying to get the primary group name like "default", "admin" which will then have a Map<String, String> where the value is the prefix
i refuse to do it over lp
why...?
luckperms has prefixes and suffixes for a reason. you should consider using it
Well yeah, but the main issue is still that getting the primary group is wrong
you probably shouldnt rely on the primary group as it doesnt really mean anything
so you mean top inherited group?
the "primary" group is pretty arbitrary. it has no impact on permission or meta calculation. you should just set your prefixes in luckperms and use the luckperms api to get them, and luckperms will handle all of that for you
no need to reinvent the wheel here
okay, thank you
o/ I'm having problems obtaining an instance of the luckperms api, not really sure what I'm doing wrong. Following the instructions on the wiki to a T but it still doesn't work. Any idea what I'm doing wrong?
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
this.luckPerms = provider.getProvider();
} else {
this.plugin.getLogger().severe(() -> "Could not obtain LuckPerms instance. Plugin will not work properly.");
}
My plugin.yml includes a depend:
depend:
- LuckPerms
Did you add it as a dependency in your build file
Yeah
Show
dependencies {
compileOnly 'io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT'
api 'net.luckperms:api:5.4'
api 'org.spongepowered:configurate-core:4.1.2'
api 'org.spongepowered:configurate-yaml:4.1.2'
implementation 'com.github.sarhatabaot:KrakenCore:1.6.3'
implementation 'co.aikar:acf-paper:0.5.1-SNAPSHOT'
}
Should I have it set to compileOnly instead of api?
Is there any errors?
Yes, Luckperms needs to be compileOnly
whoops. thanks!
hi guys, does anybody know if its possible to get the Permissions of an Offline Player?
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
!api
Learn how to use the LuckPerms API in your project.
so i loaded the user, but i cant really figure out how to get the Permissions
Ah nvm i got it
im trying to use the searchAll method in the UserManager to search for all the players with a permission. Can someone assist me? I can't figure out how to get the node matcher to work and the documentation is confusing
*confusing to me
this is what I have right now
or maybe the code is working actually but I'm trying to get all the players who have this permission even if the permission comes from a group and is not directly attached to their player
after more testing/searching I have this which does return all the palyers with a permission but not the players that indirectly have the permission from being a part of a group
that's the expected behaviour
you can do getGroupManager().searchAll(..) and handle the inheritance yourself
can i create a group with this method?
that represents a permission node
you cannot convert node -> group
you could make a group separately, and then apply that existing node
i still don't understand the documentation
the documentation makes no sense to me... does anyone have an example just to check if player has a certain permission?
If you just need a true/false, your platform most likely has an easier way than hooking into the LP api
how do i create a group with LuckPerms API? i can't find it in the documentation
okay, i'll never finish my plugin
ok
https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/model/group/GroupManager.html javadocs help here, see the createAndLoadGroup method
a whole 9 minutes, and thatโs the conclusion you came to.
that's a mood
How can I add a permission to a user with the API?
!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.
Hey everyone - struggling a little with getting Contexts:
Our server provides rank vouchers which allows people who can't donate to obtain ranks for the server. We've recently opened up a closed beta to a new server that we want all Donators to take part in, including those people who've used vouchers. We've set up the context server=survival on the group.vip permission node for these players.
User user = api.getPlayerAdapter(Player.class).getUser(player);
Set<String> permissions = user.getNodes(NodeType.PERMISSION).stream().map(PermissionNode::getPermission).collect(Collectors.toSet());```
The above code grabs all permissions assigned to a user only without any contexts. How do I include permissions on a user with context?
It's to check if they have the group.vip node to allow them into the closed beta server
group.<name> nodes are still treated like normal nodes that you can check a Boolean value using the normal platform methods afaik, any reason you need LP api to check this? If not, just letting LP deal with all that is probably easier
I tried that initially, but with our setup, using player#hasPermission("group.vip") for players who've used vouchers doesn't work. the VIP only gets applied to the Survival server via context=survival, so the closed beta server isn't picking up on the fact that they are VIP
...ah. I see
I output permissions to console and it only returned permissions without a given Context, which is why I'm asking how I grab permissions that included contexts, as well
if memory serves by default it only returns nodes that satisfy the default empty contextset, there should be an overload that takes a contextset iirc
You can use this method and build a QueryOptions with the context set you want https://javadoc.io/static/net.luckperms/api/5.4/net/luckperms/api/model/PermissionHolder.html#getInheritedGroups(net.luckperms.api.query.QueryOptions)
Okay, thanks guys, I'll have a play around
I figured out a way to do it, but it's pretty hacky. It works for the time being and isn't on a particularly large server, so it shouldn't be ran often, and will be removed in time for the public launch. Thanks for the pointers! (I will sit down to properly learn the API at one stage, just needed something fast)
Question Regarding My HubCore, We have VIP Ranks in our lobby servers. After reading the context initiative in the api documentation I'm just slightly confused. I may have also missed something.
So it there a way to justify a players group based on the server they are on?
Meaning is there a way api wise for me to get a players grounp in the context of "hub-1"
In lamens terms, how do I make it so if a player has {x} rank on this server they get {y} rank on this server.
if you just want to know about a permission or group on the current server, you can just use your platforms normal permission check method
if you need to check it for a different server, read the conversation above
When I remove a user a permission and then check if he has the permission with player.hasPermission() it doesn't update, and the user still has the permission(tried reloading and rejoining)
Node
Idk if this is what your going for, but here
public static boolean hasSpecificPermission(String name, User user, Context context) {
boolean foundperm = false;
for (Node node : user.getNodes(NodeType.PERMISSION)) {
if (!node.getContexts().contains(context)) continue;
if (node.getKey().equalsIgnoreCase(name) && node.getValue()) {
foundvip = true;
}
}
return foundperm;
}```
keep in mind NodeType PERMISSION is for the players "other permissions" meaning the ones you specify for them. The ones they get from groups will NOT be ran in this method.
I was checking for #getPrimaryGroup and it was returning null, I was silly to assume that it was returning the group for that specific server.
So i just checked for a perm under context server, hub
Nonetheless, I appreciate the quick response
Yea I am now
I didn't know that it was referencing the group of the "global" context
is it possible to assign RGB prefixes/suffixes through the api with Components?
prefixes/suffixes are raw strings
its up to the plugin that displays them to format them
off-topic to luckperms but will CompletableFuture's whenComplete be completed in the same async task that the CompletableFuture got completed in?
or will it be completed in the main thread somehow?
Yes me2, just want to make sure, logically I imagined it will run in the same async thread, I hope LuckPerms doesn't complete the CompletableFuture using the main thread by going back to it before using the #complete method, because I want to use the same thread as much as I can. However, thanks, I didn't type in general because I thought it's for "how to set player prefix using /lp" questions
#support-1 / 2 are for lp questions
Alright thanks
is name the name of the permission?
yes
hey
so im tryna check a users permissions on waterfall at PreLoginEvent
how does one check permissions off of a string of a uuid or username
cause what im trying to do is IF user does not have antivpn.bypass then ple.setCancelled(true)
the api is very confusing to me
(user.data().contains(PermissionNode.builder("antivpn.bypass"), player.toString())) {
like imo should not be this hard to check a player for a permission using the api
But uh I don't think that player.toString is ever going to work out
Permissions data is loaded during the LoginEvent, and will be available to other plugins in the PostLoginEvent
it is not available in the PreLoginEvent
omg
great so i gotta build my anti bot into my queue plugin 
not a bad feature for 6.0 ya know what ima do it thanks
there is a good reason for it fyi
what is it lol
PreLoginEvent is called before authentication with mojang
so the players profile/uuid/etc isn't known
o okay
atleast this way i can do the best option i got which is dont allow connections at all unless they have the permission
my anti bot is a website where u put your username and it adds a permission
How can I listen/subscribe to UserUpdateMessage ?
(I want to do something when a User gets updated / gets a new primary parent)
(When I use the NodeAddEvent, and I update a Users group on the Server, it won't trigger that event on the bungee. (bungee listens to that event))
!api
Learn how to use the LuckPerms API in your project.
nvm
i think it'll work if you publish your changes with the messaging thing
check pins
Is NodeAddEvent fired every time a permission is changed in luckperms be it webpage or command?
the
NodeAddEvent- called when a node is added to a user/group
i would assume that this is fired when changes in the editor are applied/saved and cause a node to be added to a player or group
hello i was wandering if you can help me with this, i am making a bungeecord plugin and trying to check if a user is a group. i have done this:
String[] ranks = {"owner", "admin", "gamemaster", "builder", "youtuber", "mvp++", "mvp+", "mvp", "vip+", "vip", "default"};
Collection<String> ranksCollection = Arrays.asList(ranks);
public void execute(CommandSender commandSender, String[] args) {
ProxiedPlayer p = (ProxiedPlayer) commandSender;
if (getPlayerGroup(p, ranksCollection).equals("mvp++")) {
}
}
public static String getPlayerGroup(ProxiedPlayer player, Collection<String> possibleGroups) {
for (String group : possibleGroups) {
if (player.hasPermission("group." + group)) {
return group;
}
}
return null;
}
but even if i am in the mvp++ group it doesn't run the code after
anyone?
!cookbook this is probably more useful than an ai that doesnt actually understand code
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
there isn't any user.inheritsGroup()?
i will try using this if (user.getPrimaryGroup().equals("mvp+")) {
btw you can just do a normal permission check for the group.<group name> permission
thanks, but the above also worked (will maybe use it next time)
It understands code, but it has to collectively understand dozens of languages and APIs, but yeah it was a shot in the dark lol
Iโve been using the inheritance node builder for this purpose, would there be any specific reason to go with one way over another?
using your platforms built-in way to check permissions is far simpler than relying on the lp api for just that
how can i get a prefix from a grup
!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.
let's assume I wanted to make it */op redundant (I was checking for a list of groups not effective permissions)
I was more or less asking in terms of effectiveness, rather than simplicity, but I understand the point
Good morning! Could someone possibly help me find out how long a rank will remain? I would like to make a /rank command that indicates how long a rank still exists. And if it is permanent, also permanently displayed. I thought I had seen something about it here before, but I canโt find it ๐ค
!placeholder
Display data such as user prefixes and groups from LuckPerms in other plugins.
!arrange
Sorry! I do not understand the command arrange
Type !help for a list of commands
!help
!advanced
!api
!argumentbased
!ask
!bedrock
!bulkupdate
!bungee
!bungeecheck
!cauldron
!colours
!commandequivalents
!commands
!config
!context
!cookbook
!default
!downloads
!editor
!editorsafety
!errors
!essentials
!extensions
!extracontexts
!faq
!forgepermissions
!formatting
!hack
!helpchat
!inheritance
!install
!libsdir
!locale
!meta
!migration
!notworking
!nowildcard
!offline
!pasteit
!permissions
!placeholders
!reload
!selfhosting
!spongeseven
!stacking
!storage
!suggestions
!switchstorage
!sync
!testingperms
!tracks
!translationprogress
!translations
!tutorial
!upgrade
!usage
!userinfo
!velocitycheck
!verbose
!version
!weight
!whyluckperms
!wiki
does anyone know why this doesn't work?
user.data().add(PrefixNode.builder("&6[MVP&d++]", 1).build());```
did you save the user
oh
no
and how do i save?
like this?
LuckPermsProvider.get().getUserManager().saveUser(user);```
yes
ok thanks
could you please help me make it instead of adding prefix to changing
because if i add it doesn't work the same (can't be seen)
remove the old one first
how to do so
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
i tried to find it
look in setprefix command
thanks it worked
but also do you know why
i have to relog for it to work?
(use the other prefix)
your chat plugin
Is there a way to detect when a temp added parent is removed from a player?
Listen for the NodeRemoveEvent I think it is
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
(Whenever i change the prefix the user has to relog for the apply to happen btw i am updating from proxy and have it connected with mysql to the backened)
Should I close the eventbus or what?
Found it, so it's for unregistering the listener (btw disabled mention ping)
See the pinned message about pushing updates
Just would like to know if you are able to see the duration left on a settemp node with the API, if its on the docs, i will try to look for it again because i probably couldn't find it
Get the node, then use getExpiry()
omg my notifications are so loud, anyway thanks ill try this
you meant getExpiryDuration() i think
sorry for ping forgot to turn that off
getExpiry() returns the time that it expires, getExpiryDuration() returns the amount of time remaining. they both accomplish the same thing in different ways
thank you for clarifying
!colours
!placeholders
Display data such as user prefixes and groups from LuckPerms in other plugins.
how does one check if a Node represents a group?
I currently check if the key is group.<group> but idk if that's the proper way ๐ฌ
return nodes.stream()
.filter(Node::getValue)
.filter(it -> it.getKey().equalsIgnoreCase("group." + plugin.getGroup()))
.findFirst()
.orElse(null);```
return nodes.stream()
.filter(NodeType.INHERITANCE::matches)
.map(NodeType.INHERITANCE::cast)
.filter(Node::getValue)
.filter(it -> it.getGroupName().equals(plugin.getGroup()))
.findFirst()
.orElse(null);```
Welp, I think this is better
probably just if its group.something and something exists as a group
theres nothing special about group nodes other than how luckperms handles it
as in they are stored the same way
Here:
CompletableFuture<Void> future = ; // action (any that writes to storage)
how to put this command in
user.data().add(PrefixNode.builder("&b[MVP&c+&b] ", 1).build());
i do this?
CompletableFuture<Void> future = LuckPermsProvider.get().runUpdateTask();
Let's suppose a group has no weight set. Behaviorally, how does LuckPerms compare a group without weight to a group with a defined weight?
My best guess would be that LuckPerms treats groups with a defined weight as having a greater weight than groups without a configured weight. Is that correct?
I'd imagine no weight probably defaults to weight of 0
Yes indeed. For future reference to users searching:
https://github.com/LuckPerms/LuckPerms/blob/48e5f428b50c2e3a3af880d82b0e9f4d2cedbc29/common/src/main/java/me/lucko/luckperms/common/inheritance/InheritanceComparator.java#L72
!api
Learn how to use the LuckPerms API in your project.
where can i get version for 1.12.2 forge
How would I go about removing/overriding a Player's prefix set by a group? (I am trying to switch a Player's prefix, while still being able to reset to their original group prefix)
This is what Im trying, but it's not removing the group prefix and ends up giving 2 prefixes, the one I'm trying to set, and Player's primary group prefix
LuckPermsProvider.get().getUserManager().modifyUser(player.getUniqueId(), (User user) -> {
user.data().clear(NodeType.PREFIX::matches);
Map<Integer, String> inheritedPrefixes = user.getCachedData().getMetaData(QueryOptions.nonContextual()).getPrefixes();
int priority = inheritedPrefixes.keySet().stream().mapToInt(i -> i + 10).max().orElse(10);
Group group = luckPerms.getGroupManager().getGroup(rankPrefix);
String prefix = group.getCachedData().getMetaData(QueryOptions.nonContextual()).getPrefix();
Node node = PrefixNode.builder(prefix, priority).build();
user.data().add(node);
});```
What is the correct way to add a permission to a player or group just for the current server, and not for any other servers?
I'd like it to be temporary to that instance of a server, and when that instance is destroyed, the permission should be too
and it should not interact with other servers at all, at risk of that player getting the permission in other servers
And unlike using contexts, these permissions are generated at will
oh, and I can't use a local database for each server, because some content (eg. prefixes, etc) needs to be synced between all servers
Tldr; of that is that I need to make a custom permission handler that can inject into luckperms somehow.
Is that possible in any way?
because I don't really want to end up with 1,000s of permissions in my default group
I'd like to keep that part simple
and just adding a small permission handler would be the perfect solution
imo
do you need them to be stored in storage?
No
transient node map
You might want to check the meta stacking settings in the config
https://github.com/LuckPerms/LuckPerms/blob/8e1553c0ed39a3af65240b3eb1b4f831acbafdcc/bukkit/src/main/resources/config.yml#L355-L417
That won't happen with the default settings, make sure they are not changed
I assume just add stuff to PermissionHolder#transientData?
yes
awesome
It looks like my meta stacking settings are default, I was thinking since I'm adding a PrefixNode it's ignoring the meta stacking and adding double? Unsure why user.data().clear(NodeType.PREFIX::matches); does not clear the primary group prefix though
No, the meta stacking is precisely to configure how it behaves when it finds multiple prefixes/suffixes, when inherited etc
That doesn't clear the primary group prefix because that's the user's own node map, the prefix from the group resides in the group
What chat plugin are you using? Perhaps its settings are misconfigured
Hmm, I'm using TownyChat (on test server), but everything looks normal there, when I try changing my prefix to the rank that is my current primary rank, I Only get 1 prefix, however if I try to use that above code to change to another I get double, here is how it looks in for lp info
Would increasing the weight on the prefix I'm setting work?
if it shows correctly in /lp user <name> info luckperms is doing its job
Alright thats super helpful to know, thank you!
Hello, does the loadUser method force reloads the user or uses the cached user in memory if available?
Feel free to ping me
The loadUser method Loads a user from the plugin's storage provider into memory.
what if the player is already playing on the server and in another word is already loaded?
The user manager is poorly documented
From my understanding of how plugins works, playing in a different world on the same server doesn't matter since plugins are loaded per server and not per world.
I would assume he is talking about another instance of LP running somewhere
I said word not world lmfao
๐ nope?
In that case, only one LuckPerms instance runs per server.
All operations are local for your case
#loadUser will pull from memory cache if avalible, however expect it could be blocking if it has to go to the DB
I'm making a command to change the data of the player who sent it, all of what I want is using the cached data which is stored in the memory instead of reloading the player from the database. However I want to use the UserManager#modifyUser method, and I was talking about the UserManager#loadUser because what UserManager#modifyUser does is loading the user, modifying him and unloading, but sounds it loads from the database everytime it's called so after looking in the sourcecode and making sure, I will manually write the UserManager#modifyUser code but by using the UserManager#getUser instead of UserManager#loadUser, I know the problem is not that hard and may be solved by 2 more lines of code, but I wanted the efficient way and writing less code
#modifyUser will not go to the DB if it has it cached locally
Sure? I can't find anything related to what you're saying in the docs
Test it
Then you need to find a different hobby XD
Even if I love LuckPerms, this case is important to be documented :/
!api
Learn how to use the LuckPerms API in your project.
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 don't really hate it, but docs already exists and the dev already knows, so it should be documented, "debug to see if it works" is not efficient and annoying, and in this case will be painful to debug. What would you do that makes you confident that it doesn't load from the database if the data already exists in the memory? Let's say I use MySQL, I will have to change the player's data from the database table and then debug the UserManager#modifyUser to see if it took the new changed data? Doesn't that look stupid and annoying? I really prefer writing the code manually instead of "test to see if it works"
What's wrong with this?
It's safer to use this, as if the user is unloaded for some reason, it will not block your entire server.
Let me explain more, I will be using it for a already loaded player, and the loading process as it always takes data from the database for a already loaded player is not efficient nor good for performance. The player is already loaded, I don't want it to reload the player, I want it to use the already loaded user. However I'm done with this I will write it myself, 3 lines of code.
hello, i am trying to send a users prefix from the bungeecord server to the backend server using bukkit-bungee-plugin-messaging-channel. It kind of works it sends the prefix but infront of it sends a symbol for example (โ&c[OWNER] AA12Pro) is that supposed to be happening and if yes how to disable/bypass it
If that symbol is not in your LP prefix, then it would sound like some decoding issue with whatever bytestream encoding you are using.
it isn't in the prefix
On the proxy log the prefix before you send it
and to decode it i am using this java if (s.equalsIgnoreCase("network-essentials:nicked-chat")) { ByteArrayInputStream arrayInputStream = new ByteArrayInputStream(bytes); try { Bukkit.getConsoleSender().sendMessage(name); name = IOUtils.toString(arrayInputStream, StandardCharsets.UTF_8); getConfig().set(player.getName(), name); saveConfig(); } catch (IOException e) { e.printStackTrace(); } }
i have made a nick plugin
and i have it made it
so it doesn't change the prefix
but only the name
.
Now log it right after decoding on the ds
i have done that
and it shows tha
after decoding the backend server sends this
โ&c[OWNER] AA12Pro
That means it's some decoding/encoding issue
hm
and how do i fix that
this is how i encode it:
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
try (DataOutputStream out = new DataOutputStream(arrayOutputStream)) {
out.writeUTF(prefix + BungeeMain.getData().getString("Player." + p.getUniqueId() + ".Nickname"));
p.getServer().sendData("network-essentials:nicked-chat", arrayOutputStream.toByteArray());
} catch (Exception e) {
e.printStackTrace();
}```
UTF
and this is how i decode it
Decoding:
ByteArrayDataInput in = ByteStreams.newDataInput(message);
in.readUTF()
let me try
i didn't undestand
Did that decoder work?
i don't know its building
DataOutputStream#writeUTF has encoding chars around your string, as it's designed to load a bunch of crap into a bytestream, and you just decoded it manually without processing it
I thought it would only be a single nullterm at the end but I guess it's more
Is there any way to make a range can give ranks but only those that are below it?
!argbased
Fine tune exactly what users with permission to use LuckPerms can do.
also #support-1 or #support-2 in the future
ok
!paste
Seeing a paste of the problem makes everything so much easier! Use https://pastes.dev/ 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!
I need help
SO
i am making a plugin for playerjoinevent
and i want different join messages for different rank
Here is the code i got so far
But it is giving me a error
Here is the config i am using for it
And here is the error it is giving
@unreal mantle
Hey Arsh Gamer! Please don't tag helpful/staff members directly.
because "this.luckperms" is null
when do you create your reference to the lp api?
.
so you dont set its value to anything...?
What's value?
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
That's not how you add LP to a plugin
So do i have to add this
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.4</version>
<scope>provided</scope>
</dependency>
</dependencies>```
to this file
???
i think that is What It Says
Hey Arsh Gamer! Please don't tag helpful/staff members directly.
Why are you pinging for no reason
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>```
that how i add it ?
Yes
Hey Arsh Gamer! Please don't tag helpful/staff members directly.
If you edit the pom you get a small reload button in the top right. This is easier than restarting IntelIJ
Doesnโt always work. Sometimes you have to invalidate caches.
Oh ok thanks for tip
From now on you can use the LP API in your plugin. Keep in mind you still need the LuckPerms plugin in your (test)server.