Learn how to use the LuckPerms API in your project.
Example usages
1 messages ยท Page 29 of 1
Learn how to use the LuckPerms API in your project.
^ (for me)
I'm trying to add/remove a user to/from a group via the API
Ok so you need help getting an instance
Ok so really it is rare to pass a instance of your plugin to an API as they don't really care about your plugin
Here is the link I will be referencing: https://github.com/lucko/LuckPerms/wiki/Developer-API
Do you have the dependency setup Josse?
(In maven, gradle, etc)
I just downloaded the .jar file (LuckPerms-Bukkit-5.1.63.jar) and added it as a library in Eclipse using "add external jars"
Ah not as familiar, if you are going to continue development I would recommend learning maven, it makes workplace management a lot easier
As long as you can see recommended tooltips you should be fine
Anyways if you look at the wiki you need to check with Spigot's RegisteredServiceProvider
Yes
The wiki spoons it to you like so:
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
LuckPerms api = provider.getProvider();
}```
larry its on the wiki mate
I know
blame luck for the spoposn
that's why I'm spoon your message
lmao
because you're spoonfeeding Josse instead of just like linking the exact part of the wiki that clearly explains this ๐
ig thats true
โค๏ธ
but ๐ฅ
Yeah I think I actually got it to work now
coolio
Thank you ever so much!
np
Oh yeah: is there a way using the LuckPerms API to check for the permission of an offline player, or do I need to use Vault for that?
you just load them and then check the perm
how to check if player has group in a way that includes inherited groups
& also takes into account context?
like
can i do this except without including ops and *
well, only ops is relevant tbh
dont think any group has * perm
Yall how would I give a permission to a player?
thats a command tho?
It's an example
ah
Hi @jaunty pecan, is not about the API, I want to know if you have any lightweight API for downloading dependencies at runtime, I saw that you have it at the Luckyperms but is builtin for the plugin or you use other library?
I'm asking this because the Maven Library from apache (aether + maven) is a hole 8mb and I want something more lightweight
Hey DevSrSouza! Please don't tag helpful/staff members directly.
Sorry old Clippy
Tkx
This work outside Minecraft ?
I want to use in a IntelliJ plugin too, not just the plugin
I'm working on a script system with Kotlin scripting and it will be fully supported in IntelliJ
yep should do
This library do not resolve dependency graph, right?
nope
is there any way at all to check if a player has a group while excluding ops?
Ops have no relation to luckperms unless you use the autoop system, in which case you exclude anyone with the node luckperms.autoop
Is it possible to set a permission false for an op-user? Or should I just deop them?
it is possible, but the better way is to use luckperms.autoop because that effectively ops them but it is controllable as a permission and not externally of LP
https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/commands/AddPermissionCommand.java
Thanks alot for that
Hi, I'm sorry, it's me the LuckPerms baby here again, but I just appear to be stuck and I don't know what I'm doing wrong... Why does this code not change the group from a user which is in the group "admins+" (which is a child of "admins") to "admins"?
User user = luckPermsApi.getUserManager().getUser(playerToReply.getUniqueId());
user.setPrimaryGroup("admins");
luckPermsApi.getUserManager().saveUser(user);
Larry: I meant that group.<group> will return true for ops
is there a way to check if the player has the group without including ops?
&& !Player#isOp()?
Hello everybody! Is there a possibility to set a bungee group via a bukkit/spigot plugin?
If they are synced: Yes
Hello, I know there is a way to do this, however Iโm new to the LuckPerms API; but how would a person check if a player in a group, and then if itโs true I may get that groups display name.
@umbral wagon synced as in the LP instances use the same database server (including the same table prefix)
@umbral wagon synced as in the LP instances use the same database server (including the same table prefix)
@crystal sonnet okay thanks for the information ^^
Hey JacksonUndercover! Please don't tag helpful/staff members directly.
@trail token the 5.1 API has getters for the groups a player is in
Ah ok thanks!
You're welcome
how to connect permission luckperms with my plugin?
!api @wanton drum
Learn how to use the LuckPerms API in your project.
Though what exactly do you want to do?
I am doing this plugin: https://github.com/kubab16/CrystalTeleport_v-1.9.20
and i want to check with lucky perms the player has permision
!api
Learn how to use the LuckPerms API in your project.
@wanton drum why not check permissions with the platform?
I try but this not work ๐ฆ
obligitory why are your method names capitalized
Also you should prefix your permissions as to not to collide with other pluigins
the normal format is pluginname.permname
Why when I do getLuckPerms().getUserManager().getUser(userName) it returns null only for some players? Usually, it works for those particular players when they are online, but if they log off, it returns null, even though they are registered with a rank in luckperms
!api You have to load them if they're not loaded already. There should be an example on that page:
Learn how to use the LuckPerms API in your project.
any idea why does LP 5.1.64 sometimes return null when called on an online player?
i just got a report from my user
LuckPermsProvider.get().getUserManager().getUser(p.getUniqueId()) returned null
Under what circumstances?
Like were they online on the bungee network but a different server?
i don't have this information, however it appears to be a single bukkit server, not a network
WEll you can try to always load the player
Like if you're in an async thread use loadUser(xxx).get()
That'll guarantee that it's always loaded
public void onLeaveBed(PlayerBedLeaveEvent event) {
Player player = event.getPlayer();
String name = player.getName();
player.sendMessage(name "died because he left his bed, what a noob!");
}
this isnt working ):
This isn't general plugin programming support
And you didn't tell what's wrong
And lastly name "died ...
C'mon
What a unique way of doing concatenation. Downright ignore it
That's almost the C way of compile time concatenation
Hello !
I'm looking for get UserDataRecalculateEvent on bukkit but don't find how to register it ...
Can someone have an example please ?
@severe cedar https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#listening-to-luckperms-events
How do I get the prefix of a group?
!API one of the first examples on this page iirc @dense shale
Learn how to use the LuckPerms API in your project.
I'm a new spigot plugin developer so I'm a bit lost with the api
I know that to load a offline player, it requires future
But if I got a command that the parameter can be both online and offline player, and I have to check if they have the permission (which returns boolean or future boolean)
Do I have to build another command for offline player only or is there a way to do it in one command only?
You can check if a user is loaded using UserManager#isLoaded
So if the offline player is not yet loaded, start loading it?
But it's future user... so how do I use it as a User in onCommand..?
You can use CompletableFuture#join or CompletableFuture#get. These block the current thread tough, meaning you have to wait for the user to load (which can take some time)
so loadUser(UUID).join() will do?
User user;
if(p.isOffline) { user = loadUser(UUID).join() }
else { user = getUser(UUID) }
checkPerms(user);
addPerms(user);
in onCommand
Seems ok
(But make sure you either have a getUser and loadUser method or use LuckPerms#getUserManager to get one and then call the methods on it)
Thank you ><
They do the same thing but I wonder which one better
(from wiki)
public boolean hasPermission(User user, String permission) {
ContextManager contextManager = luckPerms.getContextManager();
ImmutableContextSet contextSet = contextManager.getContext(user).orElseGet(contextManager::getStaticContext);
CachedPermissionData permissionData = user.getCachedData().getPermissionData(QueryOptions.contextual(contextSet));
return permissionData.checkPermission(permission).asBoolean();
}
(checked javadoc and try it myself)
NodeMap playerData = luckPerms.getUserManager().getUser(player.getUniqueId()).data();
PermissionNode permission = PermissionNode.builder("test.perm").build();
playerData.contains(permission, NodeEqualityPredicate.EXACT).asBoolean()
@severe cedar https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#listening-to-luckperms-events
@lucid rapids thank u so much
Hello, I have problem with the API
I have on server HUB (on proxy BungeeCord) and i have this code:
THE FILE
And in BungeeCord console it throws this:
java.lang.NoClassDefFoundError: net/luckperms/api/node/Node
In BuildPath i have LuckPerms the newest version for Bukkit (i tryied BungeeCord version but nothing)
Please use https://bytebin.lucko.me to send files in the future. I have automatically uploaded message.txt for you: https://bytebin.lucko.me/zI2qcLhjis
What version of LuckPerms do you have? @obtuse flame
On 1.15.2?
1.8 and only 1 server is 1.13.2.
Ah
i have 5 spigot servers running on BungeeCord proxy server
And i making plugin for BungeeCord
In /plugins in BungeeCord i dont have luckpers
luckperms*
Why don't you use the Bungee platform method for that?
bc it didnt work, :/ thats why i have on every server LP Plugin connected with MySQL Database
Right, if you don't have LP installed on Bungee the method is also not gonna work.
But LuckPerms API can't work then too
Hey GigaAdamYT! Please don't tag helpful/staff members directly.
@frank drift Sorry :DDD XD
Hey! Whats wrong here? user.setPrimaryGroup("admin");
It returns FAIL every time.
Not 100% sure but pretty sure it takes in an group object
https://image.sv-studios.net/37fa513d5376120478e53b91749e4cf7e.png It says String here.
hi does anyone know how to get the editor to propose my custom contexts? which method to implement? custom contexts are working, but i can't make the editor to propose them :p
Are they working when tab completing?
So I tried to add the permission to the player
add(PermissionNode.builder(permission).build()
And when I check from /lp user Player permission info ,
that player has no permission set....
But isn't the permission added to user?
Once you add the permission, I think you must save the user
NodeOh I think I didn't save the user..
If you're using 5.1 you can also use modifyUser
user.modifyUser((User userToEdit) ->
// add etc, saves automatically
);
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by me.lucko.luckperms.common.dependencies.classloader.ReflectionClassLoader (file:/E:/DebugServer%201.16.1/plugins/LuckPerms-Bukkit-5.1.26.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of me.lucko.luckperms.common.dependencies.classloader.ReflectionClassLoader
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Somehow I got this warning when I was starting the server
Ok~
@neat jackal @dawn orchid Just fyi loadUser will only ever load the user if they are not loaded already. Meaning if they are loaded itโll just return them. So no need to check if theyโre online or not.
Is there a way to edit a meta node's value using lp 5.0+?
Learn how to use the LuckPerms API in your project.
I looked for it and couldn't find anything about it
Have tried just replacing the node?
String value = user.getCachedData().getMetaData(luckPerms.getContextManager().getQueryOptions(user).orElse(luckPerms.getContextManager().getStaticQueryOptions())).getMetaValue("home-count");
if (value != null) {
user.data().remove(MetaNode.builder("home-count", value).build());
user.data().add(MetaNode.builder("home-count", "" + (Integer.parseInt(value) + 1)).build());
this is what I did
but i'm guessing this is wrong because data() is not the cached stuff
aka when I check the meta of the player, it won't change
Are you saving the user after you edit them? Pretty sure you gotta do that
how do I do that then
Oh I just saw something
That's for saving ^
Np! Sorry I'm not actually too familiar with the API of LP, just regurgitation of what I've heard before 

Fetching a group via a String (configurable then) then modifying the user
i'm trying to assign a user a group when they join based on what hostname they connect with, i'm running a plugin which runs on my bungee and the rank get assigned correctly however players join the server too quickly and the group is not updated until right after they spawn. I have an event being triggered on join on my lobby servers to test for rank x or rank y to change where they spawn and they do not have the rank upon immediately joining. what can i do, can i have them wait on "Logging in..." a few seconds longer somehow?
can someone explain why i can't call signalContextUpdate, is then even needed? Would this work? Do i need my ContextCalculator on both proxy & normal servers?
hello i have a bungeecord server
witch server do you set the luckperms bungeecord PLugins or
al the server
@crude plover please do not post in a bunch of channels
sorry @rustic laurel
Hey brandweermann! Please don't tag helpful/staff members directly.
loll
Hi guys wondering if someone can help me, I'm trying to see if an OfflinePlayer hasPermission but there is no method
I've found the playerHas(world, OfflinePlayer, permission) method here with Vault but don't know how to access it or if its supported with luckperms https://github.com/MilkBowl/VaultAPI/blob/master/src/main/java/net/milkbowl/vault/permission/Permission.java
Use the Luckperms API; you load the user, then check, then modify if you want, then save them
@rustic laurel i'm struggling on how to load the user
Hey Vaape! Please don't tag helpful/staff members directly.
i have an instance of the api but dont know what method
to use that loadUser method I need a Player instance though
I can only get an OfflinePlayer instance because idk they're online
ah theres an explanation underneath
@earnest ferry make sure you save the changes
Its actually working with my custom ContextCalculator on both servers- it works for permissions with context but not groups (unless the group with context is directly assigned to the user), is it not possible to add "group.exampleA" with a context to the default group?
using luckperms api?
oh bad channel
hi guys, i just want to know if a player (either offline or online) is in the group "iron" but I'm getting stuck on the last hurdle
the error on thenAcceptAsync is "The method thenAcceptAsync(Consumer<? super String>) in the type CompletableFuture<String> is not applicable for the arguments ((<no type> result) -> {})"
and the errors on the return lines say "Void methods can not return a value"
If a user is online, use the Player#hasPermission("group." + groupName)
if not, load the user and do the same thing
if you are loading the user it would be User#hasPermission
@orchid widget
how can i do that async because it says it lags the server if its not async
All loads and database inquiries are by default async
So when you use a completableFuture on the loaded user, it will be async
there is no hasPermission method for User @short fossil
Ah was looking at wrong javadocs
Well you can stream through the user's groups and check from there
just filter with inheritance nodeType
as i tried to do in my initial screenshot
but i dont know how to format it to get my result
No, you tried to get their primary group, which will not work in all cases
in which cases will it not work?
If a group has a lower priority
i only have 1 track on my server
and they're linear priority, it should work for my server in all cases
Yes but will a player ever have more then one group?
nope
Then I guess you could, though it is bad practice, your problem in your code is your async usages
how can i fix that?
Easiest and most efficient way is to just stream through groups with inheritance, it provides a more robust usage and is 100% outlined in the wiki
great where abouts on the wiki
๐
What API version do you use?
LuckPerms-Bukkit-5.1.26
I'm fairly new to plugin development, so... I'm currently using Eclipse and Java (I know some poeple use Kothlin).
I've made a bungeecord (proxy) plugin, and I was wondering how I would fetch a user's primary/active prefix.
@ me
hey guys, can anybody tell me (or just give me a Method xD) how I can add permissions to Users using the Luckperms API?
Im on Bukkit 1.8
I think this could help: https://luckperms.net/wiki/Developer-API-Usage#modifying-usergroup-data
thank you very much
hey,
Is there an event that is called when a player's group is changed using the Luck-API?
Hey, where i can update the player with the api, when i change the group, the player must rejoin but with command it will be set directly
Can anybody help me
i'm having a lot of trouble understanding and navigating the docs. could someone help me set a prefix or a player and add a parent to a player?
or just point me to the part of the docs that shows that?
LuckPerms api = LuckPermsProvider.get();
User user = api.getUserManager().getUser(uuid);
the only methods i can find are like setprimarygroup
but i just want to add a parent
and add a prefix
sure
but now
UserManager user = (UserManager) api.getUserManager();
user.modifyUser(uuid, );
user.modifyUser(uuid, );
is this the right thing to do to add a prefix, and to add a parent group to a user?
i'm trying to do
lp user <uuid> meta setprefix <prefixWeight> <prefix>
and
lp user <uuid> parent add <rank>
i'm just not sure what the action is meant to be?
@warm garnet Here's an example of how to add a prefix: https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/commands/SetPrefixCommand.java. I you don't care about removing a user's other prefixes (Their prefixes, not the group prefixes), just omit the user.data().clear(NodeType.PREFIX::matches) line. As for how to add a parent, your best option is to use the UserManager#modifyUser method. An example for that would be:
Group admin = luckperms.getGroupManager().getGroup("admin");
luckperms.getUserManager().modifyUser(player.getUniqueId(), (User user) -> {
Node node = InheritenceNode.builder(admin).build();
user.data().add(node);
}
That example loads the admin group, then builds group.admin inheritance node and adds it to the user.
How can i refresh a player that the server load the perms from the player?
it isnt automatically
When i set the rank over the api
It should almost definitely be automated. Can you show the code you're using to add the rank?
like this?
api.getUserManager().modifyUser(player.getUniqueId(), (User user) -> {
// Remove all other prefixes the user had before.
String prefix = "[test]";
user.data().clear(NodeType.PREFIX::matches);
// Find the highest priority of their other prefixes
// We need to do this because they might inherit a prefix from a parent group,
// and we want the prefix we set to override that!
Map<Integer, String> inheritedPrefixes = user.getCachedData().getMetaData(QueryOptions.nonContextual()).getPrefixes();
int priority = inheritedPrefixes.keySet().stream().mapToInt(i -> i + 10).max().orElse(10);
// Create a node to add to the player.
Node node = PrefixNode.builder(prefix, priority).build();
// Add the node to the user.
user.data().add(node);
Group group = luckperms.getGroupManager().getGroup("test");
Node node = InheritenceNode.builder(group).build();
user.data().add(node);
});
It refreshes the perms only when the player rejoint
Ryan can you say me how to update the player?
Hey Blyrex! Please don't tag helpful/staff members directly.
In your config, can you checked what your value for sync-minutes is please?
@warm garnet That looks fine to me
its -1
Alrighty, that's fine then. Do you mind uploading your config here, just be sure to omit any storage credentials
If you upload the file itself, clippy generates a link
since i am specifying the prefix weight as i would do with lp user <uuid> meta setprefix <prefixWeight> <prefix>, can i remove this?
Map<Integer, String> inheritedPrefixes = user.getCachedData().getMetaData(QueryOptions.nonContextual()).getPrefixes();
int priority = inheritedPrefixes.keySet().stream().mapToInt(i -> i + 10).max().orElse(10);
Yeah, finn
Im using MySQL. First i have runned a command over bungeecord. There the player gots the rank directly. But when im using the api over bungeecord, it updates when the player switch the serve
How can i update the player?
The command does this
๐ฉ
thanks!
Ahhh okay, just to check, do you have messaging-service configured on all your servers?
That's why it's so strange. If the command is always syncing data, so should the API when you're saving the user.
What version are you using?
The latest
And when you do /lpb user <user> info and /lp user <user> info, do the UUIDs match?
Yes
Its synced
With my prefix system. When im using /lpb, the rank and the perms updates directly on the subserver (spigot), but when im saving the user with the api, its shows the new rank on /lp and on /lpb, but it dont refresh the perms
I'm wondering it this is actually an internal issue, because that behaviour is far too strange. Just to check, does luckperms.getMessagingService().pushUpdate(); result in the perms being refreshed?
or I suppose luckperms.getMessagingService().pushUserUpdate(user); for that matter
Ahhhh, wait, it appears this may be intended behaviour. As per this comment https://github.com/lucko/LuckPerms/issues/1917#issuecomment-573329804 My bad if that's the case
Awesome!
Hello! It is quite a basic question but I never manipulated Stream and I am currently a bit overhelmed ahah.
Actually, I just need to know if a player have a permission node in his collection, examples from the LuckPerms API wiki clearly look too much for what I want
As an example, I just need to check if an user have the following permission node: mymod.subgroup.permission
(the nodes I am creating are not singleton, so I believe I cannot do a contains() call)
Why do you need to do an LP API call for that?
if (yourPlayerObject.hasPermission("Whateverpermission")) {
//your code
} else {
//do smth else
}```
If I remember well, hasPermission is coming from PermissionAPI (I am working with forge), and this embedded api does not handle per-player permissions but only "ALL", "NONE" and "OP"
I need to check if a specific player has a PermissionNode, but for now I am getting a bunch of problems with null uuid
(I have been using iterator instead of lambda calcul, but its not the best for the software complexity - but this part is working for now tho)
Ah yeah, I would only use my way on a Bukkit/Sponge server then
hello, question, my plugin's permissions don't appear in LP's verbose and bukkit's PermissionDefault.TRUE seems to not take affect with LP (as in, the player should have that perm by default). is there anything I can possibly do to make them always appear and PermissionDefault work?
Specify in your plugin.yml that the permission should be assigned to players by default?
the plugin.yml's permission syntax is wayy too verbose.. i can do it if it's the only choice, but is there nothing else?
like, i have a constant Permission(node, PermissionDefault.TRUE) object for each command and subcommand
Where do you use the Permission(node, PermissionDefault.TRUE)?
well, essentially it's annotation-based subcommands, so i have an enum which contains all permission nodes and an optionally defined PermissionDefault in the constructor. it constructs the Permission if a perm node string is not null (if null then basically having this permission enum on a subcommand means it requires no permission at all), and inside that same enum it has a high-level method similar to bukkit's hasPermission, which checks if this enum value has a permission and then tests if the player has that permission.
How can i add a permission easy to a user
how do I get an instance of luckperms? The line luckPerms.getUserManager().getUser(player.getUniqueId()); is throwing an error and I don't know what to import
You want to get an instance of LuckPerms yet your code is trying to get a User instance, which is LPs Player encapsulation class. Which are you actually trying to get?
End goal is to get a user instance
but don't I need an instance of luckperms before I can get an instance of the user?
Apologies. It would appear I'm illiterate. Reading Github more closely helps a lot ๐
Haha
Hi. Does luckperms have player group changing event? I just want to remove some player data, if his group changed from vip/mvp to "player"
Tag @ me if you know.
!API @woven frigate I believe so, the javadocs here should tell you for sure
Learn how to use the LuckPerms API in your project.
@nocturne elbow no ads please
Ok
Anyone can explain me how can i remove a MetaNode?
I'm trying with
User user = loadUser(player);
Node node = Node.builder(metaKey).build();
user.data().remove(node);
....saveUser(user);
But nothing happens :S
https://hastebin.com/wenasobefi.sql
I'm trying to load in LuckPermsAPI through maven, and it gives me this error.
Does your plugin happen to load at startup?
Also depending on LuckPerms should fix this
@azure latch now it's fixed.
But I got 1 more question, how do I add a permission node through the API?
How would I check if a player has a group using the API?
!api likely has the info you need
Learn how to use the LuckPerms API in your project.
I am fully aware that the API has what I need, just wondering how I can access it
or possibly the API cookbook, see pins
Found it, thank you.
Hey there, does anyone know a good auto rank plugin, that workes with a timing setup?
For 1.16.1 that workes with LuckPerms
Hello ! I think it's a quite simple question, but i could not find the response so far : how can I filter User::getNodes() (or any user way) to get only nodes that applies to his contexts ?
(like a getNodes() with an QueryOptions argument)
Have a look at https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#the-basics-of-cacheddata
Hey,
Is there an event that is called when a player's group is changed using the Luck-API?
I believe there is, you should take a look at the javadocs found on the API wiki
!api
Learn how to use the LuckPerms API in your project.
!lp
Sorry! I do not understand the command !lp
Type !help for a list of commands.
!permission
Sorry! I do not understand the command !permission
Type !help for a list of commands.
!help
!advanced
!api
!argumentbased
!ask
!bulkupdate
!bungee
!cauldron
!chat
!colours
!commandequivalents
!commands
!config
!context
!default
!downloads
!editor
!errors
!essentials
!extensions
!extracontexts
!faq
!helpchat
!inheritance
!install
!locale
!meta
!migration
!notworking
!nowildcard
!pasteit
!permissions
!placeholders
!selfhosting
!stacking
!storage
!suggestions
!switchstorage
!sync
!tracks
!upgrade
!usage
!userinfo
!verbose
!weight
!whyluckperms
!wiki
!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.
!config
Learn what each of the config options are for.
Any ideas as to why LuckPerms won't give all users in a for loop? I've tried using ModifyUser and the CompletableFuture but LuckPerms seems to sometimes just not modify the users groups. It sometimes works with all their groups, sometimes only a few
First attempt:
private static boolean addGroupToPlayer(String groupName, OfflinePlayer player, boolean isGlobal) throws InterruptedException, ExecutionException, TimeoutException {
LuckPerms permissions = MinecraftCpas.getPerms();
Group group = permissions.getGroupManager().getGroup(groupName);
if (group != null) {
CompletableFuture<User> userFuture = permissions.getUserManager().loadUser(player.getUniqueId());
userFuture.thenAcceptAsync(user -> {
if (isGlobal) {
InheritanceNode node = InheritanceNode.builder(groupName).withContext(DefaultContextKeys.SERVER_KEY, "global").value(true).build();
user.data().add(node);
permissions.getUserManager().saveUser(user);
} else {
InheritanceNode node = InheritanceNode.builder(groupName).value(true).build();
user.data().add(node);
permissions.getUserManager().saveUser(user);
}
}).get(10, TimeUnit.SECONDS);
return true;
} else {
return false;
}
}```
Second attempt:
public void assignGroup(UUID id, String group) {
// Initialize LuckPerms API
LuckPerms api = LuckPermsProvider.get();
Group lpGroup = api.getGroupManager().getGroup(group);
if (lpGroup == null) {
Maul.log.warning("Maul assigned admin group does not exist!");
return;
}
api.getUserManager().modifyUser(id, (User user) -> {
Node node = InheritanceNode.builder(lpGroup).build();
user.data().add(node);
});
}```
I believe there is, you should take a look at the javadocs found on the API wiki
Thanks for your help... I found an event - it's calledUserPromoteEvent- but I think it only works with tracks, doesn't t?
Hey TurtleSkills! Please don't tag helpful/staff members directly.
Yes I do believe so
Thanks, it works ๐
I think when a group is added to a player there is a node (?) Added to them
There is a nodeaddevent
In case you don't want to have to use tracks
Sooo i have a question probably dumb but how user.getPrimaryGroup works was looking at the docs but i dunno if it gives prefix group node or just the primary group name
Primary group name afaik, or displayname if one is set
thank you
Is it possible to add a perm node to a list of players?
in java?
List<SuperiorPlayer> members = SuperiorSkyblockAPI.getPlayer(player).getIsland().getIslandMembers(true);
basically trying to use this list of island members, to be added with a permission node.
@twin mauve sure it is, use a forEach
members.forEach(member -> {
//get LP User, add permission
})```
@azure latch am i getting my list right?
because it dont work...
there isn't any errors.
if anyone could help with this at all i would appreciate it so much
๐
Hey there, I am writing this message as a request to all of the LuckPerms developers..
My request is to please start working at an auto-ranking sistem for the plugin, based on time or experience..
Thank you for the consideration to anyone that will consider this request..
it will never get actually implemented
!suggestions is prob a better place
If you would like to request a feature for LuckPerms, or report a bug, feel free to open an issue on GitHub!
as if whether it will be implemented is up to the dev (those with red very unlucky tags)
Hi!, how can i see all group assigned to an specific user?
I think with user.getInheritedGroups(), but i don't understand how QueryOptions works
Thank!
There are some examplews there
thank you
@twin mauve just saw your message, what code you got? Upload it to hastebin or https://bin.katsumag.me/ please
Hi i have a problem creating a group. I create if with groupManager.createAndLoadGroup(groupName);
The group is create but i cant delete it. If i try to use groupManager.deleteGroup(group) nothing happens and if i try to delete from the Web Site when a apply the changes the log says that the group are removed but if i check it the group still there.
In both cases the group only lose the permission nodes.
Anyone know about ?
Please use https://bytebin.lucko.me to send files in the future. I have automatically uploaded message.txt for you: https://bytebin.lucko.me/J4n6dLfdhY
This is the log of my test server. If i remove any group with a custom command are deleted success but if i only generate a link to edit the permission from the site or i try to delete another group by the console , the deleted groups appear again.
Is there a way to update a existing meta node through the API? When adding a meta node with the same key but different value, it doesn't get rid of the one before.
user.data().clear(testNode -> testNode.getKey().equals("cc-value"));
I also tried clearing any nodes which matched the key but that did nothing either.
ah okay, I misunderstood what get key was. fixed by doing
user.data().clear(testNode -> testNode.getKey().startsWith("meta.cc-value."));
Hi i have a problem creating a group. I create if with
groupManager.createAndLoadGroup(groupName);
The group is create but i cant delete it. If i try to usegroupManager.deleteGroup(group)nothing happens and if i try to delete from the Web Site when a apply the changes the log says that the group are removed but if i check it the group still there.In both cases the group only lose the permission nodes.
Anyone know about ?
Does LuckPerm have a cache or something like that causing the problem? I delete H2 DB files but the problem persists.
!api
Learn how to use the LuckPerms API in your project.
I found what it's wrong with the groups problem but i don't know how can i fix the corrupted groups.
I has the next code to set a permission node into a group.
groupManager.modifyGroup(groupName, (Group group) -> {
for(String permission : permissions) {
PermissionNode node = PermissionNode.builder(permission).build();
group.data().add(node);
}
});
When i use a group name with some upper case and try to add a permission the permission doesn't add to this group and the group gets corrupted.
I solved that only adding .toLowerCase() to "groupName" but this solve the future groups but no solve the created groups that are corrupted.
Anyone know, How can i solve it? i think it's a problem with the temporally nodes but i don't know con can i remove they or something like that.
is there a 'permission' that a player always has? like, not a specific node, but say for example, would this ```java
player.hasPermission("")
I know this aint about the api, but I felt it would be the most relavent place to ask about generic permission stuff for java
Try it.
How can i give a player a permission node?
would it work similarly to a group assignment?
https://github.com/LuckPerms/api-cookbook some examples there
Thanks!
Hi, I was using LuckPerms
But the API changed
What would be the new events?
I was using this UserDemoteEvent and UserPromoteEvent
Learn how to use the LuckPerms API in your project.
Any recommendations for storing permissions data for players that haven't logged in yet? atm I load user from the UUID then completeAsync removing their data, adding a specific accepted group, then saving the user. It works, however for every few users that are added (every 3-4 UUIDs) it adds a second worth of lag for LP pulling up the editor with /lp editor. With only about 500 players (some logged in, some not), it has 30s of worth of delay when using MariaDB
When I manually purge any users that come up with just UUIDs from the DB (the bottom four in the screenshot below, for example) then the lag goes away. Makes me feel like I'm using the API wrong. https://i.imgur.com/QCUMQ9t.png
Seems that storing usernames remedies the issue. LP might have an issue with reading MariaDB data if it doesn't have a username specified.
@unreal mantle here as well ^^ lol
Guys
Can you give a string for issuing groups? Like this
public String getGroup(Player player) { try { PermissionUser user = PermissionsEx.getUser(player); return user.getGroupNames()[0].toLowerCase(); } catch (Exception var3) { return ""; } }
why there is PermissionsEx when it's help about LuckPerms API?
Yeah, I know
I want to rewrite this system under LuckPerms
PermissionsEx to LuckPerms
!api prob start from here
Learn how to use the LuckPerms API in your project.
https://github.com/LuckPerms/api-cookbook here have some examples as well
Hey,
when i try to load the luckperms api, but it returns null
How are you getting the API?
LuckPermsProvider.get()
Is LuckPerms on your server?
thats the first thing you ask
Luckperms would be on the server, otherwise heโd be getting a CNFE
So more than likely, heโs requesting the API before itโs even been setup
Just kidding, that throws an exception
best to show the code you are using so someone can help spot the problem
Their api makes 0 sense
But my plugin loads AFTER LuckPerms
Show the code?
My PC isn't on but i have an private variable which i set in my init method, the init method is called in the onEnable and last i have an getter
the mode how i set is: LuckPermsProvider.get()
it'd still be best for us to see the code and full exception you get
otherwise, we will just be playing the back and forth game for a while
Then how are you getting a null pointer?
When i am trying to use the luckperms api
just show the code
does your plugin.yml specify the dependency?
no, but why?
You should certainly have that
otherwise, you can load before Luckperms
But you shouldn't be getting a null there, either an IllegalStateException or the service
also null
/**
* Gets an instance of the {@link LuckPerms} service,
* throwing {@link IllegalStateException} if an instance is not yet loaded.
*
* <p>Will never return null.</p>
*
* @return an api instance
* @throws IllegalStateException if the api is not loaded
*/
public static @NonNull LuckPerms get() {
if (instance == null) {
throw new IllegalStateException("The LuckPerms API is not loaded.");
}
return instance;
}
never null
best thing to ask is, did your plugin load correctly
Then you're likely executing that code before you have even enabled
No
hard to give you a full answer when you censored the rest of your boot process
when is the listener created?
during enable I assume
but before or after the LuckPermsProvider.get() call
I use the listener AFTER my Join
after
All I can say is
The LuckPerms API is available and present
some issue in your code is why you're getting the null pointer
Can't say much more without being able to see the full picture
The problem is InventoryUtils
you've created it before you've established the API
which is asking your plugin instance for the luckperms API immediately, which from your variable, is still null at that moment
That's why full context helps!
Oh okay
can I get the user's rank with this api?
Yes
Examplss there
so if I wanted to print out their rank I would do player.hasPermission("group." + group)
can i set a player's nickname with luckperms api?
player.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4test")); does nothing
lp api doesn't do nicknames afaik
User user = (User) player;
user.setNickname(ChatColor.translateAlternateColorCodes('&', String.format("&%s%s", selectedColour, chosenNick)));
i think this is it
from essentials
Initial code should work
Finn java player.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4test"));That will set a players chat name
kats that didn't work actually
did nothing
setnickname worked, although can't cast directly from player to user. it's working now anyway
Does anyone know if it's possible via Vault API to set a permission with a server context?
Or will I have to use the LP API
Think server contexts within LP need the LPAPI
Oh, perhaps I can set this https://luckperms.net/wiki/Configuration#vault-server
The name of the server used within Vault operations.
I assume that means whenever I use vault to set a permission, it will default to the server set by vault-server in the config
perhaps, actually! give it a shot!
Hello. I have a question: when changing a playerโs group (/lp user username parent set groupname) is the UserDataRecalculateEvent event raised three times? If so, for what reason? The fact is that I use this event in order to update some displayed information about the player in my plugin. Screenshots of my code below. Everything works as expected, but triggering the event 3 times in a row is slightly alarming. Is there a way to solve my problem better or easier?
how do i check player group?
@marble geyser
public static String getPlayerGroup(Player player, Collection<String> possibleGroups) {
for (String group : possibleGroups) {
if (player.hasPermission("group." + group)) {
return group;
}
}
return null;
}```
How can i get all Groups ? ๐
how do i get boolean?
public static boolean isPlayerInGroup(Player player, String group) {
return player.hasPermission("group." + group);
}```
^^
Does someone know how to get All Groups?
is it getLuckPerms().getGroupManager().getLoadedGroups()?
@jaunty pecan how can i contact you? king regards
Hey gianduiotto! Please don't tag helpful/staff members directly.
hey@lucko.me @nocturne elbow
Also please follow the rules it appears you have been asked several times
Hey, is it possible to give Groups temporaly with the API? and if yes, how ๐
Can I retrive prefix in BungeeCord the same as in spigot?
Yes, there is no difference of the LP API in different platforms
ok
what about my question? xD
Learn how to use the LuckPerms API in your project.
!api
Learn how to use the LuckPerms API in your project.
how can i get prefix in a static method
Hi, I gave the group "default" the permission to set users primary parent to "player". When I now issue the "/lp <user> set parent player" command via TextComponents' ClickEvent.Action.RUN_COMMAND, only the text "[LP] Running LuckPerms v...." appears in the chat. Do I need to give the default group another perm as well?
Anybody an idea?
Found another way ๐
how can i make it for players cant craft im making a rpg world and i dont want them to craft
sorry
Closest I can find is NodeAddEvent so perhaps try that?
Considering groups are nodes identified by group.groupname
@hardy violet Hey, you had a post a few months ago regarding adding a node and then saving the user, did you manage to get that working? I can't seem to figure it out:
user.getNodes().add(LuckPermsProvider.get().getNodeBuilderRegistry().forPermission().permission(node).value(true).negated(false).build());
LuckPermsProvider.get().getUserManager().saveUser(user);```
How can i check which node is added?
On event or just checking someone's permissions?
what to replace the data lines with, so that it is like in pex, only in the LP
plz help
Looks like SQL to me, why do you want to query the database directly?
public boolean hasPermission(String permission) {
User user = this.getLuckPermsUser();
if (user == null) throw new NullPointerException("User cannot be null");
Set<Node> permissionNodes = user.getNodes().stream().filter(NodeType.PERMISSION::matches).map(NodeType.PERMISSION::cast).collect(Collectors.toSet());
if (permissionNodes == null || permissionNodes.isEmpty()) return false;
return permissionNodes.stream().map(Node::getKey).collect(Collectors.toList()).contains(permission.toLowerCase());
}
I was wondering if this is the right way of checking if a user has a certain permission
NodeType.PERMISSION is what I should be using right?
Anyone?
@normal hedge Found in docs:
private boolean hasPermission(User user, String permission) {
ContextManager contextManager = LuckPermsProvider.get().getContextManager();
ImmutableContextSet contextSet = contextManager.getContext(user).orElseGet(contextManager::getStaticContext);
CachedPermissionData permissionData = user.getCachedData().getPermissionData(QueryOptions.contextual(contextSet));
return permissionData.checkPermission(permission).asBoolean();
}```
You can finetune that the way you want but there's no reason for you to go through all nodes the way you do if you can simply check it through `CachedPermissionData`
Cheers mate
can anyone help me set up to the site. privileges were granted to the database when PEX was installed, it issued normally, but now, there are a lot of new tables and I donโt know what to use for what, please help
What do you want to do?
How would I get all nodes (including negated ones)?
@neat jackal I have a website, you can buy privileges on it when PEX was on, everything worked, but now that there is perm, there are a lot of tables and I donโt understand why it doesnโt work
Hey Limonik! Please don't tag helpful/staff members directly.
May go to Private messages and I will show, but I do not know English well
please or someone else\
@tepid night Hey, yeah I did actually figure it out eventually.
Node permission = LuckPerms.getNodeBuilderRegistry().nodeBuilder.forPermission().permission("somepermissionhere").build();
User user = LuckPerms.getUserManager().getUser(playerUniqueID);
user.data().add(permission);
LuckPerms.getUserManager().saveUser(user);
Hey ๐
How can i set the parent group of an player if hes not in this group rn ?
check it first with hasPermission("group." + groupName) ?
And after that how can i put him into the group ?
!api
Learn how to use the LuckPerms API in your project.
Which event should I listen to if I want to do something on /lp user <user> parent set <group>? There doesn't seem to be an event for adding/removing parent groups from a user.
Should I listen to NodeAddEvent and check if the node key starts with group.?
Check if the node matches with an InheritanceNode`
if (Node.getType() == NodeType.INHERITANCE) or something like that iirc
But for that command it should be on that event, no way around that, right?
Yes, I think so
Alright, thanks!
You're welcome! ๐
!api
@thorny echo Does not help bc i know that i have to do something with the node stuff but i dont know how xD Thats my problem
Hey Julian! Please don't tag helpful/staff members directly.
Hey Clippy! I just quoted his message. ๐
How can I get all player groups?
I think with LuckPermsProvider.get().getGroupManager().getLoadedGroups()
It really was easier than I thought, lol

@rustic blade elaborate your problem
Im just want to set the parent group and if the user already is in the group its returning false xD nothing else
Haven't really had an issue with using Vault before to add perms for players, but did something change recently? Doing permission.playerAdd(null, player, perm); doesn't make it show up in a /lp editor for the player.
heey @tepid night
?
Okay, so it actually looks like playerAdd is working fine, but using playerRemove doesn't look to actually remove the permission.
Hey!
how do i get the player Rank Prefix
as | Gamer | F4res ยป LoL
on hcat
chat*
| Gamer |
how do i use it!
@mint kayak are you making your own plugin?
Hey Hi - F4res,! Please don't tag helpful/staff members directly.
@frank drift SORRY
!api
Learn how to use the LuckPerms API in your project.
Gonna sound harsh, but using the LP API requires a solid understanding of programming, Java and how plugins work
Though you can have a look here: https://github.com/LuckPerms/api-cookbook
does nyone know how to set a user's prefix?
@real flint take a tiny peek above. The last two embeds will help you
Now you are
am i allowed to drop plugins related to luckperms here
Jars or links to the github?
Depends on the reason @real flint
ye github
just a plugin i made but idk if i can post it
its a simple plugin but idk
๐ฆ
not reallyy
just to show that i made my first public plugin d:
thats why i asked first
๐ฆ
Not the place
You're welcome
hi, ive read the java docs and forums around and couldnt find out why I cant the get group to work (since most of the code has changed in version 5). It is intended to return false since it is not the same group."" but it is only currently observing true (for any group the player is in). I think this mite be because its not "attached" to the luckperms database. I'm also pre new to this plugin
i've also read the github but still the same result
I have no idea what you're trying to do
basically im trying to print out in console if a group is identified
each time a player connects
if a group is identified
What?
public static boolean isPlayerInGroup(Player player, String group) {
return player.hasPermission("group." + group);
}
this
but it is showing false each time
Does it also show false after the player has joined?
Also make sure the group name is lowercase
i mean true* sorry
Test it on a non OP player
You're welcome
how do i setup luckperms api? and then get the prefix for each player?
!api
Learn how to use the LuckPerms API in your project.
Hey Gonรงalo Filipe! Please don't tag helpful/staff members directly.
can help?
The line looks correct to me, probably something before
i need help
BAD HELp
No need to ask in several channels
Use a var
[18:30:23 ERROR]: Could not load 'plugins\Core-1.0.jar' in folder 'plugins'
org.bukkit.plugin.UnknownDependencyException: Unknown dependency luckperms-api-4.4. Please download and install luckperms-api-4.4 to run this plugin.
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:272) ~[patched_1.16.1.jar:git-Paper-89]
at org.bukkit.craftbukkit.v1_16_R1.CraftServer.loadPlugins(CraftServer.java:388) ~[patched_1.16.1.jar:git-Paper-89]
at net.minecraft.server.v1_16_R1.DedicatedServer.init(DedicatedServer.java:208) ~[patched_1.16.1.jar:git-Paper-89]
at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:940) ~[patched_1.16.1.jar:git-Paper-89]
at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$a$0(MinecraftServer.java:177) ~[patched_1.16.1.jar:git-Paper-89]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_251
I keep getting this error
please help
and yes I have downloaded the jar file
don't know how to create the clickable text like the text after /lp editor
Use the new API (v5.1)
public static String getPrefix(Player player) {
try {
if(Bukkit.getServer().getPluginManager().getPlugin("LuckPerms") == null)
return "";
final LuckPermsApi lpApi = LuckPerms.getApi();
User user = lpApi.getUser(player.getUniqueId());
Contexts userCtx = lpApi.getContextForUser(user).get();
return ChatColor.translateAlternateColorCodes('&', user.getCachedData().getMetaData(userCtx).getPrefix());
} catch (Throwable e) {
return "";
}
}
then that ^ code won't work
examples there for new api
ty
How can I add a User temp. to a group via the API? So I want my plugin to have the same effect as If the Console runs /lp user ... parent addtemp VIP 1w
Any idea why when using Vault with LP, the Permission#playerRemove doesn't actually remove the permission? Adding perms works just fine.
@dull egret if you really don't want to use the new API, you can still use the old one and use the legacy api extension
!legacy
Sorry! I do not understand the command !legacy
Type !help for a list of commands.
!extension
Sorry! I do not understand the command !extension
Type !help for a list of commands.
Thank you Brian!
!extensions
A list of all the Luckperms extensions.
That one
How to get information about groups of different players?
!api
Learn how to use the LuckPerms API in your project.
Thx sorry for bother
No problem
I want luck perms on my server, but itโs forge, is there a alternative? For forge
LuckPerms is only available for Sponge @near bramble
hey guys, i need placeholders for prefix for TAB and Essentials pls
yeah
!placeholders
Display data such as user prefixes and groups from LuckPerms in other plugins.
It's been about 10 hours, so I'll go ahead and bump this question. https://discordapp.com/channels/241667244927483904/420538367986499585/733011918436171848
@dull rover Wouldn't know, it's always worked fine for me... And by the look of things, for everyone else too lol because no one said nothing on that
Yeah, it's pretty weird.
Any idea why when using Vault with LP, the Permission#playerRemove doesn't actually remove the permission? Adding perms works just fine.
@dull rover You sure youre doing it right?
I'm fairly sure. It's just Permission#playerRemove(player, perm)
isn't it nvm you're right too lol#playerRemove(World, OfflinePlayer, String)?
but
for #playerRemove(Player, String) it also says:
Will attempt to remove permission from the player on the player's current world. This is NOT a global operation
so you might be better doing perms.playerRemove((World) null, player, node)
@dull rover sorry for the ping ๐
I tried that too, sorry, I should've mentioned that.
aaa aa
I also tried giving the player the perm with the world too and removing it with the world and nothing.
At first I thought it was because I was doing it async, so I forced it back to sync, and still nope.
hello humans
i'm trying to make a discord bot which would interact with the luckperms permissions database, and I this is the most relevant channel to that end
is there any information about how to get certain information about a player straight from the database, without going through the luckperms API?
or maybe there already exists an API which doesn't need to be implemented in a plugin
There's not much to it I suppose, just get the information like you would from any other database. However that kinda does avoid the LP API which you'd probably be better off using for a few reasons
The main one is primary group calculation, which is done through the LPAPI but not in the database-in the database the primary group needs to be manually set, while LP will calculate the highest weight one for the API
hmm well i'd much rather use the API too, not only for that but also because i've never worked with SQL databases before so i'll have less hurdles
but i was under the impression that i could only use the API within a plugin, since it uses the LuckPerms plugin object
and since i want to make a discord bot i want it to be separate from my plugins / server, and all that
That's something I hadn't considered; tbh idk about that- however perhaps you can make a plugin that is the discord bot, in a way.
i was thinking about that too, but i'm a little bit concerned about performance
As for whether the LPAPI is solely for plugins, I have a feeling that it may not be but I don't know for sure, so best to leave that question here. However you can peruse the docs on that here
!api
Learn how to use the LuckPerms API in your project.
alright, thanks once again Larry ;)
Np!
Hmm... How do u use LuckPerms with sponge forge
The developer API?
Alright, here's one I haven't been able to figure out (bare with me, I am new to this)
How do I get all of the users in a specific group?
To be honest, I don't even need the users, I just want to know how many there are
I don't really understand how to use the searchAll function, there isn't really an example for it or any explanation as to how to use it in the docs
Oh, wait, I'm dumb, nevermind
Map<UUID, Collection<Node>> col = luckPerms.getUserManager().searchAll(NodeMatcher.key("group." + group.getName())).get();
The col.keySet() is the list of user UUID matches, simple enough
I'm a little noobish for the API, but, what's the proper term or way to check if a group has a subgroup? Is that the track weight thing?
group.getNodes().stream().anyMatch(NodeType.INHERITANCE.predicate(node -> node.getGroupName().equals(subgroup)));
is one way to do it
you could also use group.getInheritedGroups()
Ooo okay cool
hey
where can i report errors?
i have a big error that popped out of no where
it doenst let anyone join i htink its because of memory
If it related to the dev-api, ask here. If not, #support-1
okay
To add a user to a group, would I just do
DataMutateResult result = user.data().add(Node.builder("group." + groupName).build());
?
'cause I see in the usage wiki it shows to do so for a permission, but when I try it with a group nothing happens
save the user after as well
Ahhh, okay, I missed that part on the wiki. I'll try that, thanks
Sweet, it worked. Thanks!
np!
So I saw there's a method to load all groups, is there one for all users? Or do I have to get all the unique UUIDs and then load each one individually?
Hello! I'm having some issues @ loading LP provider on server start (sponge). The strange thing is that I have 2 projects, with the exact same gradle file, and the exact same ProviderRegistration
but when trying to load, it comes up with this:
java.lang.NoClassDefFoundError: Lnet/luckperms/api/LuckPerms;
(for 1 project only, the other one works fine)
@marsh matrix does the failing project have luckperms depended on? Could be a case of luckperms not yet being constructed
it depends on luckperms indeed, both of them do, but literally same gradle, and same code section of the loader. Something that I'm thinking of, is that one plugin starts with the M (the one that works) and the one that doesn't work starts with an H
so ig it's trying to load that before LP, as it starts with an L?
I'll try to use the gamepostinitializationevent, and see if that fixes it
Mind if I see your main class?
Itโs definitely sounding like class loader issues
@marsh matrix don't shade/include the LP API in your jar
Double check that please
You forgot the dependency aspect of the plugin annotation
So itโs going to load itself before luckperms thanks to alphabetical loading
And that
yup, that was it, have never really had to add dependencies, but makes sense, thanks a lot for the help guys!
Would there be any reason that I'm missing that the API would not load all groups when running api.getGroupManager().loadAllGroups().join();? (Yes, I know this is blocking).
Typically speaking all groups should be loaded
Have you tried getting all loaded groups instead?
Yes, and it's iterating some loaded ones but not all that should be there when calling loadAllGroups()
Here's from the database.
Anything special about those groups? And is it always the same groups?
Here's what actually is returned from that method.
Yeah, it's only those groups that actually load.
And what happens when you do the same with the loaded groups?
Wdym?
The group manager has a call to give you all already loaded groups
Have you tried that?
Correct, it's empty if I don't do api.getGroupManager().loadAllGroups().thenRun(()
How early are you calling this?
It's command-based so I wait till I can login to run the command.
So groupManager#loadedGroups is empty with an active online player?
Let me double check. One moment please.
Ahh, it's the same, my bad. So calling the method to load doesn't seem to add the rest.
I would have been surprised
In the web editor, I do see all 44 groups.
Do these missing groups have any permissions?
Yup, they all do.
It's just weird that according to the API, it's only 7 or 8 groups loaded.
And youโre really just iterating over them. Not filtering any out, right?
Correct!
api.getGroupManager().getLoadedGroups().forEach(group -> {
System.out.println("ADDING GROUP: " + group.getName());
});```
What happens if you try to get a group thatโs not on the list by name?
Would you like me to just run a get or try to load it manually by name first?
Try both
Okay! Trying a raw get without loading.
And a load and get for a different one
It works without the loading.
5.1.75
Alright. Looks like a bug to me. Iโd post it on GitHub
Alrighty. I can do that. Thank you.
Actually, what the heck...
I just debugged the size of the loaded groups and it's 44.
But it's only iterating over the first 7.
Hmm ๐ค
Big bug time
I'm just going to hush now. I think it's something on my end cause I just changed how I debugged it and now everything works.
Glares
Smh. Like 2nd time touching API.
It was a pun bro
Hello!
why does this:
group = HeldItemStopper.instance.getLP().getGroupManager().getGroup("default");
throw a null pointer exception, even if:
https://i.imgur.com/nkHchNs.png
If it throws a NPE one of the earlier method calls threw null. Not the getGroup call @marsh matrix
Apparently this one is throwing it
HeldItemStopper.instance.getLP()
Is it still related to the alphabetic loading issue?
Check if api is null or not
sure, but why would it be? it sets api to provider().get().getProvider()
Test it
yea I am, just takes a while to boot up
So you know if you need to look into that or another place
The question is does instance.getLP() return null or throw a NPE?
And why do you think that?
I did this
LuckPerms getLP() { if (api == null) { System.out.println("no"); } else { System.out.println("yes"); } return api; }
and console didn't print neither of those
just the NPE error
Good. Then your instance variable is null
oh
If a x.y() throws a NPE it's typically x that's null. Especially if you know that y() can't throw a NPE
I'm absolutely retarded
Programming 101
I apologize for wasting your time lol, just noticed that
Time to brush up your debugging skills
i realized I should have asked my question here. I'm really braindead when it comes to this stuff. How does one change out an API. For example LuckPerms verion 4.1.7 requires a version 6 API and I went and I thought I installed version 6 however in my console it still says I am running a version 7.2.0 API.
Are you talking about the Sponge API?
yes
So are you developing a plugin or just running a server?
running a server lol
ah ok sorry
Hey, how do i get the prefix of the highest group of a user
!api
Learn how to use the LuckPerms API in your project.
Should i use the CachedMetaData of the player? or do i need to get an instance to the group or something
What have you tried?
This may be useful
this as well
(and pretty much everything on the second link)
is the cached prefix always the prefix of the highest group?
It's probably the highest weighted prefix
But I can't guarantee
because i have no clue
Never used the API before so IDK much.
Should I use the API to remove a player permission or just dispatch a bukkit command?
Hi, what is the best way to catch players' prefix changes?
I've tried listening to NodeAddEvent but the problem is that it only gives me the changed prefix and i want all the stacked prefixes. I can surely get them from Vault using Chat::getPlayerPrefix(Player) but it only updates prefixes after NodeAddEvent is finished so I cannot use it within my listener.
Any thoughts about my problem? Pls
Boys imma be here soon
I want a gui to come when you first join the server
And you choose what rank you get, each has their separate luckperms track you can rank up through. can I do that?
So Iโm gonna ask really basic questions
How can I use the luckperms api in my plugin?
You can assign groups and get group information using the API, so yes.
!api read the usage page linked here
Learn how to use the LuckPerms API in your project.
There are some easier methods than some that are used on said page
In pom.xml, if you already have <dependencies>...</dependencies> add a new <dependency>...</dependency> entry
Gradle
I second this
maven
@neat jackal (sorry for the ping) #luckperms-api message wanted to bring that to your attention
Hey Cryptic! Please don't tag helpful/staff members directly.
Taken care of
Thanks Brain โค๏ธ
hey, i need to be able to compare two players' positions in a particular track but i'm not really sure where to start. any tips?
basically i need to know how to get the position of a group in a track that a specified player is in
how can i ask if a group has that permission/or is in that group and then as example set a scoreboard team or a chat color
the setting scoreboard team or chat colour is not up to LP, but as for checking for a permission see these links
!api
Learn how to use the LuckPerms API in your project.
thx
basically i need to know how to get the position of a group in a track that a specified player is in
never mind i've figured out a way to do it :)
java.lang.NoClassDefFoundError: net/luckperms/api/node/Node
I'm getting this when using the meta note builder on bukkit
on sponge, it's fine
but for some reason on magma, it won't work
or bukkit, just tried
Do you have LuckPerms on the server
Also make sure it's the API v5 and LP v5 @unique horizon
@crystal sonnet they are both that
Hey Karim! Please don't tag helpful/staff members directly.
And I do have it
Did you declare a (soft) dependency on LP?
Does it matter? Just asking
I know LP is loaded cause luckperms work
It's just that mine doesn't on magma
Yes that's important
Especially if your plugin is alphabetically before LuckPerms
Hmm, will try thank you
Btw you should declare the dependency on Sponge too
Hey. I am getting a npe when trying to create a node. This is the line creating the node
Node node = luckPermsApi.getNodeBuilderRegistry().forKey(perm).build();
the error is
[07:07:35] [ForkJoinPool.commonPool-worker-4/WARN]: Caused by: java.lang.NullPointerException
[07:07:35] [ForkJoinPool.commonPool-worker-4/WARN]: at me.lucko.luckperms.common.node.types.Inheritance.parse(Inheritance.java:76)
[07:07:35] [ForkJoinPool.commonPool-worker-4/WARN]: at me.lucko.luckperms.common.node.factory.NodeBuilders.determineMostApplicable(NodeBuilders.java:64)
[07:07:35] [ForkJoinPool.commonPool-worker-4/WARN]: at me.lucko.luckperms.common.api.implementation.ApiNodeBuilderRegistry.forKey(ApiNodeBuilderRegistry.java:60)
[07:07:35] [ForkJoinPool.commonPool-worker-4/WARN]: at io.shaded.nprisonbande.github.freakyville.utilsupdated.v1_13.luckperms.LPHandler.lambda$hasPermission$11(LPHandler.java:201)
I am using version 5.0.72 of luckperms on the server and 5.1 of the API
Sometimes I should just read the documentation and not just assume stuff, its Node.builder(perm).build() instead
You can download LuckPerms for Bukkit/Spigot, BungeeCord, Sponge, Nukkit and Velocity.
Yea Just upgraded the API version, I had tried with 5.0 API version too
package fr.Phosphate.rankplus.commands;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import me.lucko.luckperms.common
public class CommandTest implements CommandExecutor,LuckPerms {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String msg, String[] args) {
if (sender instanceof Player)
{
player.sendMessage(ChatColor.RED+player.getDisplayName()+"is now player");
}
return false;
}
}
@tribal wave
I want to bring up the player's info.
you shouldn't be implementing luckperms
how I implement ?
hum ...