#luckperms-api
1 messages · Page 44 of 1
That is out of the scope of what LuckPerms can do
I don't know why the player name is null
i try String prefix = user.getPrimaryGroup();
Right... the primary group is not the prefix
Yes
it say "null"
it's very weird
@EventHandler
public void onChat(ChatEvent event) {
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
LuckPerms api = LuckPermsProvider.get();
User user = api.getPlayerAdapter(ProxiedPlayer.class).getUser(player);
String prefix = user.getCachedData().getMetaData().getPrefix();
if (!event.getMessage().startsWith("/")) {
ProxyServer.getInstance().broadcast("§b[" + player.getServer().getInfo().getName() +"§b] " + prefix + player.getName() + " §8» §f" + event.getMessage());
}
}```
Well getPrefix can return null if there is no prefix.. did you sync the LPs together so they share the same data?
Well, Bungee LP has no idea about the data in Spigot LP
Either give yourself a prefix in the proxy LP or sync them together
i see
I will synchronize all the grades on each server
on each server there can be different permission?
You can set a permission or group on a per-world/per-server basis, through what we call "contexts".
i see contexte server: server1
it's very cool but how to migrate now all permissions and players to bungee
If you run a BungeeCord network, learn how to correctly setup LuckPerms on all server instances (including Bungee).
Syncing data between servers
If you wish to change your storage type (e.g. to YAML or MySQL) you may need to follow these instructions to ensure your groups and permissions are migrated to the new storage type.
1: create a database
if i'm setting a transient node for a user, do i have to #saveUser() afterwards
or is there no point because it's transient either way
I am 95% confident you don't have to
:::::::::::::::)
oki, thank you fefo
after checking source like 5 times
np
Any news on when the API version is going to be updated to 1.15 minimum?
Our Developer has set a minimum plugin API version.
"Could not load 'plugins\LuckPerms-Bukkit-5.3.5.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Plugin API version 1.13 is lower than the minimum allowed version"
Uuh.. LuckPerms works fine in the very latest version of Paper.. what kind of server are you running?
This server is running Purpur version git-Purpur-1016 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
why, purpur, why
for the non-ticked Chunk loading.
i mean, why does purpur have to do this to us
There is no real reason for that to be changed, LuckPerms doesn't make use of any version specific API and bumping that means entirely dropping support for 1.13-1.14 servers.
It's not purpur that caused this
Uhm yes it is
does using paper stop that error
It does cause I used it today lol
Our developer set in bukkit.yml minimum API version, I have put in a pull request to remove it
but why change it lmao
^^
That's aname I havnt heard in a long time. he still maintainer of Spigot?
yes
Developer wanted to try and "reduce amount of non maintained plugins"
hmmmmmmmmm
Mojang made the game consistent lmao
after the M$ acquisition?
Expected, yes, many plugins like LuckPerms or WorldEdit etc have no reason to set 1.15 as minimum, so they set it as 1.13 (min available)
Not sure but 1.13 brought a massive amount of changes
And the entire game is more consistent and robust internally
I'll update the pull request with a 1.13 change with as you mentioned.
Did they manage to move all the plugins off the main thread?
well..... I seen in the laters MC build they added more support for shaders, so "maybe" they have been working on MT?
Speculation at best
Not sure, but there are signs that they may be moving the game to a newer version of Java instead of old unsupported Java 8 👀
That's gonna be interesting
Hello for luckperms bungee I have to create a database?
sorry
Hello i have a problem with the api for bungeecord server, i set a new rank for a player and if player speak in chat it say the wrong prefix if i reconnect it's done :/
in chat
in tab
i'm the Character
code:
@EventHandler
public void onChat(ChatEvent event) {
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
LuckPerms api = LuckPermsProvider.get();
User user = api.getPlayerAdapter(ProxiedPlayer.class).getUser(player);
String prefix = user.getCachedData().getMetaData().getPrefix();
String msg = event.getMessage();
msg.replaceAll("&","§");
if (!event.getMessage().startsWith("/")) {
ProxyServer.getInstance().broadcast("§b[" + player.getServer().getInfo().getName() +"§b] " + prefix + player.getName() + " §8» §f" + msg);
}
}
we would say that it does not update the prefix
I suggest logging the prefix variable to check if its correct first
heu okay x)
public static String isPrefix() {
return prefix;
}
public static void setPrefix(String prefix) {
OnChat.prefix = prefix;
}```
like this ?
No lol
x)
ha
I don't understand why it doesn't display its correct prefix it only records the prefix at the connection?
no idea my mistake: /
help me pls 😦
hiya! I've searched the channel for some examples and gotten as far as retrieving all users in a group. Where I'm stuck is actually iterating through each of the users to do something (ie remove them from the group)
What I've got so far is CompletableFuture<Map<UUID, Collection<Node>>> hunters = lpapi.getUserManager().searchAll(NodeMatcher.key("group.luckyloothunters"));
Yep, that's the way; then you can do something like
hunters
.thenApplyAsync(Map::entrySet)
.thenAcceptAsync(hunterEntries -> {
for (final Map.Entry<UUID, Collection<Node>> hunter : hunterEntries) {
// modifyUser(uuid, user -> {
// for node : hunter.value
// user.data.remove(node)
// }
}
});
Thanks!
would uuid be hunter.getKey()?
hunters
.thenApplyAsync(Map::entrySet)
.thenAcceptAsync(hunterEntries -> {
for (final Map.Entry<UUID, Collection<Node>> hunter : hunterEntries) {
luckperms.getUserManager().modifyUser(hunter.getKey(), user -> {
for node : hunter.value
user.data.remove(node)
}
}
});```
yea
almost there.... I can feel it haha
could I just remove the internal for node section? Like this:
hunters
.thenApplyAsync(Map::entrySet)
.thenAcceptAsync(hunterEntries -> {
for (final Map.Entry<UUID, Collection<Node>> hunter : hunterEntries) {
Node node = Node.builder("group.luckyloothunters").value(true).build();
luckperms.getUserManager().modifyUser(hunter.getKey(), user -> {
user.data().remove(node);
});
}
});```
btw you can do Node node = InheritanceNode.builder("luckyloothunters").build()
can = should 👀
and yeah that looks about right then, keep in mind that data().remove(node) does take into account the node's expiry time and contexts, so that will work only if they have luckyloothunters as a "regular" parent group (no contexts and not a temp parent group)
gotcha; is there a different method to use to remove if it was temp?
No plans to have it as temp atm but that could change
:d
the 'node' and 'value' were giving me errors and I wasnt sure what was wrong there, which is why I removed them haha
'cause you have node built above, but you're gonna take the node from looping the Collection<Node>
(also hunter.value() cuz it's a method)
hunter.getValue()?
yeah possibly
aha!
Thanks a lot for the help
just trying to figure out how to build correctly now
using gradle but keep getting a NoClassDefFound error for net/luckperms/api/node/Node
while building or when running?
running
what LP version?
how does your build.gradle look like?
hm make sure you have luckperms as a dependency in your plugin
not entirely sure how sponge works...
if you check your logs, is luckperms starting before or after your plugin
I dont see it loading before it crashes
yea means you need to somehow tell sponge to load luckperms before your plugin
or listen to luckperms enabling before doing your luckperms stuff with your plugin
Hello I still have my problem that when a player changes his role he does not update in the chat: /
@EventHandler
public void onChat(ChatEvent event) {
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
LuckPerms api = LuckPermsProvider.get();
User user = api.getPlayerAdapter(ProxiedPlayer.class).getUser(player);
String prefix = user.getCachedData().getMetaData().getPrefix();
String msg = event.getMessage();
msg.replaceAll("&", "§");
ProxyServer.getInstance().broadcast("§b[" + player.getServer().getInfo().getName() + "§b] " + prefix + player.getName() + " §8» §f" + msg);
}
looked thru the api but couldnt seem to find it, is it possible through the api to return all players in a certain group? this would contain offline players to so returning player#getName is fine but need to do it in a way that isnt via permission, any help would be appreciated!
@bold plinth #luckperms-api message
@nocturne elbow sorry didnt see that aha thanks very much
Hey Frxq15! Please don't tag helpful/staff members directly.
Are you changing the group in bungee LP or Spigot LP? Are they synced together with a common database?
common database it's a command /lp user <player> permission set group.crew
:/
or parent add if you want to keep the current groups inherited
/lp user shark_zekrom parent remove crew
/lp user shark_zekrom parent add character
the same error :/
is the correct prefix shown in /lp user USER info
screenshot lpb user USER meta info
[16:20:50 INFO]: [LP] shark_zekrom's Prefixes
[16:20:50 INFO]: [LP] -> 6 - 'Character | ' (inherited from character)
[16:20:50 INFO]: [LP] shark_zekrom has no suffixes.
[16:20:50 INFO]: [LP] shark_zekrom has no meta.
yea I suggest you do logging of variable in your plugin, part of basic debugging
how because I check the player's prefix in the ChatEvent event
so like any info on that output that you can show
String prefix = user.getCachedData().getMetaData().getPrefix();
i use this for get the prefix
I display the value of prefix because it is when I speak in the chat
ProxyServer.getInstance().broadcast("§b[" + player.getServer().getInfo().getName() + "§b] " + prefix + player.getName() + " §8» §f" + msg);```
idk then, your code snippet look ok, works the last time I tried similar way of getting prefix on my own plugin (tho its a spigot plugin)
no thats fine
possible issue is with caching, again I suggest actually doing some debug logging
There is a getMeta method you can use to get all the mete lp knows https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/cacheddata/CachedMetaData.html
You can also try to invalidate the cache to see if its a cachign issue https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/cacheddata/CachedDataManager.html#getMetaData()
so i have to make a loop?
up to you, its just a basic debug info logging
CachedDataManager#getMetaData()
no :/
How do I add a player to a group?
with the API?
Preferably, yes.
ah okay
Asking because some people love asking general LP questions in the api channel lol
Ah, InheritanceNode, aight thanks.
eyup
Didn't think of looking at the command yet tbh.
That's an example plugin, not the actual command lul
You can check the whole repo see more usage examples
Hmm, suppose I might, thanks.
why?
Make sure you have latest version of luckperms installed on your server
this is my pom
<repositories>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
omg im so dumb
sry
i was on my testserver without luckperms
Is there an event fired when a user gets added to a group?
NodeAddEvent/NodeRemoveEvent
Oh right, InheritanceNode.
Hello,
I don't understand the luckperms api who can explain to me?
I mean it's not something you "just understand" or something you "explain"
It has many parts and depending on what you are wanting to do you may need this and that part of it
You can always start by asking a specific question or even explain what you're trying to do with it
In any case, the two main API usage wiki pages go very well over how to include it and start using it 🙂
https://luckperms.net/wiki/Developer-API
https://luckperms.net/wiki/Developer-API-Usage
@viral bone don't crosspost
And keep the question in the appropriate channel: this being support-1 or -2
Not sure where the best place would be for this but how would I depend on the Fabric version of Luck Perms in Gradle?
Could be something very obvious :p https://paste.helpch.at/nehuqagiyo.php
Well, I would expect it to add the commands and such in game, unless I'm mistaken for what it's actually supposed to do
what..?
I guess I am mistaken then
what has the API to do with the plugin commands?
Right, my question was on how I would include the LuckPerms mod itself. Not the api, wasn't sure where to ask the question so I went here. I'm assuming that exists lol.
may I ask why?
Because I want to test with it in my IDE? Don't there's another reason to have.
Unless that isn't possible
The built jar is not up in any repo, you can download it and somehow add it to the IDE's classpath, idk how loom does dependencies like that tbh
Hm okay
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
!api
Learn how to use the LuckPerms API in your project.
this is wat i needed thanks
i want to disable luckPerms messages in console
so that lp logs dont appear when the server is using my plugin
Cant
can i change the plugin prefix?
what
The only messaging service that requires players to be online is plugin messaging
Redis, rabbitmq and sql don't need them
And I don't know why you'd call that an "exploit"? The whole purpose of the messaging service is to notify changes in storage
what type of "other stuff"?
You can't just send arbitrary data through LP's messaging system, you can push updates in general about LP storage changes or specific user updates, it doesn't allow for anything else. After all it's API, not a whole library
that is not something LP should be responsible of
lol
you can try, but its not a good solution at all, if it even works
depends
if you want like a proper expandable solution, redis server or similar will be better
what
thats is used to get UUID of users that has data in luckperms
and then used to get user and check permissions
which is what luckperm is for
!help
!advanced
!api
!argumentbased
!ask
!bulkupdate
!bungee
!bungeecheck
!cauldron
!colours
!commandequivalents
!commands
!config
!context
!cookbook
!default
!downloads
!editor
!editorsafety
!errors
!essentials
!extensions
!extracontexts
!faq
!formatting
!helpchat
!inheritance
!install
!libsdir
!locale
!meta
!migration
!notworking
!nowildcard
!pasteit
!permissions
!placeholders
!selfhosting
!stacking
!storage
!suggestions
!switchstorage
!sync
!testingperms
!tracks
!translations
!upgrade
!usage
!userinfo
!verbose
!weight
!whyluckperms
!wiki
There are neither pros nor cons really, I guess the first one allows for other plugins to register their own LuckPerms service but it's like extremely unlikely to happen lol
Learn how to use the LuckPerms API in your project.
Yes
Not many, only log/publish/network events
You're probably looking for LogReceiveEvent
hey, how can I get all players in a group?
well I have the Group object as a reference is it possible to use that somehow?
Yes
here's an example for you: https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/commands/GroupMembersCommand.java#L38-L58
Yea I just found that too, Thanks!
Maybe I am an idiot but how can I set a Node to an OfflinePlayer? Have I to use the CachedPermissionData or is it just like the player where online?
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
thank you so much 😄
how do i transfer all my permissionsex groups to luckperms
i really dont wanna do everything again
!migration
Learn about the process of migrating from another permission plugin.
Hi, i cant find in documentation how to use this group.getCachedData().getMetaData().getMetaValue(""), can me somebody send a example of key, please ?
!api
Learn how to use the LuckPerms API in your project.
the key is up to you
!meta
You can set prefixes, suffixes and other meta data in LuckPerms for players and groups. Note that LuckPerms does not manage chat. You need to use another plugin to show prefixes/suffixes in chat.
Ok, for example this "prefix.100" is the key ?
no
There is a method specifically named getPrefix in the CachedMetaData
non-prefix/suffix meta is just a key/value pair
Yes, but it is not work, its always null
But i want to get prefix on specific priority
or suffix
- what exact code are you using to get the prefix
- check that the user has a prefix in
/lp user USER info
To get prefix Prefix = group.getCachedData().getMetaData().getPrefix();
screenshot /lp group GROUP info for that groupname you are getting from code
and all code
public void refreshPrefixSuffix() {
new Tasker() {
@Override
public void run() {
for (Player p: TheAPI.getOnlinePlayers()) {
User user = Loader.lp.getPlayerAdapter(Player.class).getUser(p);
Group group = Loader.lp.getGroupManager().getGroup(user.getPrimaryGroup());
Tag = group.getCachedData().getMetaData().getSuffix();
Prefix = group.getCachedData().getMetaData().getPrefix();
}
}
}.runRepeating(0, 20);
}```
ok
Ok, and its possible to get prefix or suffix on specific priority
Ok, and can you send me some key examples
thats up to you to set
What
Ok, but I cant found how this key looks like
Ok, and if i want to get prefix on priority 50, how i cant get it
^^^
Ok, and what i cant find here
what can you not find?
How i can use metod getMetaValue
like this group.getCachedData().getMetaData().getMetaValue("prefix.50") or ?
nope
thats for meta
prefix uses a DIFFERENT method
as I linked
- get a map of all prefix, key=priority, value=prefix
- get prefix value based of priority what you want by doing how all map works, getting a value based on a key.
Ok, can you send me an example
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
(please take some time to actually read the javadocs and code)
so i found the MetaStackDefinition class which seems to be what is needed to calculate the full prefix / suffix of players including spacers and i'm wondering if there is a proper way to use it within the api or if i should just build a string using it manually
CachedMetaData#getPrefix/Suffix provides the full calculated prefix based on meta-formatting and contexts already
Sounds like you're trying to reinvent the wheel lol
oh does that include like the "end-spacer" configuration settings too?
Yep
oh cool i'll try that then, did the v4 api do that or am i just misremembering
alright
@nocturne elbow what?
Hey Twiz0x_x! Please don't tag helpful/staff members directly.
sorry
Which line is 22
you tell me this?
Show the report command class
Did you add the report command to your plugin.yml
no bruh
then getCommand is returning null
ty
String.join(args, " ") is a thing btw
hi everyone. I am trying to start using luckperms. And find it very unclear on when im doing my permissions through the ingame chat.. Isn't there any txt document or something like that that i can use?? I cant find anything in the plugin folder
how is this related to the API?
Hey! Previously, I used PEX and now I decided to switch to LuckPerms. Help please, I do not understand anything in the API, how can I get the prefix in the same way as in the PEX
if you can help me please mention me. I can not always notice
have you tried reading the documentation?
there's lots of info there, including how to get a prefix :)
!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.
!apo
Sorry! I do not understand the command apo Did you mean api?
Type !help for a list of commands
!api
Learn how to use the LuckPerms API in your project.
Sorry! I do not understand the command latestversion Did you mean testverbose?
Type !help for a list of commands
5.3.16
!download @nocturne elbow
You can download LuckPerms for Bukkit/Spigot/Paper, BungeeCord, Sponge, Fabric, Nukkit and Velocity.
#support-1 / #support-2 please
if i want to change a permission from like true to false and vice versa with the api, would i just do this https://luckperms.net/wiki/Developer-API-Usage#modifying-usergroup-data and it'll automatically overwrite the old perm?
Good question
Very good question indeed
Dare I say great question
Excellent choice of a question
heh
Jason I have absolutely no fucking idea
figured :p
Give me 5
i have a skript that runs the /lp group default permission set command but i figured if imma make it in my own plugin i should see if i can use the api lol
Awesome
but yeah no rush i've not started on the plugin yet anyways :p
just trying to figure out the best way to do things first
lol
So yeah, it will remove the "other" one
sweet thanks!
yw
also i don't have much experience with running code async, what would be the best way to do it?
is that with the CompletableFutures stuff
actually ig i could use the bukkitscheduler and runTaskAsynchronously
You could do that, yeah
alright, thanks fefe ❤️
:i
lol
the heck
am i doing something wrong or why is this not appearing cuz it's definitely what the docs say heh
git gud
oh ok
git: 'gud' is not a git command. See 'git --help'.
lol
Do you uuh..... do you have a LuckPerms object named luckPerms?
nope was i supposed to make one
!api yes
Learn how to use the LuckPerms API in your project.
oh yeah i did do that
But...?
unless i wasn't supposed to put this in my onEnable?
I want to add a permission to a player.
Is there any example of how to use the API?
!cookbook both of you check this :p
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
ah i got it now thx
i did it before with vault just completely forgot to do that here too lol
:)
There is literally an example command named "AddPermissionCommand"
I'm here
Which line adds the permission?
Sorry if I'm dumb
How familiar are you with Java as a programming language?
It's even commented...
I've been coding Spigot plugins for like a year
Basically line 44 to line 58?
if thats what u wanna do then sure
Basically, yeah
Thanks
a year is.. a lot of time :d especially for something like Spigot, correct me if I'm wrong but I think one should be able to identify something like that?
Maybe I'm just slow.
I did code in my free time, I don't have your enthusiasm for learning. I'm weak.
work out and u can become strong! 💪
I can't add the permissions in loop
for (int i = 0; i < property.getVaults(); i++) {
log.info("test");
int cont = i + 1;
Node node = Node.builder("mytheriavaults.access." + property.getRegion() + String.valueOf(cont))
.build();
PPPlugin.luckPerms.getUserManager().modifyUser(player.getUniqueId(), (User user) -> {
DataMutateResult result = user.data().add(node);
if (!result.wasSuccessful()) {
log.info(player.getName() + " cometió una excepción al comprar " + property.getRegion()
+ " (ya tenía los permisos del contenedor [" + String.valueOf(cont) + "])");
}
});
}```
property.getVaults() is equal to 3
"test" is printed three times but look what I found
fefo why is this crashing my server pls help```java
while(true) {
for(Player player : Bukkit.getOnlinePlayers()) {
Node node = Node.builder("perm").build();
}
}
lol
😆
try running the for loop inside the modifyUser function; I'm not sure if that will effectively change things but it may be relevant? I'll test
is this gud
maybe i should have it shut down the server too 🤔
ok but fr question is there a way to remove/unset a perm cuz i'm not seeing anything on the site but i could be searching for the wrong thing
.remove instead of .add
gotcha thanks
hm wonder why thats not in the docs
anyways so if i'm understanding this correct i can do multiple group.data().adds and then at the end save it and it'll save it all, correct?
that's ideal
sweet thanks
so is this all i'd need really?
luckPerms.getGroupManager().modifyGroup("default", group -> {
group.data().add(Node.builder("essentials.back.into." + plugin.getConfig().getString("end-world")).value(true).build());
group.data().add(Node.builder("essentials.tpa").value(true).build());
});```
You can omit setting the value, it's true by default
ah kk
didn't know if it mattered or not since i planned on overwriting the perm tho
and when i want to remove a certain node it has to match exactly what the node is with all its contexts and everything right
:o my plugin works thats surprising
how do i get a list of all existing groups
Bruh
haha
d;help
Command(s): d;info
Example: d;info
Description: Display info about the bot.
Command(s): d;docs, d;javadocs
Example: d;javadocs
Description: Get a list of javadocs.
Command(s): d;prefix
Example: d;prefix <prefix>
Description: Set the server's command prefix.
Command(s): d;algorithm
Example: d;algorithm <algorithm>
Description: Set the server's algorithm.
!api
Learn how to use the LuckPerms API in your project.
yea that ^^ lol
and if you not sure how to get luckperm API instance and the group manager, read the api usage guide
What does getApi do
that doesnt really look like an errors produce by luckperms
it says something to do with org.jetbrains.annotations.Unmodifiable?
probably why it doesnt resolve jetbrains annotations lol
cant import the other 1 for some reason
i alr hav it manually added
idk then, I dont use eclipse
that as well
Learn how to use the LuckPerms API in your project.
I also suggest you use maven/gradle and not static classpath jars
i m not really good with them 😕
i have changed but it didnt fix the error
luckperms jar is probably not the issue tho
since the error is with jetbrains classpath
yes obv lol
Hey, i copied the line from the API and got an error, what have I done wrong?
public void run() {
Collection<String> groups = LuckPerms.getGroupManager().getGroup(groupName);
!api
Learn how to use the LuckPerms API in your project.
you did not even get the api instance
you probably managing your variable wrongly... where are you defining the groupName variable
Hello, I'm looking to check permissions of a player, during the LoginEvent (Bungeecord event), when user is "trying to log", I have only the UUID of a player, I want cancel the connection if the uuid havn't the permission
For now I have try this :
LuckPermsProvider.get().getUserManager().loadUser(event.getConnection().getUniqueId()).thenAccept(user -> {
if (!user.getCachedData().getPermissionData().checkPermission("bypass").asBoolean()) {
event.setCancelled(true);
}
});```
But, it's this code is Async 🤔
On an instantaneous event such as login, you can call join() to get the User on loadUser
But the bungee login event has this "intents" thing... not sure how it works so yeah lol you can do that
Make sure to set the event priority to something higher than LP's (which is LOW)
When I got the user ? All permissions are updated in the cache ?
Yes
I have registered a custom context calculator
Can I trigger the user recalculate event when that context changes?
ContextManager#signalContextUpdate
Thanks
Hello, I'm trying to use the LuckPerms Bungeecord api, but i don't know how can I load the Luckperms api:
make sure luckperms is loading before your plugin
not sure if bungee works the same as a spigot plugin, but usually in plugin.yml you can specify depend or soft-depend plugins to ensure luckperms load before yours
Yes i've mark my plugin.yml as depend, but it's a command, if I can execute /lpb in the console, logically LuckPerms is load no ?
yea check that your plugin starts after luckperms
also is this line of code in the onEnable method?
or is it a field variable
No, not at all, I call the method directly when the command is executed
LuckPermsProvider.get()
from that one line of code it looks ok
!paste I suggest you send your full startup log
Seeing a paste of the problem makes everything so much easier! Use https://bytebin.lucko.me/ 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!
startup log?
hmm it should in theory work
that was the problem x)
how are you adding luckperms to your project dependency
Yeah gradle, kotlin DSL
I'm try this version if u want
hello, how can i get the user prefix/suffix and the priority level?
https://cdn.discordapp.com/attachments/241667244927483904/826537838299709460/unknown.png
getCachedData.getMetaData.getPrefixes will return a SortedMap<Integer, String>, the keys being the weight of the corresponding prefix, ordered by weight in descending order
Ohh okay nice, how can i get the first key/and String
Iterator<Map.Entry<Integer, String>> it = map.entrySet().iterator();
Uh yeah that can work too
So, it doesnt work, i think he cant find the user, but what is wrong?
Main class: https://paste.helpch.at/gezadubuhi.java
PlayerJoinEvent: https://paste.helpch.at/udozixixok.java
Error: https://paste.helpch.at/afokewifil.sql
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
Put that inside setupInstances
You are calling that as soon as your plugin class is constructed, way before LuckPerms registers the service
I added LuckPerms as a dependency
That doesn't change what I said
That is still way before LuckPerms registers the service in the services manager
That happens in the onEnable stage
Yes
So you have to call that at least in onEnable
No
It doesn't work like that
onEnable
Than how does it work, i made the exp like that
👀
Bukkit will first instantiate all the plugin classes, way before calling onEnable, your "provider" object is created as soon as your plugin class is constructed, again way before onEnable, and LuckPerms registers the service in onEnable, way after you are calling that
Ohh okay
btw what should i use? QueryOptions.defaultContextualOptions()
or smth else?
getCachedMeta?
what version of the API are you including as a dependency?
I think its really 5.0
¯_(ツ)_/¯
5.3 is the latest
CachedDataManager#getMetaData() (no parameters) was introduced in 5.1
So how can i get it now? 👀
..... replace 5.0 with 5.3?
The group name of the player/prefix of group suffix, and the priority
Yes i already did that
keep in mind that the prefix that is shown in /lp user .. info may not necessarily be the prefix with highest weight
it all depends on the meta-formatting settings (a.k.a. "prefix/suffix stacking")
wow thanks a lot discord
what are you wanting to do exactly...?
what are you trying to achieve, your end goal?
This is my method
I wanna get the prefix/suffix and the weight of the prefix, for sorting
Okay then, prefixes/suffixes you can get with user.getCachedData().getMetaData().getPrefixes/Suffixes()
will return a SortedMap<Integer, String>, the keys being the weight of the corresponding prefix/suffix, ordered by weight in descending order
Yes exactly
Could you disable pinging when replying please?
Okay sry
Hello. I'm trying to register an event listener for whenever a players permissions update. Is this not the correct approach? LuckPermsListeners.java`
public class LuckPermsListeners {
private final Main plugin;
private final LuckPerms luckPerms;
public LuckPermsListeners(Main plugin, LuckPerms luckPerms) {
this.plugin = plugin;
this.luckPerms = luckPerms;
}
public void register() {
this.plugin.getLogger().info("LuckPerms listeners enabled");
EventBus eventBus = this.luckPerms.getEventBus();
eventBus.subscribe(this.plugin, UserDataRecalculateEvent.class, this::onUserDataRecalculate);
}
private void onUserDataRecalculate(UserDataRecalculateEvent e) {
// do stuff
}
}
The "LuckPerms listeners enabled" log never fires
Are you.. calling.. the register method?
I- uhm.. I guess I should do that huh? 😅
I got this example from here https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/listener/PlayerNodeChangeListener.java
Right.. and just like in here you have to call register 🙂 https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/CookbookPlugin.java#L44
do I have to do something special to make luckperms trigger the update propogation code? I'm making a gross hack of a mod to allow me to get the player's dimension on the proxy server and it works, but for the proxy to notice the change I have to do /lpv sync
Why yes with MessagingService#pushUpdate()
You can get the (optional) messaging service with LuckPerms#getMessagingService()
so just add a lp.getMessagingService().ifPresent(MessagingService::pushUpdate);?
Well it depends on when and where you call it
For example
luckPerms.getUserManager().modifyUser(uuid, user -> {
// stuff
});
luckPerms.getMessagingService().ifPresent(MessagingService::pushUpdate);
This will most likely not work as you would expect, because the modifyUser method runs on another thread and it will probably be invoked way after code that follows below (including the messaging service update)
I'm handling the loading and saving manually
Still, UserManager#saveUser(User) runs async
If you were to adapt it to something like this then
luckPerms.getUserManager().modifyUser(uuid, user -> {
// stuff
}).thenRunAsync(() -> {
luckPerms.getMessagingService().ifPresent(MessagingService::pushUpdate);
});
then that will work, yes
Because it will call the lambda when the CompletableFuture returned by modifyUser is, well, completed
is it possible to get the permission removed in a NodeRemoveEvent when the node type is InheritanceNode ?
how do you get the player's prefix in the bungeecord using metadata?
The same way you'd do on Bukkit but on Bungee
luckPerms.getPlayerAdapter(ProxiedPlayer.class).getMetaData(player).getPrefix()
is there a link that shows the entire luckperms API on the bungeecord?
Learn how to use the LuckPerms API in your project.
ok, thanks!
!api
Learn how to use the LuckPerms API in your project.
How is the Event called, that is called if a user gets a new parent?
NodeAddEvent
What's the easiest way to verifiy if an event has been fired?
Like I'm currently not listening to LP events at all but do need to make sure that a certain event gets fired at the right time
Hey
I'm trying to get temp ranks from a player sorted by their weight, I'm a bit lost at this point:
Could anyone give tips 😛
group.getWeight()?
If that would have been possible there I would have never wrote anything in this chat xd
d;lp Group#getWeight
@NonNull
OptionalInt getWeight()```
Gets the weight of this group, if present.
the group weight
I appreciate the attempt to help but when streaming through nodes it doesn't return an object of type Group
you need to end the stream with like .collect(Collectors.toList()) or smt to get the resulting groups
..
what?
Did you read my question
you said the stream doesnt return a Group object
Yes and it's not magically going to turn in to Group object by collecting the stream
well, you said temp ranks sorted by weights, means you want a resulting list/collection of groups since players can have more than 1 of those groups, so it shouldnt be a single Group object
Okay maybe my phrase wasn't extremely correct but I think most people will understand what I meant
When streaming through nodes with type INHERITANCE, and mapping and casting them to their respective Class, you are streaming through an object of type InheritanceNode and not Group
And .getWeight() is not possible on an object of type InheritanceNode
you can get the group with the GroupManager? InheritanceNode should return the Group name as a string
I can pretty easily do like ..LuckPermsAPI#getGroup(InheritanceNode#getGroupName) but I'm trying to do it somewhat cleaner
yea that what you need to do lol
Thanks for the great advice...
I mean its how the api is designed so...
open a gh issue if you think the design or structure can be improved
maybe suggest a getGroup method in InheritanceNode class to the dev if you feel its needed
uhm is there a way to get the prefix in an bungeecord plugin with the 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.
https://prnt.sc/112h9qc
uhm what
Like the error says, that is not a static method
You need a LuckPerms object to use the API
!api the first link shows how to get it
Learn how to use the LuckPerms API in your project.
How can I add someone to a parent?
and how do I do this in the api?
Basically this but without clearing first https://www.github.com/LuckPerms/api-cookbook/tree/master/src/main/java/me/lucko/lpcookbook/commands/SetGroupCommand.java
thanks
You're welcome
How is it not working? What are you trying to achieve?
few things wrong just by looking at the code:
- primary group is based on weights, not to be manually set https://luckperms.net/wiki/Weight
- Why are you running
saveUserinside ofmodifyUser? The point ofmodifyUseris so it automatically saved
Are there any placeholders for display name in LPC config? I tried like {username} but it didnt work since its neither in LPC config or a Placeholder.
Basically how do I get the display name placeholder
oh okay sry
how would i check if someone has a permission node from luckperms (with luckperms bungeecord)
you are coding a bungeecord plugin?
ye with the luckperms api
You can use the UserManager#searchAll method to get all user UUIDs that have the node for the given matching criteria
https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/model/user/UserManager.html#searchAll(net.luckperms.api.node.matcher.NodeMatcher)
See the NodeMatcher's static factory methods to create one https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/node/matcher/NodeMatcher.html
thank you so much
its says in my ide that it can not instintate the type luckperms
should i just create a construtor?
Learn how to use the LuckPerms API in your project.
the first one explains, among other things, how to get an instance of the LuckPerms interface
im sorry, but how do i use the searchAll method? for the paramaters do i need a player, or what?
I did, but not thuroughly my bad!
i found it
so another question what is a node?
like is it a string
ik its an object, but like what does it store?
The Node class encapsulates more than just permission assignments. Nodes are used to store data about inherited groups, as well as assigned prefixes, suffixes and meta values.
cool
i may be an idiot, but is this how you use it? ```if (api.getUserManager().searchAll(api.getNodeMatcherFactory().key("jayden.toros.servers")) != null) {
sender.sendMessage("hi");
}```
oh ok
so how should i do it?
it tells me its not gonna work if i remove the doesnt equal null
How should you do what?
So LuckPerms needs to be installed on every server instance in the bungeecord network. Will a proxy plugin be able to add/remove groups using the LuckPerms API?
If it's also installed in the proxy and every LP instance is connected to the same messaging service, yes
See the MessagingService interface in the JavaDoc 📌
So the Bungeecord server is receiving the changes, however, my proxy plugin isn't.
It prints this if it does receive the change (which it isn't doing)
EventBus eb = api.getEventBus();
eb.subscribe(NodeAddEvent.class, this::nodeAdded);
is the code
how am I supposed to extract any useful information out of those events?
would it require String parsing?
Yes
well would it give me the same output string as the one above if the change was made by a plugin instead of a command?
How to check all groups of a player/offline player in a specific server? because i'm reading the documentation but i don't understand how context/query work.
This isn't really about the luckperms api, more about the helper api
can I ask about that here?
Not sure where else to ask about it
you can do something like
Collection<Group> groups =
user.getInheritedGroups(QueryOptions.builder()
/* direct parent groups only */ .flag(Flag.RESOLVE_INHERITANCE, false)
.context(ImmutableContextSet.of("server", "survival"))
.build());
replace survival with w/e the server context value should be ofc
I do not know whether this is the right place for this question. When a player is in a group named abc he has the permission group.abc, hasn't he? Now my question: if I remove the permission group.abc do I remove him out of the group abc too?
How can I add a player to a group via API?
!cookbook 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.
Thanks, I'll look into that!
Yes
thanks
Hey, is it possible to assign permission / set the parent of a user, but silent? aka not trigger a log message
I don't think there's a way to have a single permission be silent, but there's a setting in the config to make all logs silent
There's also a permission to see logs you can set to false.
Adding permissions with the API doesn't show any logs?
When i do /lp editor and Edit my perms the perms that i Added even of i clicked save and wrote that in the chat it Doesnt make Any changes why?
is this to do with the LP API?
!api
Learn how to use the LuckPerms API in your project.
All is well and explained somewhere up there ^ :D
well, used the cookbook I guess
got what I needed
what if I want to set the node to 'false'?
nvm
When I add a player to a region using the API, the player still cannot leave the region that was secured with exit deny. What can I do about this?
lp doesnt have regions...?
Wrong server, this should go to WorldGuard 😄
Hi. I'm making a plugin what sets the players rank to the rank stored in out database. My problem is that, I'm getting the correct data for the change and I save it too but, it isn't changing.
!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.
Has examples how to add it
Does travertine support lpb?
Yes
alright
!help
!advanced
!api
!argumentbased
!ask
!bulkupdate
!bungee
!bungeecheck
!cauldron
!colours
!commandequivalents
!commands
!config
!context
!cookbook
!default
!downloads
!editor
!editorsafety
!errors
!essentials
!extensions
!extracontexts
!faq
!formatting
!helpchat
!inheritance
!install
!libsdir
!locale
!meta
!migration
!notworking
!nowildcard
!pasteit
!permissions
!placeholders
!selfhosting
!stacking
!storage
!suggestions
!switchstorage
!sync
!testingperms
!tracks
!translationprogress
!translations
!upgrade
!usage
!userinfo
!verbose
!version
!weight
!whyluckperms
!wiki
!clolors
!weight
LuckPerms allows you to set weights in order to determine the priority of certain nodes, like permissions and even prefixes. A higher weight number is a higher priority.
!editor
LuckPerms offers an easy to use, powerful Web Editor, with which you can add, delete and change permissions of groups and players.
!api
Learn how to use the LuckPerms API in your project.
@tribal halo @errant jetty this isn't the bot commands channel, use #general for that purpose
o sure
!sync
To sync data between servers, you need to connect each LuckPerms plugin to the same database (for example MySQL) and set up a messaging service.
Hi, how can i get information, when temp parent expire?
._.
You can do something like
user.getNodes(NodeType.INHERITANCE)
.stream()
.filter(Node::hasExpiry)
.map(Node::getExpiry)
.collect(Collectors.toList());
how do i remove the option to op people?
hey, I get errors when I try to apply the Luckperms API to maven.
I've never worked with apis so idk
and for the vault api issue ill fix on my own i guess
heres errors:
https://imgur.com/a/maGxaKX
nope
thats all errors i get
uh
i used a plugin on intellij
idrk how to work with apis
u got an error
lol
yeah
the red bar there
Hover over the red line
Seeing a paste of the problem makes everything so much easier! Use https://paste.lucko.me/ 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!
Hey KolDren! Please don't tag helpful/staff members directly.
doesnbt give an option to choose java
Hello, I am creating a permission system for commands ran from a command block, is it possible to inject my own PermissibleBase to ServerCommandSender so it would not collide with LuckPerms? Or are there any other ways using the API to do this?
Or are there any other ways using the API to do this?
do what with the API?
missing details tho
Basically I want to check for permissions for command blocks and not give them unlimited priviledges, my idea was a single plugin that would have it's own list of permission, or just create a group in LuckPerms and take all the permissions from that group. In order to do that I have to replace Minecraft's PermissibleBase in ServerCommandSender, but LuckPerms already does that, so how do I make it to not collide? Or is there any way using the API to inject something in this class LuckPerms modifies?
LuckPerms doesn't inject a permissible into all permissibles, it only injects one into players only on join
Is it intentional that a user can have no groups?
not even the default group?
I'm on Waterfall and that is my test Command for testing:
final var uuid = plugin.getUUID(sender); // Get UUID from CommandSender
LuckPermsProvider.get().getUserManager().modifyUser(uuid, user -> user.data().clear(NodeType.INHERITANCE::matches)).thenAccept(v -> {
final var groups = LuckPermsProvider.get().getUserManager().getUser(uuid).getInheritedGroups(QueryOptions.nonContextual());
sender.sendMessage("Your Group size is: " + groups.size());
});
what a great question
curiously enough if you do the modifyUser process "manually"
(userManager.loadUser(uuid).thenApplyAsync(blah return user).thenCompose(userManager::saveUser))
it will actually give default if needed
I guess that's a bug lol
am pro at luckperms
ok?
how do i give myself a rank on ma server?
!usage
Here's a guide to help users understand and use LuckPerms for the first time.
Or if you want to do it with the API,
Learn how to use the LuckPerms API in your project.
that is documented on the usage page. also, this channel is not for LP usage, it's for writing code using LP
oh sry
is the save method need to be async? https://luckperms.net/wiki/Developer-API-Usage#saving-changes
Not necessarily, it delegates the save task to a new thread in the background;
It is highly advised you do it async if you are going to .join()/.get() the returned CompletableFuture, because that will wait until the async task is completed, defeating the purpose of concurrency in that case.
yeah I know, I already make it async. Thanks!
to add multiple permissions (with same context, value), I have to create multiple nodes?
through the api?
how do u do that
I (well) looked at the API but I can't find a method to retrieve the group in a track of a lp user.
Example: I inherit "admin" group in the staff track, is there a method to retrieve my group in the "staff" track?
Idk if I explain well but I'm not english sorry :x
do you know what the api is?
yes
no one? :x
I Think I found another bug..
I modify the user Groups on BungeeCord but it took some time that this changes are received on the server..
LuckPermsProvider.get().getUserManager().modifyUser to add a group need time..
/lpb user example parent add group works that instance.
Or did I forgot somthing to add in my code?
Push the update with the messenger
I'm blind...
https://luckperms.net/wiki/Developer-API-Usage#saving-changes
Where I find the correct code to use?
well, you could use a single builder with all the contexts and stuff you need and change the permission/node key between adds, I personally don't like it lol but it's totally valid
Thanks, should be added to the wiki page?
yeah probably
Works fine, thanks 😄
To send updates through the messaging service to other servers:
- if it's a single user (
UserManager#saveUser,UserManager#modifyUser) (preferred whenever possible over general updates):
CompletableFuture<Void> future = ...; // action (any that writes to storage)
future.thenRunAsync(() -> {
Optional<MessagingService> messagingService = luckPerms.getMessagingService();
if (messagingService.isPresent()) {
messagingService.get().pushUserUpdate(userManager.getUser(uuid));
}
});
- if it's other (non-user) changes / general changes (e.g.
TrackManager#saveTrack,TrackManager#deleteTrack,GroupManager#saveGroup,GroupManager#modifyGroup,GroupManager#deleteGroup):
CompletableFuture<Void> future = ...; // action (any that writes to storage)
future.thenRunAsync(() -> luckPerms.getMessagingService().ifPresent(MessagingService::pushUpdate));
and that's a message I'm saving to my clipboard
Pin?
will probably PR to the wiki or to api cookbook
eventually :^)
yeah until then it's gonna be pinned lmao
NodeType is invalid enum
But my IDE can't find object NodeType
a wrote this:
User user = LuckPerms.getApi().getUser(fp.getName());
String expire = user.getNodes(NodeType.INHERITANCE)
.stream()
.filter(Node::hasExpiry)
.map(Node::getExpiry)
.collect(Collectors.toList());```
collect(Collectors.toList())
what do you think this does
or
what do you believe "collect to list" means
It converts to List
I know, but which generic type must be into List?
and Node#getExpiry returns an Instant so you'll end up with a List<Instant>
the instant in time the node will expire
try importing it?
yes
❓
what API version are you adding as dependency
<dependency>
<groupId>me.lucko.luckperms</groupId>
<artifactId>luckperms-api</artifactId>
<version>4.0</version>
</dependency>```
oh ok
right
@nocturne elbow no
Hello, i've been looking at the api for a while but i don't understand it fully, I have a group that has a prefix. permission for tab and chat which has text you can put in and i want to do that with a command, from what i understand i should remove the existing prefix permission and put another one with different text..
how would i do that?
I guess you could do something like
// "Simulate" the meta setprefix command and remove all prefixes with the same weight as the new prefix
group.data().clear(NodeType.PREFIX.predicate(node -> node.getPriority() == newPrefixNode.getPriority()));
// Add the new prefix
group.data().add(newPrefixNode);
wait i dont have a node with metadata
wat
Yeah?
Nodes are immutable, you can't really "change" then
Uh not sure what you mean by that tbh
can't i change the text written there
pretty sure i just have no idea how to use the api thats why i sound so confusing
To do how the editor does it you have to remove the old one and add the new one
I mean whether you do it in the editor or not you still have to do it that way
is there a way to "search" a node
i only would have prefix. cause all else could change
so if id have to delete the node idk how i'd select the correct one
This I wrote above would suffice, if you don't care about the weight just do .predicate() alone
#luckperms-api message
i have no idea what this means though
What part of it?
nodetype.prefix (essentially) means that its a node that on the editor would start with prefix.?
Yes, it's a prefix node
and what does this do
.predicate(node -> node.getPriority() == newPrefixNode.getPriority()
do you know what a predicate is?
Not exclusively, no
I'm assuming you have a prefix node built? That's what I meant by "newPrefixNode" it'd be your, well, your new ("modified") prefix
i don't but i think i know what you mean
this? .predicate(node -> node.getPriority() == newPrefixNode.getPriority()
oops
https://luckperms.net/wiki/Developer-API-Usage#creating-new-node-instances meant to paste this
i see that there is a // build a prefix node;
would it still work if i used node.builder?
Well it would yes, but you should use the PrefixNode.Builder
Node newPrefixNode = Node.builder("prefix.5.&8[&#d980ba&8]").build();
i mean this
ah
so would it be .builder(weight,"&8[&#d980ba&8]") ?
(that number there is the weight i think)
How a node is structured internally is, as I just suggested, internal details. Using the specific builder will prevent your code from breaking if Luck goes mad and changes the structure lol
Yuss
(also I think the wiki is wrong lol, it's .builder("Prefix", weight))
Eh


