#luckperms-api
1 messages · Page 3 of 1
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 Arsh Gamer! Please don't tag helpful/staff members directly.
I am really sorry
But i have to do this before new year
send your full class
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!
Wait
Main Class
You did nothing in that for LP
And Join class
here is all stuff oF LP
.
!api please read this.
Learn how to use the LuckPerms API in your project.
Ah ok
in my plugin i am trying to do run something after a players prefix is changed how can i check when it happens
its not quite that simple
many things go into determining the players prefix, and afaik luckperms doesnt track when the prefix changes, it just calculates its value every time a plugin asks for it
i could also work with groups
and a player can have multiple prefixes displayed at once depending on how a user may have configured their meta stacking
like group.owner
what are you actually trying to do with that information?
when the players group changes
reset the prefix
like clear or the meta data the player has
this clears the prefixes : user.data().clear(NodeType.PREFIX::matches);
but i wanna check first when the group changes
why do you need to do that?
also are you making this plugin for your own server or to release?
i made a rankcolor plugin like hypixel
my own server
and maybe release at a later date
instead of directly changing the players prefix, you can include a placeholder for the color
and i wanna check that if the users group changes so it resets the prefix
no wait
i am trying
to do it
when the player is no longer on for example mvp++ group
their prefix doesn't stay for example "&6[MVP&c++&6] "
but getting it cleared
if you just make the mvp++ prefix use a placeholder for the color, you dont need to add it directly to the player, and thus dont need to clear it when their group changes
like make it if the player has for example the red ++ color to use in the message something .replace(prefix, BungeeMain.getConfig.getString("Prefix");
What is the <> of prefix
How would I check if a player has a permission using the luckperms API?
public boolean checkPermission(Player player, String permission) {
try{
LuckPerms api = LuckPermsProvider.get();
User user = api.getUserManager().getUser(player.getUUID());
}catch (Exception e){
// LocalPlayer - no LuckPerms - has no permission
return false;
}
}
if you have a player already, why not just use player.hasPermission() ?
Its a forge player. Player#hasPermission checks the permission Level and I would like to check a permission string https://cdn.lightdream.dev/idea64_lYdnZlIKip.png
I was unable to find any docs for the 1.19 version
yeah I was just looking too and I can't find any either lol
basically, you have to register your permission nodes using this event
@SubscribeEvent
public void onPermissionGather(PermissionGatherEvent.Nodes e) {
}
then you can check them using
PermissionAPI.getPermission(player, permissionNode);
the design is a bit ehhh
you can also depend on the LP UserCapability
I see thanks for all your help, do you have the forge version of luckperms on any repository or should I add it as a file lib?
would have to be file lib for now
Alright will try to the the UserCapability class
actually on second thought it is probably better to do it using the proper LuckPerms API instead of the user capability
since the player is online it should be pretty easy
If you have any docs / examples on hand it would be really helpful
public static boolean checkPermission(ServerPlayer player, String permission) {
LuckPerms luckPerms = LuckPermsProvider.get();
PlayerAdapter<ServerPlayer> playerAdapter = luckPerms.getPlayerAdapter(ServerPlayer.class);
return playerAdapter.getPermissionData(player).checkPermission(permission).asBoolean();
}
Thank you for your help, and for the work that you have done for us to not have to deal with well... the forge api 🙂
haha no problem :)
Do api events run as Spigot events?
I remember that when I was using luckperms with spigot, the permissions for all commands were displayed automatically when I configured my server with the /lp editor command.
But now with Fabric, no permission is displayed (gamemode, ...). How can I make a specific command from another mod or from Minecraft vanilla to be forbidden
I dev. a mod with fabric that uses commands, how to set this up easily so that users can configure commands easily (with autocompletion in the luckperms editor) ?
suggestions are taken from permission checks that have occured on the server, there is no api for adding them
if a permission was checked before creating an editor session, that permission will show up in the suggestions. i would recommend instead of trying to add your permissions to the suggestions manually, just document on your mod/plugin page what permissions there are and what each one does
So you're saying checkPermission is the API for adding them? 
you technically could do that but it would need to be on a player joining rather than startup probably
Im trying now for testing to deny gamemode command, so i typed /gamemode creative, then /lp editor (but in editor no suggestion about any "gamemode" permission. Is that normal ?
you said you are on fabric right?
ye
vanilla commands do not have permissions, so you need a mod that adds permission checks to them
Hello, does the API offer a way to get a list of all groups sorted by weight? Or do I just get the loadedgroups and sort it myself by weight?
Hi ! How I can set rank with your api, because I see only add and not set :/
Juste I want set also when I use /lp user <pseudo> parent set <rank>
without use this command...
Remove existing inheritance nodes and add the one you want to set, that's what the command does
There's a clear method that takes a predicate, should end up with something like user.data.clear(NodeType.INHERITANCE::matches) or similar
ok thanks !
Hey, I'm trying to give the players a role upon joining but can't figure out the PlayerJoinEvent event (https://pastes.dev/o5CfM4fKK6) - I've not worked with API's before and have already looked at the Luckperms Developer API wiki (https://pastes.dev/RMSq5xX6d8 - Both the override and Eventhandler)
How to clear user permission?
Wye not use the default role?
Can i have a reply on this?
Issues been fixed now but thanks, also the purpose of the plugin was meant to give them a role on top of the default role depending on certain circumstances
Hi! How do i change the Group name of a group that already exists? With the API? There isnt a Node for that
no, you need to sort them yourself
honestly it will be easier and potentially faster/more efficient to simply run the rename command, lp group <group> rename <to> --update-parent-lists
Ok thanks
How do I give an npc command so that it only gives vip to that player (someone clicks on an npc and automatically gets VIP)
You mean with Citizens 2?
no NPC
I know but i dont no command :D
You have a Plugin to give a Player VIP or Luckperms?
LuckyPerms
/npcmd add console lp user %p% parent add [YourGroupName]
Type that exactly COmmand in chat but change the GroupName that adds it to your selcted npc
You have citizenscmd installed?
Oh thanks it works :D
ok
I when you put there the owner, which has * rights, so it goes, but VIP what does not * so does not go
Can you show me the Command you typed and the error?
parent add VIP But you can't give that rank to that player
No give me the exact Command you wrote to the npc it starts with /npcmd
And what happens when you click the Npc?
So it woked
But my rank is still the same
I think you have both ranks. Look at /lp editor and show me what groups your user is in
Don't want to connect to my server and do it?
Ok send me ip
Dm's
jup
With that api, Can I make a discord bot to make a synchronize bot for a mc server to discord
or it is impossible
With JDA https://github.com/DV8FromTheWorld/JDA yes
LuckPerms API has nothing to do with a discord bot
Doesn't need to be JDA, could be whatever discord lib you want. LP doesn't know or care what you do with the API
(although JDA is certainly the most popular)
It is with ts and with discord.js
The api is a request xd
I don't think you can bind js with java / mc
It is an api
no a plugin
still
You can, considering Luck made a REST api for LuckPerms.
Hi, trying to use the LuckPerms API for some custom prefix stuff. I wanted to know how I could implement a specific server context to the prefix?
At the moment I have the basic code from the API cookbook, which works fine, but I only want it to apply to this specific server, not the other servers in the network.
luckPerm.getUserManager().modifyUser(uuid, (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);
Node node = PrefixNode.builder("&8[" + prefix + "&8] &7", priority).build();
user.data().add(node);
});
This is what I've got at the moment.
Any and all help would be appreciated, thanks!
Node node = PrefixNode.builder("&8[" + prefix + "&8] &7", priority).withContext("server", "hello").build();
Ah, thank you!
!api
Learn how to use the LuckPerms API in your project.
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
what kind of answer would that be? I ask for help and you always tell me that
😠
The documentation state how to get an instance of the API
i've read all the documentation, you're not helping me at all
That says how to get it
yet it seemed to me that i had already done it, i try again
The wiki says something else then what you have
mh 😵
The wiki page Cas linked shows you exactly how to get an instance of LuckPerms to work with it, with code examples.
You have something entirely different than what the docs say
not found
The wiki does not say LuckPerms.getApi()
so what do i do? D:
The wiki page Cas linked shows you exactly how to get an instance of LuckPerms to work with it, with code examples.
Read it
Its up to you to help yourself. no one is going to spoonfeed you.
you have been given direct links to code examples for obtaining the LuckPerms API, and have failed to listen to them.
i've now opened the documentation 100 times
The wiki page Cas linked has the exact answer to your question
Letter by letter
And yet you have something that is completely different
just opening the docs isnt going to change anything, you have to read it, and apply to your code.
Where did you get LuckPerms.getApi() from? What page are you even reading? Could you link it?
i start over

Hi! How can I remove group from a user?
I've tried ```java
InheritanceNode groupNode = InheritanceNode.builder(group).build();
DataMutateResult result = user.data().remove(groupNode);
but `result.wasSuccessful()` was always `false`
Fixed it! I was putting the wrong group into group variable
@stiff valley type /lp user {user} parent set default
i run "/lpcookbook-setgroup MrFil_27 admin" command
as it was shown in the code example, why is it giving me this error?
!api
Learn how to use the LuckPerms API in your project.
what is it?
thisi s the code 😦
this time i did everything right
where do you get an instance of the api?
so, i loaded the LuckPerms class in the Main class after importing the dependency in the pom.xml, then i created a "private final LuckPerms luckPerms;" in the Command class and its constructor, if any, by doing "this.luckPerms;"
i did this
!paste send your full creategroup class and main class
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!
what is it?
What is what
stop pinging me.
I told you exactly what I wanted you to do
“.” Doesn’t clear up any confusion.
sorry
@rustic laurel @thorny echo (nsfw already got deleted)
Hey fayevr! Please don't tag helpful/staff members directly.
can anyone help me please? D:
send your full createGroup class, and your main class
does anyone know why when i add the placeholder api this happens to my ranks in chat? i downloaded expansion and everything
Whatever chat system you are using does not hook into PAPI/Vault?
import net.luckperms.api.LuckPerms;
import net.luckperms.api.model.group.Group;
import net.luckperms.api.model.group.GroupManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class createGroup implements CommandExecutor {
private final LuckPerms luckPerms;
public createGroup(LuckPerms luckPerms) {
this.luckPerms = luckPerms;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player) sender;
if(!(sender instanceof Player)){
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Non puoi eseguire il comando da questa istanza.");
return true;
}
if(args.length < 1){
p.sendMessage(ChatColor.RED + "Utilizzo: /creategroup <group>");
return true;
}
String groupName = args[0];
GroupManager groupManager = this.luckPerms.getGroupManager();
Group group = groupManager.createAndLoadGroup(groupName).join();
p.sendMessage("Il gruppo '" + groupName + "' è stato creato con successo.");
return true;
}
}```
createGroup class
import net.luckperms.api.LuckPerms;
import net.madeinrp.luckpermstest.commands.createGroup;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
public final class Main extends JavaPlugin {
private LuckPerms luckPerms;
@Override
public void onEnable() {
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
LuckPerms api = provider.getProvider();
}
//Commands
getCommand("creategroup").setExecutor(new createGroup(luckPerms));
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}```
the Main class
!paate please
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!
???
read the embed
ok
i pasted the code and of necessity i saved it, now what should i do?
this is the main class, can you see them?
what are you expecting this to do?
then tell me how I can create this blessed group please D:
i'm just trying to understand
get an instance of the api in your main class. use that instance from your other classes
i am not going to spoonfeed you exactly how to fix it
i try again 😦
but the API instance i get in the onEnable method when i do
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
LuckPerms api = provider.getProvider();
}
how much programming experience do you have...?
i had 1 year of experience, but for a while i had to let it go, now that i've started again i missed some things 😦
okay, as long as i try to figure out how to use it i'm dealing with something else
Failed to handle packet net.minecraft.network.protocol.game.ServerboundClientCommandPacket@5a4de493, suppressing error java.lang.IllegalStateException: Capability missing
This is how I'm checking it
user.getCachedData().getPermissionData().checkPermission(permission).asBoolean()
Forge 1.19.2
where are you getting the api instance?
In main class
Look i am new to API Think so yeah
talk in simple Lang
So i can understand
(^_~)
@frank drift Look Can i please ping Staff members i need support fast so please cooperate. 😜
@unreal mantle
Hey Arsh Gamer! Please don't tag helpful/staff members directly.
Bruh i just talk for perms from you. For it
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!
save an instance of it, so
LuckPerms luckPerms;
onEnable() { luckPerms = …. }
Cannot invoke "net.luckperms.api.LuckPerms.getGroupManager()" because "this.luckPerms" is null
this time i tried the command found in the cookbook-plugin and it still gives me this error, what can I do to fix it?
here's what i did:
- i imported the luckperms api into the pom.yml file as indicated in the guide
- i got the api instance with the Bukkit ServicesManager, again as indicated by the guide
- i registered the denend in the plugin.yml file
- i tried to run a test with the SetGroup command from the GigHub file, and here it doesn't work
if someone could help me...
You'd use the instance you got from the services manager
Save it in a field, pass it to your command class, etc and use it from there
Hi, does NodeMutateEvent execute on all servers connected to the same db?
No, it only fires on the server/proxy it happened (command was run, editor changes applied, changed through API etc)
Okay, thanks
Hey I've got a small problem. I'm hosting server for my friends and everything would be fine if they had premium version. I noticed that if I set online-mode in server.properties to false no one can join the server, even premium users. Could someone help me?
This is the wrong channel, but also the wrong guild entirely for this issue.
Furthermore, I will warn you that many users (myself included) are not interested in assisting in allowing pirated users to play the game.
Okay so I need some help, I have global & specific server only groups, how can I get meta either from a global heigher weight or, if set the meta from the context if that makes sense?
https://i.imgur.com/8SWc3OF.png, Eytril's name is supposed to be green, but bc it doesnt have a global rank its the default color
how can i do when peaple join they get a rank instantly
with the api?
yeah i guess
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
thx
!default
LuckPerms provides a group that every player is added to upon joining the server, called default. You can use multiple methods to change the default group or change the name of it.
Hi, can someone send me a code example how to check if a player has permission or a group permanently or only temporarily.
!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.
weee bump?
How to set group for user using api ?
I tried:
Group group = luckPerms.getGroupManager().getGroup(args[1]);
if (group != null) {
net.luckperms.api.model.user.User user = luckPerms.getUserManager().getUser(args[0]);
if (user != null) {
user.setPrimaryGroup(group.getName());
luckPerms.getUserManager().saveUser(user);
s.sendMessage("§aUstawiono grupe §2"+group.getName()+" §adla §2"+args[0]);
} else {
s.sendMessage("§cUzytkownik nie istnieje!");
}
} else {
s.sendMessage("§cPodana grupa nie istnieje!");
}```
After use nothing is changed, group is still the same.
final var claimedRewards = user.getCachedData()
.getMetaData()
.getMetaValue(AeroPlus.CLAIMED_REWARDS, value -> new ArrayList<>(List.of(value.split(","))))
.orElseGet(() -> new ArrayList<>(1));
if (claimedRewards.contains(actionOrAmount)) {
sender.sendMessage(user.getUsername() + " has already claimed reward for month " + actionOrAmount);
return;
}
user.data().clear(node -> node.getKey().equals(AeroPlus.CLAIMED_REWARDS));
claimedRewards.add(actionOrAmount);
user.data().add(MetaNode.builder(AeroPlus.CLAIMED_REWARDS, String.join(",", claimedRewards)).build());
LuckPermsProvider.get().getUserManager().saveUser(user);```
How can I update the value of a meta key? I need to read a comma separated list of integers from a key, add an extra int and then sent it back, but currently with this setup, the key is duplicated
```java
[11:45:51 INFO]: [LP] -> aeroplus_claimedrewards = '1' (inherited from self)
[11:45:51 INFO]: [LP] -> aeroplus_claimedrewards = '1,2' (inherited from self)```
welp, looks like this worked
user.data().clear(NodeType.META.predicate(node -> node.getMetaKey().equals(AeroPlus.CLAIMED_REWARDS)));```
Hello, I'm trying to update an old project that used LuckPerms and something is wrong with this peace of code : https://pastes.dev/jTm6OJKYA9
I'm getting these errors in Eclipse
Node cannot be resolved to a type
The method getNodeFactory() is undefined for the type LuckPermsProvider
The method getUserManager() is undefined for the type LuckPermsProvider
User cannot be resolved to a type```
I'm using Java 17 and the latest LuckPerms
Any idea on how to fix it?
Learn how to use the LuckPerms API in your project.
!v4
Sorry! I do not understand the command v4
Type !help for a list of commands
4.4.27
you'll need to udpate it to the new api
read the links above & https://luckperms.net/wiki/Upgrading-from-v4-to-v5
!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
!wili
Sorry! I do not understand the command wili
Type !help for a list of commands
!wiki
Learn how to use LuckPerms and all of its features by reading the wiki.
!bedrock
If you're having issues with permissions for bedrock players, or it's telling you that a bedrock player's name is invalid, try setting allow-invalid-usernames to true in the LuckPerms config.
!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.
maybe when you see this code it will help you somehow
https://github.com/IndianBartonka/OsTag/blob/main/src/main/java/me/indian/ostag/utils/PlayerInfoUtil.java#L194
OsTag and ChatFormaiting for Nukkit https://cloudburstmc.org/resources/ostag.836/ - OsTag/PlayerInfoUtil.java at main · IndianBartonka/OsTag
so im tryna make a thing so that when someone joins it checks their permissions using the luckperms api i made this code https://xtev.and-his.website/uQj8Cway
its saying true for everything when the user only has kit.default
!tutorial
If you would like a video tutorial for setting up LuckPerms, try:
https://www.youtube.com/watch?v=l4anE2wOLdc
you know you can just do Player.hasPermission('node'), right?
did you define it in your plugin.yml so they're not defaulted to true
!verbose try this
LuckPerms provides a verbose command to help you find out what permissions a command/plugin is checking.
unless you explicitly add it as true, it should default to false
yesn't, it defaults to ops only, whereas false defaults to false for everyone, ops included
Hello, I'm getting this error while getting LuckPerms on Velocity:
https://hastebin.com/ubufepurax.sql
...
@Plugin(
id = "virtualrememberme",
name = "VirtualRememberMe",
version = "1.0.0",
description = "Save user's last server",
url = "https://virtualhit.es",
authors = "YoSoyVillaa",
dependencies = {
@Dependency(id = "luckperms")
}
)
public class VirtualRememberMeVelocity {
...
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
LuckPerms luckPerms = LuckPermsProvider.get();
}
}
How can I use the LuckPerms API to get a player's highest rank on a given track?
!extracontexts
Add contexts not supported by stock LuckPerms.
!extensions
A list of all the Luckperms extensions.
Hey! Do I need for %luckperms_group_expiry_time% the PlaceholderAPI? Or is there any other way to get this time?
When I use the command "lp user nick group addtemp..." the events 'NodeRemoveEvent' and 'NodeAddEvent' are called... In this case, I just wanted to handle the Add and cancel the Remove, because in settemp theoretically the Node is not removed. How can I do this?
fix
Pls?
Yeah you can pull the expiry time from the inheritance node
whats wrong?
save the user
how?
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
!api
Learn how to use the LuckPerms API in your project.
yes
is there something wrong? the add part works but when removing it doesn't
is there an api to get all permission list, like luckperms tabcomplete do?
alright thanks
hello, in the wiki i can't find the method that tells me how to delete groups
can you help me?
i do this
boolean success = api.getGroupManager().deleteGroup(partyLeader)
i've already seen this page but by applying what's written it gives me these errors
deleteGroup does not return a boolean
the javadoc shows what it returns, a CompletableFuture<Void>
a future to encapsulate the operation.
If you are not familiar with futures, I suggest you give these two lil sections a read, should be enough to get a grasp of why that method returns a future
https://luckperms.net/wiki/Developer-API#blocking-operations
https://luckperms.net/wiki/Developer-API#using-completablefutures
ok i can try later
I have made this:
https://srcb.in/BsQLOTG2J8
which checks for whenever the users group changes. how can i make it run though whenever that happens
!api
Learn how to use the LuckPerms API in your project.
getPermission is returning null
aah just realized my mistake
tysm
well it didn't fix it o_o
this is my config:
aand this is my method of retrieving perms:
public static String getPermission(String section,String name){
return get().getConfiguration().getSection(section).getString(name);
}
now it doesn't even send that INSUFFICIENT_PERMISSIONS
it just errors
same stuff still
not even with not changing permission
Are you still getting an error?
database error
this is ks amotag?
somehow fixed itself
no clue how 😄
eee what
never mind
hello
how do i use this %luckperms_check_permission% ? like can i do something like %player_has_permission_<permission>%
yes
https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders
explains a bit more about PAPI argument syntax
Hey BEAST! Please don't tag helpful/staff members directly.
sorry, how can i define if the player inherits the "work.manager" group? i can't find it in the documentation
Hey has anyone got any mod examples of using the luckperms api from fabric that i can read through?
I tried using the static access method LuckPermsProvider.get(), but I can't avoid the luck perms api is not loaded error.
I am calling from Fabric's onInitialize() with luckperms declared as a dependency in fabric.mod.json
nvm found the solution above
Hey! Just a quick question. Is the User#getUniqueId cached in any way, or should I cache it myself? Thanks!
The User object stores the player's UUID in the object itself, User#getUniqueId is not doing any lookups
Oh, perfect. Thanks
Hi there, I am having some issues utilizing the API. When I attempt to create a track and then modify it, the plugin crashes and states that the track object is null. Additionally, when I add a node with context, the context does not get added when the node is built. Any suggestions?
I’m creating it and then saving and then trying to call it but still null
Can you show some code
Yea
ok
luckPerms.getTrackManager().createAndLoadTrack(groupName);
Track thisGroupTrack = luckPerms.getTrackManager().getTrack(groupName);
thisGroupTrack.insertGroup(luckPerms.getGroupManager().getGroup("default"), 0);
luckPerms.getTrackManager().saveTrack(thisGroupTrack);
thisGroupTrack.appendGroup(thisGroup);
luckPerms.getTrackManager().saveTrack(thisGroupTrack);```
Node regWorld = Node.builder("multiverse.access." + groupName)
.value(true)
.withContext(DefaultContextKeys.SERVER_KEY, luckPerms.getServerName())
.build();
luckPerms.getGroupManager().modifyGroup(groupName, group -> {
group.data().add(regWorld);
});```
If you add java after the first three ` It will colour it nicely as well
Dont understand 🤔 Can you maybe explain? Would be very very helpful 
Hello, i am making a bungeecord plugin and for some time i have been trying and failing on how to do something whenever a players group changes any ideas?
Are you trying to create an eventhandler for player group change?
i just added the perm but its saying i dont have it
show the code you used to set the permission
public static boolean payFor(Player player, int price, String permission) {
if (Main.api==null) {
player.sendMessage("ERROR: LuckPerms api is null please report to the server owner/dev");
return false;
}
PointUser user = GamePointsAPI.getUserData(player);
user.takePoints(price);
User lpuser = Main.api.getPlayerAdapter(Player.class).getUser(player);
Node node = Node.builder(permission).build();
Bukkit.broadcast(Main.parseMesage(player,"&8[&6&lLP-KOT-EXTENTION&8] &ePlugin &e&lKOT &eadded permission &e&l"
+ permission + "&e to player &e&l" + player.getName()), "tab.staff");
DataMutateResult result = lpuser.data().add(node);
if (result.wasSuccessful()) {
return true;
} else return false;
}
need to save the user
oh totally forgot about that
Any suggestions?
Hello, i'm trying to add the LuckPerms API to my minecraft plugin.. here is the pom.xml (dependencies) ``` <dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-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>``` but "net.luckperms", and "api" are red and if i clicks on it it says dependency: net.luckperms:5.4 non found, solutions?
try reload maven/restart project
thank you, it worked
How to fix it?
How can i get the weight from a player into a int?
I have tried many ways but all of them return is a null
and how do i make it a normal int?
.get() or orElse(0)
Can you give a example of the whole code, I think I'm getting a array or something?
Can someone tell me what event fires when I change the group of a user?
I'm using UserTrackEvent and that doesnt seem to be it
show code
@slim warren
How does one get the Dependancy of LuckPerms if running it on bungeecord?
!api
Learn how to use the LuckPerms API in your project.
Hi, this is my code: String newprefix = plugin.getConfig().getString("Prefix.staff-prefix").replaceAll("&", "§"); int StafftPriority = plugin.getConfig().getInt("StaffPriority"); PrefixNode node = PrefixNode.builder(newprefix, StafftPriority).build(); user.data().add(node); LuckPermsProvider.get().getUserManager().saveUser(user);
how do i memorize the priority of the group, because now i set it to (int) an if the value on the config is every number the plugin ignores it an set i to 0, should i try (double)?
thanks
I was using aternos. I switched to virtual machine. I downloaded luckperms files but luckperms is not working
how can I get the groups inherited in other servers?
User#getInheritedGroups returns only the groups for the current server
Edit: found the method
it returns a CompletableFuture
you change it from Group to CompletableFuture<Void>
ok i try it
Hey! We're (german minecraft community) currently developing a (real) GDPR plugin. Is there any chance that you guys are interested in joining the project with some code contribution for automatic user data deletion?
if you post the project link ehre, people(not just lp ‘staff’) could look at it
You can find the github repository here -> https://github.com/Cube-Nation/CNGDPR
however, this is mostly to be addressed to plugin maintainers/developers that are interested in making their plugins GDPR compliant
The project is kind of new and still in prototyping phase - but we will release this and we will use it as our GDPR solution to become 100% compliant
Currently we're trying to talk to as many maintainers as possible to get maximum impact
hey, im on fabric and i used luckperms a while a go, is it possible to still use luckperms 4.0
is there still a documentation?
why do you want LP 4? and no, the fabric version only started existing recently no 4.x version that works on fabric
is it possible to use the luckperms api in a bungeecord plugin?, how do i registrer the provider.. in the wiki i didn't found anything about the lp api in bungee.
bungeecord doesn't have a service manager, you'll have to use the static accessor (it's the 3rd one listed in that subtitle of the wiki)
ok, thanks
TreeMap<Group, Integer> sorted = new TreeMap<>(groupMap); generating an error
it uses HashMap<Group, Integer> groupMap = new HashMap<>();
what's the error
oh i rememberd i used this a while ago and it was different, it was located at me.lucko...
and i could make it require commands permissions with Permissions.require("example") but cant do so rn
how could i do it now?
you just use fabrics permission api like normal
hello, is it possible to get remaining time from temp permission?
didnt even stay long enough to get an answer 💀
Im using a custom core which doesn't let users use spigot plugins. I'm running luckperms on the velocity server, and I want to use the data of the database in my custom core. Is that possible? I get this error when trying to get the luckpermsprovider because I cannot install luckperms.
what server software are you using
minestom
oh, oke
but this pull request hasn't been accepted?
You can try to build it yourself, currently no support for it
Hi 🖖 i'm searching for a way to get User permission (perhaps as list or by boolean) but without groups permission.
for eg:
Steve has permission "hello, hola, " and has a primary group called "default" . The group default have permission "hi, bonjour, gutentag"
i want to get only "hello and hola"
i have try with this, but it provide me all permissions :
user.getCachedData().getPermissionData()
i think it's possible cause when i type lp user <playername> permission info it only display payer permission ...
edit : found the answer:
Set<String> perms = user.getNodes(NodeType.PERMISSION).stream()
.map(PermissionNode::getPermission)
.collect(Collectors.toSet());
p
help my. install api on maven and error
send full pom
.
that doesnt look like the full file to me
try restarting idea
How can i get all the saved users?
getLoadedUsers
I shows only the online ones
getUniqueUsers()
thank you 
Why am i getting this error? Error: https://pastebin.com/LsW7Lytn
CODE:
User user = MitrasCore.getLuckPerms().getUserManager().getUser(player.getUniqueId());
assert user != null;
return new ArrayList<>(user.getNodes(NodeType.INHERITANCE));
}```
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.
how can i show the group a player is in?
I have a plugin that includes chat formatting, and I want it to show player's group name thru the HoverEvent stuff
or make it show what I want depending on the group the player is in
!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.
still not enough, srry im dumb
show code
public static void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
TextComponent nickname = new TextComponent();
nickname.setText(event.getPlayer().getDisplayName());
nickname.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
new ComponentBuilder(NEED GROUP NAME OR STUFF HERE).create()));
TextComponent divider = new TextComponent();
divider.setText(" > ");
divider.setColor(ChatColor.WHITE);
TextComponent message = new TextComponent();
divider.setText(event.getMessage());
message.setColor(ChatColor.WHITE);
player.spigot().sendMessage(nickname, divider, message);
event.setCancelled(true);
}```
get the players group then the displyname of the group
and that's what i need, but i cant, my programming skills is kinda low, i just dont know how
LuckPermsApi api = LuckPerms.getApi();
User user = api.getUser(player.getUniqueId());
Group group = api.getGroup("moderator");
TextComponent nickname = new TextComponent();
nickname.setText(event.getPlayer().getDisplayName());
nickname.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
new ComponentBuilder(group.getDisplayName()).create()));```
i tried to do it like this, but
java.lang.NoClassDefFoundError: me/lucko/luckperms/LuckPerms in chatEvent, line 31 which is "LuckPermsApi api = LuckPerms.getApi();
Caused by: java.lang.ClassNotFoundException: me.lucko.luckperms.LuckPerms
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:179) ~[purpur-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:126) ~[purpur-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
... 15 more
im literally noob in Java
also that was made with this stuff
fixed
btw
how to make this "metadata" give group's prefix
its almost 4 AM, potato mode enabled
Hey, I currently have a prefix manager plugin compatible with Luckperms via vault ( Which I submitted a pull request for ).
I was thinking on adding direct support for LuckPerms to remove the vault dependency and maybe make it more appealing for LP Users. But I did read somewhere that you guys don't recommend hooking direct into LP but instead using vault
I don't think so? Luck worked hard on the API for it to be used.
if you're planning on making a plugin that ONLY uses LP, no point in wasting time on supporting vault. if you're adding support for multiple permission plugins, vault would be the easiest route.
Uh where did you read that?
There are benefits by using LP API directly as opposed to through Vault (more specifically, you can do things you can't through Vault), but both are perfectly fine, none is particularly encouraged over the other
I'm pretty sure someone in here from the team suggested hooking into vault instead of LP directoy but I could be wrong. I want to directly support LP as well as vault for other permissions plugins
If I use
CachedMetaData metaData = BetterPrefix.getApi().getPlayerAdapter(Player.class).getMetaData(player);
And then do
metaData.getPrefix();
How are multiprefix handled? What if the user is using prefix stacking? Will #getPrefix() return all the prefixes from stacking?
yes
Amazing, thank you!
Man this API is so detailed. my god
No wonder every developer knows LuckPerms is just insane
It's hard to even wrap my head around how stuff is organized to even use the api.
I'm trying to make a loop to get every groups name and weight
how get user perms from specific server?
There's this method you can use https://javadoc.io/static/net.luckperms/api/5.4/net/luckperms/api/cacheddata/CachedDataManager.html#getPermissionData(net.luckperms.api.query.QueryOptions) by passing a QueryOptions that isn't the player's current one, see the QueryOptions builder, there are methods to add contexts for the query
Is the correct way of getting a groups weight to get the permission node weight.<weight>
But I do see Node has a type WeightNode
That's a way, although I think there's API for it
Like a proper way of getting a weight from a Group
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
I believe so. Looking at the wiki
probably something the cookbook has, if not skim the jds
what do I pass in this parameter? java public static boolean hasPermission(User user, String permission) { return user.getCachedData().getPermissionData( QueryOptions.builder(QueryMode.CONTEXTUAL) .mode(QueryMode.CONTEXTUAL) .context(what do i do here?) .build() ).checkPermission(permission).asBoolean(); }
Hey guys i just tried to use the luckperms api but i constantly get the same error
error in pic
This is my code
RegisteredServiceProvider<LuckPerms> provider;
@Override
public void onEnable() {
provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
api = provider.getProvider();
}
}
send code of player oin listener and tablistmanager
are you (soft) depending on LuckPerms
yes
send your plugin.yml
also i'm assuming the Butterfly#getApi() just returns api right
how do you generate it
with net.minecrell.plugin-yml.bukkit
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!
Please use https://pastes.dev to send files in the future. I have automatically uploaded latest.log for you: https://pastes.dev/InEyYfrU14
that is without debug
print if the provider isn't null
Please use https://pastes.dev to send files in the future. I have automatically uploaded latest.log for you: https://pastes.dev/AssKGeOF7z
perhaps you are mistakenly shading the LP API inside your plugin, can you share the gradle build script?
set it to compileOnly
also don't shade in adventrure-api sinc that's already in paper
same for gson
send your build.gradle again
also try a clean build
./gradlew clean shadowjar
or whatever
.
the luckperms dep
oh its in there twice
remove the implementation one
hmm ok i got no error but it isnt working the way i want xD
did you remove the implementation('net.luckperms:api')
yes
ok thx @turbid solar you fixed my problem the rest i have to figure out my self ^^
Hey Space Nerd! Please don't tag helpful/staff members directly.
does anyone know of a luckyperms tap plugin (lucktap)
I need urgently
ok
When adding a group node to a user and saving them, via the luck perms provider, is there a something you need to do to tell like Vault to refresh it's data so the prefixes are updated? When I open the luck perms editor the prefix gets updated instantly, so I think I am missing some sort of invalidate call
hey 👋
you are able to directly interface with the standalone lp client via its HTTP rest api if you want
there are some community made wrappers for it in php and javascript
where can i found info about api usage?
i want to get player metadata (permissions, prefix, etc)
!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.
thanks
this couln't be necessary (for me), i want to use api in forge
the actual api is the same across all platforms
How can i get this using the luckperms api, because i tried using the UserManager#getLoadedUsers() but it returns only the online ones
What are you trying to do
To get the member list of a group
I tried by getting the loaded users and check their parent groups, but it shows only the online players
how can i get the group of a player based on context on Velocity?
right now the only thing i could get from the Velocity API is ImmutableContextSet([world=survival-spawn])
world is the server which hosts the player but the spigot server also has a context
how can i get that context from proxy?
i know that LP Velocity has proxy contexts which are different from spigot ones
i just wanna know which group the player is in from the proxy but without knowing the context it's impossible
use getUniqueUsers
How can i make it async, every time i recover the members the server freezes
I tried using getUserManager#searchAll(NodeMatcher.type(NodeType.INHERITANCE)).thenApplyAsync(uuidCollectionMap -> {}); but it return nothing
If anyones has the same issue, I forgot this needed a messaging service update to, i.e luckPermsInstance.getMessagingService().get().pushUserUpdate(user);
how kann i get the suffix with the api ?
!wiki
Learn how to use LuckPerms and all of its features by reading the wiki.
Hi all. I have a problem with the API. I'm sorry if I'm on the wrong channel and please correct me.
I'm creating a plugin that, in the course of certain actions, grants rights to players. Also, the administrator will be able to take away the rights issued by my plugin.
But my problem is that permissions are not fully granted and taken away and this happens absolutely randomly, and debugging in such cases does not give me any results!
Conditionally, I give the player 5 permissions, and the output of the command "lp user <user> permission info" shows me only 3 permissions. The same thing happens when I try to pick up permissions. As I said earlier, this happens completely randomly: rights can be issued and taken away in full or in part.
I tried to debug my plugin by outputting "DataMutateResult" while I issue permissions. And then I was surprised. When issuing 5 permissions, I got 5 "SUCCESS" outputs in the console, then I immediately entered "lp user <user> permission info" and there were only 3 permissions. Shock!
What am I doing wrong?
P.S. my code = https://pastebin.com/NfWriL8F
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.
Are you adding a group or specific permissions to a user? Like what is your permission parameter values
I'm adding special perms, not a group. As an example, I add: test.perm.1, test.perm.2, test.perm.3, test.perm.4, some.third.perm
I’m not sure without trying. I’d do bulk changes instead and see if that helps
I don't understand what you mean when you say "bulk changes"
!bulk
Quickly update a large amount of user and group permissions by using the bulkupdate command.
Is it possible to do this from the API without using dispatch commands?
Hi all, I'm looking for a method that checks the permissions of the player when he logs in and removes his permissions if they start a certain way, for example, there are permissions that look like this:
"permission.example.{string}"
I would like to remove all the permissions they contain
"permission.example" how can I do?
@frosty laurel if you are adding many permissions consecutively, you might need to add them all in the same modifyUser call, so e.g. have a addPermissions that takes a Collection<String>, and inside the same modifyUser action add them all, rather than call modifyUser for each one
Take a look at NodeMatcher, and the method in NodeMap that takes a matcher
Does this command should work aswell?
lp bulkupdate users delete "permission ~~ deluxetags.tag.%"
Yes, but I didn't believe that a similar function existed, I wanted to do it for all players and therefore I thought of doing it only when he enters but if this solves the problem, it's better
Thx for the help 👍🏻
Unfortunately it didn't help
any idea?
How to set a command that all can use
How to set a command that all can use @thorny echo
Hey Satyam Gaming! Please don't tag helpful/staff members directly.
!usage
Here's a guide to help users understand and use LuckPerms for the first time.
@novel onyx ^
And this isn't the right channel for your question #support-1 #support-2
@jaunty pecan you don't know what could be wrong?
Dont ping.
sry
Hey, how can I best query the remaining time of a rank? I can't use PlaceHolderAPI because I need the whole thing on BungeeCord.
share the current code please
Take a look at how that placeholder fetches the expiry date, then you can do the same in your plugin using the LP API
*I think it's https://github.com/LuckPerms/placeholders
When I find sure
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.
Now I noticed that some permissions are not taken even after executing the unset command in the game....
That is, it works once
I noticed a strange feature: if I have these permissions and I remove them from the game using the unset command, and then give permissions again through the API through my plugin, they are not set...
But... Honestly I don't get it... There are too many variables unknown to me. For example, what is meant by the queryOptions?
QueryOptions is a filter
Which filter? How does it looks like?
I still need help because I don't understand why this is happening.
Is it possible to load LuckPerms as a softdepend?
yes?
The official documentation acquiring the API require that LuckPerms classes are present during runtime. In a setup where a plugin soft-depends on it and LuckPerms isn't present this fails because the classes are missing.
then you should check if LP is enabled and then do your stuff
Yeah it was that simple. Just catching NoClassDefFoundError on acquiring.
I'm losing hope
You mean something like (for example)
* /lp user .. permission unset blah
* /myplugin revoke blah (removes permission via API)
?
I join the game, write the command /test give <mynick> and my plugin gives me permissions. Then I remove permissions from myself with /lp user .. permission unset, and then I try to give permissions again with /test give <mynick> and permissions are given randomly or not at all.
How can i get all useres that are stored inside my luckerms database?
'getUserManager().getLoadedUsers()' gives me only the users that are currently on the server
because only users who are on the server will be loaded
not sure that getting all users is a good idea though. what are you trying to do with that
yeah, I know, but is there a way to get to useres that are not online
I want to get all users from one permission group
I need the list of useres inside a group to show some statistics in with the plugin I want to create.
But when a user get this permission group remove he should also disapear from this statistc system an new users from this group should be shown
getUniqueUsers or something
hello how can you query a permission group? and how can i go out the group the user has?
User user = luckPerms.getUserManager().getUser(event.getPlayer().getUniqueId());
String prefix = user.getCachedData().getMetaData().getPrefix();```
how can I get prefix of highest player's group?
No one knows?
send code
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.
are you ingame when you run the command when it doesn't work?
Please note that this code may work fine, but sometimes it breaks. For example, as I described above, if you give yourself permissions (/tst give <nick>), try to take some of them with /lp user <nick> permission unset <given perm>, then take the rest with / tst take <nick> and try to give yourself permissions again /tst give <nick>, the plugin will not give you all rights or give them randomly
yes
and how are you determining if LP has/hasn't given the permissions?
by performing command like "/lp user <nick> permission info"
You don't save the user after modifying it
modifyUser saves the user already
intriguing
Have you checked this yourself? I am convinced that the problem is either in my code or in the lp api, because even on a clean server such a bug occurs. But like everyone else, I can be wrong.
yeah i've been meaning to check it myself, haven't had the time yet but your code does look correct
I strongly suggest not doing this in either of the takePermission(s) methods
if (!mutateResult.wasSuccessful()) {
takePermission(uuid, permission);
}
If the removal failed, it's most likely because the user didn't have the permission in the first place, and so that will be caught in an infinite loop and messing with saving the data
I suspect that is what's making things misbehave
After I removed this code the situation has not changed.
can you show the new code?
Also, are the commands running in (very) rapid succession?
I changed a LuckPermsManager class only: https://pastebin.com/d8Jy7ess
Commands running by me in the game. I think the execution of the command takes me about 1 second of time, maybe a little less
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.
hello how can you query a permission group? and how can i go out the group the user has?
hello how can i add a group a permission ?
!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.
Hello can Fabric placeholderapi be found anywhere for 1.18 ?
no
theres a few plugins that support PAPI-like placeholders, but there is no common standard like PAPI on bukkit
also entirely wrong channel
I'm gonna be honest, I have no idea what could be wrong then; that recursive thing before was prone to mess up but without it it looks fine now, the code at least shouldn't cause any issues (and like that I also can't reproduce it)
So I will have to create an issue on the github and wait a lot of time until the developer notices my problem
Hey guys, I have a short question:
My plan is to grant a user a group (vip) temporarily.
If the user isn't already in this group it should be added for 7 days but if the user is already in the vip group the 7 days should be added to the remaining time the player has the vip group
This is what I have until now to give the user 7 days of vip but I have no idea how I can increase the time for 7 days if the user is already in the group:
InheritanceNode node = InheritanceNode.builder(vipGroup).expiry(7, TimeUnit.DAYS).value(true).build();
check if they have the group, get the expiry and add 7 days to it
https://javadoc.io/static/net.luckperms/api/5.4/net/luckperms/api/node/Node.html#getExpiryDuration()
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Duration.html#plusDays(long)
declaration: package: net.luckperms.api.node, interface: Node
no
there's an add method in the NodeMap that takes a... Temporal something.
it's an enum to specify that behaviour
How do I add a new permission via the API? I want it to be displayed in the list when using the command
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
!api
Learn how to use the LuckPerms API in your project.
it's explained in the usage page on the wiki, among a few other useful or common things
Already check the API usage page - it doesn't specify this anywhere
look again
You mean like this?
var existingVipGroupNodeOptional = user.getDistinctNodes()
.stream()
.filter(NodeType.INHERITANCE::matches)
.map(NodeType.INHERITANCE::cast)
.filter(node -> node.getGroupName().equals(VIP_GROUP_IDENTIFIER))
.findAny();
if (existingVipGroupNodeOptional.isEmpty()) {
var vipGroupNode = InheritanceNode
.builder(vipGroup)
.expiry(days, TimeUnit.DAYS)
.value(true)
.build();
return user.data().add(vipGroupNode).wasSuccessful() ? PurchaseResult.SUCCESS : PurchaseResult.INTERNAL_ERROR;
}
var existingVipGroupNode = existingVipGroupNodeOptional.get();
if (!existingVipGroupNode.hasExpiry()) {
return PurchaseResult.NOT_EXPIREABLE_RANK;
}
var vipGroupNode = InheritanceNode
.builder(vipGroup)
.expiry(existingVipGroupNode.getExpiryDuration().plusDays(7))
.value(true)
.build();
return user.data().add(vipGroupNode).wasSuccessful() ? PurchaseResult.SUCCESS : PurchaseResult.INTERNAL_ERROR;
That's not what I asked - I want to add it to LuckPerms' permissions registry, same thing as if I added a permission in a plugin's plugin.yml
check the permission using your platform stuff iirc
no way to add it to the list via api
i mean there's the checkPermission in the api, that will trigger it, but it won't really make a difference when using the platform's permission check
ahh didn't saw it, thank you
or.. check for- sure
So more like this, right?
var existingVipGroupNodeOptional = user.getDistinctNodes()
.stream()
.filter(NodeType.INHERITANCE::matches)
.map(NodeType.INHERITANCE::cast)
.filter(node -> node.getGroupName().equals(VIP_GROUP_IDENTIFIER))
.findAny();
if (existingVipGroupNodeOptional.isPresent()) {
if (!existingVipGroupNodeOptional.get().hasExpiry()) {
return PurchaseResult.NOT_EXPIREABLE_RANK;
}
}
var vipGroupNode = InheritanceNode.builder(vipGroup).expiry(days, TimeUnit.DAYS).build();
return user
.getData(DataType.NORMAL)
.add(vipGroupNode, TemporaryNodeMergeStrategy.ADD_NEW_DURATION_TO_EXISTING)
.getResult()
.wasSuccessful() ? PurchaseResult.SUCCESS : PurchaseResult.INTERNAL_ERROR;
looks good
thank you for your help
Question: I am using this code to set/remove permissions https://pastebin.com/RMYKdY3f, but it doesn't seem to work since when I use the luckperms command /luckperms users <user> permission check <permission> it says the permission is undefined so if anyone already had this issue or knows how to fix it it would be helpful, also no errors in console and here is how i register luckperms in my main class https://pastebin.com/6zAk0WhD. Thanks in advance!
if you open the editor, does the node appear there?
sadly no...
dont need to save the user there since modifiUser already does that, where are you doing this code?
is it on the same server?
i just want to add and remove permissions using luckperms
okay not what i asked though
i use the methods in an inventory click event if that helps
wdym like the plugin and luckperms?
!api
Learn how to use the LuckPerms API in your project.
(for me)
for getting the value of a meta key, i should be using Node#getMetaData, correct?
i... is it?
i didn't read it
yeah i can tell
Node metadata != meta nodes
oh, so does metadata just refer to prefixes/suffixes then?
meta(data) nodes are basically extra non-permission information you can store as a permission node
node meta(data) is volatile (doesn't get stored) information, arbitrary objects you can put in a Node object
prefixes and suffixes aren't really meta nodes, but Luck decided they'd fall under the same category lol
I'm back with more stupid questions!!
So, when i run my command /setprefix (https://pastes.dev/FcHBBPf8TK), i pass information to 2 methods - setTokens() (https://pastes.dev/kGolLd2bcp) and setPrefix() (https://pastes.dev/HNM5KEpvDo). setPrefix() then gets information from getTokens() (https://pastes.dev/yR80OPDuzi).
Here's where my issue comes in. 1. in the class where i process the command, the first thing i do is subtract 1 from the token amount. I used 2 different ways of doing this, both ended up with issues. First one MTMain.plugin.setTokens(player, --tokens); would be a hit or miss on whether or not it would actually remove the tokens. had multiple times that it would duplicate my meta key, despite clearing the key value, before adding a new one in setTokens(). the 2nd one (current code) sets back to 0 no matter what i do. (image for context)
is there something i'm actually missing? why is it failing to clear the node, and add a new one? should i be waiting for it to complete before continuing?
||skill issue||
you're probably not wrong. i worked all day yesterday on it, and got what i thought was completely done with it, at midnight. only to test and
this.luckPerms is null
is metatokens 0 after?
yeah, i did verify that it was actually set to 0
uhm, standby. it's acting different now.
doesn't update until i check meta info?
- its not showing 0 at this moment
i have a little issue in dev enviroment loading Luckperms in a Dedicated Server Dist
how can i solvet it?
??
!api
Learn how to use the LuckPerms API in your project.
oh wait... i see
but what is the difference between using forge debof with the curseforge jar and using "the api"??? (technically it is the same)
it's not the same
can you explain me please?
Using fg.debof only allows you to use the code from the jar on development instances, and does not include anything when compiled.
implmentation includes it into your jar
After adding the dependency according to the wiki, it only lets me use it in the IDE but I can't run instances with it.
After reading a bit I see that you do not have support for a modders test environment
that explains a lot, but since using the api is very simple I have no reason to complain
Thanks for the help
a
Luckperms 1.18.2 is not longer supported (for Forge)?
I mean for parches or bug fixes
no, those are not backported
why? i mean... Forge still gives LTS to one of the most used versions (1.18.2)
Forge maybe does, but for LP that means having to maintain several Forge LP platforms for different versions because they are incompatible, which isn't something that's in the project's best interest
Hey is there an easy way using luckperms to not have to struggle with int maxHomes = player.getEffectivePermissions() .stream() .filter(pai -> pai.getPermission().startsWith("athena.homes.")) .mapToInt(pai -> Integer.parseInt(pai.getPermission().substring(15))) .max() .orElse(0);
Aka catching the highest number found with athena.homes.x
use meta
Hi, if Im on server 1 can I get info about player's rank/permissions from server 2 with dev API?
Learn how to use the LuckPerms API in your project.
!cookbook has an example on how to load a user
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
ill try ty
I mean that situation if i have server 'lobby' and 'game' and I want get rank from server context GAME on LOBBy
Can You give me an example?
?
How can i get all the players in a track ?
private PromotionResult promotePlayer(OfflinePlayer player) {
LuckPerms luckPerms = RankManagement.getInstance().getLuckPerms();
User user = luckPerms.getUserManager().loadUser(player.getUniqueId()).join();
if (user == null) {
Bukkit.getLogger().severe("Couldn't promote the player " + player.getName());
return null;
}
Track track = luckPerms.getTrackManager().getTrack("police");
if (track == null) {
Bukkit.getLogger().severe("Track police doesn't exists");
return null;
}
PromotionResult result = track.promote(
user,
luckPerms.getContextManager().getContext(player)
);
luckPerms.getUserManager().saveUser(user);
return result;
}
why this doesn't work after a player logs out and comes back ?
shouldn't this load the player ?
"doesnt work" how?
idk that's why i am confused
Well how have you determined it's not working?
yes
Bukkit.getOnlinePlayers().forEach(p -> {
GuiItem skull = ItemBuilder.skull().owner(p).asGuiItem(event -> {
SkullMeta skullMeta = (SkullMeta) event.getCurrentItem().getItemMeta();
PromotionResult result = promotePlayer(skullMeta.getOwningPlayer());
if (result == null || !result.wasSuccessful()) {
player.sendMessage(Component.text("Couldn't promote the player").color(NamedTextColor.RED));
} else {
player.sendMessage(Component.text(p.getName() + " was promoted to " + result.getGroupTo().orElse("none")).color(NamedTextColor.GREEN));
}
});
gui.addItem(skull);
});
i also use this to make each player head in a gui to promote the suer
again, how have you determined this isn't working?
Without knowing what's wrong, we can't help
i logged out, came back click the button to promote the player and it will print out
Couldn't promote the player
I don't know what the behavior of loadUser when the backing player is already online is, that might be related
User user;
if (luckPerms.getUserManager().isLoaded(player.getUniqueId())) {
user = luckPerms.getUserManager().getUser(player.getUniqueId());
} else {
user = luckPerms.getUserManager().loadUser(player.getUniqueId()).join();
}
then should i do this ?>
culd use modifyUser
well i just want to promote the player using the track not modify the user directly
modifyUser loads the user, does whatever u wnat to do wit huser object then saves it
so something like this ?
private void promotePlayer(OfflinePlayer player, Player sender) {
LuckPerms luckPerms = RankManagement.getInstance().getLuckPerms();
luckPerms.getUserManager().modifyUser(player.getUniqueId(), user -> {
Track track = luckPerms.getTrackManager().getTrack("police");
if (track == null) {
Bukkit.getLogger().severe("Track police doesn't exists");
return;
}
PromotionResult result = track.promote(
user,
luckPerms.getContextManager().getContext(player)
);
if (result == null || !result.wasSuccessful()) {
sender.sendMessage(Component.text("Couldn't promote the player").color(NamedTextColor.RED));
} else {
sender.sendMessage(Component.text(p.getName() + " was promoted to " + result.getGroupTo().orElse("none")).color(NamedTextColor.GREEN));
}
});
}
also is it ok if i pass null as the context parameter ?
nullability annotations should be present everywhere to tell you whether or not that's ok
(on the LP api methods at least)
.
how could i add no context ? would it be luckPerms.getContextManager().getStaticContext() ?
How could i remove someone from a track ? Like the command /lp user godofpro parent cleartrack staff
Hello! I'm having a problem in IntelliJ IDEA. I'm trying to import the LuckPerms library, but I'm still getting an error saying that the library doesn't exist when importing "import net.luckperms.api" in my plugin. package net.luckperms does not exist
use gradle or maven
i use maven
!api
Learn how to use the LuckPerms API in your project.
try restarting your ide
doesnt help
Anyone know ?
send your pom.xml
thx, it fixed, im stupid
!cookbook has some 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.
it doesn't have an example for what i am looking for
I'm getting java.lang.IllegalStateException: Capability missing for UUID-BLAH-BLAH on Forge 1.19.2.
https://github.com/LuckPerms/LuckPerms/commit/62f2fc9714d4fe3227d1037f2ed951db914a5838
does the current build even work on 1.19.2?
No, it’s supposed to, but doesn’t. Getting very frustrating.
The changes received from the web editor were not made in session started on this server! Are you sure you/re running in the right place?
To ignore this warning and apply the changes anyway run
This error comes out when launching luckperm, what should I do?
is it possible to get the luckperms object inside my paper plugin if i installed it in velocity?
i've tried LuckPerms api = LuckPermsProvider.get(); but that didn't seem to work
if i am just trying to get the prefix do i just use placeholderapi?
you have to have LP installed on the servers too, velocity/bungee LP is not a replacement for the whole network
what does lp on velocity do then?
perms on velocity, /send, /server, proxy plugins checking permissions etc
alright thanks
!network usually it's suggested they be linked by storing permissions in a database like mariadb or mongo etc
If you run a BungeeCord network, learn how to correctly setup LuckPerms on all server instances (including Bungee).
Syncing data between servers
is there a way to load user with player name?
User user = luckPerms.getUserManager().getUser(luckperms.getUserManager().lookupUniqueId(username));
thank you!
I am trying to register a placeholder that will print on parse all the prefixes of the groups a player belongs to, but it returns nothing on parse
private LuckPerms luckPerms;
public LuckPlaceholder() {
this.luckPerms = LuckPermsProvider.get();
}
@Override
public @NotNull String getIdentifier() {
return "groupprefix";
}
@Override
public @NotNull String getAuthor() {
return "YourName";
}
@Override
public @NotNull String getVersion() {
return "1.0.0";
}
@Override
public String onPlaceholderRequest(Player player, @NotNull String identifier) {
if (player == null) {
return "";
}
if (identifier.equalsIgnoreCase("allprefixes")) {
return getAllGroupPrefixes(player);
}
return null;
}
private String getAllGroupPrefixes(Player player) {
User user = luckPerms.getUserManager().getUser(player.getUniqueId());
if (user == null) {
System.out.println("User not found");
return "";
}
ContextManager contextManager = luckPerms.getContextManager();
ImmutableContextSet contextSet = contextManager.getContext(user).orElseGet(contextManager::getStaticContext);
QueryOptions queryOptions = QueryOptions.contextual(contextSet);
StringBuilder prefixes = new StringBuilder();
// Regex pattern to match prefix meta keys
Pattern prefixPattern = Pattern.compile("^prefix\\.\\d+\\..+$");
user.resolveInheritedNodes(queryOptions).stream()
.filter(node -> node instanceof MetaNode)
.map(node -> (MetaNode) node)
.filter(node -> prefixPattern.matcher(node.getKey()).matches())
.sorted(Comparator.comparingInt(node -> Integer.parseInt(node.getKey().split("\\.")[1])))
.forEach(node -> {
System.out.println("Adding prefix: " + node.getMetaValue());
prefixes.append(node.getMetaValue()).append(" ");
});
return prefixes.toString().trim();
}
}```
hopefully someone will have an idea as to why
How/Where can I learn to grab a members tempperm time left, then add say a day, and then update their permission?
try looking at the source code for the command that adds a temp permission. there is an option for it to add time instead of replacing the time left
see ^
Any help on this? Makes LP useless on 1.19 Forge platform.
Hi! Did anyone use LuckPerms Forge version as api in other mods? Or i should use ForgePermissionsAPI to work with permissions?
if you simply want to do permission checks, use forges permissions api
Do you have some usage examples for Forge Permissions API? Looks like it isn't compatible with 1.19.2, nothing in their docs
Thank you!
I am using the luckperms api, added this is my dependency's:
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.4</version>
<scope>provided</scope>
</dependency>
But it drops the error:
Dependency 'net.luckperms:api:5.4' not found
After refreshing 😦
try restarting your ide
Hey, so i want to show the Players group prefix in the tablist with the LuckPerms API, but it doesn't work. here is my code for that
LuckPerms api = LuckPermsProvider.get();
String prefix = api.getGroupManager().getGroup(api.getUserManager().getUser(player.getUniqueId()).getPrimaryGroup()).getCachedData().getMetaData().getPrefix();
thats the code
do you have a prefix set
yes
screenshot /lp user <user> info
also just get the prefix from the user insterad of their group
String prefix = api.getGroupManager().getGroup(api.getUserManager().getUser(player.getUniqueId()).getPrimaryGroup()).getCachedData().getMetaData().getPrefix();
if (prefix == null) prefix = "";
now it works.. thanks :)
getNodes(NodeType.PERMISSION)
Does this include inherited permission nodes, or is it a set of the nodes applied specifically to the player?
inherited nodes i presume
that will give you the holder's own permissions, not inherited ones; what are you trying to do exactly? depending on that you might want to use one or another method
ive a string, and what i want to do is
if(player.haspermission(query)) return;
player.setPermission(query)
im not sure how the node internals work
so idk if resolveInheritedNodes(...).findFirst(PermissionNode.builder(query).build()) works
or contains IG
to perform a check you usually want to do that against the cached data (getCachedData getPermissionData check.. or something), and to add a permission you do that through the NodeMap (data add(PermisisonNode.builder...))
whats a tristate
the permission can be explicitly set to true, false, or it can not be defined at all
so the result is one of those three states
its annoying how undescriptive the method names are
there's javadocs
well i was looking at the api
your IDE should provide the jd
hm? like what?
nope
i didnt realize tristate was an enum
uh right
i mean there isn't really a better name for "result from one of three states"
tristate is just Null<Bool>
honestly the biggest issue i have with the api now is that the jd isnt showing up
so i have to tab between my IDE and my webbrowser lol
well that sounds like an issue with your ide
i mean ur not wrong
what ide are you using
netbeans intelliJ
i mightve overlooked something
hm
theres no mention of an extra dependency for the jd
netbeans? 
How do you have a group's colour set to something?
I'm using Meta Prefix in my code at the moment but I just want
a colour code instead of the entire prefix.
i set group-color for each group
So you set the colour in-game and what do you do from then?
get the meta value & parse it
parse the last color code from the prefix IF group-color is not set
I have a small question. Is it possible to create a plugin with the base of LuckPerms? If so, how should I start to enable a simple /Join GROUP?
LuckPerms .hasPermission() causes lag when player joins, how to fix? My database ping is pretty high
300ms
Looks like it takes time to load cache data and .hasPermission() happens before the cache data is loaded
Which causes lag
Is there anything I can do about this? Some of the plugins that do this are not open source
Maybe changing pool size can speed up the loading process
whats the package name of Luckperms in Bukkit?. i see is quite different on forge
hallo
im kinda confused uh
does filtering through user.getNodes() only return player-specific perms?
or does it also go through their groups' permissions
I assume it doesn't, and if so, any way to get a list of player's permission that includes their personal perms + perms inherited from groups?
there are a few methods that return different things, what do you need to do with it?
specifically need to get all permission that start with "visitors."
.filter(NodeType.PERMISSION::matches)
.map(NodeType.PERMISSION::cast)
.map(PermissionNode::getPermission)
.filter(perm -> perm.startsWith("eprealms.visitors"))
.map(perm -> perm.replace("eprealms.visitors.", ""))
.map(Integer::valueOf)
.toList();```
this is what i was doing
i can get all their groups and do that manually but I was just wondering if there's a way to do it directly from the api
That sounds a whole lot like you should use meta nodes
Meta nodes are basically arbitrary key-value storage but the meta cache is designed for fast retrieval
right
How do I get a list of perms from players starts with something?.
Read the conversation right above
