#luckperms-api

1 messages · Page 15 of 1

crystal sonnet
#

The wiki has examples on how to load offline players

echo harness
#

give me second

crystal sonnet
#

And yes you can do it in stream

echo harness
#

i need to somowhere add UserManager::loadUser to the stream

crystal sonnet
#

Expect that you need to do it on an instance of UserManager

echo harness
#

oh

#

so i need to store usermanager instance

#

before stream ?

crystal sonnet
#

yes

echo harness
#

ok ty

#

that helps

#

userManager.loadUser(User::getUuid) is it something like this ?

crystal sonnet
#

No

#

And I'm not your Java teacher

echo harness
#

so u wont tell me ? 😄

crystal sonnet
#

If you can't do it with streams do it without

echo harness
#

i need to figure it out by myself ?

#

wait

#

lemme try

#

this is bully lol :DDDD

crystal sonnet
#

No

echo harness
#

im just kidding

crystal sonnet
#

This is refusing to spoonfeed

echo harness
#

thats good

#

forEach(user1 -> userManager.loadUser(user1.getUuid())) am i getting at least closer ?

crystal sonnet
#

yeah

echo harness
#

oh really ? 😄

#

should i do handle async or ?

crystal sonnet
#

Now use map instead of forEach

echo harness
#

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

echo harness
#

hey void

#

u here

#

i need to do thenAcceptAsync dont I ?

#

@thorny echo

frank driftBOT
#

Hey Poggik! Please don't tag staff members.

echo harness
#

holy shit

#

im trying to figure it out for 2 hours now

thorny echo
#

Please don't ping me

echo harness
#

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

crystal sonnet
#

@echo harness you’re also getting a warning for repeatedly DMing after being told several times to not do it

echo harness
#

ok

crystal sonnet
#

3rd warning gets you a kick, 4th a ban. Just so you are aware

echo harness
#

ok

#

u wont help me anymore am i right ?

#

its just a little issue

#

after all this bully from java

crystal sonnet
#

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...

echo harness
#

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

echo harness
#

fixed

quasi veldt
#

hey cna someone help me setting up a plugin

#

i cant make my friends tp

#

how to do it

sharp bridge
#

how to i run /lp sync through a api call

jaunty pecan
#

LuckPermsApi#runUpdateTask

hot shoal
#

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?

jaunty pecan
#

Specify a null world param

hot shoal
#

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
#

yeah

#

that's vault for you...

#

😉

sonic flare
#

@jaunty pecan you should make your dependency component a separate plugin to help other devs fight obesity (fat jars)

frank driftBOT
#

Hey Aerocet! Please don't tag staff members.

sonic flare
#

oh

#

well too late

crystal sonnet
#

It is a open source library @sonic flare

sonic flare
#

well luckperms is open source, but the dependency part is integrated

crystal sonnet
#

It’s available as a separate library @sonic flare

#

Check Lucks other repos

sonic flare
#

oh

#

neat

crystal sonnet
#

Pretty sure that’s not even it XD

#

But Luck should know. Let’s hope he’ll check this out soon 😉

sonic flare
#

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

crude laurel
#

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?

frank driftBOT
#

Hey Artuto! Please don't tag staff members.

proud crypt
#

I don't suppose anyone has made a NodeJS API for LuckPerms? Figured I'd better ask before making my own lol.

crystal sonnet
#

@jaunty pecan @sonic flare is interested in your maven downloader.
I though it was a separate project you can add to your own projects

jaunty pecan
#

It's not separate unfortunately

#

only the jar-relocator component, as noted above

sonic flare
#

the look in that cat’s eyes indicate we are not seeing a stand-alone any time soon lol

jaunty pecan
#

hmm maybe

thorny echo
#

@proud crypt A node luckperms api

#

Question mark

proud crypt
#

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.

teal tartan
#

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

proud crypt
#

Yeah I'm just gonna use a JS ORM like Sequelize to hook into the database directly

jaunty pecan
#

definitely better to query the db directly

proud crypt
#

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 😆

languid pike
#

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

crystal sonnet
#

@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

languid pike
#

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

crystal sonnet
#

An User is a PermissionHolder iirc

#

Check the inheritance tree of that interface

#

@languid pike

languid pike
#

Alright. I appreciate the help

fierce brook
#

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?

dense steeple
#

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.

ripe phoenix
#

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?

proud crypt
#

Never tried myself but I would assume so.

ripe phoenix
#

Okay thank you

crystal sonnet
#

Assuming you have a proper network setup, it’ll work just fine

warm hazel
#

Hello, how do i hook into bungeecord version of LuckPerms ?

jaunty pecan
#

Via LuckPerms.getApi()

crystal sonnet
#

The API is the same on all platforms

ripe phoenix
#

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

narrow blade
#

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

crystal sonnet
#

If you have specific questions, ask them

#

But don’t expect everything to be handed to you on a silver platter

narrow blade
#

nevermind...

crystal sonnet
#

We’re here to help you. Not to teach you everything

#

That’s the wiki’s job

#

So feel free to ask specific questions.

narrow blade
#

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

crystal sonnet
#

Are you using an IDE?

narrow blade
#

i use intellij

crystal sonnet
#

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

narrow blade
#

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?

crystal sonnet
#

Yes

#

And yes can add more methods before the build method

#

Your IDE’s autocomplete should help you with finding the name

narrow blade
#

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?

crystal sonnet
#

Yes yes and yes

#

Though you don’t need the server and world

#

Unless you want to of course

narrow blade
#

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

#

?

jaunty pecan
echo harness
#

u here ?

granite spade
#

Yes

echo harness
#

ok

#

theres wiki for api

#

that can help u

granite spade
#

I already saw it

echo harness
#

this is how u get instance of api

granite spade
#

yes

#

LuckPerms.getApi()

echo harness
#

and how to add it as depedency in your plugin

granite spade
#

if i use like

echo harness
#

if you already have api instance obtained

granite spade
#

LuckPerms.getApi().getUser(p.getUniqueId())

#

But when i press . to see the syntaxes that i can use

echo harness
#

store that api instance in variable

#

in main

granite spade
#

don't appears like getPrefix

#

ok

echo harness
#

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

granite spade
#

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

echo harness
#

ok

#

just store that api in variable outside of scheduler

#

so u wont obtain new instance every time

granite spade
#

ok ;-;

echo harness
granite spade
#

How can i get the prefix now

#

AH

#

sorry

echo harness
#

np

granite spade
#

didn't saw it

undone spire
#

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

real lotus
#

@undone spire use %vault_prefix%& for the rank

undone spire
real lotus
#

do u have placeholderapi

undone spire
#

yes both of them

real lotus
#

do /papi ecloud download vault

undone spire
#

then retsrta??

real lotus
#

no just papi reload

undone spire
#

wow your one sexy ass mother fucker

#

tlove you

real lotus
#

xD yw

undone spire
#

wait now my balance fucked up

real lotus
#

um

undone spire
#

i use the new econmy plugin

#

dont have that

real lotus
#

vault?

undone spire
#

yes have cault

#

but i dont use it as my ecnomy

real lotus
#

whats ur econ plugin?

undone spire
#

The new ecomomy

real lotus
#

do u have vault tho?

undone spire
#

yes

#

would you like a list??

real lotus
#

do u use placeholderapi or the other one for the placeholder

undone spire
#

II use placeholderAPI and Maximvdw's MVdWPlaceholderAPI

#

I only downloaded the 2nd one casue luck permns said i needed too

real lotus
#

or the econ plugin?

undone spire
#

??

#

im confused

real lotus
#

of

#

oh

#

lol

#

what one do u use for the econ plugin

undone spire
#

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

real lotus
#

oh hold on i might know why

#

may i know ur server ip so i can come on real quick

undone spire
real lotus
#

ok so

#

when u downloaded the vault one

#

it made it where the eco uses vault eco

undone spire
#

oh ok

real lotus
#

try vault_eco_balance_formatted

undone spire
#

so technically i wouldent even need the new econmoy plugin

real lotus
#

no

#

vault comes with it by its self

undone spire
#

ok give me a second

#

whats the /(cash command for cault

real lotus
#

/bal

#

/balance

#

/baltop

undone spire
#

swwet going to look up the placehodler

real lotus
#

%vault_eco_balance%
%vault_eco_balance_fixed%
%vault_eco_balance_formatted%

#

try %vault_eco_balance_formatted%

#

thats what i use

undone spire
#

ok lets see

#

yo it worked

#

fuck yeah

real lotus
#

xD

undone spire
#

thanks bro

real lotus
#

np

#

if u need anything else tag me

undone spire
#

aight thanks ❤

nocturne elbow
#

@real lotus

#

can u dm me

real lotus
#

sure

nocturne elbow
#

@real lotus

real lotus
#

?

nocturne elbow
#

what app are u using for ur plugins too look like that

real lotus
#

filezilla

nocturne elbow
#

what do u use to config/edit them

real lotus
#

notepadd++

nocturne elbow
#

anyone selling custom tab or scoreboard plugin

proud crypt
#

#general please, this channel is for developers who are using the API

granite spade
#

How do i get luckperms api for bungee?

echo harness
#

api for bungee should be completely same as bukkit/sponge one

granite spade
#

Obviously no

echo harness
#

you dont want bukkit and sponge either 😉

#

so u go logically with singleton

silver sleet
#

how can i get the heaviest prefix of a group? Im not that good at coding and i dont know Stream API

echo harness
#

metaData.getPrefix(); wont return heaviest prefix ? @silver sleet

silver sleet
#

I'll try it out

#

Sorry, i haven't searched through the wiki enough

mystic glen
#

is there a way to pull the player's group using the luckperms api?

long moon
#

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)

mystic glen
#

hmmm

#

i figured it out with .getUser().getPrimaryGroup

silver sleet
#

how can i get a groups displayname?

echo harness
#

give me sec

#

i think it will be something like <group>.getDisplayName

silver sleet
#

no

#

there is friendly name

#

maybe its that

echo harness
#

oh wait

#

you can do getPrimaryGroup

#

its same

#

it dont think there is much difference

silver sleet
#

nah, i want the displayname because i've set one with /lp group setdisplayname

echo harness
#

ok wait

silver sleet
#

I'll try out friendlyname

echo harness
#

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

silver sleet
#

yeah

#

maybe its outdated

echo harness
#

give me second

#

ill try it

#

show me your code

#

that 1 line

#

no issues

silver sleet
#

which version?

echo harness
#

4.3

silver sleet
#

.?

#

i have 4.3.62

echo harness
#

but i use api

#

like

#

special jar

silver sleet
#

oh wait

echo harness
#

i think it same

silver sleet
#

i think my api was outdated

echo harness
#

but maybe theres some difference

silver sleet
#

i don't think you thought that

granite spade
#

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?

echo harness
#

you need lp on bungee too

#

bungeecord has seperated permissions from backend

crude laurel
jaunty pecan
#

looks good to me

crude laurel
#

I see

crystal sonnet
#

@silver sleet can I see the actual code that prints the command and executes it?

#

And the command itself?

silver sleet
#

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

crystal sonnet
#

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

nocturne elbow
#

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");

echo harness
#

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

crystal sonnet
#

@nocturne elbow check the wiki. It has examples on how to set a player’s group

ripe phoenix
#

How do you update a players group I have tired LuckPerms.getApi().getUser(player.getUniqueId()).setPrimaryGroup("owner"); but this is not working

ripe phoenix
#

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

crystal sonnet
#

@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

ripe phoenix
#

I already have

#

still does not work

crystal sonnet
#

You’re doing nothing I said there

#

Not saving the User object and not saving

ripe phoenix
#

Ahh got it working now thanks @crystal sonnet

frank driftBOT
#

Hey HuskyPlays! Please don't tag staff members.

ripe phoenix
#

Ohh sorry didnt know I couldnt @

crystal sonnet
#

Replying is ok

#

The bot doesn’t know when it’s ok and when not

#

Glad it’s working now

silver sleet
#

How can i get a player from a user?

crystal sonnet
#

Get the UUID and use the platforms methods to get the player @silver sleet

chrome coral
#

how to use prefix

crystal sonnet
#

How to get the prefix entirely depends on your environment

#

/platform

chrome coral
#

i am just using paper

#

and lp and my own plugin

crystal sonnet
#

And I think you need vault for the displayname to contain the prefix and suffix

chrome coral
#

i do have vault installed

crystal sonnet
#

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

chrome coral
#

i have found a video called Spigot Coding Episode 2 Hooking into Vault for Chat Prefixes that sounds legit to me

crystal sonnet
#

Yup

sullen karma
#

Is there an event called for when a timed permission expires?

crystal sonnet
#

No

jaunty pecan
#

yes there is

#

NodeRemoveEvent

#

check if the node is temporary & past the expiry time

crystal sonnet
#

Since when does this exist/work for temp perms?

jaunty pecan
#

has done for as long as I can remember :p

crystal sonnet
#

Ah ok

#

Will keep that in mine

#

*mind

ripe token
#

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.

jaunty pecan
#

Groups don't have a context

#

so you could just use the static context

ripe token
#

Ah, cool 😃

#

Thanks!

nocturne elbow
#

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());```
nocturne elbow
#

Hrrm, setting a meta twice seems to duplicate the key so I guess keys are non-unique

hardy vapor
#

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();

nocturne elbow
#

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

jaunty pecan
#

@hardy vapor I've replied on github 😃

#

@nocturne elbow Yes, the value is ignored when unsetting

nocturne elbow
#

Great, thank you

jaunty pecan
#

@nocturne elbow You'd need to unset the existing node, and then add a new node with a different value

nocturne elbow
#

that's what i thought

#

thanks

jaunty pecan
#

clearMatching might come in useful for clearing

nocturne elbow
#

ye

#

user.clearMatching { it.isMeta && it.meta.key == "foo" }

jaunty pecan
#

yep

nocturne elbow
#

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

jaunty pecan
#

Eh that could be a reasonable expectation

#

but ya it doesn't work like that in this case

#

:p

nocturne elbow
#

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?

teal tartan
#

Maybe you need to make bungeecord plugin for that to work

nocturne elbow
#

Hmm but theres a PreNetworkSyncEvent.class that works. But I need a event after the sync is finished.

crystal sonnet
#

That might be an actual bug. The PostSyncEvent not being fired after the Network Sync

#

Though only Luck knows for sure

nocturne elbow
#

Okay, if it's only a bug and should normally work, that would be nice.

celest oracle
#

How do I set up the user group as a start?

slim merlin
#

./lp user nick parent set default

#

@celest oracle

celest oracle
#

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

slim merlin
#

Yeah

#

Always all player has default rank

celest oracle
#

so I have to type this command / lp user nick parent set default only the first time and that's it?

slim merlin
#

No no

#

All user has default rank

celest oracle
#

how do I configure the default rank?

slim merlin
#

lp group default info

#

lp group default editor

celest oracle
#

ok

#

thx

crystal sonnet
jaunty pecan
#

Hey @nocturne elbow are you super super sure? :p

#

just saw your github issue & checked the code

nocturne elbow
#

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.

jaunty pecan
#

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

nocturne elbow
#

Sure you are sure that if the bungeecord plugin performs a sync, my spigot plugins also get notified via the PostSyncEvent?

jaunty pecan
#

Assuming your messaging service is all setup correctly

#

then yes

nocturne elbow
#

I'll try...

jaunty pecan
#

or in other words

#

if the PreSyncEvent is called, and is not set to cancelled, then the PostSyncEvent should definitely be called sometime afterwards

nocturne elbow
#

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?

jaunty pecan
#

Yep

#

but a "user update ping" doesn't cause a full sync task

nocturne elbow
#

Oh

jaunty pecan
#

only a reload of that users data

nocturne elbow
#

Okay /lpb networksync works fine I see

jaunty pecan
#

Mhmm

nocturne elbow
#

So is there an option to enable a full sync for incoming ping?

#

Or an event I can listen to

jaunty pecan
#

Well, a full sync isn't necessary

#

So idk why you'd want to enable that

nocturne elbow
#

Just to get the event working XD

jaunty pecan
#

Do you just want to listen for when users are updated?

nocturne elbow
#

Yes

jaunty pecan
#

okay well

#

the UserLoadEvent will be fired

nocturne elbow
#

Well, that would be nice. Let me try.

jaunty pecan
#

or more generally when any User related data changes

#

UserDataRecalculateEvent is called

nocturne elbow
#

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());
jaunty pecan
#

you only need to listen to UserDataRecalculateEvent

#

and then refresh data for that specific user

#

that will cover all of the other events too

nocturne elbow
#

Cool!

#

Thank you Luck 😃

graceful moat
#

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?

proud crypt
#

unless you're actually referring to the API, I can't really tell.

dull orchid
#

Is it possible to use PlayerLoginEvent or PlayerPreLoginEven instead of PlayerHandshakeEvent for BungeeGuard?

crystal sonnet
#

I'm by no means an authorative figure on Spigot 1.8, but I don't think it is

#

You can try it

long moon
#

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)

crystal sonnet
#

And vice versa!

dull orchid
#

Is it possible to use PlayerLoginEvent or PlayerPreLoginEven instead of PlayerHandshakeEvent for BungeeGuard? Sorry for tag but i want to ask @jaunty pecan

frank driftBOT
#

Hey Lobenski! Please don't tag staff members.

jaunty pecan
#

electronicboy already explained

dull orchid
#

How to get server name where user has for example permission group.Member?

south sinew
#

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.

proud crypt
#

"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.

south sinew
#

ah i see thank you

frank driftBOT
#

Hey Segysmundo! Please don't tag staff members.

nocturne elbow
#

hello i have a question: when i have a bungee server, do i have to put the plugin right there?

thorny echo
nocturne elbow
#

ok ty!

hollow grotto
#

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?

jaunty pecan
#

after calling setPermission or unsetPermission, you need to save your changes

hollow grotto
#

Oh, right you are.

jaunty pecan
#
hollow grotto
#

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.

jaunty pecan
#

Mhmmm

hollow grotto
#

Let me restart the server and I'll let you know what happens.

jaunty pecan
#

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

#

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

crystal sonnet
#

Though wouldn’t that be discarded when a (network) sync comes through?

jaunty pecan
#

Nope transient permissions will stay

crystal sonnet
#

Ah ok

#

So persistent during runtime I’d guess

jaunty pecan
#

Correct

hollow grotto
#

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.

crystal sonnet
#

I’m like 99% sure there should be a simpler solution

#

Though using ExtraContexts is probably your best bet

jaunty pecan
#

If your code is gonna need to update NTE too, then I guess transient is your best bet

crystal sonnet
#

Yeah. You’re right. I missed having to update NTE

hollow grotto
#

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);```
jaunty pecan
#

Uhh

#

it should work with "afk"

#

where are you calling that code?

#

Alternatively you can just pass it directly to the node builder

hollow grotto
#

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);
}```
jaunty pecan
#

Hmm that's weird

#

I'm not sure to be honest

hollow grotto
#

I have Node node = luckPermsApi.getNodeFactory().makeGroupNode(group).build();. I could change it to the group name.

jaunty pecan
#

Yea try that

hollow grotto
#

So no error message anymore about it finding the group, but still no differences in the scoreboard or nametag.

jaunty pecan
#

Erm well

#

you might need to do some debugging then

hollow grotto
#

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?

jaunty pecan
#

haha yep

#

and that might help yes

hollow grotto
#
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.

jaunty pecan
#

Erm

#

transient groups / perms won't show up in commands

hollow grotto
#

Good to know

#

I'll go back to the regular permissions for now for debugging then.

gritty pollen
#

where do i change the prefix in chat on a rank?

#

if you have the answer please @ me

jaunty pecan
#

I don't understand the question

hollow grotto
gritty pollen
#

where do i change the prefix

jaunty pecan
#

using the api?

gritty pollen
#

what?

long moon
#

I'm going to guess no

jaunty pecan
#

this is a channel for the luckperms api

gritty pollen
#

what is api

long moon
#

but what you're asking for is in the wiki

gritty pollen
#

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

long moon
#

!prefixes

gritty pollen
#

!prefixes

#

?

proud crypt
#

!meta

frank driftBOT
long moon
#

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)

gritty pollen
#

before it did

#

prefixes + suffixes

jaunty pecan
#

this is the wrong channel to discuss this, please use #support-1

hollow grotto
#

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

jaunty pecan
#

Does the event not expose the flag?

#

try using event.getValue()

hollow grotto
#

event.getValue exists but I've not been able to find much if any information on their API

#

So I'm kinda going blind.

jaunty pecan
#

it returns the value of set

#

so I guess getValue() could equally be isGoingAfk()

hollow grotto
#

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.

jaunty pecan
#

\o/

hollow grotto
#

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!

jaunty pecan
#

np

#

good luck!

hollow grotto
#

Thanks!

halcyon jewel
#

Is there any event that's called when

/lp user <name> parent addtemp <group> <time>

is executed?

crystal sonnet
#

Yes. But I don't know how it's called xD

#

The javadocs on the events should be clear though

grand parcel
#

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>)

drifting valley
#

Read up on nodes

#

!node

grand parcel
#

!node

drifting valley
#

!nodes

#

Aww

grand parcel
#

ops 😛

drifting valley
#

It's in the wiki

grand parcel
#

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?

crystal sonnet
#

@grand parcel There's a section for developers on the wiki

#

It explains how to use the API

#

Also read the Javadocs

grand parcel
#

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 :/

crystal sonnet
#

No

#

But there's an example on the wiki

bitter gulch
#

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>)

crystal sonnet
#

I know there isn't a specific event for that

#

You need to filter all the times it gets called wrongfully

bitter gulch
#

someone mentioned it had a caller

#

to know where it was being called from

#

any ideas on that?

crystal sonnet
#

Sorry no

bitter gulch
#

rip

crude laurel
#

Maybe Node(Add/Remove)Event?

#

then check if its a group node

#

there's an example in the wiki

dusty dagger
#

how to check the track of player ?

halcyon jewel
#

@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.

bitter gulch
#

thanks will give that ago

nocturne elbow
#

I couldn't figure out how to update a users role with the api

jaunty pecan
#

"roles" or groups are assigned using nodes too

nocturne elbow
#

um, how would I go about doing that, Im honestly confused, Im sorry.

nocturne elbow
#

Nvm I ended up figuring it out!

hollow grotto
#

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.

#

Now just to find out if Java reflection code is as easy to navigate as C#'s

hollow grotto
#

Luck, if I were to get something along these lines working and stable, would you be interested in a PR against helper?

teal tartan
#

There's discord server for helper

stray dock
#

Maybe anyone can help me how can i set a Node.Builder?

#

Idk how

#

I don't work with builders before now

frank driftBOT
#

Hey NycuRO! Please don't tag staff members.

stray dock
#

Oh..

#

I found, thank you

idle slate
#

hi, how do I set the parent group of a player?

#

(via api)

#

User#setPrimaryGroup(String) does not seem to work properly

teal tartan
#

I think you need to save user after you set it

long moon
#

You need to add the group and then use setPrimaryGroup

idle slate
#

I tried that. LuckPerms says the player is in the default group anymay

long moon
#

setPrimaryGroup basically expects a group that they're already a member of, it doesn't actually change their group

idle slate
#

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);```
crystal sonnet
#

@idle slate the wiki has examples on how to add a user to a group

unique olive
#

the top returns -1 and getoption returns empty

long moon
#

screenshot of meta info?

unique olive
#

rip

naive patrol
#

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.

long moon
#

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

naive patrol
#

Thanks mate, he's going to downgrade because "Java sucks"

toxic marlin
#

Probably try to make the method public

jaunty pecan
#

@naive patrol update to the latest version of luckperms

#

fixed already

hollow grotto
#

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.

jaunty pecan
#

those rules apply to bukkit event handlers

#

luckperms uses a different system

hollow grotto
#

Oh look at that - I completely missed that.

hollow grotto
#

On an unrelated note, I like the syntax sugar for catching multiple exception types.

jaunty pecan
#

Mhm indeed

#

😉

jolly herald
#

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 👀

crystal sonnet
#

@jolly herald the wiki has several examples, including how to set a player’s group

jolly herald
#

link? ^^

crystal sonnet
dark bough
#

@crystal sonnet Can you give @jolly herald a link from the exact location? We can't found an example

frank driftBOT
#

Hey Fanatic | Sven! Please don't tag staff members.

crystal sonnet
#

@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

fierce dew
#

how do i access player's info ? (bungeecord)

crystal sonnet
#

@fierce dew the API is the same on all platforms

#

And the wiki has a bunch of examples

fierce dew
#

ok can u provide me wiki link please? @crystal sonnet

frank driftBOT
#

Hey MrIvanPlays! Please don't tag staff members.

crystal sonnet
fierce dew
#

how do i get and set player's prefix/suffix ?

#

how do i set player's prefix/suffix ?

hollow grotto
fierce dew
#

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) ?

hollow grotto
#

Use your LuckPermsApi object to get a user, then create a permission node for that prefix or suffix, then use user.setPermission(node)

fierce dew
#

i need to set the player prefix...

hollow grotto
#
Node node = api.getNodeFactory().makePrefixNode(100, "[Some Prefix]").build();```
#

Then use user.setPermission(node); as described above.

fierce dew
#

why so complicated

hollow grotto
#

It's not complicated. There's a bit of a learning curve, sure, but all of this is on the page I linked above.

crystal sonnet
#

It’s not complicated. It’s actually very well designed and excellently documented

#

Though not beginner friendly

fierce dew
#

yeah, it is designed

#

but why you should make it like that

#

while you can just

#

SomeClass.someMethod(<params>)

hollow grotto
#

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.

fierce dew
#

for me is 13:32

hollow grotto
#

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.

fierce dew
#

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

nocturne elbow
#

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

crystal sonnet
#

If you’re using the same database, then yes

#

No issue

jagged ember
#
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?

crystal sonnet
#

I think so

#

I’d call it hasPermissionDefined

jagged ember
#

that's probably better, yeah

#

Thanks 😄 Got it working now

gilded timber
#

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.....

nocturne elbow
#

@crystal sonnet yes, i'm using the same db

frank driftBOT
#

Hey Duarte! Please don't tag staff members.

nocturne elbow
#

can you help me? i don't know how to check player's permission on other bungeecord.

dusty dagger
#

how to check group an permission ? please ?

dusty dagger
#

?

quick token
#

Hey, how i can get the player?

dusty dagger
#

Its my question

#

@quick token

quick token
#

yes, and I answerd you

#

so you get the permission from a specific group

dusty dagger
#

How to get the group of an player ?

#

please

quick token
#

That's my question xD

long moon
#

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

dusty dagger
#

for get group of an player ?

long moon
#

Yes

dusty dagger
#

Oke i'm looking

long moon
#

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

quick token
crystal sonnet
#

Check the wiki. It has plenty of examples

quick token
#

gunter

#

we are retarded

dusty dagger
#

why?

quick token
#

getUser().getGroup()

#

look my screen xD

dusty dagger
#

Ah yes

quick token
#

I seached for getPlayer but it's User

#

xD

dusty dagger
#

my i dont use le provider

quick token
#

USE IT

#

xD

dusty dagger
#

Oké

quick token
dusty dagger
#
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);
crystal sonnet
#

It really doesn’t matter how you get the instance of the API though

dusty dagger
#

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 ?

quick token
dusty dagger
#

no

#
LuckpermsApi api = ????.getProvider();
quick token
#

ou

#

wait

#
RegisteredServiceProvider<LuckPermsApi> provider = Bukkit.getServicesManager().getRegistration(LuckPermsApi.class);```
dusty dagger
#

yes

#

ty

#

You are french ?

quick token
#

no

#

but i speak a little bit

dusty dagger
#

Ah okey

#

Tu aime la baguette ?

#

😄

quick token
#

vi

#

Baguette, is the best! Je aime la baguette

#

!

dusty dagger
#

xD

#

its possible for get all groups of the player ?

quick token
#

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 ..

wary jacinth
#

What's the difference between getUserSafe and getUser? I assume one is intended for async tasks?

crystal sonnet
#

@wary jacinth no. The safe version just returns an Optional<User> object, while the other can return null

wary jacinth
#

ah okay, so basically doesn't matter which I use

crystal sonnet
#

Correct

#

One is even default implemented in the interface to call the other

hollow grotto
#

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();```
crystal sonnet
#

@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

rain lodge
#

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 😉 )

frank driftBOT
#

Hey TheFlash787! Please don't tag staff members.

hollow grotto
#
// 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.

long moon
#

If you want that kinda sugar take a look at Kotlin

hollow grotto
#

Oh? Good to know.

long moon
#

?? would be the elvis operator

#

return this.getItemMeta()?.getDisplayName() ?: this.material.toString();

hollow grotto
#

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.

crystal sonnet
#

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

rapid egret
#

Anyone know how to get default user from LP?

#

I'm porting GP to Paper/Spigot and need that 😃

hollow grotto
#

@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.

rapid egret
#

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

hollow grotto
#

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
#

User is an offline user

#

so pretty much the same as OfflinePlayer

crystal sonnet
#

@rapid egret you could add transient permissions to the default group

rapid egret
#

does LP API have a method to access the default group?

#

as I have no way of knowing what a server would name it

crystal sonnet
#

It's always called default

rapid egret
#

Ah so the name cant be changed?

crystal sonnet
#

Correct

#

!default

frank driftBOT
rapid egret
#

ok thanks

rapid egret
#

I dont see any methods to check permission with context sets

#

using a PermissionHolder

#

seems i can get contexts but not use them directly

crystal sonnet
#

There should be as long as it's a LP class

rapid egret
#

it is

crystal sonnet
#

Maybe check the examples on the wiki

#

I'm pretty certain that you even have to supply a context to properly check permissions

rapid egret
#

with sponge Subjects you do

#

getPermissionValue but there is no method on bukkit side that i see for the same

#

ill keep looking

#

ah looks like its included with LP's Node

#

yup

#

time to make a helper method 😃

crystal sonnet
#

Afaik contexts aren't a concept on Bukkit

#

Though thankfully they are for LP

rapid egret
#

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

crystal sonnet
#

👍🏼

rapid egret
#

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 😃

crystal sonnet
#

For sure

regal fulcrum
#

Does luckyperms support featherboard?

crystal sonnet
#

It should

regal fulcrum
#

Should i just type {prefix}?

crystal sonnet
#

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

neat jackal
#

vault_prefix should work too, if Vault is installed

#

With /papi ecloud download Vault before (and a server restart)

hollow zodiac
#

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?

hollow grotto
#

?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.

hollow zodiac
#

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?

hollow zodiac
#

waits for that essay to hit like a sack of bricks

#

I see you typing. I'm really curious.

hollow grotto
#

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.

hollow zodiac
#

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.

hollow grotto
#

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.

hollow zodiac
#

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.

hollow grotto
#

Tbch I'm not entirely sure what a context calculator is, but given its name, it sounds like you're not using it properly.

rapid egret
#

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

hollow zodiac
#

My event happens once every 12 minutes. Once every 12 minutes, activity time is updated. Once every vote, vote counts are updated.

rapid egret
#

doing anything in a tick event is trouble, i never liked them

hollow zodiac
#

That's when I want to set contexts for users/globally

hollow grotto
#

How would you recommend handling the 7 hours passing while the user is on the server, bloodshot?

rapid egret
#

scheduled task

hollow zodiac
#

And then, I want to specify permissions that are unlocked when certain contexts are true

rapid egret
#

NOT tick

#

check on an interval

#

simply check once a minute

#

and this can easily be run async

hollow zodiac
#

I have this info to work with

#

I just want to set user perms based on the dynamic result of this info ^^;

hollow grotto
#

What is U_ActivityTotal - seconds?

hollow zodiac
#

i was told contexts were the way to go

#

U_ActivityTotal is... minutes.

rapid egret
#

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

hollow grotto
#

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.

rapid egret
#

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

hollow grotto
#

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

rapid egret
#

ahhh

#

via an event?

hollow grotto
#

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.

rapid egret
#

yea that makes sense for context

#

since you only want them to be used if a player is afk

hollow grotto
#

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

rapid egret
#

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

hollow grotto
#

Right, yeah

rapid egret
#

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

hollow grotto
#

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.

rapid egret
#

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

hollow grotto
#

I'm only just getting back into plugin development myself. But I can say the same. He's great at what he does.

rapid egret
#

GP uses so much of LP now that I could never survive without it

#

and hes very quick at fixing any issues

#

Im actually going to rename it so its not confused with GP Bukkit