#luckperms-api
1 messages · Page 31 of 1
UserManager#loadUser returns a CompletableFuture<User>, maybe try using that to get the player group if they aren't loaded?
hi there, could you please tell me what is the correct way to switch one's primary group via developer api
LuckPerms luckpermsApi = LuckPermsProvider.get();
User user = luckpermsApi.getUserManager().getUser(player.getName());
user.setPrimaryGroup(permissionGroup);
luckpermsApi.getUserManager().saveUser(user);
i tried this, but it doesn't work even when i set "primary-group-calculation" to stored
Problem solved, just use this as noted by RyanJH:
without going too far into detail, anyone know why this would pop up when trying to check permissions and follow everything in the dev-api wiki? https://i.imgur.com/st12hhy.png
What is your LuckPerms version?
Bukkit-Legacy-5.1.75
Make sure your plugin loads after LuckPerms (depend or softdepend in plugin.yml)
i'm having a bit of trouble adding the luckperms API as a dependency through maven
when i hover over the dependency it says 'not found'
oop never mind xd
is anybody familiar with how to use the stream API to get all of a user's groups which are not inherited?
except i don't want inherited groups
nvm
i realize the error of my ways
What do you mean with groups that are not inherited?
brainstone dont roast me
Ok
That's LP loading up
That's another error tough
The LP plugin instance cannot be cast to an instance of the API
Larry, server won't start after upgrading luckperms version, uploaded crash report below. (I deleted old files as well still no boot)
https://bytebin.lucko.me/oksaVC5m24
@mental linden that looks like a plugin is depending on the old API of LP
Try installing the legacy API extension
!extension
Sorry! I do not understand the command !extension
Type !help for a list of commands.
One sec
np
!downloads
You can download LuckPerms for Bukkit/Spigot, BungeeCord, Sponge, Nukkit and Velocity.
Scroll down @mental linden
i've got it
Also wrong channel
I need that file: LuckPermsBridge
Make a bug report on GitHub
does anyone know how I can get the display names to work as they are not working at the moment
Elaborate
I have seen on another server everyone has their role appear next to their gamertag and in the TAB window I was wondering how I do this. I assume it is done with the display name
No it's not
Also not really LP related
Btw most of those plugins are open source
So why don't you just take a look?
Oh ok thanks for your help
You're welcome
So question im trying to get luck perms to work with Multiverse. it seems to work fine. but everyones prefix is either. [world] [world_nether], or [world_end] and lucks perms does not seem to over wright tho's prefixes with the groups and prefixes i made with luck perms
i dont know if that exsplained it, but idk
is that under the plugin file for it? or in game
It's in the multiverse config -also this is not the correct channel, please use #general for non-LP things
my bad. i just want sure cause idk if it was multiverse or luckyperms
Even LP things should go in #support-1 or #support-2 unless they're related to the developer API, in the future
larry, do you know if all it takes to assign a user to a different group / remove them from a group is
LuckPerms api = LuckPermsProvider.get();
User user = api.getUserManager().getUser(uuid);
user.data().add(Node.builder("group.my_group").build());
user.data().remove(Node.builder("group.other_group").build());
You need to save the user after but I do believe so
ahhhhhhhh that's what i'm missing then
thanks larry 😉
.... for some reason i'm getting a sense of deja vu here
hmm i'm having an issue where my bungee plugin might try and create a LuckPerms api object very soon after the server starts; and when that happens I get an illegalStateException saying that the LuckPerms API is not loaded
is there a way to detect when the API is loaded? or even better, wait until it is?
Make sure you depend or soft-depend on LuckPerms in your plugin.yml (or whatever that is for bungee)
hmm... I added LuckPerms as a dependency, but when I try to get the API in onEnable(), it still throws an error
it says depends: instead of depend: because it's a bungee.yml and not a plugin.yml
actually now that i've added LuckPerms as a dependency, it throws an error EVERY time I try to get an instance of the API lol
Are you shading it in?
i was using the luckperms-bukkit jar as a dependency
which just might be why it isn't working with my bungee plugin.... xd
i'll try using the API jar from the maven site and see if i have better luck with that
though the bukkit jar did work for me before, for whatever reason.. hmm
using the api jar didn't help; and tobi i don't think i was shading it in - i was using the normal jar and not a shaded one
Can you open your built Jar file with something like WinRar?
my plugin one? sure
If you see a net/luckperms/api folder in there, then you have it shaded, that would be my last guess
You shouldn't have the API shaded, because iirc you try to access your shaded API and not the one provided by the LuckPerms plugin. So it can't be loaded.
ah
so what do I do? just not export the api along with the other stuff?
(if i can figure out how to do that 😅 )
Do you use Maven?
i've been trying to, but i'm also using normal external jars dependencies alongside it
Do you have a pom.xml with something like
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
in it?
nope, nothing to do with shading
i only have
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
so am i right in saying the api is throwing the error because I'm including the luckperms api as part of my plugin jar?
Yes
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artiactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>net.luckperms:api:jar</exlude>
</excludes>
</artifactSet>
</configuration>
<execution>
</executions>
</plugin>
try add that, not sure if it works tho
Or wait, no, I messed something up
it might be because I'm also using the luckperms external jar
in my build alongside the maven dependency
but i was getting issues before when i was just using the maven dependencies
iirc
oh... i just removed that jar and it worked
i'm so sorry tobi XD
Hello. Where i can find the maven of luckperms?
founded
<dependencies>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
What is the best way to get like a list with all groups the player inherits?
General permissions checking question. If I check for, say, group.staff.*, would it return true for a player who has group.staff.admin?
hello i recently got luck perms and i got rankgrant+ too and i make a group i set its prefix and i put for me then the prefix doesn't have a space between the prefix and the player name help plz
Is there an event when group removed?
Learn how to use the LuckPerms API in your project.
It's on the usage wiki, second link on the embed iirc
The target is a permissionholder, so user or group
I cant find it, please tell me the line
My second sentence is me telling you
The target is a permissionholder, so user or group
Is the playername the friendlyName?
???
getFriendlyName
I know like basically zero java and I have a feeling you know less
Getfriendlyname is not from LP
Not as far as I know
i only want the playername or uuid, but im not a pro, sorry...
A node can be removed from players or groups
getTarget will get the player or group
You can further limit it to just be a player after that afaik
The javadocs are linked here, read the ones for that which you need
!api
Learn how to use the LuckPerms API in your project.
First link
@uncut timber in your code snippet, you do not save the user
You gotta save the user
!api
Learn how to use the LuckPerms API in your project.
Examples and explanation found on each of these two links
Ok thanks!
How can i load all users from the database?
@uncut ice ^
Hey all, got this code:
public void setCount(@Nonnull UUID uuid, @Nonnull Map<String, Integer> counterValues) {
LuckPerms api = LuckPermsProvider.get();
User user = api.getUserManager().getUser(uuid);
if (user == null) {
return;
}
for (String counter : counterValues.keySet()) {
user.data().add(MetaNode.builder(counter, String.valueOf(counterValues.get(counter))).build());
}
api.getUserManager().saveUser(user);```
It works exactly how I intend except when it's called multiple times, it assigns multiple values to the same meta key
eg setCounter(myUUID, <"brewing", 10>) -> adds meta brewing = '10'
then setCounter(myUUID, <"brewing", 20>) -> adds meta brewing = '20'
Is there any way I can make it so the key only ever has one value, the latest set?
Or so I can override the prev value as oppose to add another?
`Modifying existing nodes
Nodes are immutable - meaning their attributes cannot be changed. However, we can easily create a new node based upon the properties of an existing one.
e.g.
Node negated = node.toBuilder().value(false).build();`
I read this to mean we should just create a new node and add that instead - the same way as above, so this should work in theory?
Any ideas would be greatly appreciated
After looking at https://github.com/lucko/LuckPerms/blob/2ac7d3dfe6591200486f86700054a931f560def2/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java#L89 - my solution is:
public void setCount(@Nonnull UUID uuid, @Nonnull Map<String, Integer> counterValues) {
LuckPerms api = LuckPermsProvider.get();
User user = api.getUserManager().getUser(uuid);
if (user == null) {
return;
}
for (String counter : counterValues.keySet()) {
MetaNode toSet = MetaNode.builder(counter, String.valueOf(counterValues.get(counter))).build();
user.data().clear(node -> node instanceof MetaNode && ((MetaNode)node).getMetaKey().equalsIgnoreCase(toSet.getMetaKey()));
user.data().add(toSet);
}
api.getUserManager().saveUser(user);```
I'm not sure who wrote this up https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#listening-to-luckperms-events but thank you.
How can I get a user and add a parent rank to them?
!api
Learn how to use the LuckPerms API in your project.
these links, taken together, contain the sum total of all the knowledge you will need
Excellent.
is there a way to retrieve all users who have a specific permission?
InheritanceNode staffNode = InheritanceNode.builder("group.staff").build();
NodeMatcher<InheritanceNode> matcher = NodeMatcher.equals(staffNode, NodeEqualityPredicate.ONLY_KEY);
CompletableFuture<Map<UUID, Collection<InheritanceNode>>> result = api.getUserManager().searchAll(matcher);
result.thenAcceptAsync(res -> { ... });
```trying this but it's not returning anything even if the player has group.staff inherited from a group :/
I can't seem to init the API on Bungee since the example uses Bukkit
https://hastebin.com/qiwedizoqo.cs
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
Well shadowolf you are looking for Bukkit there, your first step should be to find what the bungee equivalent of the bukkit servicesmanager is
Will the API 5.1 also work in an Bungee(Waterfall) plugin or do I need another one in this case
Well if anyone knows how I could force changes I did to nodes (like a group change) appear directly to a user, a tip would be welcome. I guess I have to flush the permission cache somehow. At the moment the changes (add/remove) get saved to the database but only apply after a users logs out and in again. Thanks
That doesn't seem related to the luckperms developer api
Well meanwhile tryed a lot like
LuckPermsUser.getCachedData().invalidate();
LuckPermsApi.getMessagingService().get().pushUserUpdate(LuckPermsUser);
LuckPermsApi.getMessagingService().get().pushUpdate();
All does not solve the problem
are you saving the user after you make the change, and that still doesn't update the player ingame @hardy sedge
I wrote a plugin for bungee, means waterfall. When the user joins with the prefix * (will be changed later to Floodgate listener) it adds a group to the player. So in this case it adds the group in the MySql database as it should, but the player itself does not gets it applied.
Except if the player logs out and in again
I guess Luckperms checks the data on mysql again
What are your database settings? Ideally i believe they should have watch-files to true
I use the plugin message service
Well that's probably the reason
But is recommended for a proxy
I mean, at least try using sql, so updates propagate correctly
SQL will fix it indeed since it rechecks the databse periodically
I mean, pluginmsg relies on online players to propagate changes
sql relies on online database
Well actually let me check if it is indeed an online issuse, just wanna know if thats it. I will shedule the push message half a minute
you could also, as i said earlier, set watch-files to true and don't schedule changes. That way when any change is detected it will automatically propagate
This is activated at the moment, but according to config it only takes effect if you use fiule type storage engine
I will not keep the shedule, is just a test do uinderstand it
Idk man pretty sure if you try it, it should work for the db? I'm not certain tbh
Ya is actually really a problem with the connection, shedule works. I did'nt think about that since the player either is connected to bungee and not to a server or already on a server. It seems like luckperms ignores update pushes (global and per user) as long as the player is not etablished on a server. But I thought that in that case it would request the perms on server connection
Well for some reason it looks like it already got them
maybe because the perms get cached once
I can fix that now listening to other events
Thanks so far
Might really be the problem, that the local server plugin caches the whole perm list from mysql on startup anw will not update anymore (pluginmsg service) as long as no update push will come. But seems to ignore all pushes for offline players not processing the data again
Now I know
😛
pluginmsg relies on having an online player on the target server or else it simply doesn't work
Yes, thanks, I can fix it now easily since I know that
awesome
Thanks again!
np!
Hi
i have so much trouble to install LuckPermsApi i search while about 2 hours can someone helpme please
i can't find LuckPermsAPI
You just obtain a LuckPerms object instance, either through bukkit service manager or LuckPermsProvider
what you have there
Correct me if I'm wrong but I don't think there's a LuckPermsAPI class? You just work with the LuckPerms provided object...
The root api instance is LuckPerms yea
how do i check if someone has a group?
!api that's explained fully on these two links (taken together)
Learn how to use the LuckPerms API in your project.
thx
you can use ```java
if(p.hasPermission("rank.vip"){
//do stuff
}
Theres probs an easier way
that's only gonna work for fully online players, afaik
It is the easiest I've seen tho lol
Probs
hooray
wrong channel. come to #support-1
Hi !
So i have a question
It's about LuckPerms i just try to access to the LuckPermsAPI
i download api, i write
but now that i have the instance what can i do for access to the API
That is the API @woeful pilot
ah ok other mod tell that just instance so how can i get LuckPermsAPI ?
That is the API class @woeful pilot
There is no LuckPermsAPI class (anymore)
That’s the API instance
That’s what you want
ahh.. ty i guess
Learn how to use the LuckPerms API in your project.
Thank so much but....
Do you know how to Java?
It is my highest recommendation that you do not jump straight into making plugins without having however basic a grasp of Java first
I do not recommend jumping into plugins with anything short of a solid understanding of Java or at least OOP programming
Like around a year of solid experience
And that’s still not enough to use the LP API. It’s not made for beginners
How i can get user metadata? prefix and suffix for example
thx
how to then i add plugin server just goes off
What?
Are you asking about the Luckperms developer API? If not, wrong channel
does the developer api works with bungeecord?
Yes
How do I use it? There are only examples for spigot and sponge on the wiki
As far as usage is concerned, I believe it's platform independent
Okay thanks
is and emerald or diamond EMERALD_INGOT or just EMERALD?
declaration: package: org.bukkit, enum: Material
thanks
How can I check if a User (NOT the group) has any permission
!api it's explained pretty well if you take the info on both of these links together
Learn how to use the LuckPerms API in your project.
I dont find any way to NOT include "Group Permissions"
get a permissionholder which can be a user or group and then only give it users?
Oh do you mean directly inherited
Use that on the user permissionholder
Sorry! I do not understand the command !javadocs
Type !help for a list of commands.
>:(
!help
!advanced
!api
!argumentbased
!ask
!bulkupdate
!bungee
!cauldron
!chat
!colours
!commandequivalents
!commands
!config
!context
!default
!downloads
!editor
!errors
!essentials
!extensions
!extracontexts
!faq
!helpchat
!inheritance
!install
!locale
!meta
!migration
!notworking
!nowildcard
!pasteit
!permissions
!placeholders
!selfhosting
!stacking
!storage
!suggestions
!switchstorage
!sync
!tracks
!upgrade
!usage
!userinfo
!verbose
!weight
!whyluckperms
!wiki
!whyluckperms
Why should you choose LuckPerms? Read here to find out.
Is this the way I'll get the permission from an User user.getNodes().stream() (and not from his group)
I want to make player being able to use "/gamemode spectator/survival" bot how do i do that, without them having permission to go into other gamemodes like creative
then give them the permission
you also can give them the permission only when the type in the command and later you remove the permission
I dont know how to do that. And they should be able to go into spectator and survival everytime they want
do /lp group groupname permission set minecraft.command.gamemode.* true
if you use essentials..
/lp group groupname permission set essentials.gamemode.* true
also, wrong channel bro
move onto #support-1
np
Okay I'll try it thanks
Ok so I dont really understand how to use it in my Code
@nocturne elbow
Alright give me a minute
why am I doing this
Set<Flag> flagsToApply = ...;
QueryOptions queryOptions = QueryOptions.nonContextual(flagsToApply);
Collection<Node> nodes = user.resolveInheritedNodes(NodeType.NODE_TYPE, queryOptions);
https://javadoc.io/static/net.luckperms/api/5.1/net/luckperms/api/query/Flag.html
You will definitely not want to add Flag.RESOLVE_INHERITANCE since... well... read the docs.
Okay thanks
Why do I need flags
I dont understand wich Flag/QueryOption do I need
Wich Flag should I use when I'll get all Player Specific Permissions? @nocturne elbow
You add the flags to the set you want to query for, and don't add the ones you don't want
Yeah but I dont really understand wich do I need
You will definitely not want to add
Flag.RESOLVE_INHERITANCE
Thats the problem I dont know wich ones are the best for my "problem" so I want to get all Permissions from a user that arent from his group
So now I've another problem when I type in all this my IDE says that the method dont exist and I should remove the NodeType
The method resolveInheritedNodes(QueryOptions) in the type PermissionHolder is not applicable for the arguments (NodeType<PermissionNode>, QueryOptions)
You might want to switch to the 5.1 API
Okay I'll try it
Okay thanks
Either that or you can get all node types and filter them out yourself
That would work too
Is not happening on any of my test systems so I have a hard time to repeat that error
Not all instances of LuckPerms will have a messaging service setup and configured.
How hard would it be to create a plugin that changes your spawn point when you die, and your /spawn point depending on what group(s) your in?
I'm new to plugin development
Non-LP related dev in #general please and ty
(this channel is only for the Luckperms API)
I put it here because the group thing is related to the luckperms api 😛
fair enough I guess it is related enough to stay here, ignore me
haha no worries
To answer your question, that shouldn't be too difficult
@snow willow the code you originally posted user.getNodes() is already what you want
This does not include inherited nodes
I mean why didn’t you just give it a try?
There are like 4 different methods to get the nodes of a player. If one of those returns just the nodes assigned directly to the player it should be pretty easy to find within 4 attempts
Or one if you try all 4 at ones
And with try I mean just printing all the permissions that are in the lists
Im not sure if this is the appropriate channel to ask questions about the editor, hopefully someone can help me. Im using a minehut server and prior to the 1.16 update i had had all my ranks setup. There were lots of issues with many plugins so i wiped all files to start over. Now the ingame commands tell me i have all the old groups and track but when i use lp editor only the tracks port over, the groups only show default.
Is it possible to promote a user without a context? Or does it need the context?
luckPerms.getTrackManager().getTrack("ranks").promote(user, <Context>);
You could pass ImmutableContextSet.empty()
https://javadoc.io/static/net.luckperms/api/5.1/net/luckperms/api/context/ImmutableContextSet.html#empty--
You could pass
ImmutableContextSet.empty()
https://javadoc.io/static/net.luckperms/api/5.1/net/luckperms/api/context/ImmutableContextSet.html#empty--
@nocturne elbow Thanks a lot
np
Is there a way to get a players current rank on a specific track via the api?
Currently trying something along the lines of:
List<Group> common = new ArrayList<Group>(ranksGroups);
common.retainAll(groupsPlayer);
To try and get a common group between the trackgroups and the players groups
Hitting the issue of tracks.getGroups returning a list of strings, and the user groups are of the Group type
Convert them using streams @hard oar
Thanks!
Another small question, this code doesn't actually promote the player, how can I promote him?
PromotionResult promotionResult = ranksTrack.promote(user, ImmutableContextSet.empty());
Remove the old group assignment and add the new one
I need to make a sky block server and it won’t let anyone without op/* break or place or interact with permissions ex how do I fix
please do not crosspost in several channels
Can someone please teach me how to edit luck perm permissions
aaah ok
I need help again 😦 , How do i activate the permissions from the /lp editor, I checked my default perms using /lp group default permissions info, but it says not are listed
Top right corner
Save button
It'll give you a command, you run that command on your server
Oh tysm I will see if it works
And please go to any of the general channels if it's not related to the developer API
oooh I thought this was for like developing servers sorry XD i just joined
I would like to get the suffix of a group. For that I need to get the group meta ofc. For getting metadata you need queryOptions... how do I get the query options of a group?
I keep getting java.lang.ClassCastException: me.lucko.luckperms.common.api.implementation.ApiGroup cannot be cast to org.bukkit.entity.Player
When using this QueryOptions queryOptions = luckPermsApi.getContextManager().getQueryOptions(group);
Is there a different way of getting queryOptions for groups rather than players or users?
And another question: if I get the suffix of a player and that player doesn't have a custom set one will the api return the inherited one from the group the user belongs too?
I would like to get the suffix of a group.
@ripe token https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/model/PermissionHolder.html#getNodes-net.luckperms.api.node.NodeType-
That will give you the nodes the group holds, it won't resolve inherited nodes
If you want that to happen you'll need to use #resolveInheritedNodes(NodeType<T>, QueryOptions), and you can create the QueryOptions you want with the QueryOptions.Builder class
What do I do with the nodes the group holds?
Just to ensure I'm not going crazy, this should check if a User has a given permission, correct?
(Having to do it this way because this is running in AsyncPlayerPreLoginEvent, and so have no Player#hasPermission to use)
boolean hasPerm = user.resolveInheritedNodes(NodeType.PERMISSION, QueryOptions.nonContextual()).stream().anyMatch(permissionNode ->
permissionNode.getPermission().equalsIgnoreCase("<some node>") && permissionNode.getValue());
cough cough paper, a hasPermission method of some form on that event would be great, I can't be the only person doing this
I can't be the only person doing this
bet
People write strange software out there in the wild...
What I'm doing isn't that special though, just a permission based whitelist-esque thing
I'm sure there's hundreds of other plugins that do that
do u have vault too
easy way to do it through vault i know of
o luckperms too
during APPLE @wild whale
Or schedule a sync task for the next tick, check for the perm and kick then 👌 👌
Then I'd have to deal with cancelling the join/leave messages as well, since my goal is for them to disconnect silently
(been having lots of problems with spambots using a VPN that our AntiVPN isn't catching, and spamming hate messages against prominent members of the community. Captcha plugin stopped the hurtful messages, but we still get join/leave spam)
Offline mode 👀
does the old api still work or do I need to update the dependency to the latest one, if so do I just need to state the the api adress or is there a new "node", "contexts", "user" etc
nvm i'm dumb
lol
You can use the legacy API extension to make plugins with the old API work with the new version of the plugin @somber owl
Hi
I'm making a better chat format plugin , would it be possible using LuckPerms API to get all of the prefixes of a user (each group has a prefix) and display them in the chat? Also do I need Vault for this ( I hope not) 😮
Learn how to use the LuckPerms API in your project.
And no you don’t need to use Vault
Thank you this is all info I needed before start
Though generally speaking using it is better as that allows your plugin to work with pretty much any permissions plugin
But I will develop for my own Server
It's not something that will be publicly available so I know my environment and I will not use Vault, because we will have all custom plugins
Of course I use ONLY LuckPerms
Because it's the best
And I wouldn't really be able to replicate it myself
Let me tell you right now that holds true for most other plugins. Or at least the respective best of their kinds
Well for example I am replacing EssentialsX & EssentialsXChat with custom solution that will better suit my server
The same holds true for me. And I’m a professional (plugin) developer.
And if I could replicate it it would take a significant amount of work that’s typically just better spent configuring existing plugins
Well I'm not a professional developer, but I have now 2+ years of Java and Spigot development
Thanks for helping, now I go
You’re welcome
Awesome
I still haven't got a clue of how the website system works 😔
I tried looking at source but I'm not used to huge projects such as this
Well LP uploads the data to a pastebin like server hosted by luck only for LuckPerms
Then the URL for the editor contains the ID of the paste and displays the data
Wouldn't having a dedicated server with users and databases be more efficient?
When you save the editor it saves the data back to the pastebin and creates the command that contains the new ID. Running that command makes the server load that data and apply the changes
Wouldn't having a dedicated server with users and databases be more efficient?
@rough chasm what do you mean?
Like a real website hosting where each user creates an account and manages his server , all servers and permissions and groups would be stored on a database on the website
Are you insane?
Well I'm not a web developer I don't know this kind of stuff
hey BrainStone how are you!
Well take a guess. What kind of resources would it take just to run the database just for all users here in the discord (LP has waaaay more users)
yeah rip money
And then what do you do when someone doesn’t want to store their data centrally?
Or what happens to those people that have censored internet?
They then just can’t use the editor?
I mean it could be a cool "premium service" idea, in my opinion
So the servers run worse?
Ok nvm I realized this suggestion is not efficient
And we haven’t even touched the legal issues that arise from a service like that
@hushed oxide hi
Hi dude
Is there anything you want from me?
^
i am Blue_Tree remember me?
you helped me in a lot of stuff
I help a lot of people
Hey moldyfish1! Please don't tag helpful/staff members directly.
i didnt tag i just quoted
With a tag
No
😭😭😭😭😭😭😭😭😭
I mean I’m sure I did. Because I always do that
But as mentioned: I don’t remember you
```:(````
And if I did that wouldn’t be a good thing. Because I typically only remember the bad cases so I know not to respond. Gotta keep my sanity somehow
I must be speaking Chinese or something...
I mean what part of “I don’t remember you” is hard to understand?
i am trying to make you remember me
Which frankly is rather pointless
nvm
And again. Why are you wrapping your messages in code blocks?
That is so irritating
I have fun using the code blocks
can you not please
code blocks are for code
if you aren't doing code, it just irritates everyone
lol
Smh yea always see ppl overuse code blocks
It’s not just for code tho that’s a fact
You could also use to for console output etc
Configs
well yeah. Just please not for chat.
code blocks for system.out.printIn("Yea that is how to use code blocks");
Heya guys, 2 questions here with api version 5.1:
1- In the below codeblock, I have a previous instance of user, can I use that one instead of creating a new one (user1)
2- The below code doesn't seem to fully update the user to the group like /lp user <user> promote <track> would. It deletes the currentgroup, adds the new group node but other plugins do not pick up on the permissions of the new group (For example: Tab prefix doesn't update using the below code)
What am I missing here? Added a paste to the full class under the block.
Any other tips are appreciated!
this.luckPerms.getUserManager().modifyUser(player.getUniqueId(), (User user1 /*Can I use my user here?*/) -> {
Node node = InheritanceNode.builder(promotionResult.getGroupFrom().get()).build();
Node node2 = InheritanceNode.builder(promotionResult.getGroupTo().get()).build();
user1.data().remove(node);
user1.data().add(node2);
});
1- probably, but you should test that
2- tab plugin may not update on change but rather just be scheduling an update. Also be sure to save the user at the end of that codeblock, always have to save the user
I changed the 2nd param of modifyUser to my previous instance and couldn't get it to work, it doesn't accept it and gives errors.
The tab plugin updates almost instantly on a manual /lp user <user> promote <track>. According to the API docs modifyUser should auto load and save the user after the actions. Nevertheless I tried saving the user agan after the block with no luck
get the user again if it doesn't work for #1, and as for the save, yeah pretty sure you save in the block, as the last action
Mhm, saving the the user didn't do much.
this.luckPerms.getUserManager().modifyUser(player.getUniqueId(), (User user1) -> {
Node node = InheritanceNode.builder(promotionResult.getGroupFrom().get()).build();
Node node2 = InheritanceNode.builder(promotionResult.getGroupTo().get()).build();
user.data().remove(node);
user.data().add(node2);
luckPerms.getUserManager().saveUser(user1);
luckPerms.getUserManager().saveUser(user);
});
Supposedly, #modifyUser saves the user for you, but it saves the one you asked to modify (player.getUniqueId())
https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/model/user/UserManager.html#modifyUser-java.util.UUID-java.util.function.Consumer-
Loads a user from the plugin's storage provider, applies the given action, then saves the user's data back to storage.
Yea that's exactly the player that's supposed to be saved
But for some reason it isn't.
Maybe there's an underlying reason i'm not aware of in the other parts of the class?
you're modifying user, not the provided user1 tho
why have your own instance of user somewhere else if you're gonna call that method anyway?
I need to get the PromotionResult, which takes user as a parameter
User user = luckPerms.getUserManager().getUser(player.getUniqueId());
if(user == null){
plugin.getLogger().severe("User is null!");
return true;
}
PromotionResult promotionResult = ranksTrack.promote(user, ImmutableContextSet.empty());
This part
then why call modifyUser?
Because the promotionResult doesn't actually do anything on its own
??
Or am I not understanding the concept behind the promotionResult?
mind showing the whole code snippet?
Wait so, you're promoting a player and then applying the promotion changes manually?
Doesn't #promote do that for you...?
Try saving the user after calling #promote instead of calling #modifyUser (and doing the changes by yourself)
I'll try that, thanks
Is the promotion successful tho?
Yes, it goes to the manual part
You're not the first person I read saying that #promotion doesn't work as expected... so that's odd
That seemed to work great, thanks!
One problem I'm experiencing on my dev server (a copy of my live server) is that the String currentGroup always returns to the first group, no matter what group I'm in.
This does not happen in my testserver and I have no idea why. This is how I'm getting the group:
public static String getPlayerGroup(Player player, Collection<String> possibleGroups) {
for (String group : possibleGroups) {
if (player.hasPermission("group." + group)) {
return group;
}
}
return null;
}
Found the issue, thanks for the help !
Sorry :)
Ok nevermind, I did not manage to find the issue yet oO
@nocturne elbow Mind if I dm you ?
yea sure, I don't mind
So after some more debugging, the promotionResult#promote combined with luckPerms.getUserManager().saveUser(user); doesn't actually seem to save the user.
Other plugins still see the user with their previous rank as its group.
When invoking /lpb user <name> info it does update the user and every other plugin gets the correct group and its info.
Is this a bug with the API or is whatever happens when doing /lp user <name> info something I have to do in my code as well to actually save the user?
Many times when I use this method to pull the player's prefix it ends up giving incompatibility in certain APIs of other plugins when determining the player in String, is there another method that is more efficient and effective in the prefix that is?
Player player = Bukkit.getPlayer(prefix);
User user = LuckPermsProvider.get().getUserManager().getUser(player.getUniqueId());
prefix = user.getCachedData().getMetaData(LuckPermsProvider.get().getContextManager().getQueryOptions(player)).getPrefix();
return prefix.replace("&", "§");
}```
this may have something that you could take a look at
Public use I loved it
Does LP have a single event that triggers on a permission update? I've looked at UserDataRecalculateEvent but that triggers multiple times on every single update and I've yet to find a way to tell each event apart.
I'm looking for an event that triggers once when the player joins, and again each time the players permissions are updated, ie changes world, single event. Add a permission, single event.
Add a block of permissions, single event.
I tested it with a single plugin that that event fired 413 times when a player joined.
UserDataRecalculateEvent is what you're looking for, it will trigger on every update and doesn't buffer
if you want a buffer, then you'll need to implement that yourself
this code might be useful if you want something that is time based: https://github.com/lucko/LuckPerms/blob/master/common/src/main/java/me/lucko/luckperms/common/cache/BufferedRequest.java
:0
Thanks, but not really what I'm looking for.
I was really after somethign that didn;t spam events. Only triggered upon completion of an update
Like GM has a GMUserEvent which triggers any time it performs a player.recalc on the permissions
UserDataRecalculateEvent is what you're looking for
if you want a buffer, then you'll need to implement that yourself
isn't that the answer?
Not really Fefo. LP handles perms differently to GM and Bukkit so its behavior is different
Okay, and what is it you need exactly?
internally UserDataRecalculateEvent is actually just a cache invalidation, permission (re)calculation happens sometime after when the permissions are actually needed
Thats what I was afraid of. I'll likely just have to go for a timed check for LP and be less accurate.
Okay, and what is it you need exactly?
unless. Is there a simple way in the userDataRecalculateEvent to see what permission was added/removed?
NodeMutateEvent?
Called when a node is added to/removed from a user/group
https://javadoc.io/static/net.luckperms/api/5.1/net/luckperms/api/event/node/NodeMutateEvent.html
I'm looking for specific permissions being added/removed from a player
....
that will cover that - however it won't be called when their effective permissions change
e.g. after a world change
(there's not any event that will cover that, though)
I can alwasy listen on the bukkit events for a world change if LP won;t trigger on that
(there's not any event that will cover that, though)
actually, I lie -- https://github.com/lucko/LuckPerms/blob/master/api/src/main/java/net/luckperms/api/event/context/ContextUpdateEvent.java
Last probable question - will the NodeMutateEvent trigger for a player even if the change is to a group node?
it will trigger for the group only
is there a reason why you need to detect/react to effective permission changes, as opposed to just querying when you need to query?
I'm writing a plugin that can issue commands upon nodes being granted or removed
a repeating task is your best bet imo
ie, if someone had a permission node to fly, when the perm expires this plugin can issue a command to switch the player out of that mode
i've written such a plugin -- timer or just react to the event works fine
yep, I already have a repeating task for other permission plugins. GroupManager has an event I can listen on and I was attemptign to implement somethgin similar for LP
unfortunately the contextual nature of the way LP handles permission queries makes it tricky to react to changes in effective permissions reliably, also not viable for me to provide an event beyond what the DataRecalculate event does already -- so yeah, repeating task is your best bet with LP anyway
k, thanks for your help. I'll have a play and see if I can do something with what you have given me.
um, silly question. Is that contextUpdateEvent in the release build? I see it on github but I'm not seeing it in 5.1 that I'm building against
Yep, I checked in teh 5.1.26 jar and its not in the API
I mean... what lmao
it's due to be added in 5.2
ah ok, that explains it 🙂
but the latest 5.1 builds include it already 🙂
Is it in the api jar? 🤔 cause I can't find it (I should update my local repo too lol)
it's not in Maven yet, no
ok
Aa
Question, would this code be correct to check if a group is in an inheritanceuser.getInheritedGroups(QueryOptions.builder(QueryMode.NON_CONTEXTUAL).build()).contains(group) And a second question would the returned groups also contain the users main group?
Yea it brings every group the user inherits directly or indirectly
!cookbook not for me, don't mind me
Sorry! I do not understand the command !cookbook
Type !help for a list of commands.
!advanced
!api
!argumentbased
!ask
!bulkupdate
!bungee
!cauldron
!chat
!colours
!commandequivalents
!commands
!config
!context
!default
!downloads
!editor
!errors
!essentials
!extensions
!extracontexts
!faq
!helpchat
!inheritance
!install
!locale
!meta
!migration
!notworking
!nowildcard
!pasteit
!permissions
!placeholders
!selfhosting
!stacking
!storage
!suggestions
!switchstorage
!sync
!tracks
!upgrade
!usage
!userinfo
!verbose
!weight
!whyluckperms
!wiki
Learn how to use the LuckPerms API in your project.
meh..
!permissions
A list of permissions used by LuckPerms commands.
Can I set multiple Groups for players
Or why is the GroupSet Methods Name setPrimaryGroup and not setGroup
@snow willow is there an addGroup
Is it possible to do stuff with the LOG thingy? so i have JDA in my plugin and its connected to a bot. So i want to do so when u create a group it logs to discord.
is there an event for logging
this log ^^
Wow i just explained that so bad xD
from my very quick looks at the api recently, yes, there is a log event that you can listen to
Why so many questions in one of the least used channels all of a sudden? .-.
@snow willow is there an
addGroup
@nocturne elbow No
!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.
Hi! Which event should I listen when a player gets added/removed from a group?
NodeAddEvent I believe
Thanks, I'll check it
!api
Learn how to use the LuckPerms API in your project.
These two pages should have all the info I need (including the link to the javadoc ofc 😄 )
I was between using the node add/remove/clear event and the user promote/demote event, I just wanted a second opinion :P
Promote and DemoteEvent are for tracks, so your application wouldn't, well... apply, if you don't use them.
Okay is it
LogPublish
LogReceive
or logNotify Event.
I want the event that when something is changed (look picture below)
it sends message to discord. The discord thing i know how, but idk the event.
print all three and see which one does what you want when you want
Fefo thanks for the video
was about to ask
xD
I have never been into the listener system Luckperms uses
so i am trying to learn it :)
didnt work :/
Something to do with the api thingy
i've done smth wrong
at crazynetworkcore.Main.onEnable(Main.java:96) ~[?:?]```
Error ^^
Line Main: Bukkit.getPluginManager().registerEvents(new LuckPermsLogListener(this, luckPerms), this);
Line 15 in logListener: EventBus eventBus = api.getEventBus();
Anyone know why it wont work?
i most likely did something wrong
but i am new to that type of event
Well hard to say what’s going on when you leave out the most important part of a stacktrace: the exception
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.
😂
shhhh
Still missing the exception
its nothing more
Yes there’s more above it
The first at is on the second line of the stack trace. The first contains the exception
I’d say so
NullPointerException
it came
java.lang.NullPointerException: null
but
this is correct:
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if(provider !=null) {
LuckPerms api = provider.getProvider();
}
}```
What?
Well, when are you calling that?
After my onEnable
wait wait wait wait
WAIT
is it supposed to be before onEnable
xd
its after
Which line throws the NPE?
Not any Java expert or something, but if the method above gets called, I think nothing happens, you don't set any variables outside the method (or am I blind?)
That also
at crazynetworkcore.Events.LuckPermsLogListener.<init>(LuckPermsLogListener.java:15) ~[?:?]
at crazynetworkcore.Main.onEnable(Main.java:96) ~[?:?]```
i have this
private LuckPerms luckPerms;
LMFAO
you don't set luckperms to anything
Initialized by magic then I suppose
Then you’re frankly doing the wrong thing
I think we’re past that
I dont wanna sound like an idiot also
so i am trying not to ask to stupid things xd
I dont wanna sound like an idiot also
@sturdy niche too late
Just alone not being able to properly copy a stacktrace was more than enough tbh.
bruh
why does this keep happening to me
im i so stupid
when u get banned from 1 discord then get a meme on another and what next
bruh
I have never been into the listener system Luckperms uses
@sturdy niche the best ways to learn are:
- read the damn docs lmao
- listen to shit and start printing whatever lol
you'll start learning when and how some things get called
I am reading the docs
OKAYT
just dont care
i guess the api is for advanced for me :/
why does this keep happening to me
@sturdy niche if this is a regular occurrence, I’d start worrying if I were you
And don’t worry
You’d have to be several levels stupider before we even consider a ban.
To this date I only ever banned one person for being stupid
literally i dont know how i can do stuff
Learn how to use the LuckPerms API in your project.
i literally made a bot that i can change chatformat from the discord server through the bot
There’s also the API cookbook with plenty of examples
literally i dont know how i can do stuff
This is for the other message
Does someone have the link handy?
cookbook
ye
is this good?
is the prefix command in the cookbook outdated
I don’t think so. Why are you asking?
iirc the cookbook was originally written in 5.1
Larry
is the discord bot good?
like what i did with it
that i can change chatformat through the bot
It is indeed a neat idea
i also have a GUI to it ingame
with disabling custom commands and enabling or disabling that it sends messages to discord that it disabled or enabled a command.
will it work?
Will the events work
after days
of reading cookbook
no errors
in console
cookbook dont work
lol
new PlayerUsernameChangeListener(this, this.luckPerms).register();
thats not working
lul
or
We really would absolutely love to help you out! However, telling us that it isn't working wastes everyone's time. Please, just describe the issue you're having clearly and with as much detail as possible, and send any relevant screenshots of whatever problems you're having.
Lmfao
it gets Null
But i did what i was supposed to do
EventBus eventBus = this.luckPerms.getEventBus();
This gets null
did you define luckperms yet
new LuckPermsLogListener(this, this.luckPerms).register();
private LuckPerms luckPerms;
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.
sorry
its long af
private void setupLuckPerms(){
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if(provider !=null) {
LuckPerms api = provider.getProvider();
}
}```
Aaa I see the issue
You have a LuckPerms object somewhere in your class
But you assign provider.getProvider() to a local variable, not to the other object
3 things:
- private means that only an instance of your class is able to see that method
- void means it does t return anything
I literally have no clue why its around there
- I suggest you learn at least the basics of Java (and a bit more won't hurt) before diving deep into the LuckPerms API, since it is just a tad bit advanced
wdym by java
That is not exactly apparent by the mistakes you're making
Also, please stop spamming, use the space bar instead of enter 😛
im sorry im just used to type like that xd
Do you? No offense, for real, but seems to me that you don't know it that much.
bye
👋
Start with this -
https://docs.oracle.com/javase/tutorial/java/concepts/index.html
Breeze through this skipping stuff that doesn't seem relevant like bitwise operators-
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/index.html
and then hit this
https://docs.oracle.com/javase/tutorial/java/javaOO/index.html
They're the first three from this larger thing - https://docs.oracle.com/javase/tutorial/java/index.html
Which you should definitely go through overall. But those three should be enough for slightly better understanding of wtf is happening here without feeling like a huge time sink
That one is a small part of this larger site - https://docs.oracle.com/javase/tutorial/index.html
wherein "Essential Java Classes" and "Collections" also have good useful stuff
along with anything else you'd want of course
oh god the embeds
@sturdy niche those resources were given to me by mbax, and they've helped a lot. I recommend reading them, you'll probably spot some problems that are easily resolvable
so read all the three links
there are 5
They're 'umbrella links' but generally the first three first yes
i'mma take a look through them now
and have a look tommorow too when i am more awake :)
there's quite a bit, make sure you're mentally prepared or it's wasted time
wdym by mentally prepared?
have the brain power and not be too tired to understand
That's a secret no man should know
better idea: copy paste them and DM them to dyno
dyno can be your personal bookmarks collection
or my custom bot
that too
Okay my google home will scream to me tmr
😂
But do you think i can fix the problem by going through the pages
Once you understand java basics, the problem should be obvious, and so should the solution
I'm having a problem in my server where any member can literally promote theirself to owner or whatever they want. Can someone help me not make them able to do that :P
!argumentbased
Fine tune exactly what users with permission to use LuckPerms can do.
Found my problem thanks :D
why are u guys using this
if(provider !=null) {
LuckPerms api = provider.getProvider();
}```
Its something to do with this ^^
I think
but i am to braindead
for coding eitherway
so
is the problem easy to see
Yes the problem is easy to see
3rd line
yeah
What do you do with that variable?
i know its something to do with that
Nothing
i know
but idk what to do with it
thats the problem
xD
I know its not being used
You're trying to get the instance of the API
Here you get the instance of the API but store it in a variable and do nothing with it
but i cannot do something with "api"
You're not supposed to
But maybe you could intialize something else in that spot
idk
What new thing?
new LuckpermsListener bla bla bla
No
I thought you have a private LuckPerms luckPerms variable
where is it initialized?
Ok
Soz for butting in but how would one go about getting a groups parent group?
Since getting the users InheritanceNodes and then getting the groups from them do not display parent groups
So now you have a LuckPerms variable that you want to be initialized that doesn't get initialized and a useless local LuckPerms variable that does get initialized
mhm
I wonder what you could do about your class variable not being initalized...
@lavish chasm API 5.0 or 5.1?
5.1
Get the group instance and the it has a method to get the parent groups
LuckPerms api = null;
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if(provider !=null) {
api = provider.getProvider();
}
wouldn't this work in his case
or is my brain dead
No. You're declaring the variable twice
It would compile, but wouldn't work as expected
ahh soz yeah
There we go
It would compile, but wouldn't work as expected
@nocturne elbow No it wouldn't
yeah it wouldn't I edited it now
The variable is also null by default
Yes it would, variable shadowing is a thing
Yes but not within the same method
^
It would compile in C++ iirc
Well, that api object would still need to be a member variable for you to use it elsewhere 😛 (for some reason) I assumed it already was lol
Of course
If api was also a member variable, that would be shadowing
And that would compile
im done with this api 😛
Get the group instance and the it has a method to get the parent groups
LuckPerms luckPermsAPI = Sponge.getServiceManager().getRegistration(LuckPerms.class).get().getProvider();
User LPUser = Objects.requireNonNull(luckPermsAPI.getUserManager().getUser(((Player) src).getUniqueId()));
List<InheritanceNode> groups = LPUser.getNodes().stream()
.filter(NodeType.INHERITANCE::matches)
.map(NodeType.INHERITANCE::cast).collect(Collectors.toList());
for (InheritanceNode groupName : groups) {
Group group = luckPermsAPI.getGroupManager().getGroup(groupName.getGroupName());
}
Something like this then?
Objects.requireNonNull ?
ignore that xD
That would still throw NPE
i cannot do shit either way
im done with this api 😛
@sturdy niche I mean this basic programming. This has nothing to do with the API
Yeah I just saw that @crystal sonnet
Group group = luckPermsAPI.getGroupManager().getGroup(groupName.getGroupName());
String primary = group.getCachedData().getMetaData().getPrimaryGroup();
Hey kristi71111 | BacoNetworks! Please don't tag helpful/staff members directly.
That would still throw NPE
@lime rune that's the whole point of rnn lol
is codecademy good?
I'll do it the docs way nvm
Yes but I don't quite know what you're trying to do @lavish chasm
Basically I'm making a prefix selector.
So I need to know all groups the player has and then get the prefixnode if it exists
Ok. In that case get the groups
getInheritedGroups would return all the groups the person has?
Yes
Thanks for the help 🙂
Brainstone
Yes?
is codecademy good?
I don't know
https://www.youtube.com/watch?v=hBh_CC5y8-s Do you think this is good?
🔥Edureka Java Training (Use Code: YOUTUBE20) - https://www.edureka.co/java-j2ee-training-course
This Edureka Java Full Course will help you in understanding the various fundamentals of Java in detail with examples.
Check out Java Playlist: https://goo.gl/ES3dI3
This video co...
so this part:
5 50 27 - XML using DOM, SAX, and StAX parser
in Java
5:56:15 - Introduction to XML
5:57:44 - Demo - To Read From and Write To a File
6:17:51 - Reading and Writing File Objects
6:21:40 - Demo - XML File
6:25:33 - XML File Tree Structure
I got it all working now. Thanks again 😄
@nocturne elbow yes Ik although it felt out of context to have it there.
Yes Stilau
is it nessecary to look through all 10 hours?
You're welcome @lavish chasm
Consider a normal null check would probably be better as far as I can see it
rnn doesn't magically de-nullify your object lol that'd be awesome, it's mostly used for when writing interface code.
Doesn't stop you from using anywhere else tho
¯_(ツ)_/¯
I mean the most important thing is practice anyways @sturdy niche
how can i practice when i am stupid?
Fefo I don’t really see your point but that’s correct
By just programming
Read others code
and read documentation lol
Don't just read code though, try experimenting i.e. could download a simple, public plugin (something like supervanish comes to mind). Try tweaking some lines and see how it responds
Yes reading code purely out of context isn’t smart but it’s generally good to see how other people is structuring code and solving problems.
It can give inspiration and also more knowledge.
Plus if you don't understand it you're just overwhelming yourself without learning anything
anyone here know how to take away an rank for an set ammount of time
!api should be here
Learn how to use the LuckPerms API in your project.
should add the repo and depencie
Plus if you don't understand it you're just overwhelming yourself without learning anything
@wild whale you know that you can ask and Google stuff you don’t understand right?
Hey Conclure! Please don't tag helpful/staff members directly.
In this case since they didn't understand even basic programming concepts, don't think that would help
and no, you don't get banned for pinging helpful people provided you aren't spamming it
(I usually don't mind anyways)
wait don't I need a repo for this
That’s true although I don’t think someone would read advanced code if they don’t understand the basics atleast. Well my point wasn’t really that you should go straight away to nasas open source and try to learn everything from it.
I mean if you don't understand something as basic as variable scope, you probably shouldn't be using the LP api (or spigot for that matter), yet here we are
