#luckperms-api
1 messages · Page 25 of 1
@hollow geyser replace getUser with loadUser
getUser only works with online players
And work with queryoptions instead of contexts
@hollow geyser replace
getUserwithloadUser
@crystal sonnet
Haha its not that easy x)
Hey MR.CLEAN! Please don't tag staff members.
Why?
I only have a username, but it needs uuid
An the 2. option loadUser(uniqueId, username) throws Nullpointer if: if the uuid is null
Bruh really. Thx.
Javadocs typically help 😉
CTRL + Space xD
Or that
How would I obtain a list of the people in a specific group?
I don't know if the issue is on my-side of the plugin however any changes made through my plugin don't go into affect until after you do /lp sync
I've made sure to save the user everytime I do any changes to nodes or parents
as well as pushUpdate() after I am all done with node editing
however it still takes a manual /lp sync to see one of the changed groups
Everytime I add permissions by writting the permission in the highlighted area nothing happens. How am I suppose to add permissions for a group?
Wong channel @nocturne elbow. Use #support-1 or #support-2
Hey I am trying to use the api to create a custom context but it returns an error in my console saying "[LuckPerms] An exception was thrown by com.ralphy.morecontexts.PlaceholderApiCalculator whilst calculating the context of subject CraftPlayer{name=[player's name]}"
You get a NullPointerException your code
This has nothing to do with the LP API
This is an issue in your code
Can I send my code so you can tell me what I’m doing wrong? I’m confused
There is my code, I followed the guide on Github, and I am trying to creating a class that will make a context for checking a player in a group
You never set the luckperms variable
@jovial saffron well the error happens on line 17, which you didn't provide, so it's hard to tell
But again. Nothing LP specific
It's probably you never initializing the luckPerms variable
How do I do that?
Sorry I don't, I am not that great at programming. I haven't done it in a while.
Learn the basics, then make plugins, and then use external APIs
If initializing a field is too advanced for you, then I'm sorry but this won't work out for you
Look I know the basics but I dont know the terms, are you referring to placing an argument after LuckPerms luckPerms = .....;?
Yes
Okay thanks I'll try that
No error in chat BrainStorm, I made a ticket on git with a bunch more information and code snippets and stuff
Or error in console
Everything runs as normal, but nothing is updated
I asked you waht LP version you are using... @short fossil
I said it was in the GitHub ticket but it’s 5.0.78
You can download LuckPerms for Spigot/Paper, BungeeCord, Sponge, Nukkit or Velocity.
I’ve updated and the issue still persists, same as before
I seem to be having a hell of a time navigation the docs or understanding. Can I be pointed into the correct direction on how to grab a specific data, like a user's prefix?
!api have you tried both of these links?
Learn how to use the LuckPerms API in your project.
that is what i'm currently looking at yes
yup I'm looking at that, there is nothing on the specific types of data you can grab so I'm left to wonder what I need to filter through
ngl, I'm really unfamiliar with this side of luckperms. I'd guess it's similart to this but without the time/expiry filters:
int maxWeight = user.getNodes().stream()
.filter(Node::hasExpiry)
.filter(NodeType.PREFIX::matches)
.map(NodeType.PREFIX::cast)
.filter(n -> n.getContexts().getAnyValue(DefaultContextKeys.SERVER_KEY)
.map(v -> v.equals("factions")).orElse(false))
.mapToInt(ChatMetaNode::getPriority)
.max()
.orElse(0);
also without the context, unless you wanted that
not sure, sorry, I'll wait for someone more qualified to respond
that is fine, thank you for trying to help me
Yea it does not seem to like the mapToInt too well
@candid tapir there’s a link to the javadocs on the very top
I know
is there a way to filter out ops when checking if a player is in a group unless if they actually are in that group
cause right now I'm filtering them completely
Afaik the player should only have the group permission node if it's directly added to them
OP shouldn't affect group memberships
So the getnodes call returns every single group node if you're OP'd?
hasPermission will return true for ops, yes, you'll want to get the users permission nodes / inherited permission nodes and check if the group is there
Hi is it possible to give a player permission in your code if the player clicks on something?
hey so im running a server and i was wonder how to use this plugin
i already have it installed and need to learn the commands
same :/
Humm on the Doc, i havent see how add a permission to a player.
!api
Learn how to use the LuckPerms API in your project.
Check the section on adding nodes @dreamy schooner
Is there an example ?
Do you have an example please?
User user = api.getUserManager().getUser(p.getUniqueId());
DataMutateResult result = user.data().add(PermissionNode.builder("permission").build());
api.getUserManager().saveUser(user);
works for me
Humm ok ty, one other question , hasPermission work ?
Please ask a properly worded question
hasPermission work if we use for check if the player have the permission on LuckPerms
Yes
Hi i have a problem he is not reading the api.getusemanager with me
What?
Hi, I currently have a problem with the LuckPermsAPI in conjunction with Multibungee. When I try to query a user via API and the user is on a different bungee cord, I sometimes get the user and sometimes null back. The UUID that is passed is on the network and correct. LuckPerms itself is connected to Redis and should be compatible with Multibungee, I thought?
this.userModule.getLuckPerms().getUserManager().getUser(this.uuid)
^ null
Does anyone have any idea what I'm doing wrong?
Use loadUser instead @jolly herald
thank you 🙏 worked!
Hello how can i check permissions with your api please cant see anything on DEv API
Learn how to use the LuckPerms API in your project.
!api
Learn how to use the LuckPerms API in your project.
Is there a way to overwrite the * permission for LuckPerms?
be super specific in what youre trying to do
Ok so. We have a togglerank plugin, which removes your prefix and adds the one you're toggling to.
This is done via deluxe chat
It removes the permission chatformat.group and adds the new one thus keeping your group permission so you appear as a different rank
However it doesn't work with my owner group as it's conflicting with the * permission.. If someone has any ideas please @ me
Hi. It would be great if someone could help me. Basically, I own a network server. We moved to a dedicated host about a month ago and since the transition, everything has been messed up. Recently, all servers in our network crashed due to a 'database issue' and our only dev struggled to get them back, and so far has only managed to get one. On this one open server I have noticed that as I start to type /lpb, not even enter it, the server completely crashes and takes forever to get back. Also, all our ranks are cleared. I will point out that I am not a dev, and our only one is getting really pissed off and requesting pay even tho we didn't say we'd pay him when we hired him. Is there anyone that can help - and make sure ranks are safe in the future??
@jaunty pecan @proud crypt
Hey Megan! Please don't tag helpful/staff people directly.
could someone help me with setting up my ranks in a bungee server
i have the ranks the same name as each other
but im not sure on how to sync em
also is there a way to like merge two ranks together?
!bungee @pine mulch
If you run a Bungeecord network, learn how to correctly setup LuckPerms on all server instances (including Bungee).
Syncing data between servers
https://github.com/lucko/LuckPerms/wiki/Syncing-data-between-servers
Also this should be in #support-1 unless it’s related to luckpermsAPI
@nocturne elbow whoever hosts the database should be contacted. Luckperms relies (like most other programs) on a solid connection to a database that doesn't change. Also when typing /lpb is that the only thing that crashes the server? Also, what version of LP are you on, what messaging service, and what kind of database? Please bytebin your startup log for the proxy and the server that crashes, as well as send /LP info from a server and /lpb info from the console of the proxy
!paste
Seeing a paste of the problem makes everything so much easier! Use https://bytebin.lucko.me/ for easy pasting!
Pastebin any relevant segments of the console log. If it's a startup error, this includes the entire startup log!
Pastebin the entire LuckPerms config file (passwords removed) as well as any other relevant files!
Hey @nocturne elbow do you still need help?
Hello, how does someone get all the permissions & groups from a player?
What do you mean? just a list of a player's stuff?
lp user <user> info will show groups
lp tree <scope> <user> will show all permissions checked against a player that partially match <scope> and what they returned
Learn how to use the LuckPerms API in your project.
yea I already tried. tho I've only read the API package XD I'll try to read others
All you need to know is on those pages
hey, is this proper way to remove a permission
plugin.getPermissions().getUserManager().getUser(player.getUniqueId()).data().remove(Node.builder("randomspawnplus.wild").build());```
I think that works. Be sure to save the changes in the user object @subtle reef
That's probably what I'm missing 😂 been trying to get this to work for a little while
Thanks
You’re welcome
how i can get from loaduser the user sync?
What do you mean? @dusky wagon
Use the loaduser function but do .get(int, TimeUnit.[Seconds/Minutes/etc]
Don't believe it is possible to load it, however you can treat it as a sync function using .get
@dusky wagon
and why not only .get?
ok
The API gurantuees that it'll return eventually.
And don't load players sync
It'll lag
If you're on a async thread just add .get()
Ok so. We have a togglerank plugin, which removes your prefix and adds the one you're toggling to.
This is done via deluxe chat
It removes the permission chatformat.group and adds the new one thus keeping your group permission so you appear as a different rank
Is there anyway to override the * permision as theat is blocking this working.
If you know the user is online, use getUser @dusky wagon
@chrome rain Those are statements. What is your question?
Sorry I pressed enter too early, Brainstone, I've edited my message :p
public static boolean hasPermission(UUID uuid, String permission) {
LuckPerms lp = LuckPermsProvider.get();
User user = null;
if(lp.getUserManager().isLoaded(uuid)) {
user = lp.getUserManager().getUser(uuid);
} else {
try {
user = lp.getUserManager().loadUser(uuid).get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
ContextManager contextManager = lp.getContextManager();
ImmutableContextSet contextSet = contextManager.getContext(user).orElseGet(contextManager::getStaticContext);
CachedPermissionData permissionData = user.getCachedData().getPermissionData(QueryOptions.contextual(contextSet));
return permissionData.checkPermission(permission).asBoolean();
}
I use this
yes i need this.
if(lp.getUserManager().isLoaded(uuid)) {
user = lp.getUserManager().getUser(uuid);
} else {
try {
user = lp.getUserManager().loadUser(uuid).get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
That's completely pointless
In that case just use lp.getUserManager().loadUser(uuid).get()
Does the same
But in any case it's important that you run that code async if you don't want to lag the server
but if the player is already loaded I don't have to load it again
And lastly use this:
ContextManager contextManager = lp.getContextManager();
QueryOptions queryOptions = contextManager.getQueryOptions (user).orElseGet(contextManager::getStaticQueryOptions);
CachedPermissionData permissionData = user.getCachedData().getPermissionData(queryOptions);
LP does that already
Which you knew if you read the javadocs
ok
!nowildcard
Some plugins are created in a way which results in odd behaviour when the root '*' wildcard is used.
@chrome rain
Oh I see
Though the easiest way to fix it is setting chatformat.* to false
It overrides the *
I'll give it a try, thank you Brain!
public static boolean hasPermission(UUID uuid, String permission) {
LuckPerms lp = LuckPermsProvider.get();
User user = null;
try {
user = user = lp.getUserManager().loadUser(uuid).get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
ContextManager contextManager = lp.getContextManager();
QueryOptions queryOptions = contextManager.getQueryOptions (user).orElseGet(contextManager::getStaticQueryOptions);
CachedPermissionData permissionData = user.getCachedData().getPermissionData(queryOptions);
return permissionData.checkPermission(permission).asBoolean();
}
it is so right?
And the individual chatformat.group override in turn the chatformat.*
Except that you'll get a NullPointerException if loading the player fails and that you have consequently ignore what I said about sync and async, yes that looks ok
@chrome rain yes
Perfect thank you :)
I'll give it a try
I can keep the * permission on the group ?
Yes
Except that you'll get a NullPointerException if loading the player fails and that you have consequently ignore what I said about sync and async, yes that looks ok
i run the methode async, or what you mean?
Hey Meerpaluten! Please don't tag helpful/staff people directly.
sry
Make sure that whenever you are checking permissions with that method that you are not on the main server thread
(Or that you're not making the main server thread wait on your thread)
Else you'll lag the game
Thank you BrainStone that's fixed it!
Yes @dusky wagon
But your entire code
Not just that function
Are you even understand what I'm talking about?
Because I have the feeling you don't have a clue
Yeah, I see what you mean, maybe it doesn't come across that way.
Ok. Good
Is there a way to check if the user has ever joined (data created). I need this non async
@crystal sonnet
Hey !Tom! Please don't tag helpful/staff people directly.
non async
Not possible.
And async?
!dev
Sorry! I do not understand the command !dev
Type !help for a list of commands.
Check the userManager in the Javadocs
I did
BukkitCore.getPlugin().getLuckpermsHook().getApi().getUserManager().lookupUniqueId(str).thenAcceptAsync(s -> {
System.out.println(s.toString());
});
Ok
This isn't working
!nw
We really would absolutely love to help you out! However, telling us that it isn't working wastes everyone's time. Please, just describe the issue you're having clearly and with as much detail as possible, and send any relevant screenshots of whatever problems you're having.
Nvm...
Ok
bad support tho
? You know that he can't read your mind to know how it's supposed to work or what it's supposed to do, right
Not working can reach from the code not compiling to it blowing up your computer
You gotta be more specific
Hence I droped this
!nw
We really would absolutely love to help you out! However, telling us that it isn't working wastes everyone's time. Please, just describe the issue you're having clearly and with as much detail as possible, and send any relevant screenshots of whatever problems you're having.
@charred shell
!help
!advanced
!api
!argumentbased
!ask
!bulkupdate
!bungee
!cauldron
!chat
!colours
!commandequivalents
!commands
!config
!context
!default
!downloads
!editor
!errors
!essentials
!extensions
!faq
!helpchat
!install
!locale
!meta
!migration
!notworking
!nowildcard
!pasteit
!permissions
!placeholders
!selfhosting
!stacking
!storage
!suggestions
!switchstorage
!sync
!tracks
!upgrade
!usage
!userinfo
!verbose
!weight
!whyluckperms
!wiki
!essentials
Make sure you are using EssentialsX and Vault for prefixes. For any other issues with Essentials, you should seek support in either #general or the official EssentialsX support Discord.
@verbal finch I mean even if I wanted to I couldn’t have. Too little information
!config
Learn what each of the config options are for.
is there a way to read and/or edit the config through the api (I know seems kinda odd)
https://github.com/LuckPerms/extension-default-assignments/blob/master/src/main/java/me/lucko/luckperms/extension/defaultassignments/LuckPermsConfigAccessor.java
That is being used for the default-assignements extension
Can somebody pls help me i got a struggle with lucky perms ! 😦 Pls reply..
is there anyone who would be able to tell me how i get the prefix of a player via the api?
if you don't find in 6~ hours, I'll be able to tell
o mad it be like that xD
@lilac mountain you can’t edit it. Why do you want that in the first place?
!api @scarlet harness
Learn how to use the LuckPerms API in your project.
@terse cipher is your question about the developer API?
Its already done thanks 🙂
@crystal sonnet so i was just asking how i would get the prefix of a players group so i can display it next to their name within a chat event
Hey Joshツ! Please don't tag helpful/staff people directly.
^^ mybad
!api
Learn how to use the LuckPerms API in your project.
Does anyone know what method I would need to call to get a particular player's position in a promotion track? This is my first time building a plugin with dependencies so any help is much appreciated
i came up wit this but getting errors any ideas?
User user = plugin.luckapi.getUserManager().getUser(p.getUniqueId());
ContextManager contextManager = plugin.luckapi.getContextManager();
ContextSet context = contextManager.getContext(user).orElseGet(contextManager::getStaticContext);
return user.getCachedData().getMetaData((QueryOptions) context).getPrefix();
}```
thats on the javadocs
i gathered the context part from the javadocs tryed to cache the prefix using something i made up
Use QueryOptions directly
QueryOptions queryOptions = contextManager.getQueryOptions(user).orElseGet(contextManager::getStaticQueryOptions); @scarlet harness
how do I get the global context? I need it to pass into the track promote method
From the context manager @twilit jasper
right but how, do I just say global like api.getContextManager().getContext("global")
trop compliqué
It should have a method for getting the global context directly @twilit jasper
@white topaz what do you mean?
nothing shows up in the code hint
i mean "too hard" sorry !
What’s too hard?
This is for plugin developers working with the LuckPerms API
!api @twilit jasper Check the second link and there should be some example on how to create a context
Learn how to use the LuckPerms API in your project.
If I’m not mistaken the empty context is the global one
i think someone need your help on #support-1 🙂
I was thinking of adding a little plugin that would add a fallback database but I think that might be far more useful in the full plugin
especially since the plugin denies players from joining which isn't a bad thing but a like internal or external fallback database that gets updated every hour or so would help out so that there are fallback permissions
Trust me in 9/10 cases you're better off knowing that something is wrong
Because having a backup could easily lead to only the backup working without you knowing
And then if that dies you're just as screwed, if not more
Yeah but the fallback database is more when cough cough a provider of such database cough cough MCPH cough cough decides that without notice there database server is going offline and that would go for any provider really. But I'm thinking of it more as a if the server can't connect than an issue where the database is corrupted
Get a better host 😛
Im new to plugin making so this is probably a dumb question but idk what to do about this being red
We use shockbyte for the main servers other than the hub. I think I might move the database over when it starts up again soon or later were going to host it ourselves so we never have to worry about these issues again
means it doesn't know what that is
You probably need to reload the maven dependencys
@stiff thistle that's just syntax highlighting I guess
This is a startup error.
https://pastebin.com/x7HZVaYw
I stumbled on the code I made after seeing WIKI.
What are the possible causes?
(I am bad at English.)
The following is the source code for that part.```java
private boolean setupLuckPerms() {
if (getServer().getPluginManager().getPlugin("LuckPerms") == null) {
return false;
}
RegisteredServiceProvider<LuckPerms> rsp = getServer().getServicesManager().getRegistration(LuckPerms.class);
if (rsp == null) {
return false;
}
luckpermsApi = rsp.getProvider();
return luckpermsApi != null;
}
@ancient heron you don't have LuckPerms installed
Is it a plugin?
It's luckperms
So you try to add support for LuckPerms but don't know what it is in the first place?!
Well, I don't understand much.
I have LuckPerms in my plugins folder.
Ah...
I have to apologize ...
I was using the wrong version.
You need a 5.x.x version
just double checking, I should use luckperms getpermission method over the player#getPermission method?
Either should work
I use getPermission across all my plugins withn no issue @radiant kiln
do you think luckperms method is faster than the player one?
I'd say the player one is probably faster however speed is going to be negligable
i can only find a way to get/set the primary group for a user, how do i add/get additional groups?
do i just use the permission nodes group. etc?
i want to check if a user is in a group, or put them in a group
I use java Set<String> groups = permission.getUserManager().getUser(playerUUID).getNodes().stream() .filter(NodeType.INHERITANCE::matches) .map(NodeType.INHERITANCE::cast) .map(InheritanceNode::getGroupName) .collect(Collectors.toSet());
to get a set of a user's groups (parents)
and then you can filter through this
using a for each loop on groups
then use the user manager to load the user
CompletableFuture<User> userFuture = permissions.getUserManager().loadUser(player.getUniqueId());
then use ```userFuture.thenAcceptAsync(user -> {
//Modify user groups &| permissions here
});````
to modify the users group
or permissions
and then finally save the user using UserManager#saveUser(user)
@eager shore
ok thanks
yup
!api for reference
Learn how to use the LuckPerms API in your project.
@tender walrus scroll up a little bit here, you should see what you're looking for
I’m using Vault
Oops sorry
How i can get the highest rank of user ?
if i promote a user up a track, do I then have to save the user, group and track?
i.e
LuckPermsProvider.get().getUserManager().saveUser(user); LuckPermsProvider.get().getGroupManager().saveGroup(group); LuckPermsProvider.get().getTrackManager().saveTrack(track));
if anyone familiar with the API + perms stuff could help me here, trying to work on this again
luckPerms.getUserManager().getUser(player.getUniqueId()).data().remove(Node.builder("randomspawnplus.wild").build());```
trying to remove a permission when a command is executed
line is executed, no errors or anything
seems to not do anything
Did you save the user?
@eager shore only the things you changed need to be updated
So typically only the user
@subtle reef saveUser
Now does the permission you try to remove have a context?
Is anyone else having issues where you set a player's permission using the permission set command but when the player is typing the command it shows as red and auto-complete doesn't work until the player reconnects to the server or there's a /reload?
It also does it reversed where if you take the permission from the player then it shows that you can type it and auto-complete works until you reconnect. ( Latest version of Minecraft [1.15.2] )
That’s normal behavior
Hello all,
Is the expiry stackable on multiple use in same NodeBuilder or overwrite it the time?
it overwrites
oh okay.
Just keep track of the time elsewhere 😉
Is the expiry not the time for temp group/permission?!
it's easy enough to extend the expiry of an existing node, if that's what you're trying to do
yes it is
Ah ok , thanks 😉
Hello again,
in the Node list of a User, represent the key of the Node a Group name and/or Permission string? I had think first that's only the permissions but now i cant find the groups of the user.
@crystal sonnet I don't think so? It's just set in group default. I'm trying to negate it for whoever uses a command
Hey apt! Please don't tag helpful/staff people directly.
@subtle reef alright
Try finding the existing node and removing that from the set
@subtle reef can I see your current code?
apt, if you're trying to negate a node
you need to use something like
luckPerms.getUserManager().getUser(player.getUniqueId()).data().add(Node.builder("randomspawnplus.wild").value(false).build());
data().remove(...) removes a node from the set
which as you can see from /lp user ... permission info - is empty :p
so instead, you need to data().add(...) a negated node
Thanks so much luck 👍👍
finally got around to testing out that code, and yeah it worked flawlessly first time. again, thanks a ton 😄
Ah. I thought you were trying to unset that permission (which was set to true) in the first place
luckPerms.getUserManager().getUser(player.getUniqueId()).data().add(Node.builder("randomspawnplus.wild").value(false).build());
Same works with groups? And without luckPerms.getUserManager().saveUser(user)?
You can use InheritanceNode instead of Node for groups.
And you still have to save the changes
Hi, if I want to get to user's group/rank(for example Admin) do I use UserManager?
You get the User Instance from the UserManager
hi all i see this on the git wiki page and curious what needs to be put in place when calling this method for the possiblegroups ?
for (String group : possibleGroups) {
if (player.hasPermission("group." + group)) {
return group;
}
}
return null;
}```
What are you trying to do @scarlet harness
That will return the first group and nothing more
do you want to return primary, most weighted, or?
primary
Ok so rather then use hasPermission I would use LuckPerm's api
Set<String> groups = permission.getUserManager().getUser(playerUUID).getNodes().stream()
.filter(NodeType.INHERITANCE::matches)
.map(NodeType.INHERITANCE::cast)
.map(InheritanceNode::getGroupName)
.collect(Collectors.toSet());```
that is within luckperms api i got that from the wiki
player#hasPermission is a bukkit method
It will only return if a player is in a group, not anything more
however I wouldn't recommend it because it doesn't take into account much else then if in the group
the code I sent gets a string set of all groups a user inherits
but if im trying to display only one how am i then choosing the primary
Well you will have use the groupManager in luckperms
then you can get info about the group
Group group = luckPerms.getGroupManager().getGroup(groupName);
for example you can get a group's weight through group#getWeight
However if you are just going for primary group
%luckperms_primary_group_name%
will do the trick @scarlet harness
If you are insistant of doing it through the api
load the user using userManager#loadUser(uuid)
then do user#getPrimaryGroup()
Either one will do the trick
so @short fossil i just tried something like this am i doing it wrong or am i juyst getting confused
User user = plugin.luckapi.getUserManager().getUser(p.getUniqueId());
String group = user.getPrimaryGroup();
return group;
}```
wait instead of what or a new line?
Well i guess since you aren't modifying the user it doesn't matter much
But that looks good to me
i just tried it and it erroed
Send error?
wait nvm i believe the erroe may or been caused by somethjing else
Ok let me know
yeah it worked now
Coolio
is there a way to get the primary group display name tho?
YEah
how would that be done
permissions.getGroupManager().getGroup(user.getPrimaryGroup()).getDisplayName()
wait so what am i going about with that
What do you mean?
so how am i calling that in my method
plugin.luckapi.getGroupManager().getGroup(group).getDisplayName();
ooo i see i got u makes alot more sense now thank you alot bud helps so much very healful
helpful
np
Hi, I have a problem with getting user's group:
User player = manager.getUser(minecraftID);
if (player != null) {
String primaryRank = player.getPrimaryGroup();
event.getMessage().getChannel().block().createMessage("Rank: " + primaryRank).subscribe();
}
else {
return;
}
I have the user stored in LuckPerms/json-storage/users
player seems to be null all the time
I would use the userManager#loadUser(uuid)
hello, just checked the wiki quickly, i'm not perfectly sure if i am able to find any way to modify a user's prefix?
with that, i mean mostly a direct method from LP, not adding prefixes as permissions
!api try both of these links, including the javadocs which are here somewhere
Learn how to use the LuckPerms API in your project.
oh, must have missed this
// build a prefix node
PrefixNode node = PrefixNode.builder(100, "[Some Prefix]").build();
``` this one correct?
thiiinkkk so, you'd have to try (or wait for someone who really actually knows) cause idrk
Yeah that is what I use to modify prefix's @lucid rapids it should work
👍 with addNode right?
user#data#add(node)
yeah that
yeah
okay seems good, asynchronously or won't matter much?
I'd use loadUser just out of habit, but it shouldn't matter either way
loadUser just allows offline I believe
and thus access database and needs to be async
okay seems good, thanks!
np
Is it not currently possible to set meta data with the API as of now?
!api it is, check both of these links, should be there. If it's not, ask a really specific question
Learn how to use the LuckPerms API in your project.
weird, I found it, wasn't looking in the right place!
glad to hear it! 😄
UserDataRecalculateEvent is this event called when a player gets added to a node?
Yes. Plus a lot more, so be sure to filter for what you want
sweet. also, how can I get an instance of luck perms on a bungee cord server?
Learn how to use the LuckPerms API in your project.
sweet, thank you
You're welcome
how can I get what was updated in UserDataRecalculateEvent? can't seem to find anything
I just need to know if a node was given or taken from the user
It should have methods that tell you
User getUser();
CachedDataManager getData();
LuckPerms getLuckPerms();
Class<? extends LuckPermsEvent> getEventType();
thats the methods
getData?
Ah wait
Keep in mind that that event might have been triggered for various reasons
So either keep track of the relevant nodes yourself and look for changes or use another even
*event
do I check if a player has a group in bungee using if (player.hasPermission("group.admin")?
or do I have to do something weird like
CachedPermissionData permissions = user.getCachedData().getPermissionData(QueryOptions.defaultContextualOptions());
if (permissions.checkPermission("group.admin").asBoolean()) {
}
That should work
There's probably another way
But when you add someone to a group, if u check /lp user (name) permission info it would say group.whatevergroupname
https://hastebin.com/xevoputebo.java this doesn't print out "has group" even tho in the mysql database, I have group.admin
it prints out admin and owner from this .peek(System.out::println)
so getRanks() is not empty
Learn how to use the LuckPerms API in your project.
thanks. I just need to get a list of all the groups a user has access to
Wait i thhink i found it on the javadoc
Lemme link hold up
Oh shit u need all the ranks
Not just orimary
Ill keep lookin
http://prntscr.com/sch8o7
I did the command /lp user SimonM34 parent add admin and it made my primary rank admin, do you know why this is? does primary rank show the heaviest rank the player has?
thats exactly what I need 😛 I didn't know that
Lol alrighty
sorry about that
No api need? xD
well I guess not lol
thank you, luck perms really confuses me
The javadocs really confuse me lmao
actually
Idk it's unorganized
http://prntscr.com/schbj6
it says this, but when I do System.out.println(user.getPrimaryGroup()); it prints out default
Wtf
Heh
Try user. Getprimarygroup. Getweight if that exists
Sorry for caps
Im on mobile rn
If the weight is the admin's weight, ur good
getPrimaryGroup returns a string
Ye
Ik thats weird that it says default
What if u put default as a higher weight
Check if then it aays admin
BrainStone you got anything?
I set the default weight to 1000 and to 1 and it still returned default both times ;p
user.getNodes()
.forEach(node -> System.out.println("node: " + node.getKey()));
this also only prints out the default group when I have given myself admin group ._.
downloaded it like 10 minutes ago
Sometimes i forget lmao
Do you have context on either of the groups that might be excluding it
what do you mean?
It means like different weight for different worlds, areas, etc
Is the group added to your user with context
Delected weight is not per context except for prefixes and suffixes
I don't think so. all ive done is /lp user SimonM34 parent add admin
Delected, if you know what's going on, feel free to help out,, but if you don't, let's wait for BrainStone who knows a lot more about LPAPI than either of us
I was just helping him find methods off the javadoc
Ill literally readthe description
Hmm "which method is configured..."
I appreciate you helping tho
Not sure
That's in the config, where you set primary group calculation
!config check here to see what's up with why that method is returning what it is
Learn what each of the config options are for.
Just the api
The API might be different than in-game if it's configured different, no?
Hsve u changed config values for the calculator ?
well im using the bungee luck perms api
primary-group-calculation: parents-by-weight thats in the config
It should be as stated then, hm
Thats the one
Ok try amthn
Try using the set method
To set to admin
And then get it
Just to see what happens
You could also use GroupManager (the class, not the plugin) to check for the highest weighted rank iirc
it must be something wrong with how I am doing it. I removed the default rank and set the primary rank to admin and it still returned default ;-;
maybe the ranks haven't loaded yet?
@thick robin try saving and then do the age old turn it off and back on again
I may have not setup luckperms properly. could it be something to do with the bungee and spigot servers not communicating or its only setting the rank on the spigot server not the bungee?
Cause if you simply haven't synced, that's not a tough one to solve
Delected idek what you're on about tbh
whats the proxy commands?
Ok i thought i knew more than i did about bungeecord
I need to use it
All i know is how to set it up
Like configwise
still default -_- http://prntscr.com/schp8r
No. Don't do that.
/reload wot?!
Or restart w/e
Ok then stop and start smh
ive done that many times lol
Simon, the uuid mismatch error is what's concerning me
It's just quick
U on offline mode?
my spigot server is
You need a solid uuid for luckperms to know who you are
Make sure you have ip_forward, and online_mode true in the bungee config
Because when people's names change, there is no other way to tell eho thwy are on cracked
Uuids never change
And set bungeecord to true in spigot config.yml
Delected you're incredibly incorrect
Because when people's names change, there is no other way to tell eho thwy are on cracked
wottttttttttttt
cracked means no stable UUID mate
well they do, but its random
So u dont know
Larry how tf?
When you're on cracked, you are given a random uuid. If you change your name, it makes matters worse.
On non-cracked servers, even name change can screw things up for plugins w/o uuid support
Thus why luckperms has uuid support
That's what im getting at
Uuids never change
hM
Im saying on non-cracked
Best to get what you're getting at while you're getting at it
I guess that was the issue. http://prntscr.com/schttt the primary group is still default but now there is an extra node which I can use 🙂
Fantastic! Hope its all smooth sailing from here on out
thank you all for the help 🙂
Np!
PendingConnection connection = event.getConnection();
CompletableFuture<User> future = LuckPermsProvider.get().getUserManager().loadUser(connection.getUniqueId());
future.thenAcceptAsync(user -> {
if (user.getNodes().stream()
.anyMatch(node -> plugin.getRanks().contains(node.getKey().replace("group.", "")))) {
plugin.getDatabase().createSession(connection.getName(), connection.getUniqueId());
System.out.println("has group");
}
});
perfect 😉
Noice 👌
Try setting codeblocks like this, super cool:
```java
Code here
```
Or whatever language you write in, just about
Ohhh my display is screwy then, mb haha
Ye it doesn't show on mobile for some reason aaaa
I keep dissinmobike but it deserves it
Ok its 6:15 imma try to get at least 1hr of sleep today lmfao
Pce
night night
Hi, I have a question, what am I doing wrong here?
UUID mcID = Bukkit.getOfflinePlayer(minecraftName).getUniqueId();
minecraftID = mcID.toString();
User player = manager.getUser(mcID);
if (player != null) {
String primaryRank = player.getPrimaryGroup();
event.getMessage().getChannel().block().createMessage("Rank: " + primaryRank).subscribe();
}
else {
return;
}
I am trying to get a player's rank from LuckPerms
but player is always null
alright
is .subscribe() a JS function?
in that case, I cannot help
I know nothing abt JS
it's from Discord4J
it just sends a message
alright
equivalent to the JDA .queue I gotchu
actually when I got on my pc I'll send what I did for a mc -> discord "link" system
I used JDA but it stil lshould work just change it up a bit
I used a /link cmd on mc which would send you a code to type in on discord
is that what you're trying to do?
there's always DiscordSRV too lol
I have to do it myself 😦
No problem, take your time 😄
I didn't cover the rank sync but I could help w/ that too
I only did the /link cmd
since I gave up
after DiscordSRV
I just need rank sync + confirmation of link
I could always spoonfeed but I'll try to explain it while my pc loads
so basically what I did was
When a player runs /link, I would check if they were added to an arraylist called inQueue or smthn like that
if they were on the list, return because they already had a code
Yea, I store players' data in JSON file
alright cool
and so if not, generate a random code
then add them to inQueue
then on the discord side
I would check for the command !link (code)
if the code was in the list, it would store the player's link in a YAML file like so:
playeruuid, discordid
probs not the best way
I just wanted it done quickly
Okey
# so like:
players:
4faf8bf9-c59f-47b6-895a-af141434e787, 707919905978318860
would be mine
I don't remember exactly but it was similar to that
ofc there's more checks but I just didn't mention them since I'm lazy lol
ok lemme hop on my desktop
then I'll help w/ role sync
Thanks a lot!
Yes, Spigot + Discord4J
aight
Can we hop on DM? Then I'd be able to send you a little bit more maybe
If it's not a problem ofc
ok sure
hey guys
how can I change the group of a player using the api?
me.lucko.luckperms.bukkit.LPBukkitPlugin bukkitPlugin = (me.lucko.luckperms.bukkit.LPBukkitPlugin) eazyNick.getReflectUtils().getField(me.lucko.luckperms.bukkit.LPBukkitBootstrap.class, "plugin").get((me.lucko.luckperms.bukkit.LPBukkitBootstrap) Bukkit.getPluginManager().getPlugin("LuckPerms"));
me.lucko.luckperms.common.model.User commonUser = new me.lucko.luckperms.common.model.User(p.getUniqueId(), bukkitPlugin);
net.luckperms.api.context.ImmutableContextSet context = bukkitPlugin.getContextManager().getContext(p);
List<net.luckperms.api.node.types.InheritanceNode> nodes = commonUser.normalData().immutableInheritance().get(context.immutableCopy()).stream().filter(net.luckperms.api.node.Node::getValue).distinct().collect(Collectors.toList());
if(!(nodes.isEmpty()))
commonUser.unsetNode(net.luckperms.api.model.data.DataType.NORMAL, nodes.get(0));
commonUser.setNode(net.luckperms.api.model.data.DataType.NORMAL, me.lucko.luckperms.common.node.types.Inheritance.builder(groupName).withContext(context).build(), true);
commonUser.getPrimaryGroup().setStoredValue(groupName);
} catch (Exception e) {
}```
this is what I tried, but it didn't work
change the primary group?
that didn't work either
Primary group changes don't have an effect iirc
depends
on config
This modifies the "stored value" for the users primary group, which may or may not actually take effect, depending on how the platform is calculating primary groups.
IllegalStateException - if the user is not a member of that group
Anyways, why are you not using the API?
so that won't work
Anyways, why are you not using the API?
@neat jackal because I couldn't find a way to do it with it
Hey Justix! Please don't tag helpful/staff people directly.
you sure can
how
we'll help you if you get the API
that was my only question
Just add an InheritanceNode to the Users' data
how can I do that?
!api that should cover most of that
Learn how to use the LuckPerms API in your project.
or you could just uhh
setPrimaryGroup() if you have it setup correctly
just an easy way out
IllegalStateException - if the user is not a member of that group
wtf why would it throw ise
idk
https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#modifying-usergroup-data that is the most relevant section, just use InheritanceNode instead of Node and then provide the group name in the builder
Then save the user using that method: https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/model/user/UserManager.html#saveUser-net.luckperms.api.model.user.User-
and how can I unset all other groups?
Get all other group nodes and remove them
Something similar is described on the docs here, so you can get all group names (or don't use group names and use a Set<InheritanceNode> directly) a user has and then loop trough them
user.data().toMap().values().forEach(node -> node.stream().filter(node2 -> (node2 instanceof InheritanceNode)).forEach(node2 -> user.data().remove(node2)));
like this?
or like this: ```ArrayList<net.luckperms.api.node.Node> toRemove = new ArrayList<>();
user.data().toMap().values().forEach(node -> node.stream().filter(node2 -> (node2 instanceof InheritanceNode)).forEach(toRemove::add));
toRemove.forEach(node -> user.data().remove(node));```
Both seem as they could work, try it out
You also have to save the changes. Don't forget that.
I did
ArrayList<net.luckperms.api.node.Node> toRemove = new ArrayList<>();
user.data().toMap().values().forEach(node -> node.stream().filter(node2 -> (node2 instanceof InheritanceNode)).forEach(toRemove::add));
toRemove.forEach(node -> user.data().remove(node));
user.data().add(InheritanceNode.builder(groupName).build());
api.getUserManager().saveUser(user);
Try it out, I have no idea if it actually does, but if it does, great!
Don't know how much simpler this is but to me this is easier to understand and a bit cleaner imo but to each their own
Set<String> groups =
permission.getUserManager().getUser(playerUUID).getNodes().stream()
.filter(NodeType.INHERITANCE::matches)
.map(NodeType.INHERITANCE::cast)
.map(InheritanceNode::getGroupName)
.collect(Collectors.toSet());```
But I guess if you want to store them all as nodes your way may make more sense
anyone got any idea on whats it with the prefixs of players it will only show when a player is online eg https://gyazo.com/3edecc004a2bbd1b8620fab9ac19f9ff others players should have prefix also however when they are offline they is not shown
have the same issue now, think you need to use the UserManager#loadUser(uniqueId) method
appears getUser might only be for online players, correct me anyone if i'm wrong
o really i shall look at that now
I confirm
so i tried this but i assume that is wrong as the orefix is not loaded at all now
Haven't had it tested yet but this should work for @scarlet harness 's problem
CompletableFuture<User> userFuture = permissions.getUserManager().loadUser(player.getUniqueId());
AtomicReference<String> prefix = new AtomicReference<>("");
userFuture.thenAcceptAsync(user -> {
ContextManager contextManager = permissions.getContextManager();
prefix.set(user.getCachedData().getMetaData(contextManager.getQueryOptions(user).orElseGet(contextManager::getStaticQueryOptions)).getPrefix());
}).get(5, TimeUnit.SECONDS);```
If you don't mind about long wait time (e.g. not waiting on it for an event like a login) feel free to remove the .get() params
and use prefix.get() to get the string
@scarlet harness remove the cast in the 3rd line and add .get()
You can't just cast a completable future into a string
And I'd recommend that you print the exceptions for debugging
Else you'll never know what's going wrong
And be sure to not run the code sync (aka on the main server thread)
Does this go under onEnable?
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
LuckPerms api = provider.getProvider();
}
This is my main class with it. (Ive never used an api before)
https://pastebin.com/UBFfvdCF
Im just trying to be able to set users permissions
@tired sequoia you'd need to assign a variable of LuckPerms outside your onEnable()
Do I also need it in the onEnable
would be like
private LuckPerms luckPermsAPI;
public void onEnable() {
...
//do your service checks before
luckPermsAPI = provider.getProvider();
}
public LuckPerms getLuckPermsAPI() { return luckPermsAPI; }```
nono you aren't caching the service
I'm confused. Sorry.
Im looking up other tutorials on youtube about using an api and none are like luckperms
@tired sequoia I mean he put the code right there
When I put what he put I get errors
Though frankly you only need to get API in classes where you need that
Like what?
Oh he edited the code thing
one sec
so this would work then correct?
https://pastebin.com/UBFfvdCF
and i could do Main.getLuckPermsAPI().methodExample()
You posted the wrong link
That would work
ty
And no, you need an instance of your plugin
But then it would work
But again
I'd recommend you only get the API in classes you need them in
Unless it's a lot of them
ok
In that case you make a helper class
That may even hold some common functionality
Like getting the prefix
So the API is only ever inside that helper class
ok. Thank you
You're welcome
has #data changed?
What do you mean?
On the wiki it says in order to change someones permission you can do this
DataMutateResult result = user.data().add(Node.builder("your.node.here").build());
wait
I messed up something
I needed to cast player to user
No
You need to get the user
If you're casting there's a 99% chance you're dong it wrong
Unless the classes are in a direct relationship
Like casting Nodes to InheritanceNodes
Oh yeah not casting.
After checking they are InheritanceNodes
What would be better, loadUser or getUser
What do I do with DataMutateResult?
public static void lpAddPerm(Player player, String... perms) {
User user = Utils.loadUser(player);
for(String perm : perms) {
DataMutateResult result = user.data().add(Node.builder(perm).build());
}
luckPermsAPI.getUserManager().saveUser(user);
}
thats my method
but there is the DataMutateResult type just sitting there. I know I'm missing something but idk what.
Ignore it
Don't capture it
Don't care for it
Just because a method returns something doesn't mean you need to care for it @tired sequoia
You're welcome
a
wut
Here's a command that I've been working on for a server I'm developing... For some reason I cannot get the MetaNode node to change their metadata? Any help?
public class rankup implements CommandExecutor {
Economy econ = Core.getEcon();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
EconomyResponse canRank = econ.withdrawPlayer(player,prisonUtils.rankValue(player));
double newRank;
newRank=prisonUtils.getPrisonRankInt(player)+1;
String nextRanked = prisonUtils.getRankFromInt(player,newRank);
if (canRank.transactionSuccess()){
MetaNode node = MetaNode.builder("prison_rank",nextRanked).build();
prisonUtils.printMessage(player,"You ranked up to "+prisonUtils.getPrisonRank(player)+"&7 for &a"+econ.format(prisonUtils.rankValue(player)));
}else {
prisonUtils.printMessage(player,"&cYou cannot afford to rankup to &f"+nextRanked);
prisonUtils.printMessage(player,"You still need &c"+econ.format(prisonUtils.rankValue(player)-econ.getBalance(player)));
}
return true;
}
}
!api
Learn how to use the LuckPerms API in your project.
@hardy badge well, you’re not doing anything with the node after you created it. Not sure what you’re expecting
Can you create a group using the API instead of commands?
How would I build the node then?
@hardy badge I mean that's how you build the node
But you're just not doing anything with it
@young vault yes
!api Check the methods of the GroupManager in the javadocs
Learn how to use the LuckPerms API in your project.
How would I apply it to the player then?
Thanks.
!api @hardy badge
Learn how to use the LuckPerms API in your project.
You need to add it like you would with any other node
I mean look at this line:
MetaNode node = MetaNode.builder("prison_rank",nextRanked).build();
How is that ever going to get assigned to a player?
The player isn't even mentioned at all
And the variable is unused
(Which your IDE should warn you about btw)
Okay, I've rewrote it using the DataMutateResult, but I now see the result of that being unused. Thoughts?
if (canRank.transactionSuccess()){
User user = api.getUserManager().getUser(player.getUniqueId());
MetaNode node = MetaNode.builder("prison_rank",nextRanked).build();
DataMutateResult result = user.data().add(node);
api.getUserManager().saveUser(user);
//getServer().dispatchCommand(getServer().getConsoleSender(), "lp user " + player.getName() + " meta set prison_rank "+nextRanked);
prisonUtils.printMessage(player,"You ranked up to &f"+nextRanked+"&7 for &a"+econ.format(prisonUtils.rankValue(player)));
}else {
prisonUtils.printMessage(player,"&cYou cannot afford to rankup to &f"+nextRanked);
prisonUtils.printMessage(player,"You still need &c"+econ.format(prisonUtils.rankValue(player)-econ.getBalance(player)));
}```
Don’t store return values you’re not using @hardy badge
So don’t store the data mutate result
Okay yup, i got that working, next problem is I need to actually set the value, rather than adding a new one (:
Remove the old one and set the new one
I've been trying that, but when I check using the DataMutateResult, it shows it was unsucessful
User user = api.getUserManager().getUser(player.getUniqueId());
DataMutateResult result = user.data().remove(MetaNode.builder("prison_rank",prisonUtils.getPrisonRank(player)).build());
user.data().add(MetaNode.builder("prison_rank","A2").build());
staffUtils.informativeMessage((Player) sender,"Your prison rank is: "+prisonUtils.getPrisonRank(player));
staffUtils.informativeMessage(player, String.valueOf(result.wasSuccessful()));
Oh i found it
I'd recommend using streams to find the other node to remove it
Hi!
How get primaryGroup for oflinePlayer?
Because If the user was not on the server after starting the server i have NPE
net.luckperms.api.model.user.User.getPrimaryGroup() is null
i think, i need load user:
getUserManager().loadUser(Bukkit.getPlayer(user).getUniqueId()).get()
Load a user using loadUser & get the primary group in a CompletableFuture @flat void
I need this methods for LuckPerms:
PermissionsEx.getPermissionManager().getUser(p).getPrefix()
PermissionUser user = PermissionsEx.getUser(p);
PermissionsEx.getPermissionManager().getGroup(g).getWeight();
!api
Learn how to use the LuckPerms API in your project.
Hey, I have a method like that to save a user after modifications :
private static void saveUser(User user) {
luckPermsApi.getUserManager().saveUser(user);
}
Should it be called async or not necessary, because it's a save in the database for example (I use mariaDB) ? Thanks 🙂
To my knowledge it's run async.
I'm trying to auto-rank people in a custom plugin, I tested this originally and it appeared to work but recently it didn't promote a real user and threw no errors. Any ideas?
User user = api.getUserManager().getUser(p.getUniqueId());
ImmutableContextSet contextSet = api.getContextManager().getContext(user).orElse(api.getContextManager().getStaticContext());
api.getTrackManager().getTrack("default").promote(user, contextSet);
Make sure to save the changes to the user @twilit jasper
ok, didn't know that was a thing. Is this how? api.getUserManager().saveUser(user);
Yes
Hello, how can i set player meta with the help API?
!api
Learn how to use the LuckPerms API in your project.
@mossy grotto I think it would fall underMetaNode
Thank, i already found
is it possible to change the primary group through a custom plugin with the api i have my script here I'm setup to an sql database but when i run the code the primary group stays as default
UserManager userManager = api.getUserManager();
if (!player.isOnline()){
throw new IllegalStateException("Player offline");
}
User user = userManager.getUser(player.getUniqueId());
Group group1 = api.getGroupManager().getGroup(group);
System.out.println(group1);
if (group == null){
System.out.println("Returned");
return;
}
user.setPrimaryGroup(group1.getName());
System.out.println(user.getPrimaryGroup());
userManager.saveUser(user);
} ```
any help would be apreciated
or is there anyway to do an rank up system through code?
!api @gray agate
Learn how to use the LuckPerms API in your project.
Alright thank you
public static DataMutateResult setPrefix(String playerName, String prefix) {
User user = LuckPermsProvider.get().getUserManager().getUser(playerName);
PrefixNode prefixNode = PrefixNode.builder(prefix, 100).build();
user.data().add(prefixNode);
LuckPermsProvider.get().getUserManager().saveUser(user);
return LuckPermsProvider.get().getUserManager().getUser(playerName).data().add(MetaNode.builder("prefix", "100").build());
}
why doesnt it work, help please)
@mossy grotto
a) use a prefix node
b) you need to save changes to the user
c) unless you really need it, you don't need to care for the DataMutateResult
d) Have a look here: https://github.com/LuckPerms/api-cookbook
thank you, but i have trouble, when add prefix, then remove it
how remove old player meta/
Find the node in the existing ones and remove it
Thanks BrainStone ! But sincerely, is it useful to manually save the user after modifications, or it will be saved automatically after 🤔
You need to save it
before changing a user's group would one need to load that users before then saving it
or does anyone know a reason why User.setprimarygroup would fail?
they need to already be a member of the group
the way group memberships are set is using inheritance nodes
see here for an example
ok that makes sense thanks alot
Ok so it seems like my auto-promote code works temporarily, but then after some time they're back to the original rank
User user = api.getUserManager().getUser(p.getUniqueId());
ImmutableContextSet contextSet = api.getContextManager().getContext(user).orElse(api.getContextManager().getStaticContext());
api.getTrackManager().getTrack("default").promote(user, contextSet);
api.getUserManager().saveUser(user);
my player says this ran once and didn't promote her at all, then ran later and did promote, but after switching worlds and typing in chat she was back down at the original rank. I have this code running every hour on players whose playtime meets a min requirement for the next rank
ok it seems like teleporting worlds is key
my player thinks she got the right rank once she returned to the main world
and she died and is back to default rank
so that code above isn't saving
here's my full file. this task runs every 10 mins to check playtime and auto-promote. everything works except the save https://hasteb.in/noyakuwo.swift
ok confirmed it happens on death. sorry for wall of text!
ok so I watched. user in my group "respected". player dies. is back to group "default". player teleports home, get "respected" back. none of my code ran during this phase, only for the initial promotion
all in the same world
ok running through a debug, it fires and seems like it's promoting but doesn't.
[08:44:36 INFO]: user: me.lucko.luckperms.common.api.implementation.ApiUser@f41af24
[08:44:36 INFO]: contextSet: ImmutableContextSet(contexts={gd_claim=[5aa6bebc-1e40-43b2-9923-a3eb36a9e28d], server=[global], world=[world]})
[08:44:36 INFO]: res.getStatus(): ADDED_TO_FIRST_GROUP
[08:44:36 INFO]: res.wasSuccessful(): true
but immediately running /lp user [user] info still shows them in the default group
it's because you're promoting using their active context
so when that context changes, the promotion no longer applies
so just promote using
api.getContextManager().getStaticContext()
in your case, griefdefender claims and worlds are affecting active context
ok thanks! when I asked how to get the right context, I did feel a little unsure it was right for my needs
a few days back
well to be fair that's a tricky question to answer
because if you're querying permissions, it doesn't matter if you have a few extra contexts in there
generally, you want as many as possible, so using the active contexts is perfect
understood, that makes sense
but when you're setting new nodes, you need to decide where you want the node to apply
ya I felt I was clear on my use case, but anyway that's seems like it's clearly my problem
I wasn't blaming you :p
i'm sure you were clear too, it's just it can be tricky to understand, that's all haha
I didn't think you were, I was just saying, I should have been more questioning when I accepted the code the first time I asked
also lp is amazing btw, as someone who used pex for ~6 years it's like night and day. command auto-complete helps, but the commands are so straight-forward and consistent
I am going to make a tablist with that owner is on the top etc
Do i need to add the API for that?
Perhaps, depending on how advanced you want the group calc to be. If you just want to use primary group on top you can just use vault afaik. If you want something more advanced and LP specific, you'll need the LPAPI
The colour is set by luckperms, ideally, so you don't really need to worry about that in your plugin. I'd suggest taking a look at how TAB manages to order the tablist to get a better look at what you're going for- TAB orders it by group name through vault afaik
but how would i do so that owner is on top etc with Vault?
or thats not gonna be asked here
Well, have your plugin look at a players primary group
And order it by name of group
can't i use the weights?
what are you trying to do?
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if(provider !=null) {
LuckPerms api = provider.getProvider();
}
}```
Make luckperms as a dependency