#luckperms-api
1 messages ยท Page 7 of 1
hi, how i register a custom event in my plugin that uses luckperms api? i use currently NodeAddEvent
it is for bungee
( it is a bungeee plugin )
how i do this for bungee? https://prnt.sc/DdLY93dRpqDP
bungee does not have a services manager
you need to use the static accessor LuckPermProvider
this dont work https://prnt.sc/R-Qk2F3LBR8C
the event dont get fired
well, i don't know what your NodeEvento.register does but assuming it's correct the event will be fire accordingly
though, events like NodeAddEvent will only fire on the LP that change occurred in
so, if you want to listen to that event on the proxy, you will have to run /lpb ... permission set
I have fixed It. The objetive IS to Create a custom antiop event that Will ban The player who receives * permission and dont have owner group.
And since everything is mysql connected even If i do /lp user instead of /lpb user The event stills trigger and Bans The offender
events do not fire across the network
I have tested with /lp and i think it banned them
I think it IS because It IS mysql synced?
So ALL instances are connected?
no, events do not propagate, most events will be called only on the source server the changed happened on
I have It on spigot side too. My plugin IS both for spigot and bungeecord. So i think that IS why It banned
some "exceptions" are things like, UserDataRecalculateEvent, but that is only because the user data is recalculated everywhere when a change is made
Yes. The custom antiop plugin IS installed everywhere
So If they somehow got * and dont have The primary group seted was owner
IS a ban
In spigot side i forked The antiop plugin from spigot and made somes changes. The owner primary group thing IS only in bungeecord
well, if you install the plugin everywhere then yeah, one of your plugins will catch the event ๐ wherever it is called
In spigot side It checks If The player IS not on config and has *
In bungee side It checks If primary group IS owner and has *
So no bypasses here
If he IS not owner on bungee side or dont have his UUID or name in config on spigot side and has *
He got a PERMANENT IP BAN
scary
It is to Prevent skids and hackers to get opped in my server without my consent
Can I give the player a node that disappears after 0:00?
If that doesn't work, I wonder if there is a way to remove all players in the group.
(using LuckPerms API)
Yes, you can add an expiry time to nodes
I want it to be after 00:00, not after n hours.
after 00:00 as in expires at a specified time, or 00:00 as in expires immediately
nodes have an expiry date, with the API you can pass an Instant or what have you to NodeBuilder.expiry
is there an event that triggers this?
"[LuckPerms] [Messaging] Received user update ping for 'name' with id: b8992870-c7cc-410a-99ba-c9607d6b6b98"
cant seem to find any what i want todo is when it receive this update it run some code
probably the NetworkSyncEvent
Is that cancellable. I want to break my server
:)

I want to create a GUI on the server and add it to the group in the luckperm plugin when I click on a specific item, but I don't know how to implement it with a script. Please tell me how to do it.
This is very confusing...
I installed the PAPI Placeholders Extension for Luckperms, then upon using %luckperms_meta_messagecolor%, it returns nothing.
This is my group's values.
#support-1 or #support-2 , but meta is in the format meta.<key>.<value>
Oh!!!!
Thank you so much!
hey en der kan hjรฆlp
help
Hi, i want to remove a group of a player (this group contain a prefix), when i, remove it, the prefix stay, in game but not in luckperm editor so why ?
hi, i created group (vip, admin ect...), but they dont show in the tab list, how can they show?
Doesn't seem like a LuckPerms API related question. Please use the proper channel.
oh ok
!ask in English, as you're more likely to receive support this way, or use a translator.
Please ask the question you have. Don't ask to ask, or ask to DM someone. There are people here to help you, but we need to know what to help you with, so please just ask the question you want to in as much detail as possible!
how to promote like member to vip? i did the tracks but idk the command
That's not a LuckPerms API related question either.
Use #support-1 or #support-2. ๐
Use the proper channel please. This channel's dedicated to "Questions about using the LuckPerms Developer API - https://luckperms.net/wiki/Developer-API", as stated in the channel description.
mb i just discover how to promote
Is there a way to tell how far through a track a player is or do I have to go through the collection of inherited groups and check which is the furthest through the track?
Hello, I try to code a nick plugin - I already got it to work with prefixes (that it shows the normal one) but how can I fix the sorting ?
I sort by priority - but then admins would be above normal players then everybody knows that they're nicked
any ideas?
not really an api question, but why not just make them appear as default if they are nicked?
i do that by changing the prefix to the default group
But the tab is sorted by prio so I would have to remove the group too (priority)
use the default groups weight for nicked staff instead of their actual group? anyways, should move to #general
You can also download a plug-in like essentials and use their nick system
Hello; I'm trying to use the LuckPerms API to listen for when nodes get added/removed from users/groups, which works great if the nodes are added/removed from the same server I'm checking them from. But, every one of the events that work for local changes doesn't work for changes from other servers. The PreSyncEvent and PostSyncEvent seem to work for changes to groups, but not for users; meanwhile the PreNetworkSyncEvent looks like it works for users, but there's no matching PostNetworkSyncEvent. That, and if I want to use those events, I have to make my plugin store a copy of all the permissions it wants to track, and whenever the sync event finishes, read all the permissions it cares about again and see what changed the hard way. https://luckperms.net/wiki/Developer-API-Usage#events explains how to use the events that work for local changes, but completely skips how to listen for events from other servers. All that, and I haven't even thought about if the web interface has some third set of events.
Is there some simple documentation for listening for when permission nodes change that I'm missing? And if not, why? And what events should I be listening for to tell when permission nodes change on a user/group? If I'm going to get events to listen for when permission nodes change, I would have expected them to work regardless of how they were changed. I'd really love to be proven wrong about needing to duplicate every bit of data I care about in order to check if it's been updated.
can you explain why you want to listen for changes? what is your final usecase?
I'm pretty sure I've got everything working except for detecting when a player gains/loses an inheritence node; I'm working on a guild plugin. If the player is on the same shard as the person who added them to/removed them from the group, it's detected just fine, but if they're on another server the player being added/removed doesn't receive an event to for further plugin code to work off of.
I'm also rather concerned at how much code I had to duplicate to watch for changes to nodes on the group itself. For instance, I've got a metanode within a guild group that acts as a lock on a guild to prevent changes through the guild plugin's interface until a moderator gets involved. I had to watch for a pre-sync event, get a list of all guild groups that were/weren't locked, watch for the post-sync event, and do it again to find the differences.
Further explaining on why I need to listen for the user's group changing, I need to update a chat plugin for what the player's current guild chat is, and it is properly permission locked, but making the guild chat command spit out an error when joining/leaving a guild isn't ideal.
hello you have docs for api forge ? i dont see forge in documentation
it's the same api on all platforms
How to use the service manager ?? is on bukkit
NodeAddEvent/NodeRemoveEvent?? I guess you are trying to synchronize state within LP with state outside of LP, which is probably where the challenge is coming from. I suggest not doing that, just have a single source of truth, either in LP or not
ok i use this ?
LuckPerms api = LuckPermsProvider.get();
the only way that 'events' are sent between different LP instances is via the messaging service, which is used for action logs and sync notifications
yep :)
ok thanks ๐
LP is the single source of truth. However, my plugin code isn't getting properly notified when that information has updated. The chat plugin in particular does check if you have permission to talk in a given chat channel on every message, but the shortcuts for various chat channels doesn't care what those shortcuts are set to, only that you have access to them. The other plugin that manages guilds assumes you're only in one guild at a time and is supposed to update that shortcut when you change guilds.
I'm only receiving the events that a user has changed permission groups if they're on the same server that their permission group was modified from. Say we've got two servers named Valley and Isles. If you're on Valley and a moderator on Valley adds you to a permission group, then the NodeAddEvent is received and the other plugin code can use that event to update the plugin code that depends on LP. If the moderator then adds a new permission node to the permission group, then the NodeAddEvent fires again for the permission group and the other plugin code can again be informed that the permissions have changed.
Trying that same experiment with the moderator on Isles, neither modification results in a NodeAddEvent, so the other plugin code has no idea that the permissions changed using that event. I had to use the PreSyncEvent to temporarily copy the list of relevant permissions and who's in which permission group, then compare that to the results after a PostSyncEvent to see what changed, which lets me see when the permission group gets a new permission node - but neither event fires when adding a player to the permission group. Instead, the PreNetworkSyncEvent fires for players being added to a group, with no event that I can find firing after the sync is finished, leaving me with no way to track when a player is added from another server. In theory I could use the PreNetworkSyncEvent to grab the player's permission groups before a sync event, then assume the sync has finished the next tick and compare what changed - but I would have expected to be able to skip this whole paragraph and just use the NodeAddEvent, or something similar.
But the issue is, the LuckPerms documentation only gives documentation for how to listen for the events that work on a single Minecraft server - not for changes to permissions from other servers over MySQL or whatever other network synced solution.
Is there any reason you're caching permissions and not just checking them when needed?
This sounds like a lot of work to maintain what appears to be some cached permission states
checking them when needed
That is the issue - I can't tell when I need to check them, otherwise I could look it up easily.
The goal with the shortcut for guild chat messages is that it doesn't care how guilds are implemented, and thus doesn't updated automatically. It's expecting another plugin to manage that for it.
Ok now I'm even more confused. I'm getting increasing XY problem vibes - What is it you're actually trying to accomplish, and why do you not know when you'll need to check permissions?
I suppose it doesn't help I'm trying to solve multiple problems at once, so starting with a simpler case:
I want to notify players when they've been invited to a guild, with invites tracked by a permission group specific to that guild's invites. If you invite a player that's on the same server as you, then the NodeAddEvent fires properly, and the plugin code can listen for it and inform the player they've been invited to the guild.
If the player is invited to the guild from another server, then the NodeAddEvent does not fire. I do not know which other event to listen for that would tell me that they've been added to the group. I also do not want to remind them that they were invited to other guilds, so if I were to only be informed that their permissions have been updated, I would need to make sure the plugin remembers which notifications they've already received, and not tell them about those.
I am not sure using luckperms makes sense for that, sounds very custom and would probably benefit from being in it's own database + use of a message broker for notifications
but if you really wanted to - I guess you could store the invite as metadata on the User who was invited
I've already got the majority of the code completed using LuckPerms as the database/backend; an example invite group:
/lp group guild.aba.invite.member
I do have a message broker I can use if needed, though. It's just a matter of tracking when the permission groups update at this point.
I suppose you could use https://javadocs.dev/net.luckperms/api/5.4/net/luckperms/api/actionlog/ActionLogger.html#broadcastAction(net.luckperms.api.actionlog.Action) and https://javadocs.dev/net.luckperms/api/5.4/net/luckperms/api/event/log/LogBroadcastEvent.html but tbh I would recommend just using your message broker for notifications
declaration: package: net.luckperms.api.event.log, interface: LogBroadcastEvent
Out of curiosity, though - why is it that the NodeAddEvent only shows up if you're on the same server that it was created from? I would have thought that it would be possible to listen for it from other servers with the same database in some way, or that there would be an equivalent event somewhere.
And yeah, if these only log events from the current server then I would be better off using my message broker to handle this.
because the eventbus (the thing that delivers events) doesn't send events between servers
Well that'd do it.
I'm guessing I'll need some way to make sure I don't receive the notification from my message broker before LuckPerms has received remote data?
there is a 'messaging service' concept in LP that allows it to communicate with other instances, but only for a few things: log broadcasts, and update "pings" (correspond to the sync events) which basically say 'hey this user has changed, refresh their data from the DB if they are connected'
Well then you'd be splitting to 2 sources of info, which comes with a whole host of "what to do if you recieve conflicting info" problems. I'd strongly encourage you to just entirely use your own DB + Messaging service for your own data, and leave LP to be just permissions
just include all the state you need in the message
Fair enough. Though if there's a way to tell when player data has finished syncing, then I can check re-check that easily enough - I only see the pre-sync event for player data right now, with no post-sync event.
UserLoadEvent will be fired
Including for players who were already online? So it's not the UserDataRecalculateEvent?
that one works too
Thanks, I should be able to handle it from here.
how do I see if a player has a certain group? I want to implement a 'minimum' group function that determines if a player has the lowest possible group in order to see something.
well you should probably use a permission for that, but to just check if a player has or inherits a group, you can just do a permission check for group.<group name>
Is it better to instantiate LuckPerms luckperms = new LuckPerms(){}; everytime I use it or is it better for it to be somewhere where it can be accessed as static?
Learn how to use the LuckPerms API in your project.
the first link shows how to obtain the API instance
the luckperms plugin provides you with the api instance, you don't create it
Hello Dash, how can I add temp to a rank that has both rank and job?
How come Custom Storage implementation is not part of the API?
Is that on purpose? Seems like it should be there
val luckpermsProvider = Bukkit.getServicesManager().getRegistration(LuckPerms::class.java)
if (luckpermsProvider != null) {
luckpermsAPI = luckpermsProvider.provider
} else {
// error message
Bukkit.getLogger().log(Level.SEVERE, "[$name] LuckPerms์ด(๊ฐ) ๊ฐ์ง๋์ง ์์๊ฑฐ๋ ์ค๋ฅ๊ฐ ์์ต๋๋ค.")
Bukkit.getLogger().log(Level.SEVERE, "[$name] ํ๋ฌ๊ทธ์ธ์ ์ข
๋ฃํฉ๋๋ค.")
Bukkit.getPluginManager().disablePlugin(this)
return
}
(Main.kt)
val luckpermsUserManager = Main.luckpermsAPI!!.userManager
val luckpermsUser = luckpermsUserManager.loadUser(UUID.fromString(uuid))
luckpermsUser.thenAcceptAsync {
it.data().add(Node.builder("group.${Main.instance.config.getString("settings.vote_group")}")
.expiry(Util.convertToUnixTimestamp(Util.getPermissionResetTime()))
.build())
luckpermsUserManager.saveUser(it).thenRunAsync {
val messagingService = Main.luckpermsAPI!!.messagingService
if (messagingService.isPresent) {
messagingService.get().pushUserUpdate(it)
}
}
}
my code has problem? sometimes my code doesn't run.
i'd use editUser
How can I send a group a message? e.g. admin
is there a generic "user changed" event? i need to listen to whenever a player's "rank" changes
nodeMutateEvent + a check if the change was on a user
ah tyty
if i wanted the rank's prefix, would it be the primary group's display name?
or how would i go about getting that
as a Component/Text(yarn), doing some hackery with a clientside optional mod for our network
if you wanna get the player's final prefix, you'd do something like user.getCachedData().getMetaData().getPrefix()
the color is not something that exists in a string, it entirely depends on the format the prefix is in
it could be json, legacy, minimessage, etc
that depends on what is rendering it
yeah, hence why i said the Component/Text, like the final prefix
i geuss thats only compiled when needed
the prefix is stored as a string
it can be in any format you want
then you deserialise it however you need
hm i see
if it's in json format, you use some json serialiser, if it's in minimessage format, you use the minimessage serialiser etc
yeah
is <red> valid? I though it was dark and light
red and dark_red
was just an example ig
it's the vanilla color names
mm
you can use hex if on 1.16+
Entirely dependent on the admin's chosen data storage type
ah
!storage
LuckPerms allows you to store data in a variety of storage types, read about the benefits and drawbacks of each type on the wiki.
But none of that is exposed in the API, that's all implementation details you don't need to worry about
What is it you're trying to do?
figure out the formatting we use so i can manually pick apart the prefix strings
That'll be entirely up to your display plugin(s) then, that's not something LP handles.
All LP does is expose the literal prefix string set by an admin, and lets other plugins handle formatting however they want
ah
how can i safely get the luckperms api on fabric?
i dont see much on the wiki about when
The singleton works on every platform
yeah but when is safe to load it
i tried in SERVER_STARTED event but even thats apparently too early
imnot
uh from what it seems
both of these seem to return the same thing
do anyone know how to get user's case sensitive name
I'm using luckperms api in my plugin, and it throws an error when I run the plugin
[11:10:06 ERROR]: Error occurred while enabling Plugin v1.0 (Is it up to date?)
net.luckperms.api.LuckPermsProvider$NotLoadedException: The LuckPerms API isn't loaded yet!
This could be because:
a) the LuckPerms plugin is not installed or it failed to enable
b) the plugin in the stacktrace does not declare a dependency on LuckPerms
c) the plugin in the stacktrace is retrieving the API before the plugin 'enable' phase
(call the #get method in onEnable, not the constructor!)
at net.luckperms.api.LuckPermsProvider.get(LuckPermsProvider.java:53) ~[StartStream-1.0.jar:?]
at me.osarikas.startstream.Plugin.onEnable(StartStream.java:19) ~[StartStream-1.0.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:281) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:189) ~[paper-1.20.1.jar:git-Paper-196]
It provides the potential causes in the error message
Most commonly it's forgetting b - registering the dependency
I know that there are possible problems and solutions written there, but none of them helps
the dependency is registered in pom.xml
You need to also register a dependency in your plugin (I forget how paper-plugin.ymls handles that) - otherwise paper doesn't know your plugin needs to load after LP, and it's a coin flip which happens first
it seems to be present as well
That's the Bukkit way, but according to that stacktrace, you're using a paper paper-plugin.yml instead of a bukkit plugin.yml and as such registering dependencies etc is different. Consult Paper's docs for how to correctly handle dependencies
(If you don't know the difference between a Paper plugin and a paper-compatible Bukkit plugin, I'd suggest sticking with the older bukkit-style plugin system, there's a lot more documentation about it out there)
Thanks, I'll try it
the paper documentation says that dependencies need to be added in the same way as I did in the plugin.yml file
I already figured it out, it helped me to re-write the dependencies The first time the project simply didnโt see them
Everything works for me without paper-plugin.yml, only plugin.yml
That's an annoying problem, I ended up setting a username meta tag on playerdata when a user joins
Your other options are storing it some other way or doing some non-cached request to an external service
true i ended up stop doing what i was doing
Guys help me some hacker auto matic hack my server how
He got full access to luckprems
Please use one of the support channels. This channel's for questions regarding the LuckPerms API.
Trying to award a player a rank after a certain amount of time. I checked out the cookbook and used this code. If usera is offline, it produces a nullpointer and does not give the player the rank. How do I give a rank to an offline player?
LuckPerms luckPerms = LuckPermsProvider.get();
User usera = luckPerms.getUserManager().getUser(UUID.fromString(playerUUID));
Group group = luckPerms.getGroupManager().getGroup(permissionNode);
// Group doesn't exist?
if (group == null) {
return;
}
luckPerms.getUserManager().modifyUser(UUID.fromString(playerUUID), (User user) -> {
user.data().clear(NodeType.INHERITANCE::matches);
Node node = InheritanceNode.builder(group).build();
user.data().add(node);
});
luckPerms.getUserManager().saveUser(usera);
You'd have to load the user.
https://luckperms.net/wiki/Developer-API-Usage#obtaining-a-user-instance
thanks, that worked
there a way to get offline player displayname?
No, displayname is runtime-only, and regardless LP would have zero reason to store it
what about get prefix/suffix?
Learn how to use the LuckPerms API in your project.
!cookbook should have examples for that particular use case
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
How do I change the text color to a specific group?
For example: Admin group's text will be red (what they write).
You've already been told how to do that on #support-1. Do not cross post and use the proper channel at all times.
This channel's for questions regarding the LuckPerms API.
I cnat get %luckperms_prefix% to work
@wild whale maybe instead of troll reacting peoples posts you can actually help them
Hey blu1776! Please don't tag helpful/staff members directly.
instead of posting in multiple channels, this one being completely unrelated you can actually keep it to the correct channel.
fr
Hey guys I am using velocity and currently making my velocity essentials plugin and am having trouble listening to the luckperms "UserDemoteEvent" i believe that I have followed the Wiki correctly but i just dont see what is wrong and why it's not working, can someone help me?
I come to find out that only the UserDemoteEvent is not working, I tried listening to 'UserDataRecalculateEvent' and that seems to work just fine.
But it still doesn't help me because I need to listen to UserDemoteEvent for what I am trying to do.
Hey all. Can someone explain to me how to change a player's suffix through the API? I got kinda lost in the documentation... ๐
Oh nevermind, found it.
https://luckperms.net/wiki/Developer-API-Usage#creating-new-node-instances
according to the javadoc, the demote event is only called when the user is demoted down a track, not when a group is removed
user#setPrimaryGroup doesn't work?
luckPerms = LuckPermsProvider.get();
public static void setPrimaryGroup(Player player, String group) {
User user = luckPerms.getUserManager().getUser(player.getUniqueId());
user.setPrimaryGroup(group);
luckPerms.getUserManager().saveUser(user);
}```
I am not recieving the group.
I have also tried this:
InheritanceNode node = InheritanceNode.builder(group).build();
user.data().add(node);```
It adds the group like this??
heya, is there a way i can check what group a player is in on another server?
a player doesnt have a single group
they can have multiple groups
regardless of contexts
dont crosspost. your issue is not related to the topic of this channel
I've got some code here which adds a user to a group called "dead" upon death. It works completely fine without saving changes, yet the API says to always save changes. The expected behaviour was for this to not work. Are there some circumstances where you don't need to save changes?
nvm - just realised that the changes don't save across server restarts, unless i save my changes in the code
always save your changes guys :')
theres a modifyuser method that handles that for you
Hey, does the #getLoadedGroups() already return all loaded groups, or are they null? And if they are null, how do I add all existing groups in the set of groups? Maybe iterate through all groups, but Idk how
Or maybe work with the User object
Perhaps something like this
Its fine, got it to work. Thanks tho
theres a version of luckperms for mc 1.12.2?
dont crosspost
Hello, I need to know if (and how) I can remove a specific group from a user. In the api cookbook, they simply remove all inherited groups from the user // Remove all other inherited groups the user had before. user.data().clear(NodeType.INHERITANCE::matches);
however I don't want to remove all inherited groups, as the user might have purchased a donator group, or might be staff ect. So for this reason, I want to only remove one of these groups from the user private final static String[] prisonerGroups = {"c-fange", "b-fange", "a-fange"};. How can I do this? Thanks :)'
Hello, do you have an event to know when to add/remove a permission to player?
Looking at this method, does the comment about "Unique" mean that the method will not return users who are just a member of the "default" group?
if yes, then how do I get every single user? i'm doing it on server startup so i don't care about blocking the main thread really
luckperms does not store any data about users who only have the default group, as an optimization
Mods can you tell me when I do /lp user parent set owner to a pocket player it's says do /uuid why
np ty
i'm listening for NodeRemoveEvent to check when a player is removed from a specific group. it works fine for the most part, but it doesn't fire when the player's parent data is reset, i.e. when /lp user <user> parent set default is used, despite this also removing the user from the group. how would i also cover for this scenario?
NodeClearEvent iirc, something like parent set is a clear + add process
listening for NodeRemoveEvent and NoveClearEvent should cover all possible ways in which a player can be removed from a group (that isn't default)?
i mean it will still fire if you remove default to add something else
but yeah sounds right
nice
actually, looking at the docs, NodeClearEvent says it's called when a user/group has all/some their existing nodes removed. does this mean that i don't actually need to listen for NodeRemoveEvent, because the clear should cover it as well?
no
basically, NodeRemove is when one individual node is removed (basically NodeMap#remove(Node)) whereas NodeClear is when a bunch are requested for removal (could be a bunch of one) NodeMap#clear() or #clear(Predicate)
got it, thank you!
parent set foo will clear existing inheritance nodes and add foo, whereas something like permission unset cool.thing will remove that one permission
does the add process of this call NodeAddEvent?
it looks like it doesn't... is there another way to catch that?
for context, i'm trying to keep track of all players who are a member of a certain group in a cache
why do you need to cache it?
currently, as well as listening for NodeAddEvent and NodeRemoveEvent, i'm listening for NodeClearEvent and checking whether the set of nodes contains an InheritanceNode for the group, and removing them from the cache if so. but NodeClearEvent is called when doing /lp user <user> parent set <group>, and if the group is the specific group i'm targeting here, they are not added back to the cache, despite now having that group as their primary
this cache may be checked frequently (whenever a player runs a command) and i don't wanna be doing these luckperms queries each time
unless you need offline players too, iterating over online players and doing a permission check should be fine
it does include offline players
yes it does
๐ค
I'll have to check why it didn't behave as expected for me when I get back to my pc
the only case when it doesn't fire is when you already have the node (parent), which is not gonna be the case after clearing them all with parent set
That might have been it tbh
nvm i'm not sure what it was, but it's working as expected now. ty for the help!
Anyone?
in the console do lp editor and then you get a link. Click it and follow the editor it will make it easier for you
this channel is for developers using the api to automate things in luckperms
does LP store when a player was added to a group, and if so is it retrievable?
LP has an internal audit log, I know you can listen to events as they fire, I don't remember if there's API equivelants of the /lp log commands though.
There's definitely no explicit "this node was added at Instant .." api though, that's not stored
there is API for the action log yeah, but it's nothing specific to nodes, just "something happened at this time with this as cause with this as target and this description"
How do I properly promote a user along a track? Currently this is what I've got
User user = luckPerms.getPlayerAdapter(Player.class).getUser(target);
if (!isGuard(user)) {
return new GuardPromotionResult(GuardPromotionResult.ResultStatus.FAILED, "spilleren er ikke vagt");
}
Track guardTrack = getGuardTrack();
ImmutableContextSet contexts = ImmutableContextSet.of("world", WORLD_NAME);
PromotionResult promotionResult = guardTrack.promote(user, contexts);
luckPerms.getUserManager().saveUser(user);
if (promotionResult.wasSuccessful()) {
return new GuardPromotionResult(GuardPromotionResult.ResultStatus.SUCCESS, "");
} else {
return new GuardPromotionResult(GuardPromotionResult.ResultStatus.FAILED, "der skete en uventet fejl");
}
}```
but I don't want the contexts to be set per world, I want it to be global (like doing `/lp user <user> promote <track>`)
just dont add a world context
Well yes, I only added that becasue I didn't know what else to do, but what context should I add instead? The method needs to have a context, right? And I don't see any "global" contexts on the website. Am I misunderstandingsomething here?
Okay wow, I missed this method ImmutableContextSet.empty() in the javadocs, which is obviously what I need
Hello, is there a LuckPerms API event that is triggered when a user is assigned a new group?
You'd probably want to use NodeAddEvent.
There's a example listener in the API cookbook demonstrating it.
Okay, thank you!
anyone know where to aquire these
what does this have to do with the api
hey so I have this code:
EventBus eventBus = luckPerms.getEventBus();
eventBus.subscribe(plugin, UserDataRecalculateEvent.class, this::onUserDataRecalculate);
^ above code is in constructor
private void onUserDataRecalculate(UserDataRecalculateEvent event) {
Player player = Bukkit.getPlayer(event.getUser().getUniqueId());
if (player == null) {
return;
}
TextDisplay nameDisplay = nameDisplays.get(player.getUniqueId());
if (nameDisplay == null) {
return;
}
String serializedPrefix = LuckPermsUtil.getPrefix(player.getUniqueId()).join() + player.getName();
Component prefix = LegacyComponentSerializer.legacyAmpersand().deserialize(serializedPrefix);
if (nameDisplay.text().equals(prefix)) {
return;
}
nameDisplay.text(prefix);
Bukkit.getLogger().info("4");
}
For some reason, onUserDataRecalculate gets spammed when I remove a user from a group or really do anything with it, and my luckperms seems to crash?
the code's purpose is that whenever my prefix changes, it should set the text display's text component to the new prefix
Ok I found out: for anyone who may get this problem, turns out actually getting the players prefix causes the event to fire for some reason lol, so it creates a infinite loop
it isn't getting the prefix
I take for granted your getPrefix function is doing loadUser
that will, well, load the user from storage, causing it to recalculate the data
you are given the user in the event, should use that directly
the package is net.luckperms.api.event.user.track, not net.luckperms.api.event.user
You'll need to load the User if they're offline
explain
!api
Learn how to use the LuckPerms API in your project.
Second link of the above embed explains how to get a User, including what to do if they may or may not be online
Hey maximus_yt! Please don't tag helpful/staff members directly.
mb gang
wait
ok
i did this
will that work?
No. I'd highly suggest reading a guide on CompletableFutures.
What kind of context is this running in, is it on the main thread or async on some other thread?
idk what its on
i tried that b4
Yeah, that also will not work, any variables external to a lambda are effectively final inside the lambda.
Again, I highly recommend reading a guide on CompleteableFutures, async programming isn't the easiest thing in the world to understand.
what abt this
or is that the same thing above
can u just tell me what to put please?
we arent going to write your plugin for you. like _11 said, you should read up on how futures work in java, as its clear that you dont understand them
this is only a couple lines
ik how java works its just this is confusing
you dont know how async tasks work, which is critical when working with offline player data. you dont want to do things that freeze the main thread as will cause lag
Hey, I'm currently experiencing some issues with the nametag color of some players. For reference I create a Team ("hidePlayer") that has the nametagvisibility disabled. To hide the nametag of a player i just add the player to the team. To show it again i remove him from the team. The problem that occurs now is that after showing the player the color of it's nametag is lost and only is reset after rejoining (prob. also when changing rank). Is there something i have to take care of like saving the old team? before adding the player to the other team.
How's that related to the LuckPerms API, considering teams are vanilla minecraft provided? LuckPerms uses groups.
Feel free to elaborate.
Hey!
Would the following method from the docs return whether a player has a permission string or not?
How would this work with Brigadier's command tree, and does it query their group as well, or just the per user permissions?
public boolean hasPermission(User user, String permission) {
return user.getCachedData().getPermissionData().checkPermission(permission).asBoolean();
}
if you just want a simple permission check on an online player, just use your platforms permission check method (eg Player.hasPermission(permission) on bukkit). that way you dont lock your users into using luckperms instead of another permissions plugin if they wish
you can help me with this code?
because
in the bungee api
dont reply to unrelated messages just to ping
every platform has a built-in way to do a basic permission check. look at bungeecord documentation if you dont know what it is
in the bungee is player.hasPermission
but
not work
every return to false
well then you dont have the permission you are checking for
but, i have OP
bungeecord has no concept of OP
since you are using luckperms, you must assign permissions inside of luckperms
okay
this private boolean is correct?
private boolean hasPermission(ProxiedPlayer player, String permissao) {
if (Main.luckPerms != null && player != null) {
User user = Main.luckPerms.getUserManager().getUser(player.getUniqueId());
if (user != null) {
Tristate result = user.getCachedData().getPermissionData(QueryOptions.defaultContextualOptions()).checkPermission(permissao);
return true;
}
}
return false;
}```
Yes, though theres Tristate#asBoolean() which can clean up the tristate stuff.
But also just to make sure you're aware, bungeecord has CommandSender#hasPermission(String) (which ProxiedPlayer extends), so you could just do that unless there's a specific reason you're querying directly from LuckPerms
i using the bungeecord
but
every time return to false
but
i have the permission in the panel of luckperms
have you actually given yourself the permission using luckperms?
yes
show /lp user <your name> permission check <the permission being checked>
What's the output of /lp user <who> permission check <affected permission>?
dammit
frypan
is this from /lp or /lpb?
lp
show it from /lpb
Repeat it with /lpb

Ok I'm blaming my VPN making my ping shit ๐
That'll be why
how to set the permission in the global?
!network
If you run a BungeeCord network, learn how to correctly setup LuckPerms on all server instances (including Bungee).
Syncing data between servers
!switch
You'll probably also need to switch your storage methods since I'm betting you're still using the default h2 storage method
If you wish to change your storage type (e.g. to YAML or MySQL) you may need to follow these instructions to ensure your groups and permissions are migrated to the new storage type.
or just set it using /lpb commands if you dont have a database
if its just a test server, i wouldnt bother setting up a database
eh I'm one for setting up a test server in a similar environment to prod, but to each their own
Hey! I understand that I can utilize the platform's permission check, and this is generally the way I go to for Sponge, Bukkit and so fourth. In modern Forge however, the PermissionAPI they have is a bit meh, so I wanted to query LuckPerms directly and use that in Brigadier, instead of the built in hasPermission that checks for a level integer.
Another example is my server-side menus. It generally works to shows button components if the player has the permission level I assign to the check, but I'd like to check for an actual node instead.
Edit: Seems to work as intended hooking directly into LuckPerms to check for permission in a Brigadier command tree.
As #general does not contain any questions about code. I thought this was the the channel it belongs to. On the other hand? What exactly are groups? They aren't a minecraft concept rather then a luckperms concept are they and is there a luckperms api function to recolor the nametag? aka put the player back in the group?
"recolor the nametag" and "put the player "back" in the group" are two entirely unrelated events unless you link them in your plugin/mod
LuckPerms has nothing to do with name tags and Minecraft teams or scoreboards, it doesn't do anything with them or touch them in any way
That's entirely up to whatever other mod/plugin is hooking LuckPerms with tags
a luckperms group is a group of permissions, so when you give a player/user a group, they will inherit the grouped permissions
Hey!
When using user.getCachedData().getPermissionData.checkPermission(node).asBoolean() in a Brigadier command, or my server-side menu I seemingly have to re-log after assigning / revoking the permission to actually use a command.
Example: I want to run /ban, and gave myself the permission to do so, I had to relog for the client to actually see the change. Is there a reason for this?
I'm far from a Bridadier expert, but if memory serves, you have to explicitly resend the command list to players to refresh the clientside cache of valid commands
I'd suggest adding debug logging to ensure the aforementioned code snippet is returning the results you expect to rule out LP as a potential problem source
I might be missing something, but why is method 1 not working, but method 2 is working?
String key = "group.rankName";
CompletableFuture<Map<UUID, Collection<Node>>> futureUsers = luckPerms.getUserManager().searchAll(NodeMatcher.key(key));
futureUsers.thenAcceptAsync(users -> {
users.keySet().forEach(uuid -> {
luckPerms.getUserManager().modifyUser(uuid, user -> {
// Does not work
user.getNodes().removeIf(node -> node.getKey().equals(key));
// Does work
user.getNodes().stream().filter(res -> res.getKey().equals(key)).findFirst().ifPresent(node -> user.data().remove(node));
});
});
});
PermissionHolder#getNodes returns a view of the holder's nodes. Mutating the view has zero effect on the actual data. This is intentional behavior.
Understandable, is there a more efficient way to remove it? Or is looping through the user's nodes to find the one with the same key the best way if you're working from just the key?
i mean, it has to iterate over it anyways
even if your first method worked, removeIf(func) seems like its just filter(!func())
unless its a question regarding making a plugin or mod that integrates with luckperms, ask in #support-1 or #support-2 and wait for a response
Does offline permission check include player's op state? It looks like it doesn't - result of online bukkit check is other than offline luckperms api check. Is there a way to have the result as normal, including op?
Hey, I'm creating a Velocity/Bungeecord plugin and need help with prefix/suffix things.
What order is the default ordering to getting a prefix? For example; let's say we have;
prefix.100.Owner - server:hub
prefix.100.Admin - No server context
If the player is in the "hub" server, is it default behaviour to show the Admin prefix first or the Owner prefix first?
Lastly, is there a way to do this built-in with the API, or do I have to filter it manually? Right now I'm just using the Stream API to filter it manually. I believe there's a way to do this via the Bukkit/Spigot version of the API, but with a proxy I think there's no built-in way. I could be wrong
The behavior when a user inherits multiple prefixes of the same weight is undefined. This is why prefixes/suffixes have weights on them and not just using the group weight, since situations like this can easily arise. Use the prefix/suffix weight to be explicit as to which should be shown
Basically, a prefix weight should be globally unique, or at least set up in such a way that there's only one way for a user to inherit a prefix of a given weight (i.e. if you have 2 groups that users can choose from, having them share a prefix weight would be fine as long as the 2 groups are mutually exclusive)
Knew it! Thank you so much.
your question has nothing to do with the api. please direct general luckperms questions to #support-1 OR #support-2 (but not both!)
hello, is it possible to make a plugin that will do something ex: send the message "1" when something involving luckperms happens (a log is created/sent)?
@EventHandler
public void onLogBroadcast(LogBroadcastEvent event) {
Bukkit.broadcastMessage("test");
}
I have tried this, but doesn't seem to work.
Correct, LP doesn't use the Bukkit event system since that's not avaliable on other platforms, our API events have their own event bus
!api
Learn how to use the LuckPerms API in your project.
Please use https://pastes.dev/ to send files in the future. I have automatically uploaded code.java for you: https://pastes.dev/hjSfNU0sg9.
Someone will respond when they can.
When is this the case? I'm trying very hard to get an instance that is not up to date but it always is
uh why do you want an out of date User? This sounds like XY problem
so i know what not to do
so i don't do it on accident
why do I get nothing if the player has a prefix?
should be like: L [ะััะฝะธะบ] _MrTvist_ : msg
don't do it like that
the prefix might be inherited from a parent group
it is also calculated, rather than just a single node
you should get the meta data cache from the user, and get the prefix from that
Hellu, i have some weird problem with the Luckperms API and i am not able to reproduce myself on my own machine
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
I am getting this error
On my pterodactyl server but not on my macbook running the exact same version of purpur and luckperms while coding
And yes luckperms is installed xd
would need to see the full server latest.log and your plugin.yml/paper-plugin.yml
I am stripped our my permission fo the paper-plugin.yml
name: Keklist
version: '1.0.0'
main: de.hdg.keklist.Keklist
api-version: '1.20'
description: Custom made white and blacklist with many features!
authors: [ "hdgamer1404Jonas", "SageSphinx63920" ]
website: https://keklist.pages.dev
loader: de.hdg.keklist.KeklistLoader
contributors: [ "LPTP1" ]
default-perm: op
dependencies:
server:
floodgate:
load: BEFORE
required: false
Plan:
load: BEFORE
required: false
Luckperms:
load: BEFORE
required: false
join-classpath: true
PlaceholderAPI:
required: false```
LuckPerms
ยฏ_(ใ)_/ยฏ
but the plugin name there is case sensitive
if im in my hub server and i want the scoreboard to display someones rank (group), where can I get a placeholder to do that?
Hello, is it possible to test if a group exists (from its name) ? I saw GroupManager#getLoadedGroups but i don't know if the group i search will be loaded
Nevermind, just found GroupManager#getGroup which returns null if the group doesn't exist
nobody can help me ?
how i can set rank instead of add rank
ye like i dont even know where to start at? I want to get a permission check and now i need to learn the whole api???
what da hail a completeableFuture?
Why cant i load my offlienuser using the docs
!api
Learn how to use the LuckPerms API in your project.
giving me the api command and not answering a basic question will make the conveniert switch to vaults api even easier for me
Basically, none of the platform APIs support checking the permissions of an offline player, mainly because there's a lot more to it than an online player. You've actually got to load the user etc, deal with that whole lifecycle. There's no way to boil it down to a 1-liner like a permission check of an online player without some serious safety/performance problems
well i think i got it
unless
when there is a player that never joined this server it works perfectly, but when the player joined the server it says user is null
OfflinePlayer target = Bukkit.getServer().getOfflinePlayer(args[0]);
User targetUser = LuckPermsProvider.get().getUserManager().getUser(target.getUniqueId());
Like I said in #support-1 and above, and as explained in the docs ^, you need to load the user if the player is offline
and what do i do with that future whatever thing
Someone will respond to you when they afford the chance. Do not reply ping to grab someone's attention.
If my memory serves me correctly, CompletableFuture usage is documented on the wiki, as linked above.
Indeed it is
Use CTRL + F, unless you're expecting us to spoonfeed you.
if i search for future in the javadocs, nothing returns
User targetUser = null;
OfflinePlayer target = Bukkit.getServer().getOfflinePlayer(args[0]);
if(!target.hasPlayedBefore()) {
targetUser = LuckPermsProvider.get().getUserManager().getUser(target.getUniqueId());
} else {
CompletableFuture<User> futureUser = LuckPermsProvider.get().getUserManager().loadUser(target.getUniqueId());
Executor executor = runnable -> Bukkit.getScheduler().runTask(LaserStaff.getPlugin(LaserStaff.class), runnable);
futureUser.whenCompleteAsync((targetUser1, exception) -> {
if (exception != null) {
// There was some error whilst getting the log.
return ;
}
}, executor);
}```
I've gotten this far. How do i get the user that i get from futureUser and save it as targetUser
im stuck on this and cant get further because your javadocs dont show shit, the response time is 10 hours and the docs dont show anything useful. HOW AM I SUPPOSED TO LEARN HOW TO GET A OFFLINE USER, which BTW. is a VERY BASIC THING A PERMISSIONS PLUGIN SHOULD DO, when the only thing ur plugin docs show, is how to get some Log shit
you are not entitled to support. we are volunteers offering support in our free time. you have been linked to the page on the wiki that includes a section on how to losd users. if you dont understand something on the wiki, you need to say what part of it you dont understand, instead of baselessly claiming our documentation is useless.
What part of this page tells me even the slightest about users
https://luckperms.net/wiki/Developer-API#using-completablefutures
Please do your own research before coming here and spreading misinformation and negativity.
https://luckperms.net/wiki/Developer-API-Usage#loading-data-for-players
It's quite evident you just came here to complain, instead of seeking for genuine support with your LuckPerms API questions. We won't continue this discussion further here. Any info you'll ever need when using the API can be found in the wiki, we've already linked to you numerous times, under the "Developer" section, as well as an example plugin (the api cookbook) demonstrating essential functions and usages of the LuckPerms API found here.
First of all, you are not to tell me when to speak or not. If you cannot take serious criticism then its not my problem.
Also, you are so sure you have
already linked to you numerous times, under the "Developer" section, as well as an example plugin (the api cookbook) demonstrating essential functions and usages of the LuckPerms API found here.
Either I am blind or i have not received any links except those included in !api, which do not include any cookbook or anything relevant even to the slightest about users and completeable futures
I think this cookbook link I found from the link dark posted shows how to load an offline user?
That's more of a platform thing though and not an lp api
I probably won't get much help here, but is there a way to read the prefix of a group using user.getCachedData().getMetaData().getMetaValue("some-key") with skript (and skript-reflect)?
youd have to ask skript
also group prefixes arent normal meta
or prefixes in general
also why do you want a groups prefix and not just the users prefix?
for making rank nicks like changing the nick of a player without changing their rank/permissions, if there is another way to do it i'd be happy to try
you mean tags?
if you explain more on what tags are/what you mean with tags i could give an answer
let me rephrase it, i'm trying to make something similar to the nicking on hypixel where you can change how people see your rank, like you having youtube rank permissions but having a vip rank prefix
I have a question, namely can you get all loaded users with the api. Is it possible that all users are always loaded, even if they are not on the server?
"all loaded users" will usually just be "all online users"
and is there anything to get all the players that have ever been registered?
does anyone know why this wont work
private fun addPlayerToLuckyPermsGroup(player: Player, groupName: String) {
val user = luckPerms?.userManager?.getUser(player.uniqueId)
if (user != null) {
val group = luckPerms?.groupManager?.getGroup(groupName)
if (group != null) {
user.primaryGroup = group.name
luckPerms?.userManager?.saveUser(user)
player.sendMessage("${ChatColor.GREEN}You have been added to the ${ChatColor.LIGHT_PURPLE}$groupName ${ChatColor.GREEN}team.")
} else {
player.sendMessage("${ChatColor.RED}The group $groupName does not exist.")
}
} else {
player.sendMessage("${ChatColor.RED}Unable to find user data.")
}
}```
LuckyPermsGroup ๐
setting a users primary group doesnt do anything
you need to add an inheritance node for the 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.
mkay
like this?
private fun addPlayerToLuckyPermsGroup(player: Player, groupName: String) {
val user = luckPerms?.userManager?.getUser(player.uniqueId)
if (user != null) {
val group = luckPerms?.groupManager?.getGroup(groupName)
if (group != null) {
user.data().add(InheritanceNode.builder(group).build())
luckPerms?.userManager?.saveUser(user)
player.sendMessage("${ChatColor.GREEN}You have been added to the ${ChatColor.LIGHT_PURPLE}$groupName ${ChatColor.GREEN}team.")
} else {
player.sendMessage("${ChatColor.RED}The group $groupName does not exist.")
}
} else {
player.sendMessage("${ChatColor.RED}Unable to find user data.")
}
}```
One message removed from a suspended account.
groups do not store what players are in them. you would need to loop over players and filter the ones that are in the group
if your doing something like sending a message to only players in a certain group, you might be able to get away with just filtering players with the group.<group name> permission
If I change something in the player role with a proxy plugin, will the event also be triggered on the spigot plugin?
Probably
if it's connected with a remote database then maybe because they use their own EventBus
The two servers have the same localhost database but neither the UserDataRecalculateEvent nor the GroupDataRecalculateEvent is triggered for me, I previously had the command in the spigot plugin and it still worked.
If you already did tests on that then you have the answer
I haven't went so deep in their API i just grab user data so not really sure personally
hm okay
check pins
Is there a way to get all known perms from all connectet Servers?
no. luckperms only keeps the permissions it knows about from the current server. also xy, why do you need the list of permissions?
I would like to make the permission command easier and suggest all permissions that exist
luckperms already does that to the best of its ability
Yes, but not from all servers
how i can not shade it in gradle? for velocity?
iam getting this bug
Make sure your dependency for anything you don't want to shade on gradle is a compileOnly, not a implementation.
Hi all
For quite a long time I have been observing a problem with players losing permissions. This may have something to do with the Towny plugin.
When a player joins or leaves a town, he may lose permissions, including his privileges (group.<group_name>), this happens randomly and not all the time.
At first I thought that the problem was in Towny itself, but after talking with the developer he told me โWhen a player leaves a town, and they are online, and they are in a towny world, Towny clears their permissions and assigns the nomad permission nodes. You 'd normally see LP re-assign permission nodes for their group quickly after this. The issue you have is on the LP side of things, or in whichever plugin is not re-assigning the permission nodes to your players".
Can anyone give me a hint to solve the problem? Maybe I can do some debug for this?
luckperms doesnt "re-assign" permissions
something has to tell luckperms to do that, it doesnt just do it on its own
How "something" must tell that to luckperms?
either running the appropriate permission/group commands as console or using the api
anyways this seems more like a #support-1 / #support-2 topic
Is it intended behavior that adding PermissionAttachments during a UserDataRecalculateEvent doesn't call another UserDataRecalculateEvent?
Not sure if adding PermissionAttachments is supposed to call that event at all.
It does not
Works for my usecase ๐
[00:07:43 INFO]: 5ca251ab-589d-4f04-8f0c-28404d0686b0
[00:07:43 INFO]: [RankupMenu] [STDOUT] ForgotUrPassword
[00:07:43 INFO]: [RankupMenu] [STDOUT] rank15
[00:07:43 INFO]: [RankupMenu] [STDOUT] [Nomad, Admin, rank15]
[00:07:43 INFO]: me.lucko.luckperms.bukkit.vault.LuckPermsVaultPermission@26063384
[00:07:43 INFO]: false
Why is it when using vault#playerRemoeGroup, it returns false?
return (this.perms != null && this.perms.playerInGroup(null, p, group));
``` this returns true, they're 100% in the group
this returns false. I tried with world, no world. player name, etc.
it just won't take away the rank
Hi, i need help for make logs with DiscordSRV, does not detect the event.
Channel: logs
Embed:
Color: "#ff1100"
Author:
ImageUrl: "{embedavatarurl}"
Name: '{username} ha cambiado de grupo de permisos.'
Description: "${Optional.getGroupFrom()} **->** ${Optional.getGroupTo()}```
LP's events do not use the Bukkit event bus and as such are not compatible with DiscordSRV's alert system
Can I control how long UserManager#loadUser loads the player for, or is it just kind of GC'd whenever?
iirc api loads last for five minutes
iirc the housekeeper cleans them up after 5 minutes, whether that's from first load or last access, I can't remember
you can't decrease that (e.g. by unloading manually) but you can extend it by cancelling the unload user event
Maybe I should just use the Vault API since all I need to do is check if an OfflinePlayer has a permission.
xd
Oh, I see. Since then, vault-unsafe-lookups has been added. Doesn't matter, I'll go ahead with the API.
Would a permission check for a permission that defaults to true in a plugin.yml return true or undefined (and therefore false) here? Just interested, my design does not depend on this.
true
assuming a default config anyways, admins can disable that behavior
I know, I've disabled that myself lol
Can I subscribe to events asynchronous or does it have to be synchronous?
can i edit luckperms messages in code?
the eventbus is thread safe, yes
no
you could intercept outgoing message packets, but dont do that. its not worth it
Hey, I don't really know if this is the right channel, but here's my qustion: is it possible to add/set the parent group of a user using the LuckPerms REST API?
There's User#setPrimaryGroup
I know it's possible through the Java API, but I'm trying to use the HTTP REST api
Oh, no idea ๐คท
errr
no thats setting the nodes in a group
if you want to emulate the parent set command, get /user/<id>/nodes, filter for nodes with "type": "inheritance", and then pass those to delete /user/<id>/nodes, and then post or patch /user/<id>/nodes with the group(s) you want the player to have
post only adds 1 node, and patch can add multiple
if you want to emulate parent add, you can just do the last step
@desert fractal
I was wondering how luck perms handle &#HEXCODE?
Since it supports both mini message and &#HEXCODE... but LPC doesn't support mini message I wanted to adapt plugin to handle &#..... too.
(PS: Sorry if its dumb question to ask about classic &#)
LPC is not affiliated with LuckPerms, and support for LPC is not provided here.
I mean luckperms support &#HEXCODE both mini message when we set prefix node in both ways.
luckperms does not handle color codes
the only place it does any handling of color codes is in the preview when using certain /lp commands. it does not apply the formatting when another plugin display it in chat, the tablist, etc
but again
wrong channel
Well in /lp group <groupaname> info? The prefix and suffix seems to be formatted.
Well its not about usage help, nor web help :>
So don't know where to throw it. ๐
well it has nothing to with the api
#contributors if it's code related
Ok boss.
Hey guys
Could anyone please help me?
Im having troubles
So this is my code
Im making a Hover Plugin, where if a player hovers on top of a player username, he gets some info about his
Admin, Moderator, User etc
And it works perfectly fine
But when I put the plugin in my plugin folder
And I write a message in chat, even tho Iโm in a LuckPerms group with prefixes, I dont see my prefixes
So I implemented the LuckPerms API
But I receive this, why is this.luckperms null?
Because you never assigned any value to your LuckPerms field. Also don't reinitialize your prefix variable if the User is not null, instead reinitialize it if the User prefix is not null because a User will never be null but a prefix can be null
So I should just remove that line?
And which value should I assign to this.luckperms?
And how do I assign it?
Iโm new in this
Take a look at this > https://luckperms.net/wiki/Developer-API#obtaining-an-instance-of-the-api
I should add this to my code? ```RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
LuckPerms api = provider.getProvider();
}```
That's one way to access the LuckPerms API, yeah
But I already have the LuckPerms API installed in my dependencies
Should I send u the screenshot of the error maybe?
In your DMs?
You see the LuckPerms field?
It's not initialized, basically you're not setting it to anything. The code won't magically initialize it for you behind the settings
This code is what the LuckPerms field should be set to. You can add that to the main class and use dependency injection to give it to your ChatListener class(why is it called ChatListener when it has nothing to do with chat though)
Well Colored Usernames
You can also use the static getter LuckPermsProvider#get if you don't want to use the Bukkit services manager
But I would remove it if LuckPerms decides to work and get the prefixes
So if I understand correctly
Did you learn java before getting into spigot development?
Yes
smh
You should not hardcode the display name colors tho, that way you need to modify the code every time you make a new rank
I simply added the ChatListener bc LuckPerms prefixes didnโt work
But by testing it, it also didnโt work
You need to get the User object of the player who joined in order to access their prefix right?
Yea, but when I send a message in the chat
A whole red block of errors show up
In the console
Okay in order to access the User object you need the UserManager class right?
I guess so
you're using the UserManager to get the User
Okay, where does UserManager come from?
it comes from the LuckPerms class
You need an instance of the LuckPerms class in order to get data
This here will give you that instance
Ok so Iโll add that to my code
Sure
Will this resolve my problem?
It's throwing an error because your LuckPerms field is not initialized at all, it doesn't have any value so it can't get UserManager from it because it doesn't exist. If you had an instance of LuckPerms then it wouldn't be null
You're just making a LuckPerms field, what are you assigning it to? nothing
oops wrong image
Okay, you can give your ChatListener class that instance using Dependency Injection (since you didn't go with the static getter). Take a look at this guide for dependency injection > https://www.spigotmc.org/wiki/using-dependency-injection/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
So if I understand correctly it should be looking like this
this.luckperms = plugin;
}```
That's close
You need your actual main class not JavaPlugin though. Also please follow java naming conventions, the paramter names should be camelCased, although you should not name it LuckPerms because that's your main class not LuckPerms
What about now?
Now?
._.
Maybe now?
To get an instance of your main class using dependency injection, you make a field then initialize it to your constructor parameter
You should read the guide I sent
Read it carefully, you don't need to be on a hurry
My main class?
Which class of yours extends JavaPlugin -.-
Main class
Yeah then that's the one
But why is โpublicโ an unexpected token
The last constructor should work after you've applied what I just told you
also don't name it luckPerms because it's not that, it's your JavaPlugin class
common practice is to name it plugin since it's your plugin class like you might've seen on the guide I sent
I doubt you actually read it ๐ค
So I should just write HoverInfo?
Since its my JavaPlugin class
I read it
Yeah so you're gonna have a getter for LuckPerms in your main class, you're gonna be using DI(dependency injection) to access your main class and then use the LuckPerms getter
The getter will return the provider provided by the Services Manager
So it should be looking like this?
Iโm not understanding
this.HoverInfo = HoverInfo;
}```
Should it look like this?
This makes no sense, where's your main class field, how are you setting a non-existing HoverInfo field(breaking the conventions again) to a non-existing HoverInfo parameter?
U told me to substitute plugin with my JavaPlugin class
Here's an example:
public class MyListener implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
// Set the join message to join-message value from config
event.setJoinMessage(""); // Need the getConfig() method from the main class
}
}```
Now I can use dependency injection to get my main class. So basically when I register my event in my main class I can pass in `this` as an instance of my main class:
```java
public class MyListener implements Listener {
private final MyMainClass plugin;
public MyListener(MyMainClass plugin) {
this.plugin = plugin; // Setting the plugin field to the provided main class instance (This will get called before the PlayerJoinEvent so we will have a main class instance to access stuff from the main class)
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
// Set the join message to join-message value from config
// Now we can use the plugin field to access the getConfig() method from JavaPlugin
event.setJoinMessage(plugin.getConfig("join-message"));
}
}```
So in your case you will need your main class instance to access a method that returns an instance of the LuckPerms class that allows you to access LuckPerms methods like `LuckPerms#getUserManager`. You will make that method get an instance of LuckPerms using Bukkit's ServicesManager
On the main class I could do this:
public class MyMainClass extends JavaPlugin {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new MyListener(this), this); // We're providing "this" for the MyListener class so it can set the field named "plugin" to this instance and thus we can access methods from here (we want to access the getConfig method)
}
}
In your case you'll have a getLuckPerms method you want to access from the main class
If there's anything confusing you make sure to ask, you need to understand this perfectly :>
So Iโll need to change new MyListener(this) this
To
new MyListener(this) plugin
In my main class right?
No
You don't have a variable or field named plugin in your main class. Java's keyword this refers to the class you are in so you can just pass that as a reference to your main class that you are in
If you're in the class for example MyClass then this refers to that class (this is a Java keyword)
Oh ok
So, Iโll just need to leave my Main Class alone, I donโt need to touch it for now
I now need to make the DI
Yeah
Thatโs the part I get confused
Yeah because you're doing it wrong
But I need to understand it first
this this.plugin = plugin basically this.plugin refers to your plugin field and plugin refers to what was provided in the constructor when the class was initialized
the this keyword also refers to the fields inside the class
so this.plugin is referring to this
We're using the private access modifier for the field because we are never using it outside of this class
So do I need it?
Just put it there yeah
Okay, now go to your main class and make a getter for LuckPerms that returns the provider from Bukkit's Services Manager. You can use the code you got from LuckPerms' wiki
This one?
We already added it
You added it into the onEnable but you're never using it
Make a LuckPerms interface field in your main class, and set it to your provider.getProvider(), then make a LuckPerms getter that returns your field
What don't you understand exactly?
This
Do you know what fields are?
Int, Boolean, double etc
You can have primitive type fields but they aren't only primitive types
public class Example {
private int exampleInteger; // <-- That's a field
}```
Now make a LuckPerms type field and set it to provider.getProvider() in your onEnable
private is the access modifier of the field
int is the type of the field (In your case you want a LuckPerms one)
exmapleInteger is it's name
And this one isn't initialized yet. You want to initialize yours on the onEnable and set it's value to provider.getProvider()
Where do I find LuckPerms fields?
Bro you already have a LuckPerms field in your ChatListener class. Just delete it and put it inside your main class instead, then assign it's value to provider.getProvider()
And make a method that returns your field
That's really basic java stuff
Yeah that's an instance field
Just move it it to your main class
And do the steps I told you
I already have one in my main class
Where is it?
Oh nice, and you have a getter for it too
Now add back the code you got from LuckPerms' wiki, and instead of making a new LuckPerms variable and assigning it to provider.getProvider() assign your instance field
Where should this all be placed?
I know in my main class
Inside your onEnable method
So I should write this luckperms wiki code 2 times? One for bukkit Manager and 1 for the instance?
The same it was, but just set the provider to your LuckPerms field. I assume you know how to assign a variable, don't you?
No, just write it in the onEnable once and do the the steps I told you to do
I have already one luckperms code in the onEnable
Donโt u remember we wrote it together?
It was for the provider
Ohh this was your old code
Can you send a new paste with your main class?
Sure
Okay, you see this line
LuckPerms api = provider.getProvider();```
Instead of making a new variable called api and setting it to provider, just set your luckperms field to the provider instead
LuckPerms luckperms = provider.getProvider();
You are still making a new variable
You need to set your luckPerms instance field to that instead of making a new one
did you learn java ?
He told me he did but I really doubt it
ye
@frozen pike
you create a new variable in the main class
then initialize it in the onenable
I donโt know how to
Could u explain?
Let's say you have a price variable:
double price = 2.99;
Do you know how we can reassign this variable to be 4.99?
Just change the 2.99 to 4.99
No, I mean reinitializing it
double price = 2.99;
// We feel like changing it to 4.99 here
System.out.println(price); // This should print 4.99 not 2.99
How would you do it?
price = 2.99
``` at this part of the code, we're initializing it to 2.99
How could we re-initialize it to 4.99 afterwards?
Idk
This is extremely basic and is covered in every single beginner java tutorial ._.
You should learn java before hopping into Spigot Development so that you can know what you're writing
Hey everyone, How to use the command /lp bulkupdate users delete "permission ~~ quests%" but I don't need to enter a confirmation code
what should I do? Is there any configuration to fix it or how to use the api to turn it off?
Ops
That has nothing to do with the API. You've enabled a setting in your LuckPerms config allowing you to skip bulk edit confirmation.
Additionally, you shouldn't attempt to mass ping others when asking for support.
Could u explain?
bro
So can you show me where it is located?
No, but you can search for yourself using CTRL + F in your text editor search for skip or bulk.
hmm, i use luckperm 5.4 but i don't see any char skip or bulk in config
If you can't locate it, manually add it yourself. You can keep your config up-to-date, by comparing the one you currently use with the default one from GitHub.
For further non API questions, please use #support-1 or #support-2. 
Btw I did it
this.luckPerms = provider.getProvider()
Exactly
Now use your plugin field to access the getLuckPerms method and get the player's prefix
How would u do that
I couldnโt find that anywhere
Replace this with your main class' getLuckPerms method
bro what do you have the main class instance for?
Yeah you have your HoverInfo field...
Yes
Yeah access your HoverInfo's getLuckPerms method using that
Using this? this.luckPerms = provider.getProvider();
Well yeah, your getLuckPerms method returns the provider
Just use your getLuckPerms method
You already have access to your main class
So for example like this
LuckPerms getLuckPerms = provider.getProvider();
No
Wait
Mmmmh
Why are you changing your ServicesManager code?
Okay, now use your plugin instance field to access the getLuckPerms method
How would u do that?
I would do this
Perfect, thanks :)
public LuckPerms getLuckPerms() {
return api;
}```
I should add this to my main class
Where
I strongly encourage you to take a basic java course :>
It's really not good to start writing spigot plugins when you lack basic java knowledge
Where do u see that bruh
Here
I had already told you to make a getter for your luckPerms field a trillion times
it is expected that you have a basic knowledge of how to program with java before writing a bukkit plugin, and by extension, using the luckperms api
LP's API in particular uses several more advanced concepts like futures, so at least get comfortable with the bukkit API and java before attempting to use LP's API
Also, if you're just trying to get a player's prefix, the vault API might be easier, though it's less powerful
It's the same tbh, you need to grab an instance of Vault's chat API using the bukkit ServicesManager too. The only difference is the prefix getter with Vault is a little shorter line than LuckPerms
Vault's get prefix thing is a single call, LP's API requires getting the user, then getting the prefix from their cached data. LP's API is far more powerful, but for the majority of users who just want to grab a prefix, I'd say vault is easier (plus compatible with other permission plugins)
That's exactly what I mean by Vault's prefix getter line is shorter. Don't think those 2 extra getters that will get you to getPrefix really matter also when you're making your own plugin that grabs data from permissions plugins you really don't need Vault because you're 100% sure of which permissions plugin your network/server is using
This is what another coder suggested me to add
and replace private LuckPerms luckPerms; with private LuckPerms luckPerms = plugin.getLuckPerms();
You can't do that tho
Since your plugin field is not initialized when this code runs it will throw an NPE or your IDE won't let you do that
Could u explain me then what u mean in ur step?
I donโt understand what u mean
Iโve been stuck here since 3 days
again, you should have a grasp on the fundamentals of java before diving into bukkit plugin development
Yeah and that's why I am continuously suggesting you to leave this project and learn java fundamentals then come back here
Hi! I am confused on using luckperms on a fabric server. Trying to do basic commands to ranks and have prefix displays however after creating the group and adding as parent there is no display in chat
seems like the luckperms with all groups doesnt work on my fabric server
Just curious, is it possible to have the fabric mod and include plugin perms when using Arclight? Or in any chance that you can combine the perms from plugins into fabric or vice versa
That's not a question about using the LuckPerms API and hybrid software, such as Arclight, are unsupported.
One message removed from a suspended account.
One message removed from a suspended account.
LuckPerms only stores the lowercase username for storage and lookup purposes
it isn't for displaying etc
you have the user uuid anyway so you can just get the OfflinePlayer by id and the name from that?

i have a paper plugin that adds/removes permission nodes (that are groups) from players
but for some reason, that information doesnt update on the proxy until i do /lpv user <> info
i havent had any issues with luckperms in general across the network up until coding this little thing, but its meaning that my velocity tab/chat plugins arent updating properly until its force updated
any ideas?
see pins
ahh okay that works, thankl you
!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, Is it the right way to set a permission to true with the luckperms api ? Thanks
private void addPermission(String group){
LuckPerms luckPerms = LuckPermsProvider.get();
GroupManager groupManager = luckPerms.getGroupManager();
groupManager.getGroup("group").getCachedData().getPermissionData().getPermissionMap().put("permission.x", true);
}
I looked here and I don't understand how to modify permission, how to set them to true or false...
https://luckperms.net/wiki/Developer-API-Usage#creating-new-node-instances
Is it like that ?
PermissionNode permissionNode = PermissionNode.builder("permission.X").value(false).build();
groupManager.getGroup(group).data().add(permissionNode);
Yeah but you got to save the group afterwards GroupManager#saveGroup, or you can use GroupManager#modifyGroup which handles it for you. Take a look here > https://luckperms.net/wiki/Developer-API-Usage#saving-changes
yes i just saw that, thanks
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Hey, I looked at this, did it, and it still doesn't set my group.
does it do anything?
it wont set the persons rank
do the messages send? does it clear the previous groups?
read above
dont reply just to ping
sorry, but can you help?
ok then turn it off
how are you verifying that?
i use the right code but it wont set
how
/lp user (player) parent info
and both of those messages are being sent?
yes
do you have any LP event listeners that could be interfering? any other plugins running?
not that i know of
well then, are you listening to any LP event? and what other plugins are running on the server?
not that i don't wanna try but i know for a fact that that code is not flawed (apart from the Player cast, I'd use getPlayer instead) 
are you listening to any LP event?
or changing the groups anywhere else, in some bukkit event or whatever
explain
thats only for sending the msg
and it works
no
ยฏ_(ใ)_/ยฏ
if you have a minimal reproducer with just lp and your plugin without other stuff potentially interfering (even from within your plugin) then that's worth investigating for sure, but that code you shared right there is WAI
just to be sure
!paste your LP config
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!
that's no easy answer, and there are many parts involved in that single snippet as well
yeah it's not super straightforward, but it resolves the parent groups from the inheritance nodes
what about /lp user <user> permission info ?
hold on
or better yet, /lp user <user> permission check group.whatever, screenshot that please
i tried this originally
setting primary group doesnt do anything by default
but you were asked to send a screenshot of a command output. please do that
which version of the code does that correspond to ๐ฅด
this one
well, that snippet of code certainly works as it is, so it's something else somewhere (be that some setting in LP or something else in the plugin or some other plugin) that's messing around the wrong way
i can't see your entire setup, you could send your lp config and publish your project somewhere on github or similar, but other than that it's on you to debug why really, that's all i can say from just this info
Hello Guys ๐๐ฟ
Im trying to add a user a group if he buy it in the ingame rankshop
My Code:
Variables:
LuckPerms api = LuckPermsProvider.get();
User player = api.getUserManager().getUser(p.getUniqueId());
If he buy it:
p.closeInventory();
user.getEconomyAccount().withdraw(250000);
p.sendMessage(prefix + "ยงaDu hast den Kauf erfolgreich abgeschlossen!");
player.setPrimaryGroup("premium");
api.getGroupManager().saveGroup(api.getGroupManager().getGroup("premium"));
api.getUserManager().saveUser(player);
setPrimaryGroup is no-op with the default config, you realistically shouldn't ever need to call that method.
See the cookbook for an example of how to set a player's 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.
Please use the double slash for comments in your code. Also LuckPerms' User class does not have a getEconomyAccount method.
As for setting the group, instead of using User#setPrimaryGroup you should add an InheritanceNode to the User, see LuckPerms cookbook ^^
The getEconomyAccount is from a other API
thanks
oh mb
is there any way to access the luckperms common module?
no, why?
because i need to access the files on my plugin load
what files?
dont change the config
if your plugin requires a certain thing to be in the luckperms config, note that somewhere in your plugins documentation or something
How to fix this error?
https://pastebin.com/6cvYQj7B (build.gradle.kts)
https://pastebin.com/8xJhsSGZ (Error Stacktrace)
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.
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.
Did you verify that you didn't do any of these?
- The Plugin is downloaded
- It dose (in build.gradle.kts)
- In which part should I mention Luckperms first? Is the part with @Inject wrong?
Did you add it as a dependency in the plugin.yml?
actually wait you're using velocity
You need to share your code, please paste it in a pastebin
you need to get it in the proxyinitializeevent, not have it as an @injected field/constructor parameter
^^
https://pastebin.com/6cvYQj7B (build.gradle.kts)
https://pastebin.com/8xJhsSGZ (Error Stacktrace)
https://pastebin.com/dAd9nEB6 (Post Login Listener)
https://pastebin.com/AKbEDfGA (Luckperms.java)
That was the fix, Thank you so much!
Velocity's onEnable equivalent is the ProxyInitializeEvent so you should get LuckPerms inside that, idk why LuckPerms assumed you were using spigot in the last quote :p
it probably says the same thing on every platform
!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.
Hi everyone. I'm writing my own server web cabinet and want to get current parent group of user.
I can get it from db, but maybe someone know more better way? Bcs in db table lp_user_permissions saved all player groups as permission
and it's hard to manage it
Hey there ๐ wanted to ask if there was a chance that a User object can die while the player is still connected to the server?
Or if it may return null or smth at some point
No, as long as the player is on the server, their User object can't return null
Yeah that's what I assumed
you can/should use the rest api extension instead of accessing the db directly
!rest
Sorry! I do not understand the command rest Did you mean latest?
Type !help for a list of commands
Yep thanks, i found it
that's gonna run on a real LuckPerms instance and will be able to do all of the standard node resolution etc
it's pretty nifty
Hello, do you maybe know what loadUser() internally does?
provider = LuckPermsProvider.get().getUserManager();
if (provieder.isLoaded(uuid)) {
group = provider.getUser(uuid).getPrimaryGroup();
} else {
provider.loadUser(uuid).thenAccept(...);
}
What would happen if the user is already loaded and I would use loadUser() on it? Would it then just use the getUser() or somehow unload -> load it again?
Or is loadUser that check doing too?
loadUser will always load from storage, if it's already loaded it will reload it, e.g. for messaging changes between instances of an online user, the instance responsible needs to load it again
or if you don't have messaging set up you can load the user or trigger a full sync manually