#luckperms-api
1 messages ยท Page 50 of 1
.
can you help me because im noob ๐
^
We're now entering the territory of "If you don't know java before trying to use the LP api, you're going to have a bad time"
What's your end goal here?
@sinful ibex ^
i want to block player command ( Tab complete ) who dont have luckperms permissions
- You can do perm checks on Bukkit without depending on LP:
Player#hasPermission - Blocking tab complete for commands w/out perms is already built into bukkit
yes please suggest me so i can research and complete the code โค๏ธ
Hey ๐
I have a question regarding contexts. @sonic wolf and me just wrote an integration so BetonQuest provides it's tags as LP contexts. However, after doing these changes it does not work anymore:
https://github.com/BetonQuest/BetonQuest/pull/1633/files
We made sure the lambda code get's executed, it looks correct in the debugger. But the contexts are not showing up on the player when using a lp permission check command.
contexts don't show up on lp p check iirc. Have you checked lp user <> info?
Bukkit.getScheduler().runTaskAsynchronously
why
context calculators are to calculate contexts on the spot
We used /lp user SalZx permission check betonquest which does show contexts. I didn't know the other command existed, sorry for the confusion
๐
by the time the new task's thread is spawned and started you'll already be on the next game tick and the context consumer will be processed already
It's async because there are database queries involved when no PlayerData is loaded which may happen in edge cases.
check the description for the ContextCalculator interface
hi
Hey, I plan to do in the listener so that the player can use the item if he has a VIP range but I don't know how I use this plugin for the first time
in permissionex I did it like this if (pu.inGroup ("owner") &&! player.hasPermission ("core.plugins")) {
tbf you can just check if player.hasPermission("group.vip")
though that will account for wildcards and, if you're on bukkit, probably op status (depends on config but it will by default)
I want to do this for the group
public void onPlayerCommandPreprocesss(final PlayerCommandPreprocessEvent event) {
final Player player = event.getPlayer();
final User u = UserManager.getUser(player);
LuckPermsApi api = LuckPerms.getApi();
Group group = api.getGroup("owner");
final String message = event.getMessage();
final String[] splittedMessage = message.split(" ");
final String[] pluginCommands = { "/op" };
if (containsIgnoreCase(pluginCommands, splittedMessage[0])) {
event.setCancelled(true);
ChatUtil.sendMessage((CommandSender)player, "&cno permission");
}
}
I did it, but it doesn't work, I can do it in another way without using maven?
err, what "other way" and.. what are you depending on exactly?
is this v4 API?
without using the maven
why would you not use maven?
but most importantly^^
the latest api matches
what?
can you share your pom file?
!pasteit
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!
<modelVersion>4.0.0</modelVersion>
<groupId>UHC-testowe</groupId>
<artifactId>UHC-testowe</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>me.lucko.luckperms</groupId>
<artifactId>luckperms-api</artifactId>
<version>4.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
christ, use a paste site
I want to do something like here but on luckyperm https://hastebin.com/ozakecogif.php
and yes that's v4 API, don't know how you got there
See https://luckperms.net/wiki/Developer-API#maven for the new API group/artifact/version
ok
and again if you want to check if a player is in a group you can simply player.hasPermission("group.<group>")
that's like, the easiest and least convoluted way tbf
?
without the <>
usually <something> means "fill in the blank"
other than that, yep, that's how I'd do it
Bukkit.broadcastMessage(ChatUtil.fixColor("&7[&AI&7] &7(&6&lVIP&7) &c" + pu.getName() + " &7join
&cMutant!"));
}```
still doesn't feel like adding luck to it
are you reading any of what I'm saying?
it does not work
what does not work?
this is for permissions i want on the group
what?
if (pu.inGroup("vip")) {
this is the group from permissionEx want to do the same but luckyperm
e.g if (lucckyperm Group("vip")) {
holy
okay
I'm out
i updated my Server to the 1.13.2 and had to see that PermEx didn't get an Update, so i had search a liitle bit and found LuckPerms.
Now i have to Update all of my Plugins to work with LuckPerms, but how can i get the User group?
In Pex i used this:
PermissionsEx.getUser(p).inGroup("owner")
But how does it work in LuckPerms? I implementet the Plugin.jar in my Project and tried to find it, but it doesn't.
Thanks for the Help!
Sullaysur
Are you deliberately not reading my messages?
I read, I checked as you said, but it does not work, I gave myself a group and it does not work
how does it not work?
did you debug in any way?
yes
how?
what was your debugging process?
I did if (! player.has Permission ("group. <owner>"));
I gave the owner to myself and nothing
spigot debuger
what?
and what is a "spigot debugger"?
plugin
my mistake I am a bit tired and in general I talk in a different language on a daily basis I just don't want to go for permissions only for a given group in luckyperm
for permissions, I know how to do
for example if (! player.hasPermission ("core.plugins")) {but that's not what I mean
yes, and you can also use that same function to check for group membership
in api documentation there is no way to check a specific group, it is just how to check if a player has a group
a parent group is literally just a group.<group> permission node
player.hasPermission("group.vip") or player.hasPermission("group.owner") or player.hasPermission("group.default")
and this is like the very first thing shown in the API Usage documentation
Whats the best way to get the top inherit group for a player
i dont wanna loop through 30 groups
@nocturne elbow
Hey Mal! Please don't tag helpful/staff members directly.
sorry
reading too hard?
i cant read english that well
but you understand the exact same thing after pinging
Caused by: java.lang.IllegalStateException: API is not loaded.
LuckPerms.getApi()
Using this
share the whole error
might need to clean before rebuilding
maven does weird things sometimes that need cleaning
share your pom ig
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.lucko.luckperms</groupId>
<artifactId>luckperms-api</artifactId>
<version>4.0</version>
<scope>provided</scope>
</dependency>
the whole pom
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<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>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
Please use https://paste.lucko.me to send files in the future. I have automatically uploaded message.txt for you: https://paste.lucko.me/C0p5rnuGoW
thank you
np sorry
wait waht
the shaded jar doesnt shade it
but the other one does
??? lol
"other one"?
The shadeed
but it still dont load
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
player.setScoreboard(board);
String group = LuckPerms.getApi().getUser(e.getPlayer().getUniqueId()).getPrimaryGroup();
for(String rank : plugin.getConfig().getConfigurationSection("tab.ranks").getKeys(false)) {
if(group.equals(rank)) {
for(String nameRank : teams.keySet()) {
if(nameRank.equals(rank)) {
teams.get(nameRank).addEntry(player.getName());
System.out.println("Set " + player.getName() + " rank to " + nameRank);
return;
}
}
}
}
}
you should be using 5.3 API, not v4 lol
.
got it
yea
LuckPerms api = LuckPermsProvider.get();
String group = api.getPlayerAdapter(Player.class).getUser(player).getPrimaryGroup();
should be sorted now
looks good
Is there a luckperms event that is called only when the player's parent set changes?
how can i get rank prefix from api?
I think this will point you into the right direction. (Found via discord search function)
Learn how to use the LuckPerms API in your project.
probably User#getTransientNodes, Node#getExpiryDate?
which one?
getTransientNodes isnt for temp ranks. Transient node are for things that wont save to storage, and therefore wont persist on user unload.
The permission node for rank is group.<rankname>, so just query that get that node and then Node#getExpiryDate
Can you write me the api idk what u mean
the API is already there. all you have to do is add it to your plugin, and use it.
is there something that returns every user in a group?
but what api say the expiry day of rank?
Hey. So I was wondering which event allows me to listen to users being put into groups?
Out of curiosity why is LuckPerms using 32 as parallelism for its FJP?
Get the user's nodes, find the one you want based on the key and get the expiry Instant
NodeAddEvent, check that the node is an InheritanceNode and that the target is a User
is there a way to demote in a Track but not allowing to leave the Track? i.e. demote unless it kicks out of the Track
check if the demotion would take them off the track, and if it would, don't demote?
should be a simple if
get the current group and check if it's the first group on the Track?
(๏พ*0*)๏พ
Oh
Discord compressed that lol
That's better
Not really API, but it probably fits here best, so:
What would be the best way to listen to LuckPerms data changes from a standalone program?
what type of program?
its either read directing from database or write a mc plugin that interace with a web api service like discord bot
Don't - write a plugin that runs on a barebones (probably proxy?) Velocity or BungeeCord instance that hooks into the LuckPerms API and forwards data to your other service
Genius!
Also, couldn't I just write a standalone module?
you could, but it's probably easier to just run a velocity instance
it has basically no overhead when players aren't connected
at least, not enough overhead to worry about
Okay, I don't know who wrote the documentation, but this is what I live for
that is one of the worse options to handle async tasks
ofc
I would personally use a callback/consumer
but I just like the method name 
Hmm, if a user doesn't belong to a specific group, does User#getPrimaryGroup just return "default"?
eehh that method..; by default, yes, but you can change some settings and run some commands here and there and then it may be different
but like in 99.99% of the cases it will be the parent group with highest weight (default if they have no other)
I'm listening to the UserDataRecalculateEvent and it doesn't get called when I change the prefix of a group the player is in. Is that intended behaviour? And if so, which event should I listen to to catch that kind of stuff?
lol
Is there a method to get the InheritanceNode of a group?
InheritanceNode.builder ?
Ah, looks about right, Thanks
poor question but anyway :( How invasively can i intercept user meta through the api/whatever? let's say i have a meta stacking setup with multiple format entries, one of them being a highest_on_track_ranks sorta thing, and I want to give certain players a completely custom rank that would go in the same prefix slot. Ideally I'd want to have that prefix info directly on the user, otherwise I'd need a track with a billion entries for each user. Is that feasible through the API or should this be done on like, the chat-plugin level or something? or thinking about it now the best solution would probably be to dynamically construct that track and just accept that it's really long but i guess asking for ideas since i dont know the API
Well hello there
What do you mean by "a completely custom rank"? What's different in it that other groups and what is it to do with the track?
Do you want to "replace" the meta stacking entry with that group's prefix?
a completely custom rank meaning per-player, so i'd like to avoid groups and attach it to the user directly, which ofc means i lose all sorts of group and track context
also hi
So you just want to add a prefix?
Like, actually "add" to the stacked ones? You could use highest_own for that and put the prefix node in the user data
right, and the duplicate resolver would make sure that all of the other stuff would stay as is if an user doesn't have such a special rank?
what
oh highest_own oops
Yeah, that entry will ignore inherited prefixes/suffixes
๐ i think i can make this work, thanks emi
โบ๏ธ
!tab
LuckPerms only acts as the source for prefixes / suffixes, it doesn't actually apply them. You need an appropriately configured chat/tablist formatting plugin for them to be displayed. If the values appear correctly when you run /lp user <user> info, LuckPerms is doing its job!
Why is this happening?
18:55:25 [SEVERE] Caused by: java.lang.NoSuchMethodError: net.luckperms.api.cacheddata.CachedDataManager.getPermissionData()Lnet/luckperms/api/cacheddata/CachedPermissionData;
Either you've got a corrupted LP jar downloaded, or your LP version and the version of LP you're depending on for the API differ
Thank you for explaining it to me
The api version differ from the LP version on server lol
What is the placeholder api that show the expiry day of rank? I set temp rank in my server
!placeholders
Display data such as user prefixes and groups from LuckPerms in other plugins.
Also #support-1 / #support-2 / #general for non-dev API question please
Can u help me i dont find it
is there something wrong here?
List<String> groups = new ArrayList<>();
plugin.getApi().getGroupManager().getLoadedGroups().forEach(group -> {
if (player.hasPermission("group." + group))
groups.add(group.getName());
});
or is it "group." + group.getName()?
You would use the name, yes
what?
that is not even a version that exists
But all in all, the API is completely independent from the Minecraft version and modding platform
what do i put in repository in my plugin to import luckperms api?
i only found dependency
its on Maven Central
on the page
so you dont need to add anything
Only the dependency
oh okay
how to know if player is already in "vip" group or not?
/lp user <user> parent info will show all of their groups
no in api
mb
tbh you dont need lp api for that. Its just a simple hasPermission check of group.<groupname> permission node.
๐ณ
๐
if(player.hasPermission("vip")){
will this work?
i am trying to get group of player
if its vip
Close but not... lol
group.<groupname> is the full permission, so doing group. + vip is redundant unless that vip changes
Unless you are wanting to change for different groups, just do "group.vip"
Looks good.
now how do i assign group to user?
Have you even try to read the api documentations?
this doesnt seems to work
public static List<String> getPlayerGroups(Player player) {
List<String> groups = new ArrayList<>();
groupManager.loadAllGroups().whenComplete((v, th) ->
groupManager.getLoadedGroups().forEach(group -> {
if (player.hasPermission("group." + group))
groups.add(group.getName());
}));
return groups;
}
maybe i'm doing something wrong
i know but that didnt work either
What is "that"?
trying to put the groupname and the prefix into a map
this gets the playergroups
and after that i get all the prefixes
Well this is pretty.. bad tbh, you're calling a method that runs asynchronously (and possibly in a future time) to populate a list which is returned immediately
hmmm
Using the loaded groups will suffice unless you are unloading groups
i tried that but for some reason i got a npr at the group so i thought they werent loaded or something
my bad
Hm
hi there, I'm having a somewhat unique issue
okay
wow I was not expecting someone to respond that fast, 100% should've typed it out before I said anything lol
you should always do that ๐
I'm promoting players to higher levels on a track using this very basic method
public void promote(final Player player, final String trackName) {
final User user = Objects.requireNonNull(this.luckPerms.getUserManager().getUser(player.getUniqueId()));
final Track track = Objects.requireNonNull(this.luckPerms.getTrackManager().getTrack(trackName));
track.promote(user, ImmutableContextSet.empty());
this.luckPerms.getUserManager().saveUser(user);
}```
the issue is that when promoting the player multiple times, they seem to keep the old rank which they were promoted from. this issue disappears if I do `/lp user <user> info` between each promote
Objects.requireNonNull ๐ท
shh it's dev
what's wrong with it
the way it's being used
btw you can use the PlayerAdapter if you have a Player object
ideally you would
will do. any idea about the issue, though?
LuckPerms::getPlayerAdapter or smth
"multiple times" as in one after the other or after long periods?
one after the other
same as running /lp user promote <user> track <track> multiple times in rapid succession
if it'd help, I could send a video of what I'm talking about
sure ig
my guess is that they're being promoted before the data is stored so it goes silly or something
hmm
if you'd like, I can throw some more code snippets on paste
I'm assuming you just call the promote function in the command and that's about it? Or is there more to it?
it does also check if the player has another group on the track, do you want me to share the handler code?
let me just try the promote method on its own
Well, LP will check that too, the Track::promote method returns a PromotionResult (I think that's what it's called?), I'm sure it'll be useful
issue is still happening with this command handler code ```java
final var sender = (Player) c.getSender();
this.luckPermsService.promote(sender, "player");

yeah idk it works fine for me 
@bright tapir can you add a debug line on saveUser(user).whenComplete to see if and when the user data is saved?
ye
yup, the issue is still happening.
here's the handler code https://paste.lucko.me/HsprdZdKeb
forgot to log the promotion result, here's a video showcasing that as well. (handler code was changed only by wrapping #promote with Player#sendMessage)
I'm heading to sleep for the night, but do feel free to ping me if you have any ideas on why this is happening
Hey, it might be a silly question, but that would be the equivalent of /lp user <player> parent add <group> from the API?
See this example from the cookbook, just ommit L59 (which removes all other groups like /lp user <who> parent set <g> does)
https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/commands/SetGroupCommand.java
Thank you
hi
how can add a few days of a group to all players?
i was looking for something like this
idk
ah?
Nodes are immutable, you'd need to make a builder out of them (toBuilder), set the expiry and replace, remove the old node and add the new one
smth like this?
note that i do not intend to use this often
just like once
i guess that the new node will overwrite the old one
luckperms works that way i think
Node#getExpiry will return null if it isn't a temp node
When do I need to call LuckPermsProvider.get() in Fabric?
I believe after SERVER_STARTING is fine
alright ill try that
Definitely safe on SERVER_STARTED once everything's been initialized
would prefer to be before then so everything is good to go before its all loaded
looks like SERVER_STARTED does it
Sweet
this was running 5.3.68
Yeah man I don't know. That's really weird
How is it able to promote in the first place
There was an issue with promotion/demotion actually not removing the previous group node, but that was like a single version and way before v5.3 I believe, but it also did fail when you tried to promote again
What happens if you try to promote consecutively by running the LP promote command instead?
How do I get the net/luckperms/api/LuckPerms class if I have BungeeCord version of LuckPerms installed? I'm newbie to plugin development and I don't know anything about a bunch of spigot> bungee
Or do a plugin special for bungee?
I would assume that if you have something to do for bungee, then do it for bungee. Backend servers don't know that a bungee exists nor do they check that to begin with. It would be news to me if they did
Or connect to the lp database directly. thanks for the answer
luckperm api is independent of the server platform you run on
iirc, no issue, but Iโll re-check everything on latest lp and no other plugins
luckPerms.getUserManager().searchAll(PermissionNode.builder("my.permission").build());
I need the right equivalent of this.
I want to get all users with a certain permission offline also
that means you need to load all the users, which is possible but very bad for performance
Ok, then I have to find another way, Thank you
youโre probably looking for User#getPrimaryGroup
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Hey Clo945310! Please don't tag helpful/staff members directly.
svp
!ask
Please ask the question you have. Don't ask to ask, or ask to DM someone. There are people here to help you, but we need to know what to help you with, so please just ask the question you want to in as much detail as possible!
merci
@iron matrix how are you building your plugin? maven, gradle, or what ..?
maven
Share your pom.xml please
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.
uh
you aren't even.. depending on LP? as in, you're not adding it as a dependency in your pom
Ive done what Ive always done for adding luckperms into my plugin?
What exactly do I need to add / do?
What are you doing exactly, step by step to build your plugin?
Im using itellij, and I use the project structure to add the luckperms jar to the global library
why aren't you adding it to your pom.xml? you're already using maven, why add them to the project like that?
any tab plugin for luckperm?
TAB is a good one
https://haste.nycode.de/qawamodaje.coffee
Hi there,
I am currently trying to write the auto update method for my plugin. Problem is just how do I do this for bungee cord. In the link I made it for Spigot but I don't know how to do it for Bungee cord who can help?
there is no difference in terms of luckperms api, but you will need to research on how to make a bungeecord plugin first then.
Hey @obtuse jolt
Hey CubeAttack! Please don't tag helpful/staff members directly.
I just can't get on what's red right now
I am not familar with bungee api, looks like you are just trying to use methods that doesnt exist on bungeecord api. Tbh you can just use the singleton method LuckPerms api = LuckPermsProvider.get(); it works for all platforms.
Hey, I'm having a little bit of a problem, setting the primary group of a user doesn't seem to be saving
I also tried it with the UserManager#loadUser then UserManager#saveUser but that also didn't work
I have put a System.out.print(user.getPrimaryGroup) imediatly after the setPrimaryGroup and the code definetly reaches the setPrimaryGroup method
Don't know if I'm doing something wrong
That method does not do what you likely think it does
If you want to add a parent group, build an InheritanceNode for that group and add it to the user's data
If you want to additionally remove all other parent groups, use the NodeMap::clear method that takes a Predicate (or a NodeType?) to only remove InheritanceNodes, then add the one you want
it sounds more complicated than it is
!cookbook I think there's an example of setting a user's group in the cookbook somewhere
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
FAKE LINK MODERATOR REMOVE THE MESSAGE
Hey how can i get metaData in the LP BungeeCord version?
https://haste.nycode.de/xomayihezi.xml
when I want to install Luckpermsweb this error comes when I enter npm run serve. What can I do ?
NodeAddEvent/NodeRemoveEvent; check that the event target is a User and that the node is an InheritanceNode
t
download
Hello, is there a way to set a suffix with the api?
SuffixNode
Would it wokr with a single player?
I'm trying to set a suffix for a single player @obtuse jolt
Hey Lotter! Please don't tag helpful/staff members directly.
Alright sorry Ben
Just add the suffix node to the User.
You can see the section on modifying user data on that.
SuffixNode node = SuffixNode.builder(suffix, 1).build();
user.data().add(node);
Suffix.getMain().getLuckPermsApi().getUserManager().saveUser(user);
have I done anything wrong?
It does not add the suffix to the player
Does it show in lp user <user> meta info?
no
Any errors or anything.. ? That should work fine
no errors, when i do /lp editor i dont see it
Can you add some debug println? Like e.g. print the return value of the add method, the node and suffix variables etc, and after it screenshot this command^^
scam
sorry for the ping but scam?
not what your saying but the message above what i said
i am making a command /wizard, when executed i want to give player certain permission
how do i do it using api?
anyonee??
oh shit didnt see
Hi! When building with a jar file with Maven it doesn't manage to find LP: cannot access net.luckperms.api.model.user.User
Anyone knows how to solve this issue?
(yes, I've included LP in the POM file...)
but i want to integrate with luckperms api
usually ppl wont want to use luckperms api for just giving a single permission node, bcu it will limit users, but ig there isnt any good permission plugin other than lp lol
!api in this case, there is quite a good guide
Learn how to use the LuckPerms API in your project.
!cookbook for 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.
Anyone? ๐
this error is during compile time or run time?
when trying to compile using Maven
!paste your pom
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!
oh, nvm... apparently the error was in a project that is dependent on a different one and it didn't have LP in the dependencies
How to get the Suffix of a User using the API without using Cached Information?
whats wrong with the cached data?
well basically how to find suffix of offline user
you need to load the user first
public static @NonNull CompletableFuture<User> getPlayerSuffix(String playerName) throws SQLException {
if(PlayerStats.isPlayerRegistered(playerName)) {
String suffix;
UUID uuid = UUID.fromString(PlayerStats.getPlayerUUID(playerName));
UserManager userManager = MainCore.getLPAPI().getUserManager();
return MainCore.getLPAPI().getUserManager().loadUser(uuid);
.thenApplyAsync(user -> {
user.getCachedData().getMetaData().getSuffix();
});
}
else {
return null;
}
}
here is my code
the thing is , that this doesnt work
I want it so that, if the player is online or offline, it should display stats
suffix*
you have syntax error, there shouldnt be ; at.loadUser(uuid);
also you are doing user.getCachedData().getMetaData().getSuffix(); but not storing it or using in any way.
basically I want to return the suffix from the function
public static CompletableFuture<Object> getPlayerSuffix(String playerName) throws SQLException {
if(PlayerStats.isPlayerRegistered(playerName)) {
UUID uuid = UUID.fromString(PlayerStats.getPlayerUUID(playerName));
UserManager userManager = MainCore.getLPAPI().getUserManager();
return MainCore.getLPAPI().getUserManager().loadUser(uuid)
.thenApplyAsync(user -> {
String suffix = user.getCachedData().getMetaData().getSuffix();
return suffix;
});
}
else {
return null;
}
}
what about this?
this doesn't have any compilation error.
but would it work?
ridiculous
im not a java runtime environment ยฏ_(ใ)_/ยฏ
you will need to code in an asynchronous manner
how?
<someclass>.getPlayerSuffix(name).thenAccept(String suffix -> {
// Do stuff with the suffix
});
when you want to call that getPlayerSuffix method
for that to work, can you please check if my getPlayerSuffix Method is compatible with the above code?
public static CompletableFuture<Object> getPlayerSuffix(String playerName) throws SQLException {
if(PlayerStats.isPlayerRegistered(playerName)) {
UUID uuid = UUID.fromString(PlayerStats.getPlayerUUID(playerName));
UserManager userManager = MainCore.getLPAPI().getUserManager();
return MainCore.getLPAPI().getUserManager().loadUser(uuid)
.thenApplyAsync(user -> {
String suffix = user.getCachedData().getMetaData().getSuffix();
return suffix;
});
}
else {
return null;
}
}```
This is the one I have written, It's giving me error when I'm calling the method in another class like this:
LPPlayerGroup.getPlayerSuffix(name).thenAccept(String suffix -> {
});
this should returns a CompletableFuture<String>
and your use of static methods... not a very good code design
and there are two returns in my code.
that is not what I meant
I suggest reading up on CompletableFuture api, its considered an advanced java topic and required before trying to use lp
public static CompletableFuture<String> getPlayerSuffix(String playerName) throws SQLException {
if(PlayerStats.isPlayerRegistered(playerName)) {
UUID uuid = UUID.fromString(PlayerStats.getPlayerUUID(playerName));
return MainCore.getLPAPI().getUserManager().loadUser(uuid)
.thenApplyAsync(user -> {
String suffix = user.getCachedData().getMetaData().getSuffix();
return suffix;
});
}
else {
return null;
}
}```
what further changes should be made here?
^ This is the error on function call
i think you dont need to specific datatype for lambda functions
Good day all, I am hunting for a event that fires when /lp applyedits is ran
Ideally I'd like to pass this through to DiscordSRV's alert system, detailing who ran the command and what changed
afaik things that have a CreationCause of WEB_EDITOR or a DeletionCause of WEB_EDITOR are how you tell - you'd listen to events that provide this depending on what you want (GroupCreateEvent for example) and check if the creation cause is the editor (https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/event/cause/DeletionCause.html)
I can't find a particular event for editor being applied, and tbh I doubt it exists! https://javadoc.io/doc/net.luckperms/api/latest/index.html is a good source for finding these things
Thanks boss
:patLarry:
:3
We've got this format for manually logging things atm
Hi! How can I remove all groups and just leaving the default group for a player? Thank you!
for ALL players or just one?
Quickly update a large amount of user and group permissions by using the bulkupdate command.
for ALL players, you run lp bulkupdate users delete - that'll clear everyone
for just one, lp user <name> clear
I want to give a Bukkit Player player a permission
But i can not cast Player to User!?
yea bcu it doesnt work that way lol
!api
Learn how to use the LuckPerms API in your project.
Thanks
sorry but i did not find it in the wiki: How can i get the time to the expiry? or how can i geht the expiry date / time?
sorry I am a beginner, whats the usage of this? the add Permission works but i dont understand how I can get the expiryduration?
so my code for add Permission is
public static void addPermission1h (Player p, String perm) {
User user = LuckPermsProvider.get().getPlayerAdapter(Player.class).getUser(p);
user.data().add(Node.builder(perm).expiry(Duration.ofHours(1)).build());
LuckPermsProvider.get().getUserManager().saveUser(user);
}
For one player but leaving all other permission, just clearing groups through the API
Ah, API wise you'd have to get their nodes and remove the group ones that aren't default - that will generally require a lot of API shenanigans so I'll link you the wiki page. On it, you can find the javadocs which will have the precise things to use.
!api
Learn how to use the LuckPerms API in your project.
sorry I am a beginner, whats the usage of this? i dont understand how I can get the expiryduration?
So i have a question, if i add Luckperms API to my plugin, now can i make my plugin into a permissions plugin like luckperms? Or no
By "add" you mean implement it or use it?
?
not sure what the question is
that screenshot you sent is the method you use to get the remaining time
yes but how must i use it in a plugin
expiry duration for a permission
that tells me nothing
i want to show the player when his permissions expiry
okay, now that's something; get the user's nodes (getNodes() I believe), filter in those that do have an expiry, and get the one(s) whose key matches the permission you need
then from it/those, get the remaining time
Use it
No
If you are using it is because there is an existing permission system implementation in play
Which is like, 100% of the time will be LP lmao
till now i have this: and now?
@Nullable
Duration getExpiryDuration(Player p, String perm) {
User user = LuckPermsProvider.get().getPlayerAdapter(Player.class).getUser(p);
user.getNodes().
}
}
filter in those that do have an expiry
How can I do that?
for loop https://www.w3schools.com/java/java_for_loop.asp
streams https://stackify.com/streams-guide-java-8/
recursion https://www.w3schools.com/java/java_recursion.asp
Whichever method you find comfortable and convenient to iterate through the collection of nodes
I very, very, very much advise you learn more basic Java before jumping straight to using the LP API, it is quite advanced and non-trivial, iteration is like class 2 of any Java course
Okay. I was hoping for help with my problem. I don't quite understand why something like this is being sent to me. I have already programmed a complete lobby system, etc., but I am just not very familiar with the LuckPermsAPI. That's why I asked here. Thanks anyway.
Iterating through a Collection to get elements that match a certain criteria is not specific to the LP API
I'm not sure where the confusion is coming from
Okey then I'm sorry, but I haven't used something like that before.
A for loop?
I only used for loops with Bukkit Player and it seemed somehow different to me than here.
Okay let me ask, what part makes iteration different and/or confusing?
If you can point that out I can help a bit more, but other than that it's iterating nodes instead of iterating players
so i have a for loop but how can I check if there is an expiry
for (Node node : user.getNodes()) {
}
that is what I mean, sorry when you didnt get it
oh thanks and how can i get the time until it expiry
You sent a screenshot of the method you have to use for that earlier
So i would have to implement it, but i canโt make it into a permissions plugin?
Also sorry to ping you i didnโt see your name
???
What are you trying to do? Use the API as an end user, or implement the API to create your own permissions system implementation for others to use?
I'm not sure I'm following
I wanted to create my own permissions system implementation
Sorry i didnโt know how to explain it
Sure you can do that, it would be incompatible with the LP plugin but you can make your own implementation out of the API
After all it's platform agnostic and, well, it's an API, it has very little implementation details in it already; you'd just need to make sure to follow the relevant specifications in each interface's javadoc
ok! thanks for helping me!
hi, the api isnt making much sense, and from what I found online, I have this setup: ```java
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
LuckPerms lp = provider.getProvider();
Player p = (Player) sender;
User user = lp.getUserManager().getUser(p.getUniqueId());
System.out.println(user.getPrimaryGroup());
I dont know what I am doing wrong, if someone could explain the issue that would be amazing
Run and screenshot both lp info and lp user <yourself> info while online
luckperms api wont work for me
with maven
SO it works in maven but it wont show up as a import
Tried to invalidate caches, clean maven
have you manually added any jar files to the project "libraries" tab in intellij?
How can I get the prefix of a group with the name of the group as a string?
I managed to get the group with
val group = luckpermsApi.groupManager.getGroup(groupname)
!api Check the second page linked, the section that talks about cached data
Learn how to use the LuckPerms API in your project.
I figured it out
nenvermind
hm? what was the issue?
Is it required to implement the estimatePotentialContexts() method from ContextCalculator?
I can't extimate the contexts without access to a player object so the method is useless to me
or is there a way to get the player object in that method? Every player will have a few contexts and no player's contexts will be the same
if it was required then it wouldn't have a default implementation
That's what I figured
Gets a
ContextSet, containing some/all of the contexts this calculator could potentially submit.The result of this call is primarily intended on providing suggestions to end users when defining permissions.
e.g. the world context would submit a context set with the worlds for entries, the gamemode context for each gamemode, etc
oh alright, so its just a helpful thing for the end-user, yeah?
Any help please?
I added LP in maven as dependency
But still
Got it, imported wrong library
Hi I want to update a plugin from Sponge 7.3 to Sponge 8.0 and I use the newest LuckPerms version for this LuckPerms 5.3.8.3 or something, the problem is that I cant register the LuckPerms service (the permissions variable is always null)
!usage
Here's a guide to help users understand and use LuckPerms for the first time.
Hi. Is it possible to use the API without running any platform? (Bukkit/Sponge/etc) I wanted to create a script that would create some groups, assign some users and permissions. Maybe there's a way to do that without starting the real server?
not without actually running a server
you can make an extension if you don't want to tie it to any specific platform, but you still require for LP to be running on a server to use the API lol
I see. So I'll probably make a dummy server for that. Thank You for lightning fast response! ๐
Any idea?
Yeah I know but u can already test with it if you add it as local dependency
And I dont know if this is a bug because its always null or if I messed something up
Try testing with that jar
Ok
But I think I got the exact same jar
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.
Its throwing the exact same error
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!
Did you make sure to check that you're using the jar i send?
Yes
when using this code
LuckPerms api = LuckPermsProvider.get();
Group group = api.getGroupManager().getGroup(groupName);
if (group == null) throw new IllegalArgumentException("Group " + groupName + " not found");
UserManager userManager = api.getUserManager();
List<User> users = new ArrayList<>();
for (UUID uuid : userManager.searchAll(NodeMatcher.key(InheritanceNode.builder(group).build())).join().keySet()) {
User user = userManager.isLoaded(uuid) ? userManager.getUser(uuid) : userManager.loadUser(uuid).join();
if (user == null) throw new IllegalStateException("Could not load data of " + uuid);
users.add(user);
}
return users;
}```
i get all red errors and such. but have luckperms in the dependancies. please help
Using Luckperms api in Bungeecord, everything works unless variable luckPerms might not have been initialized
that's a basic java intelij error
Ye I know what it means, but I can't initialize it either. Cuz then I get '(' or '[' expected
This is seeming like you're trying to use the LP api without knowing java
Ye I'm still learning
forget it, fixed it already LuckPerms api = LuckPermsProvider.get();
Hey, I have made a function that returns the prefix of a user.. Now I have changed the permissions of the groups so that they inherit each other, but the function is now returning the prefix of the lowest group... How can I change this so that I get the prefix of the highest group where the player is currently in?
guys how to do ultimate homes permisions
does luckperms require an SQL database or is it optional?
if u want it to link to more then one server u need a database yes
else if one server then no database needed
ik play.capboi.net uses the db feature very well
as for some reason I gave perms to players to use /warps and /spawn (this is from a spigot plugin called warpsystem) but its not letting them use these commands
idk as Im not the owner of this server so im not allowed to invite FYI the server is still in early dev
#support-1 this isnโt related to the api
my bad pls do not ping me though
Check the instructions sent there to help
yes yes ik
my dependency is not working <dependency> <groupId>me.lucko.luckperms</groupId> <artifactId>luckperms-api</artifactId> <version>5.3</version> </dependency> version is red
!Api
Learn how to use the LuckPerms API in your project.
guess maven is not working for luckperms for me, I add the jar to the library and it clears up all the errors, so no updates needed for that class, just need to fix the maven info
what does your lp dependency look like now?
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.3</version>
<scope>provided</scope>
</dependency>```
did you load maven changes after you updated it?
yes, thats auto, and invalidate caches and restart
no idea, ive got the same thing in my pom.xml, and it works fine. 
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.3</version>
<scope>provided</scope>
</dependency>
taken straight from mine.
well, if it wasn't a maven issue for me to make a plugin then it wouldn't be me
I removed most of my dependencies and now it work, guess one of them is messing with me, I will add them back a few at a time
Hi, it is possible to get the first node that has certain prefix on a player?
yes
How can I do it?
just copy the prefix phrase on groups and put it to users
What?
u know the prefix.0.
No no
Lets say I give this perm to a player: plugin.homes.5
So I want to find the node (permission) of a player that have the plugin.homes prefix, is it possible?
@woeful gale are these permissions from your own plugin?
Yes
If so, you should really use MetaNodes instead and check the data from the CachedMetaData (PermissionHolder#getCachedData ...)
It's essentially a Map.Entry (key->value pair) and LP caches differently them so you can just query them by key
Thank you!
See in here https://luckperms.net/wiki/Developer-API-Usage the section that talks about cached data and storing custom metadata
Thank you a lot! What if a player have multiple nodes with the same prefix?
great question
How do I edit the permissions for people using a plugin for example the spawn tp plugin if I only want 1 player to be able to tp to spawn?
How can i get List Members of group (API)
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
thanks
Hello, how can I get the weight of an InheritanceNode (or of another node) ? My goal is to get the weight of a rank
the Group itself holds its weight (since it's yet another node, a weight node), not the node representing the group
you'll want to get the group from the group manager and get its weight from it instead
how i get code for crate so players can get rank from crate?
Maybe let your crate-plugin execute the command "/lp user {placeholder-for-user} parent add {rank}" if that's possible
how can i get the prefix of a player? i already have Objects.requireNonNull(lp.getUserManager().getUser(p.getUniqueId())).getPrimaryGroup(); which gets the primary group but i want to get the "primary" prefix of the player
!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.
why this error?
this is the first time i try to use luckperms api
ping in case, thx
yes
mmh nope, i just insert the dependency in my pom.xml
and do the thing
now i try to compile, in case of errors I'll tell you
what
anyone?
Send main class
Please use https://paste.lucko.me to send files in the future. I have automatically uploaded message.txt for you: https://paste.lucko.me/6MJHnzBJ6O
uh, thanks you
ping me in case thx
Remove the public Noswear(LuckPerms
the constructor, you mean?
thx
To interact with a user's groups (adding or removing), is it just the node group.group_name? (just making sure)
Correct
this is right in the docs , but if i cast it to (User) when the method is called throws an ClassCastException
always ping in case, thx
The docs explain why that code snippit is not possible
And then go on to explain what to do instead
In other words.. keep reading
right! thanks you!
How do I add a permission with the API?
org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: net/luckperms/api/node/Node
๐ฅฒ
Hi guys, i'm having problem with the api of LuckPerms. Here the problem in console
Please use https://paste.lucko.me to send files in the future. I have automatically uploaded message.txt for you: https://paste.lucko.me/obB1gJHtO0
Make sure LP is installed, and you've added it to your dependencies in your plugin.yml - if you don't LP might load after your plugin and thus your plugin won't find the classes
Hey MaxPlay066! Please don't tag helpful/staff members directly.
._. sorry
just add dependencies: ["LuckPerms"]
https://www.spigotmc.org/wiki/plugin-yml/
i'd have a look at this. it shows you what you can use in plugin.yml
Nothing. Same error
you have LP installed?
Yes
what version
5.3.74
!latest
5.3.75
should be fine. 
In logs, does LP load before or after your plugin?
after, but i added it as a depency in my plugin yml
You sure you properly rebuilt etc? If it's a dependency it should load before
yes
!paste can you send your plugin.yml
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!
Resolved, using depend instead of dependencies
oh derp my bad
Hi guys im trying to obtain the instance of the api but i have this problem
i literally copied that from there
Show full code
Do it in onEnable
Set<String> permissions = prev.getNodes().stream() .filter(NodeType.PERMISSION::matches) .map(NodeType.PERMISSION::cast) .map(PermissionNode::getPermission) .collect(Collectors.toSet());
This way will I get all the permissions that the right player has? eg (my.special.permission)
I mean that's what it says on their website, so yes possible. Not really sure though
try it out to see if it works
seems working
pog
ะฒะฒะฒะฒะฒะฒ
ะฟั
@rustic laurel ^ scam link
Hey Kevin! Please don't tag helpful/staff members directly.
Itโs in a few channels
New to luckyperms,
How do I use luckyperm API?
How would I set and get permission from luckyperm?
Do I just store everything locally?
Is there a good 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.
!api
Learn how to use the LuckPerms API in your project.
Thank you
what it does mean?
i'm using LuckPermsProvider.get()
it happened hours after the server started
Is lp loaded
it is
how do i get a user's prefix? im new to this lel
i think you need to get it by a group
String prefix = plugin.getApi().getGroupManager.getGroup("owner").getCachedData().getMetaData().getPrefix();```
correct me if i'm wrong
What's the benefit of using tristate over a nullable boolean?
same reason why some developers use Optionals over a nullable value, it indicates that a value can and will be "not present" when some conditions are met, or when some aren't
null is usually interpreted as an error in the program, Optionals and TriState tells the end-developer that it's proper to not be present in some cases
i dont even know what to import from the api file ;-;
!cookbook id suggest having a look at this. it may help you out.
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 (this might exist?) if so, it'd also be useful
Learn how to use the LuckPerms API in your project.
using this seems to work just it says that getApi is an invalid method
sorry if i am being stupid i started java yesterday ;-;
Maybe this helps: #luckperms-api message
or this #luckperms-api message
and #luckperms-api message
I have tried using String prefix = LuckPerms.getPlayerAdapter(Player.class).getMetaData(player).getPrefix(); but it says 'Cannot make a static reference to the non-static method getPlayerAdapter(Player.class) from the type LuckPerms'
!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.
!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.
@nocturne elbow and @dense steeple say hi! Vic ask away!!!
Just gonna legitimize this interaction with the Larry referral stamp of referral
false alarm
hii
๐
How should i parse colors in prefixes/suffices, i'd assume the ampersand legacycompoenentserialiser?
that's what most people use
or minimessage
but to LuckPerms it's just a string.. so there's no right answer in that sense
Not sure if this is the correct channel, but how do you check for meta?
Is metaData.getMetaValue the only way, or is there a more standardised way that would work with all perm plugins?
I am referring to things like this, which was listed on the wiki.
max-homes = 5
username-color: blue
Well metaData.getMetaValue is specific to LP
https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/cacheddata/CachedMetaData.html#getMetaValue(java.lang.String)
So it won't really work with other perm plugins because, it isn't from other perm plugins lmao
If you're working on a Bukkit plugin you can use the Vault API https://github.com/MilkBowl/VaultAPI, if you're working on a Sponge plugin I believe its API has some methods for that as well
Thanks! I was mostly wondering if there was some way to do it without vault
You could make an interface of your own and an implementation for each permission plugin
ยฏ_(ใ)_/ยฏ
LP API is LP API, not "generic perm plugin API"
That would be where Vault fits in
does the luckperms API support bungeecord?
it seems like this part required Bukkit: RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
keep reading
I know luckperms does support bungeecord as a plugin, but how do I use the API for bungeecord?
!api
Learn how to use the LuckPerms API in your project.
I know how to use the normal API
Keep reading the page, then youโll know how to use it on bungee
here: https://luckperms.net/wiki/Developer-API#obtaining-an-instance-of-the-api, it only shows bukkit and sponge
Keep reading
@turbid solar
Hey lisandro! Please don't tag helpful/staff members directly.
Why?
How am i able to get all the users loaded in the database?
How come java userManager.modifyUser(user.getUniqueId(), modifier -> modifier.setPrimaryGroup("admin")); is returning FAIL? lp user dkim19375 parent set admin works fine - is there a way to do the same thing as the command without using setPrimaryGroup? (I could dispatch the command into console but i assume theres a better way ๐ค)
!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.
parent set is different from primary group.
._.
and how do I get the parent? I assume it's something with the nodes (since I know that the group node is group.nameofgroup) but isn't anything that I could find in the docs talking about how to get (or set) the parent group
by default, the primary group is the direct parent group with highest weight
but that can be changed in the config (https://github.com/LuckPerms/LuckPerms/blob/272d289d4a64f96e5d720ff20ec69e54035a3d3f/bukkit/src/main/resources/config.yml#L301-L312)
If all you want to do is emulate parent set, clear all of the user's inheritance nodes and add the one you want
that's what parent set does; keep in mind that using parent set does also not guarantee changing the primary group, again that behavior is configurable
in the end, the primary group is somewhat irrelevant from what I know. I didn't dig enough to actually know what it's for but from what I understand it's just a Vault construct, so it's to satisfy Vault's needs and does not affect permission calculation.
also
and how do I get the parent?
users (and groups as well) can have more than just one group as parent group, sooooo there is no right answer to that
hey how can i get the metaData of a group? every time i get the metadata he is getting metadata from inherited groups.
What do we think is the best way to get PlaceHolders for an OfflinePlayer?
Just trying to think if its possible to get a users LuckPerms prefix if they're offline and messaging from discord...
You can get the UUIDs of all non-default users with UserManager::getUniqueUsers(), then from there you'd have to load them individually
This it. To just obtain and instance. I know that far. I mean using PAPI placeholders for an offline player. Is this possible
yeah i found it, its just the docs doesn't explain it very well, literally just says what the method says, gets all unique players. But that could mean a lot ;/
no
the palceholder expansion uses UserManager::getUser, so it has to be loaded beforehand
it returns a CF<Set<UUID>>? what else could it be
Gets a set all "unique" user UUIDs.
"Unique" meaning the user isn't just a member of the "default" group.
I don't see how "that could mean a lot"
What if the user was loaded in memory then the placeholder was called? Theoretically the placeholder is called on completion of the user load. Hold the user in memory for a certain amount of time and bin off if not used
that should work, yes
if i'm not mistaken Users loaded from API are discarded after 5 minutes, but I think you can unload them yourself too
Yep, UserManager::cleanupUser(User)
If they are reused in the 5 minutes I'm guessing the timer resets? Ideally looking to get ChatControlRed to support LuckPerms prefix if the user is typing from discord
uh I think so, not entirely sure; you can also cancel the UserUnloadEvent though personally I'd advise against doing that, or if you do it be in a controlled manner and not just cancel EVERY user unload
it shouldn't be an issue but uh I personally wouldn't want to have potentially hundreds of unused user objects in memory
Any reason why I keep getting an NPE from this?
does it have anything to do with you missing the t in getMultiSuffix ?
Im trying to switch over from PEX and recreate my chat plugin with luckperms. This method is suppose to get all the prefixes and suffixes from all the groups a user has but I seem to keep getting an NPE.
Nah that shouldn't do anything
Seeing the actual error would probably give a hint btw - also you can use getPrefixes/getSuffixes to get the inherited prefixes/suffixes, already in the cached metadata of the user, instead of going through each group manually
That makes sense lol dont know why I didn't think of that
Yeah still didn't work
This is what is at chat event 43
The NPE is being thrown in ConfigMessageUtils::getCReplaceMessage @ line 118, which is called from ChatEvent::onPlayerChat @ line 43
what's in ConfigMessageUtils @ 118?
That cant be right though ive used this method before and it works fine
ยฏ_(ใ)_/ยฏ
Something's wrong in that function, I can tell that much - either getMessage is returning null, args is null (though that would be a bit odd) or args[i] is null
๐ตโ๐ซ im positive that's not the issue, I feel like im using the lp api wrong in someway. That method works fine, maybe its one of this methods
I don't know what you want me to tell you, the stack trace doesn't lie
The only "issue" I see there is that UserManager::getUser(UUID) may return null, but that's only if the player is offline and the user is not loaded -- but even if, the error is clearly coming from getCReplaceMessage, not one of those prefix/suffix functions
Hmm alright lemme make some changes real quick
It works when I remove the lp methods
Right, so it's likely then that for one of the args, args[i] is null then, CachedMetaData::getPrefix/getSuffix returns null if there is no evaluated prefix/suffix
Ah alright
Yeah it seems that getting prefixes/suffixes from the player through CachedMetaData::getPrefix/getSuffix just returns null
Is there a way I can just loop through all there teams for the prefix and suffix of that team
I want to check if a user has a rank or higher
and I cant find a simple way to do it with the API
is there something built in?
Then handle null cases?
getPrefix/getSuffix return whatever you see in /lp user <user> info
Or rather the other way around but that's a good visual confirmation that what you're getting corresponds to what you're expecting
No, there is no concept of "higher ranks" really; How are the groups ordered? Are they on a track?
I just got the ranks weights and compared them
I got it working
@lyric gyro did you make a variable called luckPerms?
no I did not create a variable named luckPerms
then you should read the guide more throughly ๐
somewhere put LuckPerms luckPerms;
Then luckPerms = providerโฆ in onEnable with that
:/
It's not a static method, you need to call it on a LuckPerms instance
and how do I create an instance of luckperms?
I have to create a class?
.
.
you have it named api and then in your other screenshot youre trying to use luckPerms...
plus, you probably dont have the getUserAdapter code in the same onEnable block as that screenshot
youre gonna have to show us more code context to get sufficient help
sounds like someone needs to learn a bit about java lol
that too
is that the same class as your onEnable main class?
No it's in another class
Hey I keep getting an npe on this, ive tried multiple ways of getting the prefixes and suffixes of every group a user is in but I cant find one that works, any suggestions on how to do it?
and yeah I tried getting all the prefixes and suffixes from a user through their MetaData didnt work
What line do you get the npe on
Use a debugger or whatever or use Java 15+(?) cus that has better exception things
alright give me a sec
This is where im getting the npe
The methods that im calling are the ones above that
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!
How to Check null in Java with java tutorial, features, history, variables, object, programs, operators, oops concept, array, string, map, math, methods, examples etc.
I know how to check for npe
the issue is it returns an npe when there shouldnt be one
Why shouldn't? We stated that getPrefix/getSuffix may return null if there is no prefix/suffix in the user's cached metadata
And I said that you should check that to be the case with the user info command
You should handle null cases of you know it's a possible outcome
If what you say is true then all of the Jvm is broken and millions of peoples programs would be broke right now
What em said
The player does have a prefix I checked using the info command but it still returns an npe
That's why I said it shouldn't return an npe
Idk if I did something wrong ill just have to check later
Can you share a screenshot of lp user <user> info and println getPrefix?
What is the difference betweenjava public static boolean isPlayerInGroup(Player player, String group) { return player.hasPermission("group." + group); }Andjava public CompletableFuture<Boolean> isAdmin(UUID who) { return luckPerms.getUserManager().loadUser(who) .thenApplyAsync(user -> { Collection<Group> inheritedGroups = user.getInheritedGroups(user.getQueryOptions()); return inheritedGroups.stream().anyMatch(g -> g.getName().equals("admin")); }); }Don't they technecly do the same thing? I just want to check if a player is an admin
The latter works for offline players and works on every platform as-is, the first one works for online players only and will need to be adapter for each platform
no u
so basically I should use isPlayerInGroup
I mean you can use whichever you want ยฏ_(ใ)_/ยฏ

