#luckperms-api
1 messages · Page 47 of 1
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!
and you're building with mvn package right?
building what?
your-- plugin?
how are you building your plugin
oh boy
maven is the build toolchain, you're not really supposed to use artifacts and "project libraries" when you're using maven
it takes care of all that, managing dependencies, compiling etc
I mean using a weird ass mixture between those 2 things probably
mm
could a User be loaded at startup and stored for use later (maybe when they are offline)
Ideally you load the user as needed
Why?
Is it possible to cancel the NodeAddEvent? I don't believe it is, so the best alternative solution would be to remove the node from the User, right?
Why
I previously setup usages of /lp user (name) permission set (permission) but never included the context. I'm not setting everything up with mySQL and want to basically force those old commands to give context
I'm storing a players "balance" for my plugin in their meta value, and i'd like to still be able to query it even if they have logged out. I will always have a list of their UUIDs in config, so was wondering if i could just .getUserManager().loadUser(uuid).join() at the start of the server and cache the Users so I don't get any null exceptions. Purely because I can't figure out how to do a CompletableFuture that works with how I've structured the code.
public int getOfflineLimit(User p){
LuckPerms lp = LuckPermsProvider.get();
net.luckperms.api.model.user.User u = getLPUser(p.getUniqueId()).get();
String s = lp.getGroupManager().getGroup(u.getPrimaryGroup()).getCachedData().getMetaData().getMetaValue("bloader_offline_max");
String s2 = lp.getUserManager().getUser(p.getUniqueId()).getCachedData().getMetaData().getMetaValue("bloader_offline_personal");
if(s2==null){
s2="0";
}
if(s!=null)
return Integer.valueOf(s) + Integer.valueOf(s2);
else
return 0;
}
i need to return an int, but ofc with CompletableFuture i don't believe i can? maybe I'm missing something. Alternative is to just cache the specific meta values and run an update Task every so often i guess
CompleteableFuture<Integer> i think
I think i figured it out, is it okay to call CompletableFuture.get() to get the results async?
public CompletableFuture<List<String>> getOfflineValuesAsync(UUID who) {
return luckPerms.getUserManager().loadUser(who)
.thenApplyAsync(user -> {
List<String> strings = new ArrayList<>();
strings.add(user.getCachedData().getMetaData().getMetaValue("bloader_offline_max"));
strings.add(user.getCachedData().getMetaData().getMetaValue("bloader_offline_personal"));
return strings;
});
}
//FIND MAX NUMBER OF OFFLINE LOADERS THIS PLAYERS PRIMARY GROUP CAN PLACE
public int getOfflineLimit(User p) throws ExecutionException, InterruptedException {
CompletableFuture<List<String>> future = getOfflineValuesAsync(p.getUniqueId());
List<String> offlineBalances = future.get();
String bloader_offline_max = offlineBalances.get(0);
String bloader_offline_personal = offlineBalances.get(1);
if(bloader_offline_personal==null){
bloader_offline_personal="0";
}
if(bloader_offline_max!=null)
return Integer.valueOf(bloader_offline_max) + Integer.valueOf(bloader_offline_personal);
else
return 0;
}
Hey guys am I doing this right in order to receive the user's uuid? ```java
public User giveMeADamnUser(UUID uniqueId) {
UserManager userManager = LuckPermsProvider.get().getUserManager();
CompletableFuture<User> userFuture = userManager.loadUser(uniqueId);
return userFuture.join(); // ouch! (block until the User is loaded)
}
I'm getting the method like this User user2 = giveMeADamnUser(target.getUniqueId());
I just keep getting NullPointerException so I presume not
I'm basically trying to get the suffix of an offline user
send the full stacktrace
AllianceTagCommand.java:217
what's in there at that line?
yea ^^
User user2 = giveMeADamnUser(target.getUniqueId());
Ahh I see... which makes sense tbh. Do you know how I can resolve this then? I basically wanna get the UUID of the Player in Args[1]. I'm currently getting it like this obviously Player target = Bukkit.getPlayer(args[1]);
getPlayer will only return a player if they are online
Yeah
if you want to include offline players, getOfflinePlayer is what you're looking for
Will that get both Online and Offline I presume?
yea
Thank you! It is fixed 🙂
Hello, I'm using Velocity and I wanna use the API of LuckPermsVelocity. Is the dependency the same as in Spigot/Paper or is there another dependency / do I have to shade it?
? XD
which depend?
I got this compileOnly("net.luckperms", "api", "5.3")
Yes
Yes
!api first link here haz the guide, btw
Learn how to use the LuckPerms API in your project.
might make it easier
Yeah I know
But there is no tutorial for Velocity
I have to use the singleton static access
it's all the same
Yes
well, most
kinda sad
Huh?
hello i was in here for some help with CompletableFuture and async stuff earlier, i just wanted to run this by someone to make sure i can nest CompletableFutures like this without any issue
util.getOfflineLimitAsync(p).thenAcceptAsync(maxOff -> {
util.getOnlineLimitAsync(p).thenAcceptAsync(maxOn -> {
util.getAvailableOfflineChunksAsync(p).thenAcceptAsync(offline -> {
util.getAvailableOnlineChunksAsync(p).thenAcceptAsync(online -> {
txtList.add(Text.builder().append(util.textSerializer("&l&6-&r&bOnline: &6"+online+"&8/&6"+maxOn+"&b chunks")).build());
txtList.add(Text.builder().append(util.textSerializer("&l&6-&r&bOffline: &6"+offline+"&8/&6"+maxOff+"&b chunks")).build());
PaginationList.builder()
.title(util.textSerializer("&l&8[&r&bB&aChunks&r&l&8]&r - &6Your Available Balance:"))
.contents(txtList)
.padding(util.textSerializer("&8="))
.sendTo(src);
});
});
});
});
oh jesus what in the world is that lmao
I feel like it’s very poor class design lol
this is true it is but it works so now i can optimise it thank u friends
helo it me again
public CompletableFuture<Map<String, String>> getPlayerLimitsAsync(UUID who) {
return luckPerms.getUserManager().loadUser(who)
.thenApplyAsync(user -> {
Map<String, String> strings = new HashMap<>();
luckPerms.getGroupManager().loadGroup(user.getPrimaryGroup()).thenAcceptAsync(group -> {
if (group.isPresent()) {
BChunks.getInstance().getLogger().info("group is present");
Group foundGroup = group.get();
strings.put("bloader_offline_max", foundGroup.getCachedData().getMetaData().getMetaValue("bloader_offline_max"));
strings.put("bloader_online_max", foundGroup.getCachedData().getMetaData().getMetaValue("bloader_online_max"));
strings.put("bloader_offline_personal", user.getCachedData().getMetaData().getMetaValue("bloader_offline_personal"));
strings.put("bloader_online_personal", user.getCachedData().getMetaData().getMetaValue("bloader_online_personal"));
BChunks.getInstance().getLogger().info("getLPGroup: " + strings.toString());
}
});
BChunks.getInstance().getLogger().info("loadUser: " + strings.toString());
return strings;
How can i make sure that strings does not return until the second CompletableFuture is finished? the first logger is always an empty map, followed by the populated map
you can create a new CompletableFuture lol
public CompletableFuture<Map<String, String>> getPlayerLimitsAsync(UUID who) {
CompletableFuture<Map<String, String>> future = new CompletableFuture<>();
luckPerms.getUserManager().loadUser(who).thenAccept(user -> {
Map<String, String> strings = new HashMap<>();
luckPerms.getGroupManager().loadGroup(user.getPrimaryGroup()).thenAccept(group -> {
// stuff
future.complete(strings);
});
});
return future;
}
ig something like this
something... went wrong
loll
it's like it just stops running at some point during the Future
it's 7AM though and i'll figure it out later 
thanks anyway friend
…
??
util.getAllPlayerBalancesAsync(p).thenAcceptAsync(stringStringMap -> {
BChunks.getInstance().getLogger().info("after future" + stringStringMap.toString());
src.sendMessage(util.textSerializer("0"+stringStringMap.toString()));
String onlinePersonal = stringStringMap.getOrDefault("bloader_online_personal", "0");
String offlinePersonal = stringStringMap.getOrDefault("bloader_offline_personal", "0");
String maxOn = stringStringMap.getOrDefault("bloader_online_max", "0");
String maxOff = stringStringMap.getOrDefault("bloader_offline_max", "0");
src.sendMessage(util.textSerializer("1"+stringStringMap.toString()));
int bloader_offline_total = Integer.parseInt(maxOff) + Integer.parseInt(offlinePersonal);
int bloader_online_total = Integer.parseInt(maxOff) + Integer.parseInt(onlinePersonal);
src.sendMessage(util.textSerializer("2"+stringStringMap.toString()));
});
hello it me (again part 2) so i have a CompletableFuture and i want to use some of the results it gives me to calculate something, but every time i try to do a calculation like int bloader_offline_total = Integer.parseInt(maxOff) + Integer.parseInt(offlinePersonal); inside the future, the future stops entirely, because i receive the "0" and "1" messages but not "2". I'm assuming I can't calculate inside the future, how would I get the value i needed?
it's nothing to do with the future
Integer.parseInt is probably throwing an exception (likely a IllegalArgumentException), you can try and catch that and handle the exception
even if i'm using .getOrDefault on the map? I will try anyway though, thank you 💚
getOrDefault does not guarantee the string will be number-like
it just returns whatever value is there for that key, whether it's number-like or not; if there is no value it will return the default, yes
I see, thank you so much as i believe you have just solved my issue 😄
Hey guys wondering if someone could help me. ```java
Player target = (Player) i.getInventory().getHolder();
target = (Player) Bukkit.getOfflinePlayer(target.getUniqueId());
String name = target.getName();
User user = giveMeADamnUser(target.getUniqueId());
user.getCachedData().getMetaData().getSuffixes().clear();
LuckPermsProvider.get().getUserManager().saveUser(user);
like 30% of all that is redundant
Whats on L73
user.getCachedData().getMetaData().getSuffixes().clear();
It seems this keeps throwing a Null error, even in my normal class where I'm getting the player directly, which is weird
I see.... so how could I then instead clear all of their suffixes in a different way?
Still getting used to the API sorry haha
Nodes include the prefix too though correct?
I just want to remove the suffix instead of both prefix and suffix
That worked! Thanks
!maven
Sorry! I do not understand the command maven
Type !help for a list of commands
?maven
!api
Learn how to use the LuckPerms API in your project.
Its on maven central
okey
how to check permission by context?
code logic:
if (User has permission ("plugin.command", on server "survival")) {
}
@jaunty pecan Can you help me? I still have a problem with that... >. <
Hey Rollczi! Please don't tag helpful/staff members directly.
Sorry :<
This should work
final QueryOptions queryOptions = QueryOptions.contextual(ImmutableContextSet.of("server", "survival"));
final Tristate result = user.getCachedData().getPermissionData(queryOptions).checkPermission("some.permission");
// check result
!cookbook should have it somewhere alr
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Hey!
I am currently changing my LuckPerms Groups with a command using the #modifyUser Method of the API.
It works fine on the spigot server meaning that /lp user <User> info shows up the new group with the correct prefix.
But my Scoreboard and Chat is handled by my BungeeCord plugin, which gets the Prefix with the LuckPerms API as well.
My issue is, that the update is not recognized by the BungeeCord LuckPerms -> the old Prefix is still shown.
This is only fixed, if the player relogs to the network. Can I fix this somehow?
look pins
I already looked at those, and it seems like using #modifyUser should handle this update via PluginMessage, shouldnt it?
Oh my god, sorry I can't read. Thanks!
So im new to using maven in plugins but idk what ive done wrong as i copied it from the website
Oh thanks
how are building your plugin?
maven
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!
well 1st of all there is no reason whatsoever to use such an ancient version like 4.0... use 5.3 which is latest
2nd add <scope>provided</scope> in the LP dependency
Its on central
well then it cant find it
<dependency>
<groupId>me.lucko.luckperms</groupId>
<artifactId>luckperms-api</artifactId>
<version>5.3</version>
<scope>provided</scope>
</dependency>```
!api
Learn how to use the LuckPerms API in your project.
it tells maven the dependency is provided at runtime, that it shouldn't be compiled with your project
how to get luckperms instance now
yea
i figured
uh
last question
why is this null
nullpointerexceptiobn
public static String getPrefix(UUID p) {
LuckPerms lp = LuckPermsProvider.get();
User user = lp.getUserManager().getUser(p);
Map<Integer, String> prefixes = user.getCachedData().getMetaData().getPrefixes();
return ChatColor.translateAlternateColorCodes('&', prefixes.get(1)) + getColor(p);
}```
this line
Map<Integer, String> prefixes = user.getCachedData().getMetaData().getPrefixes();
yes
they are
no
they arent
lol
Load the user
Yes
also there's a getPrefix method that returns the final, calculated prefix
instead of getPrefixes which returns a map
nah i have my own prefix system
i have 2 prefixes for players
their rank color
and their chat prefix
so thats what i use
riiiiiiiiiiiiiiight
By default yes
is it possible to get the case sensitive username of an UUID with the LuckPerms API?
is there a way i can check if a group has a particular temporary permission node, and get how long until said node expires?
!Api yea, you can look into the Node object and how to query nodes
Learn how to use the LuckPerms API in your project.
How does LuckPerms get around the issue with Java 16 that restricts the appending of classes into memory through the addUrl method?
This i think
Thanks!
Will I experience issues if I don't run use a scheduler when using the LuckPerms API?
As long you dont block the main thread
I'm unfamiliar with that.
Are there common ways people block the main thread without meaning too?
Thanks!
!api @thin matrix check those pages, 1st on depending on LP and 2nd on loading data for offline players
Learn how to use the LuckPerms API in your project.
Also the section "CachedData" -> "Performing permission checks" once you have the loaded user
alright so after I load the user I can access the cached data.
yep
how do I get the group/rank name of the player
not the prefix
like Owner
not
&7[&4Owner&7]
Players can inherit multiple group
But a assume you can use getPrimaryGroup since it seems you only want the highest priority group
you could cycle through players permissions to see if any node is an instance of Node.INHERITANCE
and then get that node
You can call PermissionHolder.getNodes(NodeType) to get owned nodes of a specific type
you would get sth like "group.owner" from that, i believe
so you need to cut the group. out to get the actual group name
I mean you wouldn't get that, you would get a collection of InheritanceNodes
Which has a method that provides the actual group name they represent
getNodes does not return a collection of Strings
what are you trying to achieve?
Please stop spamming channels. #support-1 for LP support.
I just checked code I made some time ago, removing or adding LP groups (InheritanceNode) to a user. For some reason I remember that I did not implement a check against the LP cache if a user holds/misses the group before I perform the operation to add/remove. But at the moment I find no reason why I'm not checking before to save unnecessary operation.
Or did I miss smth
yeah there's no real reason to
adding and removing nodes returns a erm
something, that tells you if it succeeded or why it failed
d;lp nodemap#add(node)
@NonNull
DataMutateResult add(@NonNull Node node)```
Adds a node.
the result of the operation
node - the node to be add
DataMutateResult :^)
Ohh I see thanks
How would I be able to get a groups prefix and suffix?
From the CachedMetaData
!API check out the second page linked here, it goes over using them
Learn how to use the LuckPerms API in your project.
Thanks also how would I get an array of groups?
Check the methods in the GroupManager
getGroups or something, can't quite remember
ok
How would i get if a user has multiple groups?
Is this good or is it weird? (Also don't mind the errors those are for a diffrent thing)
Im trying to get the groups a user is in and get the suffix and prefix of each of the groups, Im trying to store it in an array list but it dosent seem to work
Sorry if its a bit weird im tryna switch over from pex and thats what I did xD
i'm sorry i'm not trying to be rude or anything but what is going on?
With the code or.?
With the Code its getting each group a user is in and saving it to an Object and then getting the prefix and suffix of the group.
Have you heard of "enhanced for loops"?
no..
also known as a "for-each", I can assure you this will make everything look so much cleaner https://www.tutorialspoint.com/what-is-enhanced-for-loop-in-Java
you are kinda on the right path though but you should definitely consider using these bad boys ^
give me a few minutes and i'll tell you what I see wrong in that you need to change to fix, mkay?
ok
Okay so:
-
First off,
UserManager.getUser(UUID)may (and most likely will) return null if the player is offline; you should definitely put that in a variable and null check, if it's null, handle the situation, if it isn't continue as normal. If on the other hand the player is guaranteed to be online then you can either ignore it or use thePlayerAdapterinstead (see in the page linked above the section "Loading data for players") -
Objects.requireNonNull(Object)purposely throws aNullPointerExceptionif the object passed is null, please do proper null checks unless you actually want an NPE to be thrown -
getInheritedGroupsreturns aCollection<Group>, you don't need to turn it into a group array, take advantage of that and use the enhanced for loop ("for each") to iterate through the groups one by one instead
The string builder part seems to be good
Ah that makes sense but it runs when a player dose /(command) so they are guarenteed online, heres a test I came up with is it better?
Ill try to use the player adapter
that looks better, I still suggest you put the user itself in a variable but that works as well i suppose
Ok thank you will do
Hello, I know I'm using the API wrong. Can anyone guide me how can i use API so I can use isPlayerInGroup method.
!api
Learn how to use the LuckPerms API in your project.
Has a way to check
I'm on that wiki, I've imported dependencies.
Its an example method
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
wat
getInheritedGroups
uh what about it doesn't work?
are you getting an error or..?
uh..
you're gonna need to share more code or more details about what "isn't working" and how it isn't, i simply cannot tell just by looking at that though
uh right
sharing the contextual code will surely help...
that does not even compile
Hi, I'm trying to learn how to manipulate permissions programmatically, but a lot of the objects in the javadocs such as NodeBuilder return an access denied error when I try to view the page.
The wiki has a section for modifying user/group data:
DataMutateResult result = user.data().add(Node.builder("your.node.here").build());
but I'm not sure if the example would necessarily do what I'm trying to accomplish.
In case a user node already exists for the permission, will this code replace the existing node? I read that nodes are immutable, but I'm not quite sure how I would go about removing a specific node from a user. I was hoping that this particular method would just automatically remove an existing node, but I'm seeing that the DataMutateResult enum has a value called "FAIL_ALREADY_HAS", which I'm assuming would be the value that returns if I try to add a node that already exists. Any advice would be greatly appreciated! :)
Adding a node will not remove an existing one, it will simply add it if it does not exist and return DataMutateResult.SUCCESS.
DataMutateResult.FAIL_ALREADY_HAS is returned when the node "already exists", the attributes that are taken into consideration is node key (the "permission" itself), node value (true/false), the node's applicable contexts and if it has an expiry date (it ignores the expiry date itself, but it checks if it has one); so if there is one node matching those 4 attributes with the one you passed, it fails
To remove a node you can use NodeMap#remove(Node node), which only needs 3 of the 4 attributes: node key, node's context set and if it has an expiry (again the expiry value is ignored, and so is the node value (true/false)). If there is a node matching those 3 attributes, it's removed and DataMutateResult.SUCCESS returned, else DataMutateResult.FAIL_LACKS.
If you just want to remove a node regardless of context and expiry (i.e. key only) then you should probably use NodeMap#clear(Predicate<Node>) and pass a predicate created with NodeMatcher.key(String key).
Okay great, thank you very much!
Do you also happen to know why so much of the api javadocs are inaccessible?
because java is stupid
will be fixed by the next api publishing
for now you can remove the /undefined from the URL or navigate by clicking the hyperlinks
I'd love to have everything exclusively C++ but I don't own a time travel device to make Notch choose the right language
-.- I just realized that I overlooked the link to the source code ... lol
wht to do
Hello, if I check permissions from the Velocity it only accepts permissions which the player has global. Why not the permissions which the player has on the current server? And is there a way to change this?
To sync data between servers, you need to connect each LuckPerms plugin to the same database (for example MySQL) and set up a messaging service.
Show code of where its not working
if (user.getCachedData().getMetaData().getPrefix() != null) {
prefix = user.getCachedData().getMetaData().getPrefix();
}
Im using this
Screenshot /lpv info & /lp info
It is capped on one server
wait
If I change this permission to global then it works as wanted.
Wait, are you doing that code on velocity?
Because of the context
How do I do this?
CachedDataManager#getMetaData/getPermissionData can take a QueryOptions
you can build one with the context set you want with QueryOptions.builder()
If you use the method that does not take a QueryOptions it uses the user's active one
user.getCachedData().getMetaData(QueryOptions.builder(QueryMode.NON_CONTEXTUAL).build()).getPrefix();
Right?
no
you do want to take contexts into consideration
and you do want to pass the context set to the builder
well, do you?
do you just want to take "any prefix" regardless of context?
or on a specific server context?
you need to pass it the context
to the query options builder
and you don't want it to be non-contextual
because you want to query for context
the one you pass in
I think this is completely wrong but this is my try:
user.getCachedData().getMetaData(QueryOptions.builder(QueryMode.CONTEXTUAL).flag(Flag.INCLUDE_NODES_WITHOUT_SERVER_CONTEXT, true).build()).getPrefix();
you are still not passing the context
give me a min
Hey guys, real noob here, sorry about that.
I'm trying to use LuckPerms API in my own plugin coding, but it seems I dont have access to its methods ( they dont appear after the dot) while the LuckPerms API do appears at 1st.
Questions about using the LuckPerms Developer API - https://luckperms.net/wiki/Developer-API
There is a complete tutorial
yes Thanks but I've followed it and dont understand what I did wrong
The Luckperms API is installed the right way manually
Use api
I am a real noob lol sorry about that can u explain more
Doesnt matter
yes
Instead of the 2nd LuckPerms use api
oh okay thanks, and where in teh code should I add that ? below the imports ?
In onEnable or just make a method for this
and call it in onEnable
sorry, u mean that ?
Yes
Im really new in this API this is my 2nd interaction with it ^^ Im sorry.
Just make sure you're depending on LP ij your plugin.yml
what is that whitespace
LP is the depositories in pom.xml if that what u mean
sorry guys must be pain in the ass to explain noobs
e.g.
should I have access to the LP's methods after the api. ?
oh plugin.yml crap ok
Dont feel like typing it on phone
the problem with this is that it uses all prefix on all Servers or not? Because if im on Server A i get the prefixes of Server B probably?
in your plugin.yml, make sure you've got LuckPerms in your dependencies, as well as in your pom.xml / build.gradle
no, you are explicitly telling it to do consider contexts and you are explicitly giving it which contexts you want to consider
is this a proof I have it ?
see below
is there a way to use all? (does it support RegEx)
didn't you say you wanted to get the prefix for a context?
I have it in my pom.xml tho
in there add LP as a dependency, see here for examples and explanation https://bukkit.fandom.com/wiki/Plugin_YAML
Yes, so that tells Idea and maven that you need LP. But you also need to tell Bukkit that you need LP, otherwise you'll run into a bunch of issues
ok so I do that by adding it in plugin.yml then I guess, trying to do so now
Im sorry. My english is not the best. I try it again.
I have 3 Servers
- A, B, C
I wanna get through Velocity the current prefix of the player the one with the context server=A und world=AWorld
If i get it only shows GLOBAL prefixes -> it ignores everything with context.
And is there a way to avoid that?
Hope its better now.
thanks for the help guys really appreciated
yes, that's why you build the query options... you give it the contexts you want to get the prefix from
that's like the entire point of it
Yeah but it is on every server different? Don't I get the prefix of server A if im on Server B?
?????????
??????????
if you tell the query options to get the prefix for server A, it doesn't matter where you are or if the user is online at all, it will obey the query options and get the prefix for server A
ok i try it out give me a few min
Ive pasted those info from the JAR luckperms's plugin.yml file
not sure if im supposed to do something else but it didnt fix the problem
yes
U use api.
api.whatever you want
this is basic java
congrats
....
those are packages
Do you even know how to use Java?
If you're trying to use the LP api without knowing java (which it seems is the case), you are going to have a really hard time
Yeah and this is the problem.
the LP API is not exactly beginner friendly
Learn Java, then write Plugins
Hell, the spigot api isn't either
thing is my plan was to learn while experimenting those stuff u know
but the LP API is worse kek
Learn java, then learn spigot, THEN learn LP api
I know python
you shouldn't be touching spigot if you don't know java
Python != Java
python and java have literally nothing in common
(aside from the fact that they're both programming langauges)
the thought process yes
but packages have nothing to do with the thought process
sorry to bother u then, but where can I learn about packages and shit ?
if you know python
I just want specific tutorials on those if that's possible
My plan is to learn java doing those stuff, I rather figuring projects out than follwoing boring tutorials
and learn thing as I need them u know, I did that with python
that may work with python, but with java there's a lot of base concepts you need to get down first
i.e. OOP isn't something you can just follow a tutorial on
"boring tutorials" are boring because you are not willing to spend the time on learning the language but okay
Online Courses:
Online courses are also great for learning java. Some websites that offer them are:
- Coursera - Free unless you want a certificate
- PluralSight - Great courses from what I've seen. Mostly Paid
- Udemy - Never used them myself but they seem to all or at least most be paid.
Coursera. - I can say it was pretty good at introducing me to the programming world as a whole not just java.
Oracle Docs:
Oracle docs can help a lot at learning and understanding java:
- Start with this,
- Breeze through this (skipping stuff that doesn't seem relevant like bitwise operators),
- Hit this.
They're the first three from this larger thing which you should definitely go through overall. But those three should be enough for slightly better understanding of what is happening here without feeling like a huge time sink.
That one is a small part of this larger site wherein "Essential Java Classes" and "Collections" also have good useful stuff
Other services:
Some other cool services that will help you learn java are:
you can't expect to drive a semi-truck without knowing learning how to walk first
no they are boring because if it's like other langage, u wont use most of what u learn and will need to look them up as you need them anyway, it's theory, I prefer learning through practicing projects
anyway
Thanks for the ressources and help guys
you will use most of the things you will learn
that's the thing
if you don't know what a variable is, what a class is and what a package is, if you keep insisting in "i don't need those", they are a requirement in java, you use them every single time you use JAva because java enforces their usage
yes but in python, I can really well try to do stuff once I got the basics, and just google what I dont know and learn it as i need it doing a projects u know. It's wayyy more fun to learn that way by doing actual projects
so you can do with java???
I know what a class and a variable is, not a package tho or how does it relates to the api thing
I guess i need to get those basics 1st then
If you want to see bukkit specific stuff I personally recommend the official bukkit wiki
https://bukkit.fandom.com/wiki/Plugin_Tutorial_(Eclipse) (yes i know it says "Eclipse" but it doesn't really matter)
okay will look into it, thanks!
Im currently in the lobby and included the survival server in the context -> i get on lobby the prefix of survival
the prefix should look on the context and should watch if the player completes this context.
And if all matches then it should be used.
What??
Fuck my English...
Yes that is what happens, you tell it to query for the metadata with survival server context
Regardless of where the player is in
Was that not what you told me you wanted??
Sorry I can't help you if I can't understand what you're wanting to do
Yes
Next Try:
Im on the server A with the permission prefix.1000.Test with the context server=a world=test
If I now get the prefix of the player I dont get this prefix but the player is in the right world & server.
Better?
Okay let me see if I understand this time around
^^
Okay I see what's going on
Its maybe a bug?
Not a bug, it's intended behavior but let me explain
To put it shortly: when you get the getMetaData() (no query options, let's forget about the query options), it uses the user's active options based on the LP that processes the request. What does that mean? It means that, for a plugin on Velocity using the LP API on Velocity, it will use the contexts shown in /lpv user <user> info, because it's LPV processing said request. If the plugin using the API is on the backend server, then the contexts used are the ones shown in /lp user <user> info.
The server context does not mean "where the player is in", but "which LP is processing the request" (set in the config), so for LPV the server context will always be "proxy", in the LP on survival it will always be "survival", for the LP on creative it will always be "creative", etc. The server context is based on the setting in config, meaning it will always be the same "by default".
The world context does not necessarily mean "the world the player is in", but it means "where is the player located". For LP on a proxy, the world context is the name of the server (in the proxy settings) the player is in, the player is located in one of the servers, so for LPV that's the world context. For LP on the backend server, the world context is the Minecraft world the player is in, the player is located in one of those worlds so that is the world context
The thing is that each LP runs entirely independent and disconnected from the other LPs in the network, they don't really communicate with each other, they are "isolated", the only thing they share is a common database
"To put it shortly"
Lmao
So if you use getMetaData on a plugin on the server it will work as expected
U mean that I have to write a plugin for the backend server to send the things to the proxy?
It was so clean without other plugins
Only a simpel Velocity Plugin :/
Yeah I know, the best you can do is get the user's world context and use it as server context for the query options, but you can't get the actual world without a plugin on the server that acts as a bridge to send that info
that is really annoying...
Not really a bug, that's just how it works
yeah
Each LP is its own, with its own set of contexts used to calculate the data
This page for some general concepts you will benefit from being familiar with: https://luckperms.net/wiki/Developer-API
This other page for general API usage with some examples and explanations for each thing you'll probably use: https://luckperms.net/wiki/Developer-API-Usage
@gaunt hare
tysm 😄 yes those 2 links definitely help
guys what is Node#getPermission() in 5.0 api? is it #getKey()?
uh you should use 5.3 lol
yes but what are you wanting to do with it..?
im linkinf on latest rn
well im converting my code over to new api
and i have some Nodes that i get from event.getNode()
but then Node#getPermission() is gone 🤣
i c
i figure its gotta b getKey() since it's the only string method... guess we'll kno when some1 dosent rank up lol
is there a javadocs? o.O
yeah but they are kinda broken right now, you can still navigate them though
!javadoc
Learn how to use the LuckPerms API in your project.
third link
ahh ty 😄
.
o rip in pieces api#getNodeFactory()
i gotta say doe .-. a lot more hasnt changed then i thought
still got usermanger etc.
yeah you generally don't use that directly
you use InheritanceNode.builder() or PrefixNode.builder(), PermissionNode.builder() etc
ohh 😮 ty 😄
Plugin.Permissions.getUserManager().saveUser(user);```
is this all i need 2 do to set a node? .-.
yeah, that or
userManager.modifyUser(uuid, user -> user.data().add(node));
oh thats evn better 😄 ty
btw i know 4.0 api didnt support offline player perms, wat about modern api? .-.
Hello, I am using the latest LuckPerms API and tried to set a primary Group to a user. But ot doesnot work, and I am working for 2 hours with this problem, I need help. https://i.imgur.com/0n3yITq.png
!cookbook has examples @merry scroll
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Thank you
how would I add permissions with my plugin to show on the website without registering a command for them
like I have a command with underlying commands but the underlying commands are built into the main command
LuckPerms will cache any permission that is checked
I believe you can add them with the API, I'm not sure, would need to check, or just trigger perm checks for players at random :^)
so would that include if I check it in my code
like in my code I have this line
if (!player.hasPermission("amazing.vanish.list")) {
would that apply it
or is there a way I could change it so it did
LuckPerms will cache any permission that is checked
Hi, how can i get (and set) the players prefix, not the prefix of the players group?
@thorny echo ahh
boo
Hi guys, i have a question. Can someone please tell me how can i remove permission from a player? Thx (Im new to api)
I tried this but its not working
Can someone please help me?
All of what you need to know to achieve that is in here https://luckperms.net/wiki/Developer-API-Usage with examples even, and also here https://github.com/LuckPerms/api-cookbook
You need to save the user with the user manager
That's also explained in the first page of the two I linked above ^
For some reason user.getInheritedGroups can not be found, any idea if this has been changed or am I just a bit stupid?
nvm outdated version hihi
Now I am stuck at the following, I want to see the time left on a group that has been added to a player to determine when it will expire, how could you do that, I can not find anything related to this on the wiki besides getting a node with 1d as a time modifier.
and then the it will work?
Should
Get the user's InheritanceNodes with getNodes(NodeType) and filter those that have an expiry date
||hi||
||how are you guys. im worried how this is going to go this is the first time that im using this and this thing||
do you have a question regarding the API ...?
this might sound really dumb (I'm not familiar with java at all, but I'm still trying to power through regardless)
what does possibleGroups mean in the API usage? how can I change this list to limit what it looks for?
huh?
oh
holy, i hate that example is there
basically that example does the following: you pass a player and an ordered collection of group names, ordered from "higher" to "lower" group priority, you define that yourself
(e.g. Arrays.asList("owner", "admin", "mod", "jr-mod", "helper", "vip+", "vip"))
and the method checks for each one of those strings, if the player has the group.<group> node, the first one found is returned, if none is found it returns null
it's a rather stupid example and i hate it's there lmao
because that is exactly not using the LP API
LuckPerms luckPerms = LuckPermsProvider.get(); this would work on both sponge and spigot right?
someone is getting an error on a spigot (guessing magma/mohist) server
but it works fine on sponge
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.
this is the error
not really sure what is causing the error
that looks like a problem with whatever hybrid they are running
LuckPermsProvider.get() works on every platform so long as it (the platform) does things properly (expose/bridge classes between both "modding universes")
any tips/idea on how to resolve the issue,
yeah tell the server software maintainers to fix it lol
or use an actually functional and stable modded platform
I would do the latter
rip alrighty, ty for the help
With the API?
why wold this return null? look at line 96
Well what if there is no meta node for the key "land"? In that case getMetaValue will return null
Unless you're referring to something else
Well yeah but if it dosen't exsist its suppose to tell to user it dosen't which it dose but when it exsists it just gives an npe
?????????????????????
hmm gimme a sec lemme just quick check my code
Why would this return null?? Did I do something wrong? or is there a better way of getting a user's group and getting that groups prefix/Suffix? Same thing for the user
if you're just trying to get their active prefix, I usually find the vault api to be easier than LP
User may not been loaded? Depends on what exactly is null
Im trying to get there groups prefix and it seems that getting there prefix somehow returns null and I don't get why
How can i get group int?
Something like when i do logger:
getLogger.info("Loaded" + LoadedGroupsHere + " Groups");
Not working
It returns with [me.lucko.luckperms.common.api.implementation.ApiGroup@123455]
.size()
Thanks it's working!
Why i can't change rank for player?
What is wrong?
lp.getUserManager().getUser(target.getName()).setPrimaryGroup("VIP");
that's not really what setPrimaryGroup is for
!cookbook check out the cookbook for some 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.
Can you show me an example to how i set a specific player to a specific rank?
I didn't find any good examples
Hi guys! If I try to register the service in my Main class using RegisteredServiceProvider and do if (provider != null) {
LuckPerms api = provider.getProvider(); it just give me an error, if I try to start the server without this part, it just says that the API isn't loaded!
Just fixed this, but how can i use the api in other classes?
By passing it around to the other classes, generally through their constructors
See https://github.com/LuckPerms/api-cookbook for examples
That's my main onenable part:
private static Main plugin;
@Override
public void onEnable() {
plugin = this;
PluginManager pm = Bukkit.getPluginManager();
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
LuckPerms api = provider.getProvider();
pm.registerEvents(new Events(api), this);
}
but i get this error when loading the plugin java.lang.NullPointerException: Cannot invoke "org.bukkit.plugin.RegisteredServiceProvider.getProvider()" because "provider" is null
can't pastebin it because my pc is very slow
yeah you gotta check if provider is null
did you add LuckPerms as a depend in your plugin.yml?
softdepend
how are you building your plugin?
maven
send the pom.xml please
<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>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.2</version>
</dependency>
</dependencies>
</project>
the important parts are these
and the java version is 15
add <scope>provided</scope> to the LP dependency
if (provider != null) { LuckPerms api = provider.getProvider(); }
pm.registerEvents(new Events(api), this);
why api is returned as unknown?
?
yeah because in there api is inside the if block, and you were trying to use it outside
WORKS
TYSM
how can i check if a player is in one of 3 groups?
for (String VIPs : VIPs)
if (user.getPrimaryGroup().contains(VIPs)
something like that?
public final List<String> VIPs = Arrays.asList("Superior", "Legend", "Void");
that's the VIPs array
!API There's an example method you can use for that in the first or second API page linked here
Learn how to use the LuckPerms API in your project.
Can this works?
public final List<String> VIPs = Arrays.asList("Superior", "Legend", "Void");
for (String VIPs : VIPs)
if (p.hasPermission("group." + VIPs)) {
yeah that would do it
actually no
String VIPs : VIPs
the string variable can't be named the same as the list itself
name it vipGroup or something idk
nope seems not working
How can I use LP api with bungeecord api?
The same way you'd use it on every other platform, the LP API is platform agnostic
!api in the first page you'll find lots of concepts you'll benefit from knowing, and the second one goes over the LP API itself and many things you will probably end up doing
Learn how to use the LuckPerms API in your project.
How would I get a user instance tho?
That is explained in the dev api usage page
yes but in bungee there is no Player variable
ProxiedPlayer
Same thing
only ProxiedPlayer and I tried with that and it didnt work
What did you try exactly
or not
is GroupManager#getLoadedGroups() guranteed to have every group that is currently assigned to a player on the proxy? (velocity)
@thorny echo all channels
Thanks
Another question abt groups: how would get every player on the proxy with a certain group? do i just loop through every player and check CommandSource#hasPermission("group.mygroup") or is there some proper way to do it through luckperms api?
?? That method had nothing to do with either players or the groups being assigned to someone. It just returns the groups that are currently loaded from storage into memory, that's all
Check out the UserManager#searchAll method
Yeah, but is is guaranteed that the groups will be loaded if players with that group assigned to them are online?
Odds are all groups will be loaded at all times unless another plugin unloads them, it's not something I generally worry about
How can i check permission time expire event or group/perm expire/remove event on a player?
UserDataRecalculateEvent isn't working. (I've tried debug no any responding)
NodeMutateEvent/NodeRemoveEvent
Hi, I'm just porting a plugin to run on Bungee, can reuse the same API calls (and repos) or will it be different?
It's the same API anywhere you use it, entirely platform agnostic
how do i link my bungeecord lp to my servers?
With the API?
Then how can i grap player object from NodeMutateEvent
Hey how can I clear ALL Meta Data for a Player?
.data().clear(NodeType.META::matches)
!api
Learn how to use the LuckPerms API in your project.
I am trying to get how much time a player has a permission left. I am struggling to find where this is in the docs. Could any one point me in the right derection?
I need to get the amount of time before the permission node expires into a string
ok now i can not get the player info
yeah because Player is not a class in bungeecord
use the corresponding equivalent
the example assumes you have a luckPerms variable
of type LuckPerms
which is the main API class you work with
@nocturne elbow Can you check #support-1 please ?
Hey Amiyo! Please don't tag helpful/staff members directly.
no
well can you answer my question then ?
not here
k
i'm busy
Ok i am not able to get any thing out of it
i got the player name but i can't get the Expiry
what would i have to uses to get the Expiry
Probably something like
user.getNodes().stream()
.filter(Node::hasExpiry)
.filter(NodeMatcher.key("some.permission"))
.map(Node::getExpiryDuration)
.findAny().orElse(null)
Or something similar
Now i get a null pointer exception
23:36:43 [WARNING] Error dispatching event PostLoginEvent(player=ldash5) to listener me.dash.events.Events@778ca8ef
java.lang.NullPointerException
at me.dash.events.Events.postLoginEvent(Events.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.md_5.bungee.event.EventHandlerMethod.invoke(EventHandlerMethod.java:19)
at net.md_5.bungee.event.EventBus.post(EventBus.java:47)
at net.md_5.bungee.api.plugin.PluginManager.callEvent(PluginManager.java:412)
at net.md_5.bungee.connection.InitialHandler$6$1.run(InitialHandler.java:536)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.lang.Thread.run(Thread.java:748)
it looks like User user = luckPerms.getPlayerAdapter(ProxiedPlayer.class).getUser(player); is returning as null
Can't really tell with just a single line
Share the whole method up until that point
import me.dash.send.Send;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.model.user.User;
import net.luckperms.api.node.Node;
import net.luckperms.api.node.NodeType;
import net.luckperms.api.node.matcher.NodeMatcher;
import net.luckperms.api.node.types.InheritanceNode;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import java.time.Duration;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
public class Events implements Listener {
private Send plugin = Send.getInstance();
@EventHandler
public void postLoginEvent(PostLoginEvent event) {
ProxiedPlayer playerr = event.getPlayer();
if (playerr.hasPermission("send.1")) {
LuckPerms luckPerms = null;
User user = luckPerms.getPlayerAdapter(ProxiedPlayer.class).getUser(playerr);
Duration test = user.getNodes().stream().filter(Node::hasExpiry).filter(NodeMatcher.key("some.permission")).map(Node::getExpiryDuration).findAny().orElse(null);
playerr.sendMessage(new TextComponent(test.toString()));
ProxyServer proxy = ProxyServer.getInstance();
ServerInfo target = ProxyServer.getInstance().getServerInfo("hell");
playerr.connect(target);
//proxy.getPluginManager().dispatchCommand(proxy.getConsole(), "send " + player + " hub2");
}
}
}```
Well... You are setting luckPerms to null
Of course
You should definitely read this page, more specifically the section that says "getting a LuckPerms instance" or something https://luckperms.net/wiki/Developer-API
it does not have one for bungee
"same thing" meaning...? Does it still throw an exception? Are you getting a new error? Does it even compile?
23:50:44 [WARNING] Error dispatching event PostLoginEvent(player=ldash5) to listener me.dash.events.Events@2bfeb1ef
java.lang.NullPointerException
at me.dash.events.Events.postLoginEvent(Events.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.md_5.bungee.event.EventHandlerMethod.invoke(EventHandlerMethod.java:19)
at net.md_5.bungee.event.EventBus.post(EventBus.java:47)
at net.md_5.bungee.api.plugin.PluginManager.callEvent(PluginManager.java:412)
at net.md_5.bungee.connection.InitialHandler$6$1.run(InitialHandler.java:536)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.lang.Thread.run(Thread.java:748)
that is what i am giting
and yes it compiled
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!
Looks horrible on mobile lol
And share the code again too
test is null
Actually, you should really learn how to use Optional, it's a crucial class to handle nullability
Remove orElse(null) and read the documentation on optional to aid yourself
https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/util/Optional.html
declaration: module: java.base, package: java.util, class: Optional
check if its present then .get()
Hi ! is there a method I can call that creates a group as if it was in game command ?
closest thing I found but it wont work, cant have arg input apparently from there ?
d;lp GroupManager#createAndLoadGroup
@NonNull
CompletableFuture<Group> createAndLoadGroup(@NonNull String name)
throws NullPointerException```
Creates a new group in the plugin's storage provider and then loads it into memory.
If a group by the same name already exists, it will be loaded.
the resultant group
name - the name of the group
NullPointerException - if the name is null
!online
Sorry! I do not understand the command online
Type !help for a list of commands
!help
!advanced
!api
!argumentbased
!ask
!bulkupdate
!bungee
!bungeecheck
!cauldron
!colours
!commandequivalents
!commands
!config
!context
!cookbook
!default
!downloads
!editor
!editorsafety
!errors
!essentials
!extensions
!extracontexts
!faq
!formatting
!helpchat
!inheritance
!install
!libsdir
!locale
!meta
!migration
!notworking
!nowildcard
!pasteit
!permissions
!placeholders
!selfhosting
!stacking
!storage
!suggestions
!switchstorage
!sync
!testingperms
!tracks
!translationprogress
!translations
!upgrade
!usage
!userinfo
!verbose
!version
!weight
!whyluckperms
!wiki
!usage
Here's a guide to help users understand and use LuckPerms for the first time.
d;lp GroupManager#createAndLoadGroup
@NonNull
CompletableFuture<Group> createAndLoadGroup(@NonNull String name)
throws NullPointerException```
Creates a new group in the plugin's storage provider and then loads it into memory.
If a group by the same name already exists, it will be loaded.
the resultant group
name - the name of the group
NullPointerException - if the name is null
How do I use this in my code ? Nothing seems to work
Never encountered this syntax before so I looked up up what completable future is but it doesnt use this syntax either
Please help
!api
Learn how to use the LuckPerms API in your project.
Also look at pins
You mean the 1st pin about Completable Futures ?
I dont understand how it relates to this messaging service thing ? I thought i'd just have to call a method lol
ok thanks for link
The thing is none of their methods are being recognized in my code, even if I copy exactly what's in their example.
I seem to have imported the right things tho
I dont understand
I kind of get what's an completable future is now but nothing explains why this doesnt work
what are you trying to do with that first line....??
looks like you are very new to java itself?
Yes but I had no problem doing other things until now
I dont understand why those methods aren't recognized, I've tried every syntax possible
actionLogger is just an example variable, you need to actually use a variable that is present in your own class
CompletableFuture<ActionLog> getLog(); is a method in the log api interface, not something you use in your own code.
ah
Well that's why it seems weird to me I guess. My whole goal is to be able to create a group within my code and I got refered to this
d;lp GroupManager#createAndLoadGroup
@NonNull
CompletableFuture<Group> createAndLoadGroup(@NonNull String name)
throws NullPointerException```
Creates a new group in the plugin's storage provider and then loads it into memory.
If a group by the same name already exists, it will be loaded.
the resultant group
name - the name of the group
NullPointerException - if the name is null
this isnt something we use in our code then ?
thought it was a kind of method that would call a "create group" command
the method is createAndLoadGroup in GroupManager class yea
so first you need the GroupManager instance variable
then assume its called manager, do manager.createAndLoadGroup("testname")
then from there, handle the completable future.
how can i remove all meta prefixed with defined weight?
@Unmodifiable @NonNull
<T extends Node> CompletableFuture<Map<UUID,Collection<T>>> searchAll(@NonNull NodeMatcher matcher)```
Searches the normal node maps of all known Users for Node entries matching the given matcher.
the entries which matched
matcher - the matcher
anyways both managers have a search all method
from user
Hmm yes I understand that, but nothing appears after the GroupManager. it recognized the path but nothing is linked to it, not sure if I'm doing something wrong
wdym by "nothing appears"
yea you need to get an instance of a from the api
Basic oop design pattern for managers
you can searchAll then filter NodeType and its weights. But note it may only return results of loaded users (i.e. offline users may not be loaded unless manually call loadUser, tho it will be a very expensive call)
i need it for just one user, i have the uuid
ah I assume you said all means everyone
are you talking about this ? Because I already have this
is it a similar instance I need to get that is "specialized" for Group Manager ?
api.getGroupManager
yea ^^
you can just use this https://docs.docdex.helpch.at/luckperms/net/luckperms/api/model/PermissionHolder.html#getNodes() to get the nodes you need with some filters of the collection.
Then read the docs on modifying user data https://luckperms.net/wiki/Developer-API-Usage#saving-changes
thanks i will try it
Many thanks so far guys, so
this is used like any other method or does the Completable future type makes it deifferent ?
its a completable future. I suggest reading up on async programming with java before using luckperms api
ok will do, thanks !
Figured lot of stuff out but I dont know what I'm doing wrong here
basically it's a command that create a group (supposedly)
I add prefix to check if it works well
the command work in game, the group is created, but the prefix doesnt add
seems like the player isnt assigned to the group
well for 1. you're not actually creating the group
and 2. look at the cookbook how to set someone's rank
!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.
It's apparently created since it appears in ingame group list commands after I type my new command (command setter is hidden in my screenshot tho).
Thanks for cookbook I'll look into it
Figured it out, just had to use join() method on the completablefuture to force the asynchronous return before processing next command.....
.join blocks the thread btw
yea I kinda understand now, but it's fine here it works instantly. I guess the problem was that the getGroup() command was processed one millisecond before the completablefuture was... lol
- Users don't have weight, groups do
- Stop trying to @ staff roles
ok
Hi, lpc is disabling essentials nicknames in 1.17?
Is there any way around it with papi not being updated yet?
Hi guys! Is there any way to setup the server name programmatically through the API?
Eh would be great to can handle it, because I'm running my server instances in docker containers started from a template image
Thank you guys 🙂
@thorny echo
Hey UberSuperBoss! Please don't tag helpful/staff members directly.
@rustic laurel
Hey UberSuperBoss! Please don't tag helpful/staff members directly.
@neat jackal
Hey UberSuperBoss! Please don't tag helpful/staff members directly.
@wild whale
Hey UberSuperBoss! Please don't tag helpful/staff members directly.
No need to tag every single mod/helpful btw
Uh I mean thanks but no need to tag all the mods 😄
Best is to pick one, wait 5 minutes, then ping another if the first doesn't see
well didn't wnat someone to lose their steam account
cause if they did they could lose a lot of stuff
so does anybody know the answer to my questions?
HALp
hALp
this is why I hate using lesser used apis
no proper documentation
barely anybody to ask lol
please someone, end my suffering
Can you stop whining and wait patiently like any self respectable human being?
Jesus Christ
Get the user's inheritance nodes, filter by those that have an expiry left and then get the expiry duration, you'll end up with a collection of Durations
Something similar to this, modify accordingly to fit your needs (e.g. getNodes(NodeType.INHERITANCE))
There is proper documentation, you just need to know how to read and where to look for it, and navigate javadoc helps a ton
I would go as far as saying that the LuckPerms API is more documented than Bukkit API, which is full of uncertainty, inconsistencies and straight up lies
In the future, belittling a developer, staff, cashier at walgreens, etc. or their work is not a terribly efficient way to get support for an issue. Particularly when it's ostensibly free labor for a free product.
how do I search for specific node?
luckapi.getUserManager().getUser(player.getUniqueId()).getNodes().stream().filter(Node::hasExpiry).filter(NodeMatcher.key("group.test")).map(Node::getExpiryDuration).findAny().orElse(null)```
When I try this I get "PT730H14M57S"
The player has 4 weeks left
thanks!
How would I add a temporary rank?
!cookbook See the examples in this repo for how to give a parent group in general
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
There is an add method in NodeMap that takes a TemporaryModifierMergeStrategy or some obnoxiously long-named enum class like that
oh
um ok
I tried doing this
However it just stays
and even weirder
It becomes 29
I'm kinda a noob, how do I use it?
it's a method named add just like the one you're using
but instead of taking a single Node, it takes a Node and a TemporaryNodeMergeStrategy
is it possible to add the luckperms bukkit as a dependency in maven? i tried this, but it said that it couldnt find the artifact.
<groupId>net.luckperms</groupId>
<artifactId>bukkit</artifactId>
<version>5.2</version>
<scope>provided</scope>
</dependency>```
there is no platform specific api, there is one universal api, entirely platform agnostic
!api
Learn how to use the LuckPerms API in your project.
i already have the api one, i just want to be able to look at the code of the bukkit one in my ide
because it helps me understand what code does better when i look at the code
there is no "bukkit one", again it's completely platform independent; and you shouldn't have to worry about implementation details
as the definition of "API" implies, it is purely interfaces, the API jar contains no implementation
but if you really insist you can take a look at them here https://github.com/lucko/LuckPerms/tree/master/common/src/main/java/me/lucko/luckperms/common/api/implementation
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Does anyone know if it's safe to add nodes to a user's transient node map in events such as it is not >:(UserDataRecalculateEvent or UserCacheLoadEvent?
Anyone = @Luck 😩
It isn't, adding a node invalidates caches which dispatches the data recalculate event
I'll end up with a nice and easy SOE lol
To add nodes when, well, data is loaded and recalculated 🙃
Hm I actually can handle this to not end up with a SOE
For a "cumulative/arithmetic" nodes extension, basically if I inherit meta griefdefender.bonus-blocks from two different groups with two different values, to add the values and put the node in the user's transient node map
Same would go for permissions, kinda like plots.plot.<value> (which is not a meta node for some reason >.>)
is there any reason i shouldn't use luckperm's meta API to store things like game statistics and stuff on a player
ah ok fair enough
just write a listener in such a way as to not trigger recursive updates
:>
i.e. don't try to add a node to the map if one is already there
lmao
yes
I think the best approach here is to tag the added nodes with metadata
Got an interesting one. So I have a public project I designed back in the 2017 era. Part of the project involves adding and removing permissions from players. In the original implementation, and current that is, I just used the Vault permission API to add / remove permissions. When LuckPerms started getting attention and enforced the permissions async stuff with a config option, it started to break the implementation as this was running sync. So I figured an easy fix was throwing it async which worked fine until I found out a decent portion of the project users still uses PermissionsEx, and you know what happens when you async Vault permissions with PEX? It freaks out and doesn't allow it. So here we are, in 2021 and I have a janky module in my project that goes async / sync based on a config option.
So, given that entirely way too long context of a story. Now that we're in 2021, is there a better approach to designing this system to give / remove permissions in a way that would keep all permission plugins happy?
Additionally, UltraPermissions' Vault integration is broken :kekw: