#luckperms-api
1 messages · Page 8 of 1
you can manually call ContextManager#signalContextUpdate(player), but contexts are invalidated 50ms after they are calculated, so they should be pretty much updated every tick they are needed
thank you!
in my case, the default group inherits another group if my context is true. I have a WorldGuard region which has the "another" group added as a member, and disallows its members from exiting it - i.e. if a player is in the group, they are not allowed to leave the region.
when my code that causes the context to be true is run, WG is not realising the group change, so I reset its cache. this normally works to make WG realise group changes immediately, but it didn't in this case, so my suspicion is that the group inheritance was not being applied as soon as the context became true.
calling ContextManager#signalContextUpdate(player), and then resetting WG's cache, seems to have fixed the problem, but I'm not sure if this is the best way of doing it
can you iterate through group members and make permission changes async?
most changes occur off the main thread
I made a method that returns the current rank on a given server, is there a simpler way?
return user.getNodes(NodeType.INHERITANCE).stream()
.filter(node -> node.getContexts().getAnyValue(DefaultContextKeys.SERVER_KEY)
.map(value -> value.equals(server)).orElse(false))
.map(InheritanceNode::getGroupName)
.map(luckPermsHook::getGroup)
.filter(Objects::nonNull)
.sorted(Comparator.comparingInt(group -> group.getWeight().orElse(0)))
.map(Group::getFriendlyName)
.findFirst()
.orElse(user.getPrimaryGroup());
uhhh
user.getCachedData().getMetaData(QueryOptions.contextual(ImmutableContextSet.of("server", "lobby"))).getPrimaryGroup() 😃
So the best thing to do would be to get all the nodes from a given server, compare to the primary group and see if it's expired?
depending on the setup, a user may have a temp parent that isnt their primary group
its also possible they dont directly inherit their primary group
what exactly are you trying to do?
On the hub server, I retrieve what primary group someone has on the survival server and possibly how long it lasts (for example, if someone has a VIP rank they have it for a certain amount of time)
Hey, Gemini gives some old/wrong info about this, so how can i unset a permission from a user? Ive used this (untested) for adding perms until yet:
public void addPermission(UUID playerUUID, String permissionString) {
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
LuckPerms api = provider.getProvider();
if(Bukkit.getPlayer(playerUUID) != null && Bukkit.getPlayer(playerUUID).isOnline()) {
User user = api.getUserManager().getUser(playerUUID);
user.data().add(PermissionNode.builder(permissionString).build());
api.getUserManager().saveUser(user);
} else {
api.getUserManager().loadUser(playerUUID).thenAccept(user -> {
if (user != null) {
user.data().add(PermissionNode.builder(permissionString).build());
api.getUserManager().saveUser(user);
}
});
}
}
}```
!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.
theres probably something about removing nodes there
i see theres a .remove(node) function, is that just it?
help me pls
is not a valid username/uuid
You'd want to redirect that question to #support-1 or #support-2, as it's safe to assume you're having trouble using LuckPerms commands on bedrock players.
Hey, I have a question, how do I check whether a user has had a rank taken away and if so, which one? The same with adding who was added and to whom.
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
I have a Forge related question (Running 1.18.2 but I'm guessing it will be the same for NeoForge)
At what point it's safe to initialize API? Is it safe to add api as compileOnly? I don't want to break runServer task, because I'm guessing adding a compileOnly won't add forge distribution of LP to the runServer configuration
I tried that but nothing happens, I'm trying to install it in Valocity
youd have to share code then
public class RankSyncListener {
private final LuckPerms luckPerms;
public RankSyncListener(LuckPerms luckPerms) {
this.luckPerms = luckPerms;
}
public void register() {
EventBus eventBus = this.luckPerms.getEventBus();
eventBus.subscribe(VelocitySystem.getInstance(), NodeRemoveEvent.class, this::onNodeRemove);
}
private void onNodeRemove(NodeRemoveEvent e) {
// Check if the event was acting on a User
if (!e.isUser()) {
return;
}
// Check if the node was an inheritance node
Node node = e.getNode();
if (node.getType() != NodeType.INHERITANCE) {
return;
}
// Cast the node to InheritanceNode, and the target to User.
InheritanceNode inheritanceNode = ((InheritanceNode) node);
User user = (User) e.getTarget();
String groupName = inheritanceNode.getGroupName();
for (Player player : VelocitySystem.getInstance().getServer().getAllPlayers()) {
player.sendMessage(Component.text(user.getUsername() + " removed from the " + groupName + " group!"));
}
}
}
And
@Subscribe
public void onProxyInitialize(ProxyInitializeEvent event) {
MessageLoader messageLoader = MessageLoader.getInstance();
server.getChannelRegistrar().register(CHANNEL);
MySQL mySQL = new MySQL();
Connection connection = mySQL.getConnection();
setupDiscordBot();
instance = this;
server.getEventManager().register(this, new Listeners(server, logger));
this.luckPerms = LuckPermsProvider.get();
// Kommandos registrieren
registerCommands();
if (connection != null) {
logger.info("Datenbankverbindung erfolgreich hergestellt.");
mySQL.checkAndCreateTables();
} else {
logger.error("Es konnte keine Verbindung zur Datenbank hergestellt werden. Bitte überprüfe deine Datenbank einträge.");
}
logger.info("Das VelocitySystem wurde erfolgreich geladen.");
new RankSyncListener(this.luckPerms).register();
}
is the permission being removed on velocity or the backend
because if its removed on the backend, the even will only be emitted on that backend server
So... can I do this somehow so that I can continue to use it on the subserver
How to get metadata without CachedData ?
How can I remove an expiry permission from a player?
user.data().remove(permissionNode) don't working. I think it's because the expiration time is changing.
You need to save the changes
Heh. Thanks.
is there some luckperms library that I can shade into my standalone application?
from what I can see in the github repo, it seems that the standalone module is the closest I can get, but still not quite what I need
xy. what are you trying to do
How can I do permission node tab complete hints like in luckperms commands?
Player possiblePeer = Bukkit.getPlayer(event.getPeer().getActor().getUniqueId()); how can i check if permission have changed,i think i need the UserDataRecalculateEvent. but how can i use it in an event?
I don't quite understand what you're trying to do, but you could take a look at this wiki page for events > https://luckperms.net/wiki/Developer-API-Usage#events
becouse that if statement doesnt work i need to check if permission changed
with the uuid provided from the openaudio event
thanks i will have a look
later
SOmeone pls can help me with that
it should listen when voicechat.talk gets removed
i'm not exactly sure what you're really asking about
do you want to do something when a permission is revoked?
UserDataRecalculate should be fine for that, just check for the user's permission there to see if for the updated data they have the permission
i need something like this: if (event.getPeer().getActor().getUniqueId()== UserDataRecalculateEvent )
so i need to use an event in an event
you can't do something when 2 different events fire "at the same time", since they will never fire at the same time.
XY problem, what is it you're actually trying to accomplish?
i want an channel talk permission: voicechat.talk, so that players can only talk with the permission, unfortunately it only works if player gets in the channel, it cant hear if player gets the talkpower removed, so i have to make an luckperms event listener inside the ClientPeerAdd (only when client peer gets added, not when its should get removed, Event so i can kick him, to retrigger the ClientPeerAdd event from open audio
Why can't you just trigger the disconnection from the LP event listener?
i think i need the uuids event.getPeer()
event.getClient().
client should get disconected from peer whos permission got removed
event.getClient().kickProximityPeer(event.getClient()); // Call kick method
but it could be that it automaticly detects
i could try
it should be that it automaticaly detects the other client
thank yall, it did work
a pretty late reply, but...
I'm building an API server for the server's website and we want to rely on LuckPerms API for permissions and groups instead of reinventing the wheel
well, you are reinventing the wheel
standalone lp is designed for running the rest api extension
Loop through all registered permissions, add them to a list and return the list
It's worth noting that will not get everything. Only maybe half the plugins actually register their permissions properly, and a ton have "dynamic" permissions (i.e. derrived from stuff in your config) which typically aren't registered either.
LP builds it's list by saving all permissions that have been checked since the last server startup.
(that method also has the additional benefit of being completely platform-agnostic, so we don't need to write any hooks to the platform's permission registration manager)
If I want to modify an existing permission for a player, do I just add it to the data again or how does that work?
yeah you need to call nodemap#add
But does that overwriter existing permissions with same node key? Because that's what I want to do
"it depends"
on what you're altering exactly
if you're just changing the true/false value, it will be replaced yes
I'm changing meta data
like, a meta node's value? or metadata on a node?
Not sure what the difference is, just changing a node based on rank
public enum Rank {
GREEN,
YELLOW,
RED;
public static final NodeMetadataKey<String> META_KEY = NodeMetadataKey.of("rank", String.class);
public static final String RANK_PERMISSION = "rankupdater.rank";
public Node getPermission() {
return Node.builder(RANK_PERMISSION).withMetadata(META_KEY, name()).build();
}
}
meta nodes are nodes that let you store arbitrary information on a group/user as a node
those will show up in the editor, there are meta node commands, the data is query-able, etc
it's basically a key/value storage
Oh as in a different type of node? How is that used?
I might be misunderstanding you, but I need to use something else than the regular node right?
you'd be using MetaNodes, yeah
Ah yeah I see, nice, basically like pdc it seems
there are several kinds of nodes, you have every day permission nodes, inheritance nodes (that define parent groups), prefix/suffix nodes, and others
learned that was the worst way to do it, sure
So this looks right?
public Node getPermission() {
return MetaNode.builder("rank", name()).build();
}
yep
Not sure where I'd assign the regular node key here
Referring to MetaNode#getKey and MetaNode#getMetaKey btw
ig I need to also add key in the builder
you don't, the meta key and value form the node key, so when passing those to the builder LP will take care of those
the meta key in this case is gonna be "rank"
the whole node key is gonna be meta.<key>.<value>, but that isn't exactly important
How can I do permission node tab complete hints like in LuckPerms commands? Like this:
lol
Sorry. I'm blind.
Hello everyone, how do I transfer all Fabric mod permissions to luckperms so that they are displayed as suggested in the editor?
not entirely sure what you mean by "transfer all fabric mod permissions to luckperms"? but just performing a permission check will suffice, LP will add it to its known permissions set to be suggested
if my luckperms is running cross-server, will User user = luckPerms.getUserManager().getUser(uuid); ran in server A return a player that is in server B?
No
well, itll get the luckperms user with that uuid
that user will only have data loaded if they are on the server that ran it
afaik, luckperms doesnt communicate anything between multiple instances on its own beyond simple permission changes
How do you check if a player has a permission, either in their custom permissions or of some inherited group? Is there an easy way to do that or do you have to traverse the entire inherited group tree?
use the platform provided method to check permissions
eg on bukkit, you use Player#hasPermission(String permission)
wdym platform provided?
oh i see
the permissions system is not made by lp just used by it
yes
i forgor
there are times where you would need to use LPs api directly, such as modifying player data or getting prefixes, but you shouldnt use the LP api for basic permission checks since that prevents people from using other permission plugins/mods with your plugin/mod
thank you for the help!
Hello did you figure out why your players lose permissions?
if you are having an issue, you should share as much information as you can in one of the support channels
instead of replying to a message from several months ago
Is using LP API a more wise decision than using the Forge permissions API?
is there a way to get user's current group in a track?
I'm trying to get player's rank prefix
You can get a track, get its groups by calling #getGroups and check if your user is in one of those groups (if that's what you mean)
exactly, but I thought there would be something like Track#getCurrent(User)
what does their position on a track have to do with their prefix?
user's prefix is not its rank prefix and im trying to display users rank prefix
xy, what are you actually trying to do
actually
why do you need to get the group prefix manually and not just the users prefix which inherits from groups
user's actual prefix is not its rank by intentional
Then you can get the user's group and get that group's prefix
that's what im gonna do rn, get ranks track, iterate groups and get prefix
why don't you directly use User#getPrimaryGroup or User#getInheritedGroups?
ranks are different from other groups which user uses for their prefix
Anyone know how lpUser.setPrimaryGroup() works? Because a user can have multiple primary groups?
Primary group =/= parent group. Parent groups is every group a player inherits directly from. "primary group" is a concept other plugins use, with the default config it's calculated as the highest weighted group a user directly inherits. With the default config, that method, and it's command equivelant /lp user <who> setprimarygroup <group> do absolutely nothing.
they cannot have multiple primary groups. they can have many parents. primary group is kinda an arbitrary concept and defaults to "the parent group with the highest weight", and this is calculated on demand as it could change with contexts
Ahhhh I see, so I have 3 groups, green, yellow and red. Players cannot have multiple of these as they're setup as a progression. I'd need to manually add and remove the user from groups right?
Nope, users can inherit multiple groups (even if some of the groups are both contained on the same track), LP doesn't care.
Primary group is only used to be exposed to other plugins to request as needed, LP does absolutely nothing with primary group on it's own
it's a bit of a weird concept since every sane permissions plugin allows a user to have multiple groups, so it's only really used by a handful of plugins
Is it not possible to get all inherited groups for a user?
yeah it needs the primary group concept for Vault's getPrimaryGroup method too
Yes it is
!api
Learn how to use the LuckPerms API in your project.
The User interface has a getInheritedGroups method you can use
So if I had a node called group.whatever it adds an inherited group to the user called whatever if the group exists?
Correct
Ah yeah
Ahhh alright, thanks guys!
btw I suggest you take a look at the Cookbook, it's a project with code examples on how to use the LP API
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Probably a good idea yeah, thanks
What does lpUser.setPrimaryGroup even do then? If I only need to add a node with the group. prefix?
Admins can configure the primary group calculation to "manual", where instead of calculating it automatically via weight, they need to manually specify the primary group via either commands or that API. I don't think I've ever encountered a single case where that was legitimately better than automatic calculation though.
But with the default config it'll do absolutely nothing
Ah alright, I'll just add the node then, thanks!
Yeah, especially since setting the primary group does not add that group as a parent if it wasn't already
Yeah ran into issues because I misunderstood that part
Like I said, it's a weird system, and in an ideal world I'd nuke it from orbit since it's got so little usage. but alas, we need it for vault and a few legacy plugins
Hahah yeah vault is kinda annoying sometimes but it's just used in so many plugins
does luckperms not support color codes in PAPI placeholders ?
i'm stuck with this rigth now and its very annoying
How's that a LuckPerms API related question?
Forward it to #support-1 or #support-2. 
How do I show the ranking next to my name in the list Tap?
How can I get list of all permissions on server from LuckPerms, not from bukkit?
how does one get group of a offline player
You need to load them, using UserManager#loadUser in order to access their data
ty
is there a way to load their data without uuid?
No
How do you not have their UUID
do not store any player data by username. username changes have been a thing for almost a decade now
If it's from a command, you could use Bukkit.getOfflinePlayer
Is there a way to request the equivalent of /lp sync from the API? I see https://github.com/LuckPerms/LuckPerms/blob/master/common/src/main/java/me/lucko/luckperms/common/commands/misc/SyncCommand.java#L45 but I can't seen to find a corresponding method in the API for it.
see pins
I don't mean propagating changes via the messaging service, I mean the update task. I think I found LuckPerms#runUpdateTask though, thanks.
My case is that plugin messaging is not cutting it for an empty server and I'd like to sync the perms when checking a permission in a prelogin event. I guess I could switch to MySQL but I really do prefer Postgres.
you can configure LP to use a message broker like redis
but are you actually having issues with permission changes not taking effect when the player joins?
If another player is already on the server everything's fine, but plugin messaging only works over a player connection, which I don't think is fully established during AsyncPlayerPreLoginEvent.
sure, it wont be able to sync before the player is at least in the configuration state, but are you actually having issues related to this?
uhhh technically because the way craftbukkit does it it won't be available until a bit after they join
but that isn't important
I posted my issue several times and no one helped me, that person was the only one that has my issue!
I posted my issue.
Do you have a plugin resetting people's permissions? Or just taking a few at a time randomly? Better to link to you posting your issue than this other guy.
I am trying to log when a user is promoted and I have all the details in order to log them in my database except for the promoter's uuid. Is there any way to get the user AND admin's uuids? This is my method:
private void onGroupChange(UserDataRecalculateEvent e) {
User p = e.getUser();
try {
Players player = plugin.getDatabase().getPlayerByUUID(p.getUniqueId().toString());
if (player != null) {
String oldRank = player.getRank();
String newRank = e.getData().getMetaData().getPrimaryGroup();
if (!oldRank.equals(newRank)) {
player.setRank(newRank);
plugin.getDatabase().updatePlayer(player);
// Log the promotion
logPromotion(<admin uuid here>, player.getUuid(), oldRank, newRank);
}
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}```
Are you looking to get the source (user source) of the event?
The user data recalc event?
Nah i just need the UUID of both parties
Because I have a hunch that is what you're looking for, but I haven't actually tried it
declaration: package: net.luckperms.api.event.source
Events have sources and those sources can be players and you can use the api to get their uuids
Huge disclaimer is that it seems to be what you're looking for on the tin. But I haven't used this myself so I can't confirm from experience
Okay, I'll try it out. Thanks 👍
hi guys, how can i get the weight of a group?
by any chance:
Can i check if the player is in group with luckperms api or do i have to use permission check cause when a player has op it already has *
I guess you could do something like:
boolean isUserInGroup(String groupName) {
LuckPerms luckPerms = /* LP instance*/
User user = /* User instance*/
return user.getInheritedGroups(user.getQueryOptions()).contains(luckPerms.getGroupManager().getGroup(groupName));
}
wtf PEX api was so easy back then what happend to luckperms...
luckperms downfall
anyway:
i had this
public static Group getPrimaryGroup(Player p){
return luckperms.getGroupManager().getGroup(luckperms.getUserManager().getUser(p.getUniqueId()).getPrimaryGroup());
}```
and i get error:
```java
Caused by: java.lang.NullPointerException: Cannot invoke "net.luckperms.api.LuckPerms.getGroupManager()" because "de.whoscanel.isaserver.IsaServer.luckperms" is null```
your luckperms field (which is breaking java naming conventions by the way) is null
lemme show u my main class rq
Yeah, you never initialized your luckperms field
Hi, I have a plugin that needs to know when a player's groups HAVE changed.
After that, it will check the player's current groups against its internal database and execute some operations.
However, I'm not sure of what events I should listen to.
NodeAddEvent/NodeRemoveEvent don't get fired if the change is from another server.
(also I get a race condition because I need to wait for them to be applied, and a scheduler is a dirty solution)
UserDataRecalculateEvent and PostSyncEvent sound like a bad idea: I'd execute lots of unneeded checks on my plugin.
idk what you mean by needing to wait in node add/remove events, the events are fired after the changes are made
what exactly is your end goal here? wdym "check against its internal database"? maybe there's a better approach to this with more detail and/or you're worrying too much about something
Thanks for the response. So, this is a plugin for managing temp vips. It executes a bunch of stuff when a package is enabled or disabled (for example managing fly, homes, etc), and uses LP as a truth source on the player's active vip package.
At logins, or after a group change is detected, it compares the current player's groups to the old known "primary vip"*. This is stored in the plugin's internal database, instead of trying to listen to events, because it's more solid: if the plugin is offline I don't get a desync, and it has a way to revert the transaction if something goes wrong and don't get in an illegal state. And stuff like that.
Obviously, after the operations gets completed, the new primary vip gets updated in the plugin's database, so that future group edits will check if the primary vip is different to the new one.
*effectively, the highest group the player inherits in the "vip" track. I also considered storing it as a meta key but that didn't seem to work well, and I need to store stuff like home data anyway.
I was under the impression that NodeAdd/NodeRemove were fired before because they were cancellable or something, my bad... Still, they don't get fired from network syncs, so they're useless here.
The only way way I found to run the plugin's checks only on groups, is to listen to UserDataRecalculateEvent, save the permission map state (filtered by "group.") in a map keyed by user and each time its fired get a diff of the permission map. If "group." nodes have changes, then let the plugin do its thing. That looks horrible, though. I feel like there's a better way?
uhh NodeAdd/RemoveEvent aren't cancellable, don't know where you saw that lol
I think the data recalculate event is fine, but the way i would do it is i would store in the vip groups some key with a unique value per vip group you can weigh and compare, like meta.vip-weight.123 (it can be the LP group's own weight but you can query it from the CachedMetaData), then store the "current" vip weight in the db and in the data recalc event compare the stored with the (potentially) updated one
With the track I can use the API to easily get all the steps to go from a group to another one (it does them one-for-one to compute which operations are needed), and no weight collisions are possible.
But you're right, even better, the plugin should probably assign to each group an uuid meta.vip-id.1A2B3C4D..., so that names/weights can be edited without worry. Thanks for the help!
yah, I guess if your vip structure allows you to put them on a track I'd go for that and fetch the current position the player is on that track, but the meta key is more flexible despite it being slightly more setup
it also doesn't lock you into a linear structure a track imposes
actually that's not true, I wouldn't go for that even if it was the case lol
but it's something you can do
The track is actually abstraced in a class which tells me what the next step is, if I ever need a more complex structure I can write the logic there. By putting conditional relations between the groups (in a config) i can go crazy. I'll probably do that when this becomes a rank plugin. But for now I'll be happy to just put it in production, lol
Good afternoon, I have a question:
if I give a player a group for a certain time, will NodeAddEvent be called after it ends?
Hey, im actually developping a plugin for my server Minecraft, my server have an BungeeCord with LuckpermsProxy installed on it and an Lobby server with spigot and Luckperms bukkit installed.
And i want to get the group of the player who join the server with the spigot.
In my IDE i have import the Spigot and Luckperms API how i supposed to do ?
!api
Learn how to use the LuckPerms API in your project.
I read it but i don't know to get the Group Prefix of the user with spigotAPI 'cause the group is made with the LuckPerms in the BungeeCord
sorry for my english im french
In fact I have a BungeeCord server with LuckPermsBungee installed then I have a Lobby server with LuckPermsBukkit installed, now put Grade are stored with LuckpermsBungee, I code my plugin with the Spigot API therefore for my Lobby Server and I wish to recover the Player grades with the Luckperms API but what do I do knowing that the grades are stored in the bungee?
Are you trying to retrieve a prefix stored in the Bungee instance, via a plugin on Spigot? What storage method are you using? Have you connected your LuckPerms plugins to a remote database? The wiki explains how to grab a cached metadata for a player and then get a prefix/suffix.
Iirc, the cookbook plugin provides an example class for getting player prefixes. You can have a look below:
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
i use the default storage method the h2
Well, then each server will have its own LP h2 database.
i don't have the database link with any luckperms
but every server have the same config
But if everythings is correct if i create a group with the /lpb command is the group was also created in the /lp command ?
No. LuckPermsBungee does not sync permission and group data on its own. You require a remote database and a proper messaging service. If you're planning to create a Spigot plugin, you'd be better off syncing your LP instances together first and, once that's done, use LP API in your Spigot plugin to obtain a prefix.
but how did i sync the instance in LP ?
!network For more info on how to do that, please use either #support-1 or #support-2.
If you run a BungeeCord network, learn how to correctly setup LuckPerms on all server instances (including Bungee).
Syncing data between servers
Still relevant
No, you'd want to utilize NodeMutateEvent, which is called when a node is removed from a user.
Thank you!
it's also called when a node is added fwiw
there's NodeRemove as well
and NodeClear might be relevant
So if on the config off every Luckperms i link an Database all the group from the bungee will also be on the Bukkit one ?
Hey guys! I want to save the discord id regarding to a group in the groups meta with /lpv group admin meta set discordid <id>
got this code for that, but the optional is empty. with /lpv group admin meta info it shows the right info:
if (user == null) {
System.out.println("User not found");
} else {
System.out.println("User found: " + user.getUniqueId());
System.out.println("Meta nodes:");
user.getNodes(NodeType.META).forEach(n -> {
System.out.println("Node: " + n);
System.out.println("Contexts: " + n.getContexts());
});
Optional<Long> optionalMetadataValue = user.getNodes(NodeType.META).stream()
.filter(Node::hasExpiry)
.peek(n -> System.out.println("Node with expiry: " + n))
.filter(n -> {
boolean hasKey = n.getContexts().containsKey("discordid");
System.out.println("Has discordid key: " + hasKey);
return hasKey;
})
.map(n -> {
String value = n.getContexts().getAnyValue("discordid").orElse("0");
System.out.println("discordid value: " + value);
return Long.parseLong(value);
})
.findFirst();
System.out.println("optionalMetadataValue: " + optionalMetadataValue);```
the node exists in the group, not the user, you get the value for that meta key from the metadata cache ^
!help
!advanced
!api
!argumentbased
!ask
!bedrock
!bulkupdate
!bungee
!bungeecheck
!cauldron
!colours
!commandequivalents
!commands
!config
!context
!cookbook
!default
!downloads
!editor
!editorsafety
!errors
!essentials
!extensions
!extracontexts
!faq
!forgepermissions
!formatting
!hack
!helpchat
!inheritance
!install
!libsdir
!locale
!lpc
!meta
!migration
!notworking
!nowildcard
!offline
!pasteit
!permissions
!permplugin
!placeholders
!reload
!selfhosting
!spongeseven
!stacking
!storage
!suggestions
!switchstorage
!sync
!testingperms
!tracks
!translationprogress
!translations
!tutorial
!upgrade
!usage
!userinfo
!velocitycheck
!verbose
!version
!weight
!whyluckperms
!wiki
!errors
Here's a page with some common storage system errors.
!parseit
Sorry! I do not understand the command parseit Did you mean pasteit?
Type !help for a list of commands
!pasteit
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!
java.sql.SQLTransientConnectionException: luckperms-hikari - Connection is not available, request timed out after 5000ms.
this is not a bot commands channel
for the mysql link i change in the line "adress" i put the url of my VPS but it still don't work
That has nothing to do with the LuckPerms API. Stick to #support-1 or #support-2 for such questions.
Is this the correct way to check if they got the node?
why not just do player.hasPermission ?
It returns true if the player is opped.
i'm assuming this is on bukkit? that's only bukkit behaviour really, you can change that in the LP config or you can use player.hasPermission(Permission) with PermissionDefault.FALSE as defaultvalue; but uh yeah if you wanna stick to the lp api you can do that lol
final boolean res0 = player.hasPermission(new Permission(permission, PermissionDefault.FALSE));
Like that you're saying? This will return false if the player is opped and does not have the permission?
yeah that should do it
Okay thanks.
hi
why is the user not assigned a group when executing the /hire command? you can understand from the tab that I set a prefix for it
public static void addGroup(Player player, Group group){
api.getUserManager().modifyUser(player.getUniqueId(), (User user) -> {
Node node = InheritanceNode.builder(group).build();
user.data().add(node);
});
}
this is the addGroup() method
modifyUser returns CompletableFeture<Void>, try await operation
how can i use luckperms events in Skript? it gives me this error
i imported net.luckperms.api.event.node.NodeMutateEvent with skript-reflect
Display data such as user prefixes and groups from LuckPerms in other plugins.
This isn't a bot commands channel.
Is there a simple way to get %luckperms expired_time% via api or placeholderAPi?
Would there be any issues with frequently switching around 5-10 nodes from players? Pretty much temporarily taking them away and storing them elsewhere. Or is there any way to just deactivate them?
why so frequently? based on what are you wanting to do that?
but, what do you mean exactly by "switching", "taking away" or "deactivate"?
Are you sure you're using the right channel? This seems like a #support-1 / #support-2 type of question.
Oh shoot my bad
Essentially players are able to unlock specific permissions that I use luckperms for. I want to interface with it by taking away some groups when the user is in a specific state to keep everything balanced. To do this, I want to deactivate ||which would be the right word, mb|| the group, whether this be something that is doable in luckperms or perhaps simply taking several groups away, storing it somewhere, and then giving it back when the user is outside of the state
Perhaps I'm looking at it all wrong? Unsure.
i was tryna see if you could use custom contexts for this, e.g. you give the player the node with a context (e.g. some_custom_state=state_value) and then have a context calculator where you provide the state value for the current subject, then the node will basically apply/unapply "automatically" depending on whether the context of the node is satisfied by the player's current context
https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/context/ContextCalculator.html
in case you need to trigger a context update when the state changes and you wanna recalculate it https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/context/ContextManager.html#signalContextUpdate(java.lang.Object)
How can you give/remove permissions with the api?
You should preferably add an InheritanceNode:
Creating a node: https://luckperms.net/wiki/Developer-API-Usage#creating-new-node-instances
Adding a node: https://luckperms.net/wiki/Developer-API-Usage#modifying-usergroup-data
Saving changes: https://luckperms.net/wiki/Developer-API-Usage#saving-changes
Usage example: https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/commands/SetGroupCommand.java
Take a look at the links I sent above, but you're gonna wanna give a PermissionNode instead of a InheritanceNode
why it only save when i logout?
It looks fine to me, except that you should make the group variable and send the message outside of the consumer code block
How do i set the players Suffix?
setPrimaryGroup does not do anything with the default config
are you using paper's new command api?
yeah new brigadier api
nvm figured it out
hm? what was the issue
forgot to add null check, so if it is null its a public command
ah
Hi sorry I'm losing my 💩
I've been trying for hours to change a group displayname (not actual name) and the docs aren't completely helping
why does your plugin need to change the displayname instead of letting the user decide what it is?
The plugin is for personal use, part of this plugin is Integration with lucky perms, it's really dependant, I keep changing the test server a lot and it's a PITA to keep resseting up the groups/ranks/roles so I made a command for it
add a DisplayNameNode to the group's node map
The node builder value asks for a boolean
The value of "displayname" should be a string
Pretty sure there's a fat oversight but I'm barely functioning rn
you can just do DisplayNameNode.builder("funny display name").build()
Why does it have a separate Class 😭
because its a special type of node
If I add a displaynamenode does it override the older one or do I have to dispose it?
I saw them but I thought they were some kind of node components? Not classes
If you want only one you need to clear the previous ones
Is there a method for that or do I have to iterate over all of the nodes?
there's a clear method
clear(NodeType.DISPLAY_NAME::matches) or smth
and it shows how to do the builders right below 😭
I forgot what data returns
a nodemap
yeah right it's NodeMap#clear
It's 2am
public static void setGroupDisplayName(Group group, String name) {
group.data().clear(NodeType.DISPLAY_NAME::matches);
DisplayNameNode displayNameNode = DisplayNameNode.builder(name).build();
group.data().add(displayNameNode);
LuckPermsProvider.get().getGroupManager().saveGroup(group);
}
now we pray
yep
what is "Luckyperms"
Nvm, github was the solution
Hey, how can I check if a player has a group that is lifetime with the API?
Check if the return value of Node#getExpiryDuration is null
Why dose that error occur?
dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
compileOnly("net.luckperms:api:5.4")
}
LuckPerms luckperms = LuckPermsProvider.get();
[15:57:43 ERROR]: Error occurred while enabling LobbySystem v1.0 (Is it up to date?)
java.lang.NoClassDefFoundError: net/luckperms/api/LuckPermsProvider
at lobbysystem-1.0.0-all.jar/net.limeprog.server.lobbysystem.utils.Luckperms.<init>(Luckperms.java:11) ~[lobbysystem-1.0.0-all.jar:?]
at lobbysystem-1.0.0-all.jar/net.limeprog.server.lobbysystem.LobbySystem.onEnable(LobbySystem.java:19) ~[lobbysystem-1.0.0-all.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:287) ~[paper-api-1.20.6-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:202) ~[paper-1.20.6.jar:1.20.6-115-9d6f2cc]
at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:109) ~[paper-1.20.6.jar:1.20.6-115-9d6f2cc]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:519) ~[paper-api-1.20.6-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.CraftServer.enablePlugin(CraftServer.java:604) ~[paper-1.20.6.jar:1.20.6-115-9d6f2cc]
at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:553) ~[paper-1.20.6.jar:1.20.6-115-9d6f2cc]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:675) ~[paper-1.20.6.jar:1.20.6-115-9d6f2cc]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:437) ~[paper-1.20.6.jar:1.20.6-115-9d6f2cc]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:323) ~[paper-1.20.6.jar:1.20.6-115-9d6f2cc]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1136) ~[paper-1.20.6.jar:1.20.6-115-9d6f2cc]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:323) ~[paper-1.20.6.jar:1.20.6-115-9d6f2cc]
at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: java.lang.ClassNotFoundException: net.luckperms.api.LuckPermsProvider
at io.papermc.paper.plugin.entrypoint.classloader.PaperPluginClassLoader.loadClass(PaperPluginClassLoader.java:146) ~[paper-1.20.6.jar:1.20.6-115-9d6f2cc]
at io.papermc.paper.plugin.entrypoint.classloader.PaperPluginClassLoader.loadClass(PaperPluginClassLoader.java:107) ~[paper-1.20.6.jar:1.20.6-115-9d6f2cc]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?]
... 14 more
do you have luckperms installed?
yes
did you add LuckPerms as a dependency in your plugin.yml/paper-plugin.yml?
name: LobbySystem
version: '1.0'
main: net.limeprog.server.lobbysystem.LobbySystem
description: Paper LobbySystem Plugin
api-version: '1.20'
depend: [LuckPerms]
You mean the depend?
are you using a plugin.yml or a paper-plugin.yml?
paper-plugin.yml
that is not how you declare a dependency in paper-plugin.yml
see https://docs.papermc.io/paper/dev/getting-started/paper-plugins#dependency-declaration or just switch to a regular plugin.yml if you aren't actually making use of the features offered by paper plugins
Lost formatting because first try was caught on the automod, I guess for a masked link?
Regarding fabric-permissions-api-v0, which I assume is okay to cover in the LuckPerms server. Can write a more formal issue up later but just wanted to make sure
Is it intended that Fabric API is a transitive dependency in 0.3.1? I'm not sure if this was the behavior of 0.2-SNAPSHOT. The main annoyance is that the 0.97.0+1.20.4 Fabric API dependency will override an older Fabric API dependency such as one in a mod targeting an old Minecraft version, but as far as I'm aware, fabric-permissions-api-v0 is meant to support a wide range of versions. I'm sure I can just exclude it if transitiveness intended
masked links are mostly used for scams
can i use the luckperms api in my own app somehow?
help me
please
luckperms does not connect to the database as to the device? I set everything correctly
Could you please stop cross posting?
okey?
thanks
!usage
Here's a guide to help users understand and use LuckPerms for the first time.
#support-1 or #support-2 also, this channel is for support with LP's api
Hey rococs! Please don't tag helpful/staff members directly.
reload maven
try adding the repo to maven
Is there any way to make a group that a player can have depending on the value returned by some plugin whenever a permission check is needed?
(XY: allow using a certain command when streaming)
the problem is that there is a possibility of a server crash, power outage, etc. and a 'manually' added group may be retained for the player
do you care about the player retaining the group if they log out?
there are some permissions of this group that are not used on the minecraft server, but on the API server even when they're offline, so no
In other words, the state of a node, say group.streaming (is that how groups are added to players?) should always be provided by my plugin, regardless of whether the player is online or not
found that there are temporary permissions that I can use by setting group.streaming to true for 5 seconds every 3 seconds or something, but it seems more like a workaround than the proper solution
you can add the InheritanceNode to the user's transient node map instead https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/model/PermissionHolder.html#transientData()
hi i got a question those imports are not working ?
import me.lucko.luckperms.LuckPerms;
import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.User;
i want to import and use classes like LuckPerms, Group, and User
i am using luckperms api
Those are not the correct inports
!javadoc
Learn how to use the LuckPerms API in your project.
hi
api.getUserManager().getUser(player.getUniqueId()).getCachedData().getPermissionData().checkPermission(permission).asBoolean()
this function why alltime return true ?
can help anybody me ?
is the user op?
also you can just use your platforms api for checking permissions
eg player.hasPermission(string) on bukkit
Hi, I am writing a plugin where I need to check what group a player is apart of. I am able to get this information directly from Vault?
a player can inherit several groups
sorry. I should specify. I need some way of receiving their highest weighted group, regardless of permission manager
Does anybody know how to add LuckPerms as a dependency to a Forge mod?
This is the error I get when running the mod:
java.lang.NoSuchMethodError: 'com.mojang.brigadier.builder.LiteralArgumentBuilder net.minecraft.commands.Commands.m_82127_(java.lang.String)'
at me.lucko.luckperms.forge.ForgeCommandExecutor.onRegisterCommands(ForgeCommandExecutor.java:59)
im using 1.20.1
and i tried with 1.20.6 too
basically I'm making a mod that's compatible with luckperms forge, but I don't know how to get it into runtime
the current forge version is for mc 1.20.6
so which one should i use? and how do I use it to test in a server? barely any documentation is given for forge
I put it in my run's mod folder too
Caused by: java.lang.NoSuchMethodError: 'com.mojang.brigadier.builder.LiteralArgumentBuilder net.minecraft.commands.Commands.m_82127_(java.lang.String)'```
.-.
i tried using that version too
5.4.131
on forge, you need to use an older version of LP on older minecraft versions
okay well i am using 5.4.102 which i guess is the correct version of LP?
i mean there is documentation for installing the API but it's not very clear for forge
implementation fg.deobf("net.luckperms:api:5.4")
this is what i am doing
idk build tools, but make sure its not including luckperms inside your jar
check the jar
it shouldn’t be implementation
well then what? i tried the others
what jar
compileOnly likely
that
your mod jar..?
won't do anything
i dont see how thats relevant
its not there
so what am I supposed to do now?
I can't figure it out..
The support for forge is terrible, is there no work around apart from making an independent production server and then testing it there? That's awful, how do you expect people to make mods like that?
wat
is having a test server all that difficult?
not sure what else you mean, how else are you gonna test it?
on your gradle project, for LuckPerms you just depend on the api because that's all you should use
then have the mod run on the server
yes, because every time i test it, i need to build it, put the jar in, and repeat
rather than simply using the runServer task forge provides
could you not just put the LP mod in whichever server directory that task creates..?
perhaps.. but why is forge support so.. well.. bad? This isn't how it is usually done..
because luckperms api is entirely platform agnostic, so there is a single api that has to be shared across all platforms
then the respective mod/plugin for a given platform implements the api
So I'm going to have to create this kind of setup where the jar file is built in the mod folder of a separate test server folder? I mean, there has to be a workaround for this?? Then how do other people do it
wat
no you don't?
does the runServer task not create a server directory where the server runs?
uhh
well thats the problem
this happens
i guess a non-reobf jar can be provided for that
i searched probably the only mods that have compatibility with luckperms and barely found anything
there was a big one, uh, I don't remember the name but it was from bloodshot
Heya!
If I were to make a prefix selector/unlocker
How would I reference and save group data?
Would anyone be able to answer why the placeholder api isn't working on Fabric 1.20.1? Tried everything to no avail
PlaceholderAPI is a bukkit plugin
Are you certain?
I understand, I had just been having issues getting help for this specific problem there
Eitherway, through the api, it's possible to create groups and assign them to players, right?
!api
Learn how to use the LuckPerms API in your project.
..
how do you add player to a group
add an InheritanceNode to them
/lp user <username> parent add <group>
🤦
thank you
Hey, was wondering if there's anything wrong with my method. Never used luckperms api before, basically trying to assign players the groups of empire, kingdom and the motherland
public static void doLuckpermsStuff(String s) {
LuckPerms luckPerms;
try {
luckPerms = LuckPermsProvider.get();
} catch (IllegalStateException e) {
return;
}
if (s.contains("emp")) {
Group g = luckPerms.getGroupManager().getGroup("empire");
luckPerms.getUserManager().modifyUser(Minecraft.getInstance().player.getUUID(), (User user) -> {
user.data().clear(NodeType.INHERITANCE::matches);
Node node = InheritanceNode.builder(g).build();
user.data().add(node);
});
} else if (s.contains("king")) {
Group g = luckPerms.getGroupManager().getGroup("kingdom");
luckPerms.getUserManager().modifyUser(Minecraft.getInstance().player.getUUID(), (User user) -> {
user.data().clear(NodeType.INHERITANCE::matches);
Node node = InheritanceNode.builder(g).build();
user.data().add(node);
});
} else if (s.contains("mth")) {
Group g = luckPerms.getGroupManager().getGroup("motherland");
luckPerms.getUserManager().modifyUser(Minecraft.getInstance().player.getUUID(), (User user) -> {
user.data().clear(NodeType.INHERITANCE::matches);
Node node = InheritanceNode.builder(g).build();
user.data().add(node);
});
} }```
if this helps
is it not working or?
Yeah it isn’t, not sure why
Was wondering if the code looked correct, because I never interacted with luckperm’s api
is this running on the client?
LuckPerms is a server mod/plugin, idk about forge but on fabric it will only be loaded on a server, not the client
nope, pretty sure its running on the server, this method is called in an C2S packet
Minecraft.getInstance().player smells a lot like client code
heck ya, im stupid
thank you so much, Emily, for pointing that out, sorry for being stupid, it works 👍🏽
hey! what event should I use when a player gets assigned a group? is it NodeAddEvent?
yes, you can check if the node is a group
any idea how to get the player from the event
It's not always a player. That event is also called when a node is added to a group. Eitherway, the method is NodeMutateEvent#getTarget and you can check if it's instanceof User
then do i check if the User is an instance of a Player? I want to set the user's respawnpoint
You can't cast User to Player. Instead, you can try retrieving it using the User UUID
makes sense
I mean, it's kind of hard to do that too
public static void addCultureGroup(NodeAddEvent event) {
if (event.isGroup() && event.getTarget() instanceof User user) {
if (event.getNode().getKey().contains("empire")) {
//MinecraftServer server
//server.getPlayerList().getPlayer(user.getUniqueId());
} else if (event.getNode().getKey().contains("kingdom")) {
} else if (event.getNode().getKey().contains("motherland")) {
}
}
}```
Why wouldn't that work?
well, where would I get the server from?
That's for you to figure out. I don't use Forge
any idea how to do something like that in forge?
If you're refering to registering the event, take a look at this wiki page > https://luckperms.net/wiki/Developer-API-Usage#events
Also where did you get a message nearly 2 months old from ._.
discord has a search feature :>
it sucks that luckperms is primarily Bukkit/Spigot focused but its not that their API is bad or anything
It's not, you literally can use the API in any platform
yeah
So, you don't see anything wrong with this right? like the conditions
the event does fire
How can I use User#getInheritedGroups to only get groups with no expire time on the user? Only permanent groups, not temporary. Or should User#getNodes be used and then getGroup(group name)?
or do i have to do this
if (e.isGroup() && e.getNode().getType() == NodeType.INHERITANCE)
If it fires then you've registered it properly. You just need to figure out how to get a server-side player
You can use InheritanceNode#builder to get the group node and filter out ones that have hasExpiry set to true
Yes, I have
I was wondering if the condition I used is wrong
I mean it looks right
Do note that it's way easier to use User#getNodes with NodeType.INHERITANCE but if you persist on using User#getInheritedGroups ^^
It's not
So basically when the group is added to a player, it does something to the player. The condition seems right?
Then I have no clue why it’s not working
actually wait it is
Used User#getNodes with NodeType.INHERITANCE, thank you!
You're checking if the target is a Group and checking if it's a User at the same time
This simply means "if the node is added to a group AND added to a user {"
which doesn't make sense
yeah, forgot to mention i changed some stuff
private void onNodeAdd(NodeAddEvent e) {
if (!e.isUser()) {
return;
}
User target = (User) e.getTarget();
Node node = e.getNode();
ServerPlayer player = ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayer(target.getUniqueId());
if (player==null) {
return;
}
BlockPos empSpawn = new BlockPos(Config.empSpawnX, Config.empSpawnY, Config.empSpawnZ);
BlockPos kngSpawn = new BlockPos(Config.kngSpawnX, Config.kngSpawnY, Config.kngSpawnZ);
BlockPos mthSpawn = new BlockPos(Config.mthSpawnX, Config.mthSpawnY, Config.mthSpawnZ);
if (e.isGroup()) {
if (node.getKey().contains("empire")) {
player.setRespawnPosition(ServerLevel.OVERWORLD, empSpawn, 0.0F, false, false);
player.sendSystemMessage(Component.literal("what the hell"));
} else if (node.getKey().contains("kingdom")) {
player.setRespawnPosition(ServerLevel.OVERWORLD, kngSpawn, 0.0F, false, false);
} else if (node.getKey().contains("motherland")) {
player.setRespawnPosition(ServerLevel.OVERWORLD, mthSpawn, 0.0F, false, false);
}
}
}```
Doesn't this look fine?
figured it out
where can i download lp api i cannot find it for the life of me
Hi, I have to get players names from Luckperms User
User#getUsername. Unfortunately, nicknames are in lowercase. Is there any way to get them properly? (including uppercase if needed)
I need this especially for offline players

ok thanks
Hey, I am too dumb for Collections / Maps / streams. How can I get the highest weight amount of a user?
this.weight = user.getNodes(NodeType.PREFIX).stream()
.filter(n -> !n.hasExpiry())
.mapToInt(ChatMetaNode::getPriority)
.max()
.orElse(1);
package org.bendersdestiny.staffpro.staffplayer;
import lombok.Getter;
import lombok.Setter;
import net.luckperms.api.model.user.User;
import net.luckperms.api.node.NodeType;
import net.luckperms.api.node.types.ChatMetaNode;
import org.bendersdestiny.staffpro.StaffPro;
import org.bendersdestiny.staffpro.methods.GeneralMethods;
import org.bukkit.entity.Player;
import java.util.*;
public class StaffPlayer {
private static final Map<UUID, StaffPlayer> PLAYERS = new HashMap<>();
@Getter
private static final Set<UUID> STAFFMODEPLAYERS = new HashSet<>();
@Getter
private UUID uuid;
@Getter
private Player player;
@Getter
private User user;
@Getter
@Setter
private int weight;
@Getter
@Setter
private boolean isStaffMode;
public StaffPlayer(Player player) {
this.uuid = player.getUniqueId();
this.player = player;
this.user = StaffPro.getInstance().getLuckPerms().getPlayerAdapter(Player.class).getUser(player);
this.weight = user.getNodes(NodeType.PREFIX).stream()
.filter(n -> !n.hasExpiry())
.mapToInt(ChatMetaNode::getPriority)
.max()
.orElse(1);
this.isStaffMode = false;
}
public void enableStaffMode() {
isStaffMode = true;
GeneralMethods.enterStaffMode(player);
STAFFMODEPLAYERS.add(player.getUniqueId());
}
public void disableStaffMode() {
isStaffMode = false;
GeneralMethods.leaveStaffMode(player);
STAFFMODEPLAYERS.remove(player.getUniqueId());
}
public static StaffPlayer getPlayer(Player player) {
if (PLAYERS.containsKey(player.getUniqueId())) {
return PLAYERS.get(player.getUniqueId());
}
StaffPlayer newStaffPlayer = new StaffPlayer(player);
PLAYERS.put(player.getUniqueId(), newStaffPlayer);
return newStaffPlayer;
}
public static Map<UUID, StaffPlayer> getPlayers() {
return PLAYERS;
}
}```Whole class
How can I find out how long it will take for a player's group to end? like vips
user.getNodes(NodeType.PREFIX).stream()
.filter(Node::hasExpiry)
.mapToInt(value -> value.getExpiryDuration().getNano());
``` is true?
How can i check if a player thats offline have a specific permission?
is it possible to remove all permissions under the prefix permission? like remove prefix.*
clear the player's prefix permission
Hello, I have a problem here. I don't know why. I use Kotlin's when judgment to judge LuckPerms, which will trigger NoClassDefFoundError. I directly use when(plugin){ is LuckPerms -> xxx}
Is it because I directly judge the main class of the plug-in instead of judging the plug-in name?
im not very familar with kotlin, but why do you need to do that?
Kotlin's when (plugin) is the same as Java's switch, except that Kotlin's when can do more complex Java operations. For example, Java's switch requires break to interrupt, but Kotlin does not need to write
I want to determine permissions. I know Vault can also do this, but I want to use the LuckPerms API to determine permissions directly, rather than having all permissions determined by Vault. So I prioritize LuckPerms, and Vault is compatible with older permission plugins.
that is not how you use the LP API, LP's JavaPlugin does not implement the LuckPerms interface, nor does LP's Vault implementation; if you want to use LP as an optional dependency, first you need to check if it's installed (https://jd.papermc.io/paper/1.21/org/bukkit/plugin/PluginManager.html#isPluginEnabled(java.lang.String)), then you obtain the LuckPerms instance from the services manager or the static accessor https://luckperms.net/wiki/Developer-API#obtaining-an-instance-of-the-api
when you use when to match on classes and types, the class has to exist, so if luckperms isn't installed then it won't exist and your code will blow up
I have checked Bukkit.getPluginManager().isPluginEnable(String name). I have read its implementation. It makes two judgments, one is not null, the other is inclusion, that is, plugins.contains(plugin). But it still reports NoClassDefFoundError. However, if I don't install Vault and use GroupManager directly, there will be no such problem.
Are you saying that when I use when(plugins){ LuckPerms -> XXX } to make a judgment, I must ensure that the LuckPerms class has been loaded?
could you share some code and the stack trace? where do you have this when expression?
but as i said, this approach won't work because the Plugin class won't implement LuckPerms interface
fun getPlugin(): Plugin? = Bukkit.getPluginManager().let {
when {
it.isPluginEnabled("LuckPerms") -> it.getPlugin("LuckPerms")it.isPluginEnabled("Vault") -> it.getPlugin("Vault") else -> null }}
I don't know if you can read Kotlin, the specific judgment code is like this
fun OfflinePlayer.checkPermission(permission: String): Boolean = when (getPlugin()) {
is LuckPerms -> XXXis Vault -> XXX else -> XXX}
yes, that won't work with luckperms regardless of the NoClassDefFound
do you have a stack trace ?
some
I can tell that the LuckPerms class is missing, but I don't know why it's not skipping even though it's not there.
was luckperms installed when that error happened?
No, but the problem is very strange. I know it is because it is not installed, but I don't know why it does not skip the judgment because it does not exist, but directly feedback the exception to me.
well, yeah that's the thing, kotlin's when expects the class to exist, if luckperms isn't installed, the class won't exist
so it will blow up
That means I should judge String instead of judging the inherited class of Plugin? That is, judging the plugin name
yes that would work
and keep in mind that you can't cast LP's Plugin to LuckPerms, you need to obtain it from the static accessor or the services manager
So, why doesn't it throw this exception when there is no Vault, but only after I installed it? When there is no Vault, my getPlugin method returns null
You have also seen my code. I used static getPlugin to get LuckPerms after judging it.
no vault but LP installed? or what?
my guess is that kotlin will skip the checks altogether if it's null
and will fallback to the case null if you have one, or the fallback else
I benefited a lot from your words. I will now look at the content compiled by Kotlin. Maybe, as you said, when my getPlugin method is null, the check is skipped.
I tried to look at the compiled content, it seems to directly judge LuckPerms instead of null. I don't know if it's a problem with my compiler. You can copy my code and try it. I use the Gradle compilation tool. The current solution is not to directly judge the class, but to judge the name of the plugin.
Thank you for your guidance@fast delta
Hey xiaoxin9371! Please don't tag helpful/staff members directly.
glad you got it sorted out
Thank you for your patience. I will continue to study the API of LuckPerms.
Hey I was debugging Listener to update players team prefix when group prefix changes, i came up with terrible code (in my opinion) and it seems like when i add this prefix the event is in some kind of infinite loop?
Pls tell me what's wroong here or what i can improve, i don't really undesrand those Node idea...
private void onNodeAdd(NodeAddEvent e) {
// Check if the event was acting on a Group
if (!e.isGroup()) {
return;
}
Bukkit.getLogger().severe("NodeAddEvent");
// Check if the node was a prefix node
Node node = e.getNode();
if (node.getType() != NodeType.PREFIX) {
return;
}
// Cast the node to PrefixNode, and the target to Group.
PrefixNode prefixNode = ((PrefixNode) node);
String newPrefix = prefixNode.getMetaValue();
Group group = (Group) e.getTarget();
LuckPermsProvider.get().getGroupManager().modifyGroup(group.getName(), g -> {
Bukkit.getLogger().severe("Entered");
Collection<Node> nodes = group.getNodes()
.stream()
.filter(NodeType.PREFIX::matches)
.collect(Collectors.toSet());
Map<Integer,String> prefixes = group.getCachedData().getMetaData(QueryOptions.nonContextual()).getPrefixes();
int priority = prefixes.keySet().stream().mapToInt(i -> i + 10).max().orElse(10);
Node newPrefixNode = PrefixNode.builder(newPrefix, priority).build();
Bukkit.getLogger().severe("Adding prefix " + newPrefix + " to " + group.getName());
group.data().add(newPrefixNode);
updatePlayers();
});
}
private void updatePlayers() {
for (Player player : Bukkit.getOnlinePlayers()) {
if (!player.hasPermission("smcore.vanish")) continue;
prefixSuffixManager.updatePlayerPrefixSuffix(player, vanishManager.isVanished(player));
}
}
here is some logs from debugging
already figured everyting out
does User#getPrimaryGroup just return the group of theirs with the highest weight?
yes
How to use the rest api?
I saw this site... https://petstore.swagger.io/?url=https://raw.githubusercontent.com/LuckPerms/rest-api/main/src/main/resources/luckperms-openapi.yml#/
But I have no idea what link should i request on my website
wherever you are hosting your lp rest api
check out the readme, you can use it as an extension in an existing luckperms installation or run the docker image
what do you mean by existing luckperms installation?
luckperms as a mod/plugin has an extensions system, like, plugins for luckperms
oh, I have the plugin running on a server, so thats enough?
so you can drop the extension jar in an existing LP's extensions folder and it'll use that
https://github.com/LuckPerms/rest-api?tab=readme-ov-file
https://luckperms.net/wiki/Extensions it says where to put the jar
you can configure the port and configured auth keys you want etc via the env variables in the readme
I have my rest apu set up, but when i open the server on port 8080 it says "Client sent an HTTP request to an HTTPS server." How can i fix this?
hello, i just watch in /plugins/LuckPerms/libs folder come .jar file, is it plugin suggestion or luckperm's files ?
Don't randomly ask questions without reading channel topics.
oups my head has a bug sorry
is there any stored data how player count inside the group? Or do I have to manually loop all players and check
You can use UserManager#searchAll, which takes a NodeMatcher. In your case, you need to provide an InheritanceNode NodeMatcher. This will return a CompletableFuture containing a Map of UUIDs and a Collection of InheritanceNodes. This map contains the UUIDs of all players inside the specified InheritanceNode (the group defined in the NodeMatcher's Node builder). You can then use the keySet of this map to get the Set of UUIDs and call .size on it, just like with any other Collection.
Thank you!
If I do UserManager#cleanupUser does the map still contains the UUIDs of players? What I want to get is only getting online players and it seems to be very inefficeint to compare every player if player is online.
I don't think using cleanupUser is a good idea, because it'll unload the user from internal storage. And yes, checking if each player is online is inefficient, which is why LuckPerms doesn't include a built-in placeholder that returns the member count in the first place. I unfortunately don't have any alternative methods in mind to suggest atm.
hmm okay. But is there any problems with unloading the user from internal storage? Because I think that is what I want, something like unloading players when they exit server.
You can try it out ig
it does not work :(
Yeah as I thought, you have no choice other than filtering out offline players.
Collection<Node> nodes = getHelper().getPlayer(offlinePlayer.getUniqueId()).getNodes();
for (Node node : nodes)
getHelper().getUserManager().modifyUser(player.getUniqueId(), user -> user.data().add(node));
Is this a good way to clone a player using API?
you should do a single modifyUser call and add all the nodes in there
but this screams "use a group" instead :d
Hey, I'm using the GetGroup statement in my plugin, but the current problem is that the result is always null. So I get NullPointer.
The funny thing is that the group is loaded because I do a rankmanage GUI and in the first part all groups are loaded and displayed and it works, but when I try to use one of these groups it returns null.
oh, yeah, thanks
if i save a user with the userManager, should the update be pushed systemwide in case you have proxy + subserver setup?
I have an own plugin on my subservers, that adds and remove nodes to players. Not on the proxy. If i add the node and save the player, the update is only on the one subserver, not on the proxy or the other subservers. I need to use the /lpv user <username> permission check <permission> command on the proxy in order to fetch the newest perms of the player. Or i need to use the /lp user <username> permission add <permission> command directly on the subserver, to get it to the proxy too.
Is this the expected behaviour and is there a way to push it manually to the proxy?
you need to push the update, see pinned message
what am I doing wrong ?
[15:15:59] [Server thread/INFO]: [Grosu] Enabling Grosu v1.0*
[15:16:00] [Server thread/INFO]: [net.dv8tion.jda.api.JDA] Login Successful!
[15:16:00] [Server thread/ERROR]: [Grosu] Failed to load LuckPerms API: The LuckPerms API isn't loaded yet!
This could be because:
a) the LuckPerms plugin is not installed or it failed to enable
b) your plugin does not declare a dependency on LuckPerms
c) you are attempting to use the API before plugins reach the 'enable' phase
(call the #get method in onEnable, not in your plugin constructor!)
@Override
public void onEnable() {
try {
jda = JDABuilder.createDefault(discordToken).addEventListeners(new DiscordListener()).build();
} catch (LoginException e) {
getLogger().severe("Failed to login to Discord: " + e.getMessage());
this.setEnabled(false);
return;
}
if (!getServer().getPluginManager().isPluginEnabled("LuckPerms")) {
getLogger().severe("LuckPerms plugin is not enabled! Disabling Grosu Matei.");
this.setEnabled(false);
return;
}
try {
luckPerms = LuckPermsProvider.get();
} catch (IllegalStateException e) {
getLogger().severe("Failed to load LuckPerms API: " + e.getMessage());
this.setEnabled(false);
return;
}
PluginCommand command = getCommand("grosu");
if (command != null) {
command.setExecutor(this);
}
getServer().getPluginManager().registerEvents(this, this);
getLogger().info("Grosu Matei has been activated!");
File logFile = new File(getDataFolder(), "command_logs.txt");
if (!logFile.exists()) {
try {
logFile.createNewFile();
} catch (IOException e) {
getLogger().severe("Failed to create command log file: " + e.getMessage());
}
}
}
make sure you havent shaded lp into your plugin
can you be more specific please? I don't understand what you mean by "shaded"
and sorry for ping
rename your plugin jar to end in .zip, then open it, and see if and luckperms classes are inside it
net/luckperms
yeah, thats what you dont want
ah, ok
^
Okay, I'm now also using the MessagingService and see, that the updates are pushed to the proxy. But the plugin (one I'm using, not LuckPerms) still does not recognize that the perm is set or unset, unless I look it up via a LuckPerms command executed on the proxy. Any Ideas?
can i connect to luck perms velocity on a fabric server?
wrong channel
Anyone? ^^‘‘
Hey, I'm not sure if this is the right channel but how could I retrieve a download link for the latest build? Just trying to make an autoupdater for my plugins.
You can poke https://metadata.luckperms.net/data/all
Thanks :)
some examples here https://gist.github.com/lucko/1a3227de169279c43b2e86b260c13365
e.g. for bukkit
curl -s https://metadata.luckperms.net/data/downloads | jq -r '.downloads.bukkit' will give you the url for the latest Bukkit jar
hi api people 🙂
trying to get luckperms working on my plugin
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.
it loops with "waiting for luckperms to be ready" and "luckperms provider not found"
why are you putting this in a repeating bukkit task?
lp will be fully ready before your plugin since you depend on it in your plugin.yml, which means you can get the provider directly in onenable
Did you actually verify that LuckPerms is starting up before your plugin? I've come across cases where even though you're depending on LuckPerms, it still starts after your plugin. Additionally <version>5.4</version> > <version>5.3</version>
it might be a verion issue
ya lol just saw that - been banging my head on the java
yes its in the log
i think its the 5.3
Yeah consider updating it
Set it to 5.4 in your pom
Oh I read that wrong, yes 5.4 is enough since it's the latest API version
my plugin isnt starting until after LP loads, so the dependency is working
i'll removing the debug polling stuff and try again, clearly 5.3 was wrong
yeah remove the repeating task
does the api work with spigot / bukkit?
it should
im going to try the static singleton instead
my code is the same as whats on the docs
did you try without the task?
tbh you should upgrade to paper
Just replace the jar
bukkit plugins run just fine on paper
calling the singleton resulted in some interesting info, but none of it is true lol
If it weren't for a stupid little mistake, I bet that it'll magically work fine if you switch to paper ngl
haha
im asking the guy who built the server about it
when i use the singleton it says the plugin isnt fully loaded (it is), or im not calling it in onenable (i am) or something else lol
oh
so
i had to tell maven that luckperms was provided
go figure
i guess this build is different somehow - the other plugins like essentialsx, etc didnt need to be told that
oh well, problem solved 🙂
shading luckperms into your plugin does cause problems
the shaded luckperms will never be loaded as a plugin, so its api will never be ready
Hi! I use user.getInheritedGroups() to get all user groups. Is there a way to get the expiry of the group if its set temporary?
Use .getNodes with node type inheritance and call getExpiry or getExpiryDuration on the node
works! thanks
Is there an even which I can use to check if player meta has changed?
UserDataRecalculateEvent
Does someone know the best and safest way to check if the api is loaded when developing a architectury mod ?
I currently do it on init() but this causes some problems sometimes
Nvm I’m gonna use a lifecycle event to register the commands
Hi, how do I check in NodeMutateEvent whether a user have been added to a group? Because afaik node can be a permission as well, isn't that right?
I guess I have to filter all new nodes with node type INHERITANCE predicate?
Why not use NodeAddEvent, since you want to listen for when they're added to a group?
^ and check that the node being added is an inheritance node, you can get the node from the event
How can update a player when I set the rank with my command they use the API isn’t live updating
is there any better than using the doc method to get player group?
public static String getPlayerGroup(Player player, Collection<String> possibleGroups) {
for (String group : possibleGroups) {
if (player.hasPermission("group." + group)) {
return group;
}
}
return null;
}```
(documentation method)
**RESOLVED**
Any know this ?
If I use /lp user <user> parent set <group>, does it trigger NodeAddEvent?
it should update inside luckperms right away. what exactly are you seeing that makes you think otherwise? and share code
After set the rank there is no this rank on the tab. Its not the luckperms problem, its not the tab problem, there is no "live" update
Rank only has been set after rejoin, why
Code when I at home
User targetUser = luckPerms.getUserManager().loadUser(targetPlayer.getUniqueId()).join();
if (targetUser == null) {
player.sendMessage(PREFIX + ChatColor.translateAlternateColorCodes('&', messagesConfig.getString("messages.targetPlayerNotFound")));
return;
}
targetUser.data().clear(node -> node.getKey().equals("group"));
if (duration == Long.MIN_VALUE) {
targetUser.data().add(Node.builder("group." + targetGroupName).build());
} else {
targetUser.data().add(Node.builder("group." + targetGroupName)
.expiry(duration, TimeUnit.SECONDS)
.build());
}
luckPerms.getUserManager().saveUser(targetUser);```
does it change in /lp user <name> info?
is now worksd
this is working, but the NodeAddEvent event is not called if I add the rank to a player in another instance. How do I get him called?
if the player is in the same instance it works normally
API events are only called on the instance where the operation takes place
uhh
But does the player then have to relog for it to be updated? Or can I do something to update it in the other instance?
Yeah, you cacn push a user update with MessagingService#pushUserUpdate(User)
thanks!
Which theme is this?
Thankss
sup
i need help in showing the lp track in the score board
Hey I'm running into an issue with setting custom metadata (like show in the docs), where user.data().clear() doesn't remove the existing key so the method ends up adding another key with the same name but different value. Any ideas, I need a second set of eyes
Example Code
User user = getUser(player.getUniqueId());
MetaNode node = MetaNode.builder(key, Boolean.toString(value)).build();
user.data().clear(NodeType.META.predicate(mn -> mn.getKey().equalsIgnoreCase(key)));
user.data().add(node);
provider.getUserManager().saveUser(user);
}
I just did some more testing, it looks like it adds the second metanode when I attempt to set the value of the key to something else (enabled -> disabled)
http://i.itsdark.dev/u/qUp12A.png
pretty sure that's Node#getKey which will be meta.selene-nophantom.disabled, MetaNode has a metaKey method or something akin to that
Ah yep I totally missed the fact that I was doing getKey() instead of getMetaKey()
Thanks!

Why doesn't %luckperms_group_expiry_time% work?
I've followed all the instructions
Please move this discussion to one of the support channels, #support-1 / #support-2. This has nothing to do with the LuckPerms API.
Alright, sorry
Code: https://haste.devstorage.eu/rma9wKqIVj pom: https://haste.devstorage.eu/lw1G23M1uG Error: https://haste.devstorage.eu/QOmd4zxW8Q
DevStorage.eu free document storage with code highlighting & Web-IDE. #rma9wKqIVj
DevStorage.eu free document storage with code highlighting & Web-IDE. #lw1G23M1uG
DevStorage.eu free document storage with code highlighting & Web-IDE. #QOmd4zxW8Q
Can anyone help me?
Its on the Paper 1.21
Use the normal jar
How do I make luckperms autocomplete modded permission nodes?
How can i unload a user that was loaded by using UserManager class?
luckperms unloads data on its own
Is there a downloads API for the plugin jar itself? Specifically an endpoint to get the latest build for a certain loader.
You can poke https://metadata.luckperms.net/data/all which will return the download URL for the latest build for each platform
(among other things)
^ or is this just not possible
I thought this was the right channel since I’m trying to use the luck perks api?
And I mean permission nodes via a mod, not a plugin, that’s what I mean by modded
LuckPerms simply suggests permissions that have been checked for before
once a permission goes through LP it'll cache it and show it up in the editor/commands
Hey i want to add and remove Groups from a Player, my add methode works great but i cant remove a group. Can anyone Help me?
if (player != null && groupName != null && !groupName.isEmpty()) {
User user = luckPerms.getUserManager().getUser(player.getUniqueId());
if (user != null) {
InheritanceNode node = InheritanceNode.builder(groupName).value(false).build();
user.data().remove(node);
luckPerms.getUserManager().saveUser(user);
}
}
}
public void addGroup(Player player, String groupName) {
if (player != null && groupName != null && !groupName.isEmpty()) {
User user = luckPerms.getUserManager().getUser(player.getUniqueId());
if (user != null) {
InheritanceNode node = InheritanceNode.builder(groupName).value(true).build();
user.data().add(node);
luckPerms.getUserManager().saveUser(user);
}
}```
Hey, I don't know what I'm doing wrong...
I'm trying since yesterday, to get the API to run (i already got it in a few different plugins) but it won't work!
My Main: https://pastes.dev/Aa7IFTVE8K
This is my code - I didn't change ANYTHING and checked everything more than 10 times.
I tried everything that came to my mind...
It'll always show, the NotLoadedException but it is loaded!
[15:13:30] [Server thread/INFO]: [LuckPerms] Enabling LuckPerms v5.4.137
[15:13:30] [Server thread/INFO]: __
[15:13:30] [Server thread/INFO]: | |__) LuckPerms v5.4.137
[15:13:30] [Server thread/INFO]: |___ | Running on Bukkit - CraftBukkit
[15:13:30] [Server thread/INFO]:
[15:13:30] [Server thread/INFO]: [LuckPerms] Loading configuration...
[15:13:30] [Server thread/INFO]: [LuckPerms] Loading storage provider... [H2]
[15:13:30] [Server thread/INFO]: [LuckPerms] Loading internal permission managers...
[15:13:30] [Server thread/INFO]: [LuckPerms] Performing initial data load...
[15:13:30] [Server thread/INFO]: [LuckPerms] Successfully enabled. (took 319ms)
...
Exception in the other paste
Exception: https://pastes.dev/VGxc1QMB4l
Full Log in: https://pastes.dev/4Xx48YIL5p
I'm using the spigot-api 1.21 (server latest build), have everything in my maven right and depend: [LuckPerms] in my plugin.yml
At first I were using paper - nothing changed
Please help, thanks!
1- Update to Paper
2- Remove if check at line 28. Since you're depending on LP, it's redundant
In addition, try grabbing the LP instance using the BukkitServicesManager
I tried everything already. No difference
Why would you downgrade to CraftBukkit again then? Attempting to resolve it on Paper is better
In my opinion it is better to resolve it at all. - i don't care where... nothing works and I'm sick of it... :´)
but fine - i'll try it again
make sure you aren't shading the lp api into your jar
wait I totally missed that lol
Nothing changed
Are you shading LP API by any chance?
no
there is nothing of luckperms in the jar
oh... it is
It worked, I'm so sorry, I didn't know that
Sorry for wasting your time! 🙏
No problem. Glad you got it fixed :>
when should the fabric placeholder api be updated for 1.21
No ETA. Also, wrong channel.
How i can Set a Player in a group but temporary and Lifetime?
that's an oxymoron
how does one have a group both temporarily and forever
can add a node group.xxx with #expiry()
Node node = Node.builder("group.owner")
.value(true)
.expiry(Duration.ofHours(1))
.build();
I think?
hi
I’m trying to create a plugin for custom prefixes (like BetterPrefix) for my server where LuckPerms is set up with Velocity (in proxy) and LuckPerms (in minigame) connected with MySQL. However, when I install the plugin, it applies the prefixes in LP but not in LPV.
''
Can anyone explain me why the group permanent? https://haste.devstorage.eu/dd9RiQAZuB
DevStorage.eu free document storage with code highlighting & Web-IDE. #dd9RiQAZuB
how does luckperms know what my group is, because if i remember correct * permission bypass all permission, and then it would return true for all groups
public static boolean isPlayerInGroup(Player player, String group) {
return player.hasPermission("group." + group);
}
lets now say i want to check for all people with donator rank, but i dont want people who have * would it include that person or should it make it so if u have a group that is higher it doesn't count or what
it iterates a users inheritance nodes, as opposed to blindly checking "permissions"
👍
Hello is luckperms api hook for fabric working with 1.21?
since mine is crashing on start
No, but these pull requests add support for 1.21: https://github.com/LuckPerms/placeholders/pull/58 / https://github.com/LuckPerms/placeholders/pull/59. Also, read the channel name or description before writing :c
Thank you, only looked at the channel title sorry
oop I've been asking about this in #support-1 didn't realize 1.21 wasn't supported yet. Though this was 3 days ago so lemme check on it...
hey im porting a mod from 1.18.2 to 1.20.1 (forge), and i cant for the life of me work out how to make sure the calls to the net.luckperms.api.LuckPermsProvider.get() happen after the luckperms has loaded..
seems like whatever i do i can stop the net.luckperms.api.LuckPermsProvider$NotLoadedException: The LuckPerms API isn't loaded yet! error. so something isnt letting luckperms load first
this is the part that calls luckperms
private final LuckPerms luckPerms;
private static LuckPermsProvider instance;
public LuckPermsProvider() {
instance = this;
this.luckPerms = net.luckperms.api.LuckPermsProvider.get();
}
public static LuckPermsProvider getInstance() {
return instance;
}
private CachedMetaData getMetaData(GameProfile player) {
if (this.luckPerms == null) {
return null;
} else {
User user = this.luckPerms.getUserManager().getUser(player.getId());
return user != null ? user.getCachedData().getMetaData() : null;
}
}
public String[] getPlayerPrefixAndSuffix(GameProfile player) {
try {
CachedMetaData metaData = this.getMetaData(player);
return new String[]{metaData.getPrefix(), metaData.getSuffix()};
} catch(IllegalStateException ise) {
return null;
}
}
``` note the origonal author set the file and classnames as LuckPermsProvider hence the direct call to the full path net.luckperms.api.LuckPermsProvider.get()
if you depend on LP in your plugin.yml (or whatever the equivalent file is for your platform), LP will always be loaded loaded before your plugin/mod. If you are sure you do this already, but are still getting this error, its likely because you have shaded LP into your plugin/mod. This means that 2 versions of the API exist at runtime, one from the LP jar actually installed on the server that is loaded like normal, and the other from your plugin/mod that never gets loaded since the server doesn't know about it. You can check by looking inside of your jar and seeing if any files from LP exist (anything in net/luckperms or me/lucko/ shouldnt be in your jar!). if it is shaded, change the scope of your dependency on LuckPerms to provided in your pom
Hey tiendas3! Please don't tag helpful/staff members directly.
Don't ping and how's that related to #luckperms-api?
That sounds xy. What are you trying to do
what setting exactly?
I'm working on using a chat engine that differs from the normal MC formatting, as part of that, displaynames need to be stored both with the extended formatting and with the default MC formatting so that other plugins can use display names without formatting issues.
In order to accomodate this on a velocity network the best way was to try and store metadata in group permissions and this worked until I tried to retrieve the permission data which was converted to all lowercase despite stored data retaining caps. Is there a way to retrieve data in a manner such that the permissions are not made lowercase?
why not just use minimessage?
when you need legacy formatting codes, you can use the converter for that
The reason I'm not using minimessage is to both add additional functionality and to make chat easier to format in general. The legacy formatting codes aren't what I need and their already handled by my chat implementation by default.
The way the plugin works is it strips chat of default formatting and readds it in a way that's easier to work with in general, such as making legacy formatting like &l a toggle that can be used both to bold and unbold a message. There were also additional changes that made the usage of colors simpler than the implementation of MiniMessage provided by default so I opted to go with that instead.
The ultimate reason I chose permission data was because it provided most of the functionality I needed while allowing me to also extend the default functionality of LP Meta. The plugin uses some general checks to grab 4 parts of a users displayname, the userprefix, usersuffix, chatprefix, and chatsuffix. At the time I had not considered using MiniMessage for user prefix and suffix but now that I think about it it's probably a viable solution.
TLDR: I over complicated this and I believe my issue should be resolved.
Can someone explain how I use getGroupManager#loadAllGroups correctly? It returns a CompletableFuture of Type Void but I don't know how to handle that correctly.
when its done, you can get data from any group i presume
but you should really only load the groups you are going to use
what are you trying to do?
I need all groups that are above a specific weight, didn't find a way other than loading all groups and then filtering through them
Didn't I just describe what I want to do? There is no case like in "getting the filename" I really just want to get the groups above a specific weight to return them in a command. There is no further description to do.
unless you are unloading groups (or creating groups in server A without messaging server B about it), all groups are loaded on startup and when created
given that, getLoadedGroups sounds more like what you want rather than loadAllGroups
how do i fix this
import net.luckperms.api.LuckPerms; import net.luckperms.api.model.user.User; import net.luckperms.api.node.Node;
im coding a minecraft plugin with supports luckprms and LPC.
thiss hows a error.
yk how to fix.
is transient user data fully local or does luckperms broadcast it over the network when changes to the transient map are made and saveUser is called? do I even need to call saveUser if I don't need to broadcast transient nodes to other luckperms instances in the network?
it's local
and no, you don't need to call saveUser because there is nothing to save :d
but also, LP won't automatically broadcast any changes when calling saveAnything, you'd need to tickle the messaging service yourself, see the pinned message about that (although that is simply not applicable in this case)
Is there any event when a permission node value becomes true/false because a context changed? Like the worldguard:region=test. Because neither NodeAddEvent, NodeRemoveEvent, NodeMutateEvent, UserDataRecalculateEvent, GroupDataRecalculateEvent or ContextUpdateEvent is called.
There should be an event for the context change, but the calculated value of the node itself won't fire any events - the value of the node never changes, LP just changes which nodes it cares about.
XY problem, why do you need this?
We are using numbered permissions. These are multiplier permissions. Total value is calculated by summing them all up. For large servers, iterating through the players effective permissions on possibly every block break isn't ideal. So now we use NodeAddEvent and NodeRemoveEvent to create a Set of strings cached from our multiplier permissions. The problem is, that it isn't really work well with contexts.
Yeah, LP (and the general permission system as a whole) isn't built for that kind of thing, and thus there's no good way to do it.
There is, however, the metadata system. It's basically a key:value store on permission holders. It's easy to query what value a player has for a given metadata key
Well there is a lot of users who already setup permissions (and sadly, basically everyone is doing it this way), so I'm not sure we would want them to change everything from permissions to metadata. (Also by using permissions, we keep compat with other permission plugins, even though those servers won't benefit from the cache)
But thanks anyway!
yeah, I already the have the messaging set up 👍
although that is simply not applicable in this case
so LP never broadcasts transient nodes, am I correct?
yes, because they are never saved to storage
ok, thanks 👍
and one more question: to make all User instances always have a certain node set in the transient map, do I just need to set it on UserLoadEvent and that's it?
pretty sure, yeah
does LP modify the users bukkit display name, or is there an official way to get their prefix
Api or placeholders depending on your use
Hey,
if I call group.getNodes(NodeType.PERMISSION), do I also get the permissions from the group parents then?
probably not
since inheriting a group doesnt mean it actually has the nodes it inherits
Hallo, because i only See Maven everytime, can i implement Luckperm in a Java Project Plugin and when yes where is the correct download for Java?
hey
i've read the wiki and api cookbook but i couldn't figure out how can i create a group using the api
How can I give a player temporary a "VIP" rank e. g. 1 week and the Player has ONLY the "VIP" rank in this week and next week the default rank. That with the API
Clear the player's groups, use a builder to build an InheritanceNode, set the expiry duration to 1 week, build it and add it to the user data. As for giving them the default group back, I believe it'll automatically do that once the VIP group expires, if it doesn't, write some code that does it, I'll leave that to you to test. Here are some resources to help you apply all that:
Creating an InheritanceNode, with expiry time: https://luckperms.net/wiki/Developer-API-Usage#creating-new-node-instances
Adding the node to the user: https://luckperms.net/wiki/Developer-API-Usage#modifying-usergroup-data
Saving the user data after adding the node: https://luckperms.net/wiki/Developer-API-Usage#saving-changes
Full API Usage wiki page: https://luckperms.net/wiki/Developer-API-Usage
Example of how to clear all groups and add one: https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/commands/SetGroupCommand.java
Hey, how can I access to all DisplayNameNodes in the user object?
I add them with:
user.data().add(DisplayNameNode.builder(serializedComponent).build());
For prefix and suffix there exists: user.getCachedData().getMetaData().getSuffixes()
User#getNodes with node type DISPLAY_NAME
Note that LP display names almost certainly do not do what you think they do.
They override the group's "name" aka it's effective ID, and is not intended for display. By setting a display name, you'd need to use that display name in every LP command referencing it, and any other plugins that care about group name.
You should be using either prefixes/suffixes, or a custom metadata key for handling custom display properties
ah, alright thanks
now I'm using String display = user.getCachedData().getMetaData().getMetaValue("prefix-display");
how can I write something with the key prefix-display?
Create a MetaNode using the builder, it takes a key(prefix-display in your case) and a value, then add it to the user, the same way you were adding the DisplayNameNode
public void onServerConnect(ServerConnectEvent event) {
var proxiedPlayer = event.getPlayer();
LuckPerms luckPerms = LuckPermsProvider.get();
luckPerms.getUserManager().modifyUser(proxiedPlayer.getUniqueId(), user -> {
user.data().clear();
user.data().add(SuffixNode.builder().suffix("Test").build());
});
}```
that doesnt work
Doesn't work in what way?
The suffix is not going to be set
Hey everyone 👋
I have some Spring Boot applications and would like to use the LuckPerms API there. What is the best way to do this?
you can use the rest api client, and host the rest api in one of the LPs on the mc servers (or as a standalone app)
https://github.com/LuckPerms/rest-api
https://github.com/LuckPerms/rest-api-java-client (it's not, like, properly finished yet, but, yeah)
how i add perm without appears on chat?
public static void addPermission(UUID userUuid, String permission) {
LuckPermsProvider.get().getUserManager().modifyUser(userUuid, user -> user.data().add(Node.builder(permission).build()));
}
wdym "without appears on chat"?
When this is executed it appears in the chat that the player has gained a permission
I wish it wouldn't show up
Can you show a screenshot of the message?
yes
is admin log
im joining
this
no it doesn't unless you are running the respective /lp user permission set command or pushing the entry to the action log yourself via the action log api
you have to save the user afterwards: luckPerms.getUserManager().saveUser(user);
modifyUser takes care of saving the user
Can I change player rank with User#setPrimaryGroup()?
with the default config, that function doesnt do anything
you need to add an inheritance node to the player
!coolbook has examples
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
does anyone know how I could format the 𞉀 style colors that luckperms uses?
I want to be able to reformat a player's prefix
luckperms itself doesnt use any format
yeah I'm aware, I was just seeing if anyone knew how to format it
in the end I gave up and switched all my colours to regular spigot colours
if your targeting paper, you should use minimessage
an actually sane format that supports modern features
okay deleted message, didn't wanna answer it anyways
nevermind, LuckPerms api = LuckPermsProvider.get(); seems to work ^^
my fault gang i deleted it right before i saw you type 😭
oh well i guess i have to rewrite the message anyway lmao
How do i get the luckperms api on velocity?
Nothing on the docs seems to work properly
and
LuckPerms api = provider.get().getProvider();
gives me this error
[01:11:04 ERROR] [velocityonlinetime]: Failed to get LuckPerms API. The instance is not of the correct type.
the LuckPerms plugin won't be an instance of the LuckPerms API class
where are you trying to get the API? what event/method
ProxyInitializeEvent
yeah that should be fine, make sure you aren't shading luckperms inside your plugin jar
Does this API not get the time when the player first obtained permission?
the only timestamp a node may have is when it expires
how I get all playercount in a group?
I think
val searchAll = luckPermsApi.userManager
.searchAll(NodeMatcher.type(NodeType.INHERITANCE))
.join()
On Paper, how does lp check if a username (via a command) has played since its installation (assuming use-server-uuid-cache: false and the player is not cached)? I know it stores a combination of UUID and name for each player. Afaik the API only allows for loading a user by its UUID. Is it possible to use lp to check if a user has played before if I only have the player's username? (this seemed convenient to me as the data is already being stored, instead of doing a Mojang lookup for example to get a UUID and then check OfflinePlayer.hasPlayedBefore())
luckperms keeps its own username-id cache, the player must be in that cache, have joined to be there (if it's shared storage like sql, joined any server/proxy that connects to that sql server)
so if the player never joins and is not in that cache the command will simply fail
the api offers you some access to that cache via lookupUniqueId and lookupUsername
Good to know, lookupUniqueId is what I need thank you!
I made a VIP group with the prefix "&6[VIP] &6" and i making a plugin where the players in that group can modify the prefix color/name color like "&1[VIP] &6" or "&6[VIP] &1" changing the prefix. But how can i add the prefix to the player with a group context?
Like when the player leave the group vip the custom prefix added to him will unset
you cant. you should store the color and apply it yourself if they are in the group
Can I check if the player has a group set to them without a permission check like if (player.hasPermission("group." + group)) {?
Yes, you have multiple options. Another option that I know of is through User.getNodes() and filter for inheritance nodes. node.getType == NodeType.INHERITANCE for example (see https://luckperms.net/wiki/Developer-API-Usage#reading-usergroup-data)
appreciate it
how can I give permission to a player with lp api?
!api
Learn how to use the LuckPerms API in your project.
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Hey! I am getting an error when doing RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
Did you add a dependency on LP in your plugin.yml?
How can I add or remove a Permission from a player
in paper-plugin.yml, yes
name: Core-Spigot
version: '${project.version}'
main: org.nexuscraft.corespigot.Core
api-version: '1.20'
load: STARTUP
authors: [ NexusDevelopment ]
depend:
- LuckPerms
That's not how you declare dependencies in a paper-plugin.yml. See https://docs.papermc.io/paper/dev/getting-started/paper-plugins
ah alr thnx
I don't understand a shit lol
can yu guide me into adding lp to paper-plugin?
paper has a discord where you can get help with making paper plugins
but unless you have a reason to be using paper-plugin.yml, you should stick with the normal plugin.yml
hello I am adding a perm to player like this ``` Node node = Node.builder("cosmetics.hat1").build();
LuckPermsProvider.get().getUserManager().modifyUser(player.getUniqueId(), (User user) -> {
DataMutateResult result = user.data().add(node);
if (result.wasSuccessful()) {
player.sendMessage("Şapkan menüye eklendi!");
} else {
player.sendMessage("Zaten şapkan var");
}
});```
how can I add timed perm?
for example 30 minute perm
Add an expiry to the Node
Hello. got a question. only copy pasted relevant ones.,
LuckPermHook.java
@Getter
private static final LuckPerms luckPerms = LuckPermsProvider.get();
@Nullable
public static User getLoadedUser(@NotNull UUID uuid) {
return luckPerms.getUserManager().getUser(uuid);
}
public boolean hasPermission(@NotNull UUID uuid,
@NotNull String permission) {
User user = getLoadedUser(uuid);
if (user == null) return false;
return user.getCachedData()
.getPermissionData()
.checkPermission(permission)
.asBoolean();
}
hasPermission never gave me issue until I tried to check permission in bungee plugin. I think we're doing this a bit wrong, but unsure what's proper way to handle
above hook is in plugin SigLib.jar , located in individual bukkit server.
A "bungee" plugin SigBungeeCore is located in bungeecord, trying to check permission with LuckPermHook#hasPermission.
In other words,
bukkit server has SigLib enabled. It has LuckPerm-Bukkit. It does NOT have SigBungeeCore
bungee server has SigBungeeCore enabled. It has LuckPerm-Bungee. It does NOT have SigLib.
Bukkit and Bungee are sharing same mysql database.
Interestingly, trying to check permission with LuckPermHook#hasPermission sometimes work, and sometimes does not work.
what would be proper way to check permission from luckperm?
for basic permission checks, you shouldnt use the LuckPerms API
instead, you should use the permission check your platform provides
eg Player#hasPermission on bukkit
huh. never knew that. thanks
hello i want to ask, how to i get expiry temp permission using api? day, hours, minutes, seconds thanks
the expiry of the node is a timestamp
so youll have to convert it into the format you want
its work thanks

