#luckperms-api
1 messages · Page 15 of 1
give me second
And yes you can do it in stream
i need to somowhere add UserManager::loadUser to the stream
Expect that you need to do it on an instance of UserManager
yes
so u wont tell me ? 😄
If you can't do it with streams do it without
No
im just kidding
This is refusing to spoonfeed
thats good
forEach(user1 -> userManager.loadUser(user1.getUuid())) am i getting at least closer ?
yeah
Now use map instead of forEach
ooh
i think
that now im stuck
lemme try using more google
Map<String, String> fest = this.plugin.api.getUsers().stream().map(user1 -> userManager.loadUser(user1.getUuid())).collect(Collectors.toMap());
am i at least somehow close ?
or completely wrong
Hey Poggik! Please don't tag staff members.
Please don't ping me
sorry
okay before u go
Map<String, String> players = this.plugin.api.getUsers().stream().map(all -> userManager.loadUser(all.getUuid())).collect(Collectors.toMap());
where should i handle that future
from loadUser
still in map ?
or in Collectors.toMap
ur the only that can help me now
@echo harness you’re also getting a warning for repeatedly DMing after being told several times to not do it
ok
3rd warning gets you a kick, 4th a ban. Just so you are aware
ok
u wont help me anymore am i right ?
its just a little issue
duplicate keys lol
after all this bully from java
Please tell me you are actually trolling not that stupid...
Please tell me you’re just messing with me and do actually have the capability to read and comprehend what I’ve said...
i was joking lol
but now i really need help
ooohh
i know
its because luckperms still has in storage old uuids from old db
so multiple uuids goes to one name
but this is weird
key is the first thing in map right ?
but group should be value
so why does it say duplicated key and it shows group name
fixed
hey cna someone help me setting up a plugin
i cant make my friends tp
how to do it
how to i run /lp sync through a api call
LuckPermsApi#runUpdateTask
Hello.
When I use Vaults API to add a permission to a player, it defaults to the world they are in.
permission.playerAdd(player, permNode)
If possible, how can I make it default to global instead?
Specify a null world param
Where do I specify that? I didn't think playerAdd had a world param.
Oh, that does exist, just the params are a different order. 😆 Thanks Luck.
playerAdd(String world, OfflinePlayer player, String permission)
@jaunty pecan you should make your dependency component a separate plugin to help other devs fight obesity (fat jars)
Hey Aerocet! Please don't tag staff members.
It is a open source library @sonic flare
well luckperms is open source, but the dependency part is integrated
oh
neat
Pretty sure that’s not even it XD
But Luck should know. Let’s hope he’ll check this out soon 😉
I haven't attempted to use it yet so I'm not sure
all I know is that the maven central dependency downloader has hard-coded dependencies in LuckPerms
How would I remove a group from a player?
Like not setting the primary group
Because they might have one already
@ripe thorn do u know?
Hey Artuto! Please don't tag staff members.
I don't suppose anyone has made a NodeJS API for LuckPerms? Figured I'd better ask before making my own lol.
@jaunty pecan @sonic flare is interested in your maven downloader.
I though it was a separate project you can add to your own projects
the look in that cat’s eyes indicate we are not seeing a stand-alone any time soon lol
hmm maybe
I'm rebuilding my server's website and using a js backend to power it, need something to look up player data. Looks like I'll just have to make something myself.
Maybe just get info from db
or if that's not possible spin up webserver on one server using plugin and get data you need from lp api xd
Yeah I'm just gonna use a JS ORM like Sequelize to hook into the database directly
definitely better to query the db directly
now i just need to figure out how to generate a random string in game and store it in player meta
should be pretty easy even with my terrible java knowledge 😆
How do I remove meta keys based on key? I can remove a meta value via unsetPermission but that requires I know both the key and the value
@languid pike get the map of meta values and get the value from that
There also might be a method to directly remove the meta value
Ye. That's the way I'm currently doing it. But I noticed the /lp command is able to remove via keys
I tried digging into the source but it uses a PermissionHolder not User
An User is a PermissionHolder iirc
Check the inheritance tree of that interface
@languid pike
Alright. I appreciate the help
Hello i got this problem while launching with the newest version of spigot 1.13.2:
[23:33:40 INFO]: Set PluginClassLoader as parallel capable
>WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by me.lucko.luckperms.common.dependencies.classloader.ReflectionClassLoad
er (file:/home/server/Desktop/Server/plugins/LuckPerms-Bukkit-4.3.17.jar) to method java.net.URLClassLoader.
addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of me.lucko.luckperms.common.dependencies.classlo
ader.ReflectionClassLoader
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Any help?
Ignore it
It's just a warning and as of right now there's no alternative way to accomplish what the plugin is attempting to do which is causing that warning.
Can you use the Luckperms API over bungee? eg I am making a Staff List plugin for a bungeecord server and want to get all the people in group owner and then display them?
Never tried myself but I would assume so.
Okay thank you
Assuming you have a proper network setup, it’ll work just fine
Hello, how do i hook into bungeecord version of LuckPerms ?
Via LuckPerms.getApi()
The API is the same on all platforms
How do you get a group prefix, I have got the players group with LuckPerms.getApi().getUser(player.getUniqueId()).getPrimaryGroup())now I need the prefix from that group?
Don't worry I worked it out
Hello all 😃
is here someone how have time to give me a short intro to the API? I knew there is a wiki, but ive readed it and dont know how to begin...
Dont hate me.. I want only to learn
If you have specific questions, ask them
But don’t expect everything to be handed to you on a silver platter
nevermind...
We’re here to help you. Not to teach you everything
That’s the wiki’s job
So feel free to ask specific questions.
i just want to create a node with one permisson for an specific time... and only in one world
or how i set an expire for an node
Are you using an IDE?
i use intellij
If you are use a NodeBuilder, see what methods are there
One should be for the time
And it expects a Unix timestamp
So an end time
Not a duration
Node node = api.getNodeFactory().newBuilder("essentials.fly").build();
this is what ive atm... this is only a node with one permisson and nothing else i think is it right?
Yes
And yes can add more methods before the build method
Your IDE’s autocomplete should help you with finding the name
Node node = api.getNodeFactory().newBuilder("essentials.fly").setExpiry(time).setServer(server).setWorld(world).build();
so this should work? when i have the variable time server etc?
and i think the Expiry exept an unix time when it expires?
Yes yes and yes
Though you don’t need the server and world
Unless you want to of course
yeah i want that the user can only fly in one specific world
then thank u
exept it a unix time stamp in milli sec or in sec
?
u here ?
Yes
I already saw it
this is how u get instance of api
and how to add it as depedency in your plugin
if i use like
and this is how u use it (https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage)
if you already have api instance obtained
LuckPerms.getApi().getUser(p.getUniqueId())
But when i press . to see the syntaxes that i can use
so u dont call for new instance every time
u put this in oneanble ``` RegisteredServiceProvider<LuckPermsApi> provider = Bukkit.getServicesManager().getRegistration(LuckPermsApi.class);
if (provider != null) {
LuckPermsApi api = provider.getProvider();
} ```
u dont need to actually put it in onenable
but thats just how i do it
@granite spade
keep in mind that if u put it in onenable and u then use api outside of onEnable u need to check if api is not null
otherwise u will get nullpointerexception if api is not loaded
I'll not use out
i'm going to make a factions tag in tab and player head
only going to use a bukkit runnable
in on enable
ok
just store that api in variable outside of scheduler
so u wont obtain new instance every time
ok ;-;
https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#retrieving-prefixessuffixes and this is how u get prefix or suffix
np
didn't saw it
I downloaded the plugins i was told to download on the wiki
"To use the LuckPerms placeholders in plugins which support Maximvdw's MVdWPlaceholderAPI, you need to install the LuckPerms placeholder hook plugin."
I use deluxe Hub for the scorteboard to pop up.
https://gyazo.com/3a5b07c49d32381a5a33b91ea99cb91c
what I have in my config:
Scoreboard_Title: "&d&lWoolstonecraft"
Scoreboard_Lines:
- ""
- "&e&lPlayer:"
- "&f%player%"
- ""
- "&b&lRank:"
- "%luckperms_prefix%"
- ""
- "&a&lMoney:"
- "&f%tne_balance%"
- ""
- "&cOnline:"
- "&7%online%/%online_max%"
- ""
- "&6Thanks for playing!"
Its not working and was wondering why, I get no errors in logs/consale..
Thanks,
Me
@undone spire use %vault_prefix%& for the rank
do u have placeholderapi
yes both of them
do /papi ecloud download vault
then retsrta??
no just papi reload
xD yw
wait now my balance fucked up
um
vault?
whats ur econ plugin?
The new ecomomy
do u have vault tho?
do u use placeholderapi or the other one for the placeholder
II use placeholderAPI and Maximvdw's MVdWPlaceholderAPI
I only downloaded the 2nd one casue luck permns said i needed too
or the econ plugin?
I dident know i cans set it it just did it for me
loaded the plugin in set the placeholders and it worked
the money only changed when i did that papi thing
oh ok
try vault_eco_balance_formatted
so technically i wouldent even need the new econmoy plugin
swwet going to look up the placehodler
%vault_eco_balance%
%vault_eco_balance_fixed%
%vault_eco_balance_formatted%
try %vault_eco_balance_formatted%
thats what i use
xD
thanks bro
aight thanks ❤
sure
@real lotus
?
what app are u using for ur plugins too look like that
filezilla
what do u use to config/edit them
notepadd++
anyone selling custom tab or scoreboard plugin
How do i get luckperms api for bungee?
api for bungee should be completely same as bukkit/sponge one
how can i get the heaviest prefix of a group? Im not that good at coding and i dont know Stream API
metaData.getPrefix(); wont return heaviest prefix ? @silver sleet
is there a way to pull the player's group using the luckperms api?
Yes, User (iirc) has a method akin to getOwnNodes; which will return only directly granted nodes, then you just pull out the group ones (method on Node to check, iirc)
how can i get a groups displayname?
oh wait
you can do getPrimaryGroup
its same
it dont think there is much difference
nah, i want the displayname because i've set one with /lp group setdisplayname
ok wait
I'll try out friendlyname
try it
wait
but there is getDisplayName
are you sure you have group instance ?
not user ?
becase friendly name is for user im pretty sure
which version?
4.3
oh wait
i think it same
i think my api was outdated
but maybe theres some difference
i don't think you thought that
Can someone help me? I have luckperms on my bungeecord but any of my bungee plugins who use hasPermission works
Example: my broadcast bungee plugin says i have no permission to use the /bc
Can someone help me with this?
this is how you start getting events? https://github.com/LibertyLand/LibertyLand-Bot/blob/master/src/main/java/tk/liblnd/bot/Listener.java#L44-L46
LibertyLand's Discord Server Bot | https://discord.gg/kcGUDFd - LibertyLand/LibertyLand-Bot
looks good to me
I see
@silver sleet can I see the actual code that prints the command and executes it?
And the command itself?
wait i found something
System.out.println("luckperms user " + playerValues.get(player).get(0) + " parent set " + playerValues.get(1));
But i think i found the error
Yes, i found it, it was just my incredible skill
And the fact that i can't read
Yeah. I think I see it too
That’s why you should store the object you get back from the first get in a variable
That’ll also improve performance as you only need to perform one lookup
Hello,
i'm new by luckperms developing, now i have a problem :D
I want to set with command /setdefault <name> default group but my code not work by luckperms he dont become the new group
MyCode Line:
LuckPerms.getApi().getUser(args[0]).setPrimaryGroup("default");
Pretty sure getUser needs uuid
so you can just do Bukkit.getServer().getPlayer(args[0]).getUniqueId()
@nocturne elbow
and if you want to make it work for offline players you would need to do loadUser instead of getUser
@nocturne elbow check the wiki. It has examples on how to set a player’s group
How do you update a players group I have tired LuckPerms.getApi().getUser(player.getUniqueId()).setPrimaryGroup("owner"); but this is not working
I have also tired doing LuckPerms.getApi().getUser(player.getUniqueId()).setPermission(LuckPerms.getApi().getNodeFactory().makeGroupNode("owner").build()); LuckPerms.getApi().getUser(player.getUniqueId()).unsetPermission(LuckPerms.getApi().getNodeFactory().makeGroupNode(LuckPerms.getApi().getUser(player.getUniqueId()).getPrimaryGroup()).build()); but still does not change the players group
@ripe phoenix make sure you work with the same user object (store it in a variable)
You also should do that with the API. For readability reasons here
And lastly you need to save the changes
I recommend you checking the wiki for examples
Ahh got it working now thanks @crystal sonnet
Hey HuskyPlays! Please don't tag staff members.
Ohh sorry didnt know I couldnt @
Replying is ok
The bot doesn’t know when it’s ok and when not
Glad it’s working now
How can i get a player from a user?
Get the UUID and use the platforms methods to get the player @silver sleet
how to use prefix
And I think you need vault for the displayname to contain the prefix and suffix
i do have vault installed
Then you’ll probably have to use vault to get them
And I’m 100 certain that if it’s a Bukkit/Spigot/Paper method they’re referring to team prefixes and suffixes
i have found a video called Spigot Coding Episode 2 Hooking into Vault for Chat Prefixes that sounds legit to me
Yup
Is there an event called for when a timed permission expires?
No
yes there is
NodeRemoveEvent
check if the node is temporary & past the expiry time
Since when does this exist/work for temp perms?
has done for as long as I can remember :p
How do I get the context of a group?
Contexts contexts = LuckPerms.getApi().getContextManager().getApplicableContexts(group);
Like this?
I would like to get the suffix of a specific group.
Sorry if this question is commonly asked -
When unsetting a meta node, do I need to supply the value to it, or does it only lookup the key?
permsUser.unsetPermission(nodeFactory.makeMetaNode("dynmap-claim-colour", "").build());```
Hrrm, setting a meta twice seems to duplicate the key so I guess keys are non-unique
How can i get the Displayname from the Group
I use This to geht the Group
LuckPermsApi api = LuckPerms.getApi();
User user = api.getUser(p.getUniqueId())
String GroupName = user.getPrimaryGroup();
morning
i'm not sure how i can overwrite player's permission node
let's say i store certain data in user's meta
i want to get it, set its value and set it back
@hardy vapor I've replied on github 😃
@nocturne elbow Yes, the value is ignored when unsetting
Great, thank you
@nocturne elbow You'd need to unset the existing node, and then add a new node with a different value
clearMatching might come in useful for clearing
yep
i was thinking about getting existing node, calling toBuilder() on it and then trying to set it lol
i have no idea why i expected that, i guess 5am & overtiredness fucks me up :D
Eh that could be a reasonable expectation
but ya it doesn't work like that in this case
:p
Hello. I already subscribed to PostSyncEvent.class which is working fine when making changes on only one server. However, when I change groups via BungeeCord /lpb then PostSyncEvent.class won't be triggered. I found nothing like PostNetworkSyncEvent.class. Is there something similar?
Maybe you need to make bungeecord plugin for that to work
Hmm but theres a PreNetworkSyncEvent.class that works. But I need a event after the sync is finished.
That might be an actual bug. The PostSyncEvent not being fired after the Network Sync
Though only Luck knows for sure
Okay, if it's only a bug and should normally work, that would be nice.
How do I set up the user group as a start?
thx
Wait ... without putting the name .. a player as soon as you enter you must have that group
Enter for the first time on the server and you must have as default group
so I have to type this command / lp user nick parent set default only the first time and that's it?
how do I configure the default rank?
@celest oracle #support-1
Hey @nocturne elbow are you super super sure? :p
just saw your github issue & checked the code
Mhmm not super super sure... But tested it a few times and it won't be triggered. I can try one more time and also check mine... Gimme some minutes.
the post sync event is definitely called each time a sync occurs
It won't be called however if you cancel the PreSyncEvent
or the network pre sync event
Sure you are sure that if the bungeecord plugin performs a sync, my spigot plugins also get notified via the PostSyncEvent?
I'll try...
or in other words
if the PreSyncEvent is called, and is not set to cancelled, then the PostSyncEvent should definitely be called sometime afterwards
Ok, I tried /lpb user Rasre parent set leitung which gives me [22:56:44 INFO]: [LuckPerms] [Messaging] Received user update ping for 'rasre' with id: b695db70-ead7-4b30-ada5-82a10f35a45d on my lobby server. So I'm assuming that plugin messaging is working correctly?
Oh
only a reload of that users data
Okay /lpb networksync works fine I see
Mhmm
So is there an option to enable a full sync for incoming ping?
Or an event I can listen to
Just to get the event working XD
Do you just want to listen for when users are updated?
Yes
Well, that would be nice. Let me try.
or more generally when any User related data changes
UserDataRecalculateEvent is called
Aww that works like a charm 😄
Okay, then I'll use UserDataRecalculateEvent for that
I'm listening to this now:
eventBus.subscribe(UserDataRecalculateEvent.class, e -> refreshAll());
eventBus.subscribe(PostSyncEvent.class, e -> refreshAll());
eventBus.subscribe(NodeAddEvent.class, e -> refreshAll());
eventBus.subscribe(NodeRemoveEvent.class, e -> refreshAll());
eventBus.subscribe(NodeMutateEvent.class, e -> refreshAll());
you only need to listen to UserDataRecalculateEvent
and then refresh data for that specific user
that will cover all of the other events too
how do I add people to groups? I started a server and I am trying to give people permissions but I can't add them to the groups that have permissions
so I added the permissions and it still says that people don't have permission for that command?
#support-1 please, this isn't the channel for that
unless you're actually referring to the API, I can't really tell.
Is it possible to use PlayerLoginEvent or PlayerPreLoginEven instead of PlayerHandshakeEvent for BungeeGuard?
I'm by no means an authorative figure on Spigot 1.8, but I don't think it is
You can try it
No, it's not possible
The general gist here is that paper exposes some information in that event which bungeeguard can use to determine if the connection can proceed (i.e. passing along the secret in the players connection)
And vice versa!
Is it possible to use PlayerLoginEvent or PlayerPreLoginEven instead of PlayerHandshakeEvent for BungeeGuard? Sorry for tag but i want to ask @jaunty pecan
Hey Lobenski! Please don't tag staff members.
electronicboy already explained
How to get server name where user has for example permission group.Member?
Hello! i had a question. so for my server i just installed Luckeyperms and was havving issues with players not being able to open chests, is there a permission that would enable them to do so. also if not already, other basic minecraft things? the chests are not near any spawnpoint and i do not have a chest protection plugin unless factions is considered one.
"Luckeyperms" 🤔 that's a new one. Anyway this is the #luckperms-api channel which is not relevant to your issue, please use #support-1 for general LP questions.
ah i see thank you
Hey Segysmundo! Please don't tag staff members.
hello i have a question: when i have a bungee server, do i have to put the plugin right there?
ok ty!
So I have what I would think to be a pretty simple task. I've hooked the EssentialsX API and I'm listening to the AfkStatusChangeEvent. This works great. When the user is afk, I want them to be added to the group called "afk". When they are no longer afk, I want them to be removed from the group.
This method is identical to its counterpart, except for the fact that the last line changes to user.unsetPermission(node);. The documentation leaves some to be desired, like what a "node group" is, but I've cobbled the following together. Issue is, when the user becomes AFK, their parent groups don't change and their permissions don't change, so I'm not entirely sure what I'm doing.
public void addToGroup(Player player, String groupName) {
User user = loadUser(player);
Group group = luckPermsApi.getGroupManager().getGroup(groupName);
if (group == null) return;
Node node = luckPermsApi.getNodeFactory().makeGroupNode(group).build();
user.setPermission(node);
}```
Could someone point me in the right direction for this?
after calling setPermission or unsetPermission, you need to save your changes
Oh, right you are.
This is explained both on the wiki (https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#saving-changes) and in the code itself (https://github.com/lucko/LuckPerms/blob/master/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java#L435-L439)
Yeah, I just found that section. I was sorta skimming through trying to find how to add a user to the group. That's on me for missing it.
Mhmmm
Let me restart the server and I'll let you know what happens.
You can also save on having to do that by using setTransientPermission
otherwise LuckPerms is going to be reading/writing to the database everytime a players AFK status changes
more info here: https://github.com/lucko/LuckPerms/blob/master/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java#L477-L498
Orrrrrr
Use ExtraContexts (https://github.com/lucko/ExtraContexts) to make an AFK context, which will allow you to do things like /lp group default permission set anticheat.bypass afk=true or something like that
Though wouldn’t that be discarded when a (network) sync comes through?
Nope transient permissions will stay
Correct
That's actually pretty nice. It seems the TransientPermissions will be the way to go though, since the afk group just adds nte.afk. I then need to reload the nametag for that player to have that take effect.
I’m like 99% sure there should be a simpler solution
Though using ExtraContexts is probably your best bet
If your code is gonna need to update NTE too, then I guess transient is your best bet
Yeah. You’re right. I missed having to update NTE
So I've tried this as both "afk" and "group.afk", but either way it doesn't find the group. Is there something I'm missing?
Group group = luckPermsApi.getGroupManager().getGroup(groupName);```
Uhh
it should work with "afk"
where are you calling that code?
Alternatively you can just pass it directly to the node builder
It's in that addToGroup method I linked earlier, which is called by my event handler.
@EventHandler
public void onAfkChangeEvent(AfkStatusChangeEvent event) {
IUser user = event.getAffected();
Player player = user.getBase();
// player.sendMessage("In AfkListener Event!");
if (user.isAfk()) {
plugin.luckPermsTool.addToGroup(player, "afk");
} else {
plugin.luckPermsTool.removeFromGroup(player, "afk");
}
plugin.nametagEditTool.refresh(player);
}```
I have Node node = luckPermsApi.getNodeFactory().makeGroupNode(group).build();. I could change it to the group name.
Yea try that
So no error message anymore about it finding the group, but still no differences in the scoreboard or nametag.
So I'm looking at the information for an afk user. Knowing how things usually go for me, it's something stupid small that's easy to miss.
I assume dataMutateResult#toString() will yield some useful information?
Welp, that helps.
DataMutateResult result = user.setTransientPermission(node);
switch (result) {
case SUCCESS:
player.sendMessage("Operation successful!");
break;
case ALREADY_HAS:
player.sendMessage("Player is already a member of the group.");
break;
case LACKS:
player.sendMessage("The operation failed because the user lacks something");
break;
case FAIL:
player.sendMessage("The operation failed.");
break;
}```
Got on as my alt again and ran /afk. It reports Operation Successful! but looking at their parent groups and info, it's identical to the earlier screenshot.
Good to know
I'll go back to the regular permissions for now for debugging then.
I may have just found my problem.
where do i change the prefix in chat on a rank?
if you have the answer please @ me
I don't understand the question
@gritty pollen Is this what you're looking for? https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#creating-new-node-instances
where do i change the prefix
using the api?
what?
I'm going to guess no
this is a channel for the luckperms api
what is api
yes i need help
how do i change the prefix of my ranks
so you see in chat that you have that rank
before your name
!meta
I thought that was an alias, see the wiki in #welcome it goes over how to use the plugin; Beyond that you'll need a plugin for chat (LP doesn't control chat)
this is the wrong channel to discuss this, please use #support-1
So I think my problem is that this AfkStatusChangeEvent fires before the user changes, not after. So I'm checking to see if they are afk, but they haven't been made afk yet, so it sends them to the remove method.
So I just change it to if (!user.isAfk()) and all should be well
event.getValue exists but I've not been able to find much if any information on their API
So I'm kinda going blind.
it returns the value of set
so I guess getValue() could equally be isGoingAfk()
See, that would make more sense. Asking the player if they're afk gets their current state, not what they're going to be.
I'll just need to remember to actually dive into the source code on occasion.
That's working now.
\o/
The scoreboard/nametag isn't updating, but at this point that's an NTE error.
So I'll go hunt that down next. Thanks for the help!
Thanks!
Is there any event that's called when
/lp user <name> parent addtemp <group> <time>
is executed?
Yes. But I don't know how it's called xD
The javadocs on the events should be clear though
What's the "command" I need to use in my Bukkit Code for do /lp user <name> parent set <group>?
I mean, is there a script like p.setGroup(<group>)
!node
ops 😛
It's in the wiki
Kk
I'll check
I checked a bit but I don't fine something like what I'm looking for
Can you quickly check please?
@grand parcel There's a section for developers on the wiki
It explains how to use the API
Also read the Javadocs
Thanks I'm checking it, but I only need to know if there is a pre-created way to set an user's group like the one i said before :/
anyone know what event to use when someone's ranks have been updated using a command? (I tried UserDataRecalculateEvent but thats called on join/leave and even when you do /lp user <name>)
I know there isn't a specific event for that
You need to filter all the times it gets called wrongfully
someone mentioned it had a caller
to know where it was being called from
any ideas on that?
Sorry no
rip
Maybe Node(Add/Remove)Event?
then check if its a group node
there's an example in the wiki
how to check the track of player ?
@bitter gulch After playing around with events, What I ended up doing is listening to NodeMutateEvent. Then check if it's a player, and just get the target's primary group after the NodeMutateEvent.
thanks will give that ago
I couldn't figure out how to update a users role with the api
"roles" or groups are assigned using nodes too
um, how would I go about doing that, Im honestly confused, Im sorry.
Nvm I ended up figuring it out!
I just found Helper and I rather like the command builder pattern. I may snag this and build on it, write up some reflection-based code that builds commands dynamically.
// rough mockup
@Command("msg")
@Permission("message.send")
@Usage("<player> <message>")
public void SendMessage(Player target, String message) {
other.sendMessage("[" + sender.getName() + " --> you] " + message);
c.sender.sendMessage("[you --> " + sender.getName() + "] " + message);
}```
Something along these lines. I forget how to do attributes now.
This one is based off the example on the commands page here https://github.com/lucko/helper/wiki/helper:-Commands
Now just to find out if Java reflection code is as easy to navigate as C#'s
Luck, if I were to get something along these lines working and stable, would you be interested in a PR against helper?
Maybe anyone can help me how can i set a Node.Builder?
Idk how
I don't work with builders before now
Hey NycuRO! Please don't tag staff members.
hi, how do I set the parent group of a player?
(via api)
User#setPrimaryGroup(String) does not seem to work properly
I think you need to save user after you set it
You need to add the group and then use setPrimaryGroup
I tried that. LuckPerms says the player is in the default group anymay
setPrimaryGroup basically expects a group that they're already a member of, it doesn't actually change their group
How do I add a player to a group`?
Could that work ```User user
= LuckPerms
.getApi()
.getUser(target);
Group group
= LuckPerms
.getApi()
.getGroup(Configuration.unlockGroup());
user.inheritsGroup(group);
user.setPrimaryGroup(group.getName());
LuckPerms
.getApi()
.getUserManager()
.saveUser(user);```
@idle slate the wiki has examples on how to add a user to a group
anyone know why both of these methods don't return the actual value (a zero) which is clearly shown in lp user meta info
https://gyazo.com/ad21c8379bc4f6b3e03e462d64e41275
https://gyazo.com/046b69a8f6bd117217a1b10dc0d6230f
the top returns -1 and getoption returns empty
screenshot of meta info?
rip
Apologies if this is the wrong channel, but would anyone be able to help me as to why this:
private void onGroupChange(NodeAddEvent event)
{
//Anything else
}
Would be causing this error? https://i.imgur.com/8Q0Dy0j.png
That's the method signature of the listener registered using LuckPerms.getApi().getEventBus().subscribe(NodeAddEvent.class, this::onGroupChange); It was public before, but had the same issue.
I've not looked at the module stuff in java 9+, but looks like you've not exported that class so that LP can access it
Thanks mate, he's going to downgrade because "Java sucks"
Probably try to make the method public
Event listeners must be public and must have the @EventHandler annotation. I don't know if they copied the method without the annotations, but that's a thing.
Oh look at that - I completely missed that.
On an unrelated note, I like the syntax sugar for catching multiple exception types.
How can I set the group of a player with the api? I think there is something about it in the documentation, but I don't find it 👀
@jolly herald the wiki has several examples, including how to set a player’s group
link? ^^
@crystal sonnet Can you give @jolly herald a link from the exact location? We can't found an example
Hey Fanatic | Sven! Please don't tag staff members.
@dark bough @jolly herald the wiki has a navigation bar on the side. There's a section called "Developers". It has precisely 3 links. You really should be able to find it
how do i access player's info ? (bungeecord)
@fierce dew the API is the same on all platforms
And the wiki has a bunch of examples
ok can u provide me wiki link please? @crystal sonnet
Hey MrIvanPlays! Please don't tag staff members.
@fierce dew Everything you could ever want to know is right here: https://github.com/lucko/LuckPerms/wiki/Developer-API
i can't find how to set player prefix/suffix
there's no method in the MetaData
@hollow grotto
why the things should be so complicated in this api while luck can make it just SomeClass.setPrefix(player, prefix) ?
Use your LuckPermsApi object to get a user, then create a permission node for that prefix or suffix, then use user.setPermission(node)
i need to set the player prefix...
Node node = api.getNodeFactory().makePrefixNode(100, "[Some Prefix]").build();```
Then use user.setPermission(node); as described above.
why so complicated
It's not complicated. There's a bit of a learning curve, sure, but all of this is on the page I linked above.
It’s not complicated. It’s actually very well designed and excellently documented
Though not beginner friendly
yeah, it is designed
but why you should make it like that
while you can just
SomeClass.someMethod(<params>)
Read the section titled "The Basics of Node" on the dev api wiki page
Essentially, the answer is that Java is an OOP language, so it's sometimes more efficient to accept an object that has attributes that determine function rather than to have several methods that all effectively do the same (or very similar) tasks. That's probably not the best description because it's 0530 and I've not slept yet, but yeah.
for me is 13:32
That said, if you wanted to build a method with a signature similar to SetPrefix(Player player, String prefix); then you're definitely welcome to - there's documentation on the API page to describe how to do that.
That may be recommended if this is something that you're going to be doing in several places in your code. I don't know what your code looks like.
That said, generally speaking it's better practice to set group prefixes and suffixes and then assign group membership to players. This makes things far easier to manage in the long run. So unless you have a particular reason for needing a player prefix, you may want to go with the group method instead.
Same with permission nodes - assign permissions to group and have players inherit permissions from those groups as a function of group membership.
But that's a topic for another time.
welp, with ma new https://github.com/MrIvanPlays/VaultBungee VaultBungee we got it
combine the bungeecord permission plugins' i know APIs with every important thing you wanna get.
bungeecord doesn't have services manager so i am forced to use singletons
hello
i'm using redis. there is way to check permission between bungees?
player1 is on bungee1
player2 is on bungee2
i need to check from bungee1 permission of player2
private boolean hasPermission(User user, String permission) {
Node node = LuckPerms.getApi().getNodeFactory().newBuilder(permission).withExtraContext("server", "lobby").build();
return user.hasPermission(node) != Tristate.UNDEFINED;
}
Does this work for checking if a user has a perm defined?
is getUser(string) depr?
seems to be returning null everytime for me on latest release
yes UUID would be better but i am looking up info and getting UUID using getUuid() from the User object on BungeeCord
nvm attempting to even get my ProxiedPlayer object from bungee it is failing.....
@crystal sonnet yes, i'm using the same db
Hey Duarte! Please don't tag staff members.
can you help me? i don't know how to check player's permission on other bungeecord.
how to check group an permission ? please ?
?
You'd basically check the node list for group nodes, there is a "getOwnNodes" method or something like that which doesn't contain nodes resolved from inheritance
for get group of an player ?
Yes
Oke i'm looking
if you only want a singular group, there is a method to get the persons main group
The wiki covers a lot of this stuff
Check the wiki. It has plenty of examples
why?
Ah yes
my i dont use le provider
Oké
User user = LuckPerms.getApi().getUserManager().getUser(event.getPlayer().getUniqueId());
ContextManager cm = LuckPerms.getApi().getContextManager();
Contexts contexts = cm.lookupApplicableContexts(Objects.requireNonNull(user)).orElse(cm.getStaticContexts());
MetaData metaData = user.getCachedData().getMetaData(contexts);
It really doesn’t matter how you get the instance of the API though
I don't use getprimarygroup
I just want to check the groups that the players have
@quick token
how to create the variable for provider ?
ou
wait
RegisteredServiceProvider<LuckPermsApi> provider = Bukkit.getServicesManager().getRegistration(LuckPermsApi.class);```
idk make a for loop
o no
wait primary
I dont know, there is no person who want to help us :/
gunter, I think you can use Vault. If you think, thats the last chance.
how dafuq I can get the prefix ..
What's the difference between getUserSafe and getUser? I assume one is intended for async tasks?
@wary jacinth no. The safe version just returns an Optional<User> object, while the other can return null
ah okay, so basically doesn't matter which I use
I'm waiting on Java to do something like this so I don't have to worry about it
User user = getUser() ?? someOtherUser;```
This is just short-hand for the following:
```java
User user = getUser() == null ? someOtherUser : getUser();```
@hollow grotto you might want to check out optionals
getUserSafe().orElse(someOtherUser)
(Works because getUserSafe is a variant that returns Optionals)
(The safe thing is not Java syntax
Hey! I'm just wondering. Is there something already built into the API to allow people to easily switch prefixes/suffixes with other ones they have?
Just curious because I'm planning on designing a 'taglist' plugin where players can select which of their prefixes/suffixes show in our chat
I'm seeing if there's something in LP that can do that or whether I have to use LP to store my own set of prefixes/suffixes which I'd then concatenate into the chat
Because I'm currently storing prefixes and suffixes into our database anyway so that they'll show if somebody uses our discord -> network bridge
(pls dont steal the idea for BC3 @crystal sonnet 😉 )
Hey TheFlash787! Please don't tag staff members.
// old
public String getName() {
if(this.hasItemMeta() && this.getItemMeta().hasDisplayName()) {
return this.getItemMeta().getDisplayName();
} else {
return this.material.toString();
}
}
// new
public string getName() {
return this.getItemMeta()?.getDisplayName() ?? this.material.toString();
}```
There's a good application of this. Similar to your suggestion regarding nullable (since ?. converts to nullable, effectively).
Or more accurately, the ?. performs the subsequent operation on the object or else returns null. This is combined with the ?? operator to translate into pretty much the if/else from above - if the item meta exists, get me the display name. Otherwise, get me the material name.
Don't mind me though. I'm just a C# dev who is used to being able to use the extended syntax sugar and I start to miss it when it's no longer there.
If you want that kinda sugar take a look at Kotlin
Oh? Good to know.
?? would be the elvis operator
return this.getItemMeta()?.getDisplayName() ?: this.material.toString();
Yeah, I've seen it called that before. It's effectively a shorthand null-coalescence operator.
Return the left side, unless it's null, then return the right.
Chances are we'll never see that in Java
Java has never been a language of syntactic sugar
And too much of it is bad imo
If you have like 20 combinations of ?, :, ., ect it becomes unreadable to anyone not familiar with the language. And that really shouldn't be the goal
Anyone know how to get default user from LP?
I'm porting GP to Paper/Spigot and need that 😃
@rapid egret I'm not sure what you mean by "default user" but getting a user from LuckPerms doesn't change depending on what server software you're targeting because you're targeting the lp api at that point.
it does change as Sponge has a permissions API which doesnt target LP's API
so we have no need to use LP's API directly
a default user is used to store "default" permissions for ALL users
so doing a lookup on an actual player would fallback to default
Is a default user a Sponge concept? Because I'm not familiar with such a thing. Default permissions as far as I'm aware are determined by the default group defined by lp and, if all else fails, whether or not the plugin has default: true defined for a particular permission node in their plugin.yml.
Also, Sponge iirc has a User object, which is a custom implementation that in the Spigot version is a Player wrapper. I may not be entirely correct on that though.
@rapid egret you could add transient permissions to the default group
does LP API have a method to access the default group?
as I have no way of knowing what a server would name it
It's always called default
Ah so the name cant be changed?
ok thanks
I dont see any methods to check permission with context sets
using a PermissionHolder
seems i can get contexts but not use them directly
There should be as long as it's a LP class
it is
Maybe check the examples on the wiki
I'm pretty certain that you even have to supply a context to properly check permissions
with sponge Subjects you do
getPermissionValue but there is no method on bukkit side that i see for the same
ill keep looking
I'm using https://github.com/lucko/LuckPerms/blob/master/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java in place of Sponge Subject now
ah looks like its included with LP's Node
yup
time to make a helper method 😃
they are not which is why my plugin will depend on LP
GP cannot function without context support 😃
I just wrote a helper method so im good
👍🏼
public static Tristate getPermissionValue(PermissionHolder holder, String permission, Set<Context> contexts) { MutableContextSet contextSet = MutableContextSet.fromEntries(contexts); Node node = GriefPreventionPlugin.getInstance().permissionService.getProvider().getNodeFactory().newBuilder(permission).setExtraContext(contextSet).build(); return holder.hasPermission(node); }
Should do the trick
i like how i can pass a predicate too
might come in handy soon 😃
For sure
Does luckyperms support featherboard?
It should
Should i just type {prefix}?
This is ultimately FB’s issue. So either move this to #general or ask their support for help
Or maybe check the placeholders LP wiki page @regal fulcrum
vault_prefix should work too, if Vault is installed
With /papi ecloud download Vault before (and a server restart)
api.getContextManager().registerCalculator(new ContextCalculator(){
@Override
public MutableContextSet giveApplicableContext(Object t, MutableContextSet mcs) {
System.out.println(System.currentTimeMillis());
try {
Thread.sleep(15000L);
} catch (InterruptedException ex) {
Logger.getLogger(PermissionsService.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println(System.currentTimeMillis());
return mcs;
}
});
If I do this, then check player permissions every 1 second...
is my server going to have super lag?
in other words, are context calculators asynchronous?
how often are they called?
?code
Ah, they don't have it. Surround code blocks like this:
```language
// your code here
System.out.println("Hello World!");
```
// your code here
System.out.println("Hello World!");
Makes your code easier to read.
On another note, why do you need to check player permissions on an interval @hollow zodiac?
Permission checks should be event based, such as a player doing something or something happening in the world. If you do it this way, then even if it's async it'll add unneeded busy work to the server when a majority of the time it'll be fruitless.
oh ok hang on
api.getContextManager().registerCalculator(new ContextCalculator(){
@Override
public MutableContextSet giveApplicableContext(Object t, MutableContextSet mcs) {
System.out.println(System.currentTimeMillis());
try {
Thread.sleep(15000L);
} catch (InterruptedException ex) {
Logger.getLogger(PermissionsService.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println(System.currentTimeMillis());
return mcs;
}
});
tbh, I really don't, @hollow grotto.
I really just need to update the permissions whenever certain events happen
Like a player has 7 hours of play time? Boom. Update that context.
Now those permissions will be active for them
@hollow grotto What alternative path do you recommend here?
waits for that essay to hit like a sack of bricks
I see you typing. I'm really curious.
If you're doing time-based perks, then I might calculate the end time based on the delta (7 hours in your example) using the current time + 7 hours. Then, I'd store that in a configuration file somewhere.
Then you have one of two ways of doing this, and I'm not entirely sure which would be better. First is you could hook into the server tick event, and the second would work on hooking the player join event as well as probably some other, such as the block break event - something reasonably common.
If you go the first route, you may want to have a value in the config which sets it up to run, say, once every 10 ticks. That can be done as easily as something like if(ticks % 10 == 0) return;. 100 ticks would see the 10 in the equation replaced with a 100. Then iterate through the values and compare them to the current time. If that time has passed, then either fire a custom event or call a method on your end that handles what you would like to happen, perhaps sending a message to the player that they've leveled up or whatever. At this point, you should also update the config to match the player's next goal.
The PlayerJoinEvent will be handled the same way between the two options. When a player joins, look them up by guid. If they have no entry, then create a new entry for them under their guid. I tend to store both their current username (which is updated any time they log in if needbe) and the DateTime value for when they should have their next upgrade. If they do have an entry, see if that entry has expired, then update accordingly.
If you don't go with listening to the server ticks, then hooking an event like a block break or an interact event could be useful.
Caveats: I don't know what best practice says about timing things off a server tick, but I imagine that should be fine because that's what it's there for. Also, this solution wouldn't only count down while a player is logged in and active on the server, though if you wanted that functionality you could possibly use this as a base. Perhaps you store a timespan (e.g. 7 hours), record join time, and record leave time. While they're on the server, you could periodically check the delta (time now - join time = delta) to see if they hit that mark while on the server. On the player leave event, you could calculate the time between the join and leave time and subtract that from the time remaining to unlock that tier.
OMG THANK YOU
I was wondering if you AFKd and left your cursor in the box or sth
Okay. So.
Assuming... we want to do a one time thing.
I try to avoid timers with this solution because then you'd have a timer for player (or perhaps every online player) and that could get expensive fast.
My plugin has a timer goong on.... once every X minutes it updates the user permissions...
that would not be done with a context calculator.
Tbch I'm not entirely sure what a context calculator is, but given its name, it sounds like you're not using it properly.
do not do this in a Server tick event
all you need is the player login date and then you simply keep track of logouts
My event happens once every 12 minutes. Once every 12 minutes, activity time is updated. Once every vote, vote counts are updated.
doing anything in a tick event is trouble, i never liked them
That's when I want to set contexts for users/globally
How would you recommend handling the 7 hours passing while the user is on the server, bloodshot?
scheduled task
And then, I want to specify permissions that are unlocked when certain contexts are true
NOT tick
check on an interval
simply check once a minute
and this can easily be run async
I have this info to work with
I just want to set user perms based on the dynamic result of this info ^^;
What is U_ActivityTotal - seconds?
definitely use contexts/meta
but if these are changing constantly
well if they are simply "ranks" for something your plugin does then sure
i would use meta for that
contexts are not meant to be changed
Isn't there an LP addon that acts essentially as an event handler? Luck was telling me about it once because when the player went afk I wanted them to have the nte.afk permission added to them, and for it to be taken when they were no longer afk. I ended up doing a plugin because it also required me to hook the NTE api and refresh that player's entry in the scoreboard, so it wasn't feasible for that.
does spigot really handle AFK?
i doubt they are checking all possible cases if so
well many
there is a good Anti AFK plugin that should be on Spigot too
I'm not entirely sure if that could be leveraged here, but if you could divideU_ActivityTotal by 60 and present that to LuckPerms, you could write an event that says if it's > 7 then give them a particluar permission node or something similar.
I think spigot has some concept of it but I believe typically that's mostly handled by Essentials
But since Essentials is such a common plugin, I think Luck wrote in a handler for that.
It'd be event based on the back-end I'm sure, but it works based off context.
/perm user <user> parent add afk afk=true
I do believe it's a separate expansion plugin for LP instead of core functionality.
yea that makes sense for context
since you only want them to be used if a player is afk
This expansion plugin let you write custom contexts without jumping into code, but I'm not entirely sure how that works.
Though there's a high probability I misunderstood that part. It was an off-hand discussion and we didn't discuss it much
hrmm doesnt make much sense for me unless they are turning it into code
would also have to know exact usage
because anyone can supply a context key + value but how you want it to be used is another problem
Right, yeah
in my protection plugin, I use various contexts for protection. So lets say a player wanted to protect only when wielding an item, they would use used_item=diamond_sword as ex
also the claim UUID is a context
so for afk=true, you would have to use a context calculator to force permission checks to add it
unless essentials does it for you?
because lets say a permission is requested in LP. It won't have the afk context unless it was added via a calculator or it added the context itself
Huh, good to know. I don't think Essentials does it, but I do believe Luck's expansion has some pre-built ones for common plugins.
ah i see. I'm still a bit rusty on Paper/Spigot side of things. So not really up to speed on common plugins
still working on porting GriefPrevention Sponge
without Luck, my plugin would of been dead 😃 Hes helped me over the years tremendously
I'm only just getting back into plugin development myself. But I can say the same. He's great at what he does.