#luckperms-api

1 messages · Page 43 of 1

nocturne elbow
#

luckperms_prefix placeholder aint working on a scoreboard, it only shows 2 letters out of 9

obtuse jolt
#

Uh how is this lp api related?

nocturne elbow
#

Hello, I have problem. This function: user.data().remove(PermissionNode.builder(permission).build()); not removing permission node from user :/
Permission add works with similar function: user.data().add(...).

turbid solar
#

are you saving the user

nocturne elbow
#

Yeah

#

without saving and add function doesn't work

#

at this moment ADD works, REMOVE not

#

I tested to add permission without expire duration, and these function work

#

Keep in mind that NodeMap#remove(Node) will remove nodes that match every aspect of the node:

  • Key (the actual "permission")
  • Value (true/false)
  • Expiry
  • Applicable contexts

If you want to remove a certain permission regardless of expiry, contexts and value I suggest you do .data().clear(NodeMatcher.key(PermissionNode.builder()...))

#

That of course will remove every permission matching that key, ignoring value, expiry date and contexts

inland cradle
#

Hi, can you help me with get a rank by player? (I don't want to use p.hasPermission())

turbid solar
#

!cookbook

frank driftBOT
inland cradle
#

Ok, but i using bukkit api in Java...

turbid solar
#

Yes

#

?

inland cradle
#

Thanks, where i can get it?

hybrid panther
#

get what

turbid solar
#

!api

frank driftBOT
turbid solar
#

1st link

inland cradle
#

ok, i will watch it

#

I need some like this:
LuckPermsApi api = LuckPerms.getApi();
User user = api.getUser(p.getUniqueId());
Group group = api.getGroup("owner");

if(user.inheritsGroup(group)){

}

hybrid panther
#

sigh

#

cas gave you a link which shows how to do it

inland cradle
#

I can't use p.hasPermission(), because i need get and Operators...

hybrid panther
#

what?

inland cradle
#

I need some like this, this is my code.

#

Sorry i have small misstake with Strings...

hybrid panther
#

im not understanding what you need and what the problem is, i cant help you. sorry

inland cradle
turbid solar
#

Do you want to see what group(s) they are in or, if they are in one (boolean)

inland cradle
#

boolean, please

turbid solar
inland cradle
#

Can you give me source code for condition?

nocturne elbow
#

what?

unkempt acorn
#

guys I am kinda stuck with the developer API and i cant find (probably just me looking a the wrong place) the solution or any information about what i need.

I'm trying to promote the player when they did a certain command (though a clickable text in a book)
but beside letting the console execute the promote command im wondering if it possible with the luckperms api

nocturne elbow
#

You mean promote on a track?

#

Get the track from the trackmanager which you can get from the LuckPerms API object, get the user from the usermanager and invoke the Track#promote(User) method

unkempt acorn
#

aah yes i did but it wants a contextset as well

#

let me hastebin it 🙂

nocturne elbow
#

You can pass ImmutableContextSet.empty() if you want it to be global // with no contexts

unkempt acorn
#

aah awesome 🙂

nocturne elbow
#

lgtm

unkempt acorn
#

cool i will test it later 🙂

unkempt depot
#

Using user.getCachedData().getMetaData().getMetaValue("key-here"); - this returns null. What's the difference between that and doing user.getCachedData().getMetaData().getMeta().get("key-here").get(0);

#

Using that method that returns a list ^ I checked, and the data corresponding to key-name is there

nocturne elbow
#

Contexts

unkempt depot
#

How do I pass that first method contexts?

nocturne elbow
#

You don't, the first one returns the values for the applicable data (i.e. where context applies); contexts let you define when and where a permission is applied, so if it doesn't apply it isn't calculated

unkempt depot
#

Oh...nevermind it actually does work. The problem was that, I was setting the key keyName, and it looks like meta fetching doesn't support camel casing...?

#

I was getting with the key keyName and that was null.

nocturne elbow
#

oh yeah I think there's some woes regarding casing

#

should prolly make an issue or something

#

!issue

frank driftBOT
unkempt depot
#

yepp

nocturne elbow
#

yeah but when querying it doesn't make it all lowercase

unkempt depot
#

Right

#

So the issue is not that it's not saving with casing, it's that it's not querying with lowercase

nocturne elbow
#

yep

unkempt acorn
#

oh fefo it works 😄

#

forgot to keep you updated

steady shoal
#

i want to make a secret command and when my friends type it they get a role without me being online, but without giving them OP to have acces to giving roles.

hybrid panther
#

are you making a java plugin?

steady shoal
#

@hybrid panther im kinda noob, is there a plugin or should I learn with luckperms API?

frank driftBOT
#

Hey Panyel! Please don't tag helpful/staff members directly.

steady shoal
#

I thought that I there could be a way to override the permissions obstacle in bukkit-commands

#

I dont really know java to start doing a plugin.

#

I just need a way for my friends to get a role while Im away

drowsy galleon
#

user manager keep nulling on me?
5.2.113 Bukkit Luckperms

import net.luckperms.api.LuckPerms;
import net.luckperms.api.model.user.User;
import net.luckperms.api.model.user.UserManager;

UserManager u = luckperms.getUserManager();

Caused by: java.lang.NullPointerException
at me.reecepbcups.evnt.PlayerPicker.onCommand(PlayerPicker.java:119) ~[?:?]

nocturne elbow
#

Sounds a whole lot like your luckperms object is null

#

Are you actually getting the LuckPerms instance and assigning it to your luckperms object?

drowsy galleon
#

luckperms = getServer().getServicesManager().load(LuckPerms.class);
correct? inside of my constructor

#

wait, nvm. I am a dummy I believe

obtuse jolt
#

You should put it in the onEnable method

#

And ensure you add depend or softdepend of luckperms in plugin.yml

rain hemlock
#

Hey there, is anyone able to tell me why I am getting this error when trying to change my users group?

hybrid panther
#

broken pwfl plugin

nocturne elbow
#

Aber

#

That's erm... what they're here for lmao

rain hemlock
#

lol

#

yeah, I don't understand why this isnt working, I took it straight from the cookbook!

hybrid panther
#

ya i thought this was #support :(

nocturne elbow
#

That looks like... your Player object might be null?

rain hemlock
#

not possible though, its on the player join event! xD

#

Ohh wait...

#

*facepalm

nocturne elbow
#

👀

rain hemlock
#

i resign my right to code

nocturne elbow
#

Lol

dreamy parcel
#

Does LuckPerms Api works on BungeeCord too?

nocturne elbow
#

It's platform agnostic, the main API usage pages explain how to get the LP API instance

#

!api

frank driftBOT
ancient sable
#

!api

frank driftBOT
sick nimbus
#

@everyone

nocturne elbow
sick nimbus
hybrid panther
#

Indeed praiseverbose

unkempt depot
#

I am getting cacheddata meta when a player joins but it's returning null for keys that actually do exist

#

Is cacheddata only loaded after a join happens and that's why it's null? If so, what other method should I use to get meta / tell it to load all meta first

nocturne elbow
#

example?

unkempt depot
#
on player join:
   val = user.getCachedData().getMetaData().getMetaValue(key.toLowerCase());
   // val is null, even though I am 100% sure that it exists by doing /lp user <user> meta info
#

I am wondering if cacheddata isn't cached until after the player joins, so it shows up as null

nocturne elbow
#

testing time!

unkempt depot
#

it should be in the source

#

just wanted to know if you knew off the top of your head

nocturne elbow
#

How are you getting the user? PlayerAdapter or UserManager?

unkempt depot
#

user manager

nocturne elbow
#

Works fine for me PES_SadShrug does it return the correct value if you run it anytime later?

unkempt depot
#

I think all of this is invalid...it works fine on my environment but not on my client's

nocturne elbow
#

Keep in mind that just because it shows in /lp user <user> meta info it doesn't mean they "have" the value; maybe there are contexts that don't apply, and even if there are none there are settings to make permissions not apply if they are global // have no context

nocturne elbow
#

!cookbook @sterile tree

frank driftBOT
nocturne elbow
#

why dose he have the default rank when i promoted him to a vip

#

Is this to do with the API?

#

whats api

#

There are two channels named support and you're asking in the one that has the thing you don't know what it is in the name .-.

#

well i dont look at the name i just want my help and im gone

#

General LP help in the support channels please

#

...

#

can i please just get a yes or no answer

#

If you ask in the right channel

#

I wonder

#

I wonder hmmm

silver granite
#

Is there a way to get a list of the groups using the api?

turbid solar
#

Yes

silver granite
#

how?

turbid solar
#

Groups a player has or all groups on the server?

silver granite
#

all groups on the server

turbid solar
#

d;lp GroupManager#getLoadedGroups

slate deltaBOT
silver granite
#

So like this. Set<Group> groupList = LuckPermsProvider.get().getGroupManager().getLoadedGroups();

turbid solar
#

Ye

silver granite
#

alr ty

tall oriole
#

Hi, can I give player temporary rank in plugin by api?

tight reef
#

I want to do something every time a command or permission is denied. What event would I listen to for that?

nocturne elbow
frank driftBOT
nocturne elbow
#

d;lp Builder#expiry

slate deltaBOT
#
default B expiry(long duration, TimeUnit unit)```
Description:

Sets the time when the node should expire.

The expiry time is calculated relative to the current system time.

Parameters:

duration - how long the node should be added for
unit - the unit duration is measured in

Returns:

the builder

tall oriole
#

okay, thanks 🙂

nocturne elbow
tight reef
#

For others

#

Darn - I was hoping to make setting up permissions for a new server / plugin easier. Thanks for the response.

hybrid panther
#

PermissionDeniedEvent

#

Pr it fefo

nocturne elbow
#

No u

hybrid panther
#

Oh ok

tight reef
#

Thank you Abner!

#

@hybrid panther Is PermissionDeniedEvent something that exists or were you suggesting to create one?

frank driftBOT
#

Hey Magnum! Please don't tag helpful/staff members directly.

hybrid panther
#

Suggesting it 😛

tight reef
#

Gotcha! Thanks I misunderstood and I've been searching all over for it 😄 Yes that is a great idea. And sorry Clippy ^_^

limpid escarp
#

how can i get the Luckperms rank player?

tight reef
#

Like what group a player is in?

#

!cookbook has examples - I'm not super experienced with the API but I suggest the GerPrefixCommand for reference, just change it for group.

frank driftBOT
tight reef
nocturne elbow
#

Hello
Is there a way on the luckperms api to get the history of groups of a user?

hybrid panther
#

You were given an answer

nocturne elbow
#

Where can i find a explanation of how to use those loggers sir?

#

You can look around the methods and classes in the JavaDoc

#

!javadoc third link

frank driftBOT
nocturne elbow
#

Okay, thank you Fefo for helping me with this 👍

nocturne elbow
#

permission update event??

#

anything like that?

#

can't find anything in the API docs

#

Because permissions don't update, nodes are immutable

#

What are you wanting to achieve exactly?

#

I want to catch all the changes done by a user/console...when updating the permissions.

#

NodeAddEvent/NodeRemoveEvent?

#

Ohh yeah should should work

#

BTW

#

what is LogPublishEvent?

#

Probably to do with the log you get when someone makes a change with a command

#

But that's pure text, you would need to parse it yourself which egh

#

hmm I actually want pure text nothing much...

#

If you want to listen to updates in people's/group's permissions, NodeAddEvent/NodeRemoveEvent is what you're looking for

#

d;lp LogPublishEvent

slate deltaBOT
#
public interface LogPublishEvent
extends LuckPermsEvent, Cancellable```
LogPublishEvent has 1 methods, 2 extensions, and  2 super interfaces.
Description:

Called when a log is about to be published to the storage file/table

nocturne elbow
#

oh wow

#

I have no clue what that is to be honest lmao

#

I guess I know what that is

#

It's never been in my interests list lol

#

lol ok thanks

nocturne elbow
#

as expected.

brazen spire
#

Hello, I'm using a BungeeCord network and want to use permissions for players which are currently connected to a different server. e.g. Player A is connected to server1 but I want to do permissions checks on server2. I know how to use the API and I can load the permissions for that user. For performance and code reasons I want to keep the permission data cached and I don't want to use the loadUser method with a CompletableFuture.
The UserHousekeeper does cleanup every 30 seconds all users which are older than 5 minutes.
What's the best way to keep the cached data in memory? Do I have to call UserManager.loadUser(uuid) every 3 minutes?

nocturne elbow
#

~~ xy mmlul

#

It seems you are trying to avoid something tho... what is it you want to achieve exactly?

night phoenix
#

Hello, is there a way to keep an offline player's data loaded into cache?

nocturne elbow
night phoenix
#

I have a multi-bungee setup, and i need to keep data loaded across all the nodes

jaunty pecan
#

It’s not possible to customise the user uncache behaviour at the moment

#

But I could add an event for it I suppose

night phoenix
#

Hmm, yeah that would be very helpful

brazen spire
#

I have some sort of "bridge" api. E.g. I can use /city info <id> and get some informations from another spigot server for a worldguard region. Admins have more permissions and should be able to see more stuff there.

brazen spire
night phoenix
#

in the meantime i guess we can just call the UserHousekeeper.registerUsage method every minute or so

#

@brazen spire

nocturne elbow
#

I mean that is not API but you could do that (although with registerApiUsage instead).
IMO if it's something like commands you can run them async and wait until the user loads, but if it's for things like events that require real-time checks you should be looking at some workarounds

nocturne elbow
#

Lol or that

hybrid panther
nocturne elbow
#

Luck making API changes across patch version

#

Smh

midnight flint
#

Heyo! What's the best way of getting recently changed roles? Any return for when a role is set or a sort of log?

#

Working on making OBS alerts for role change hahaha

nocturne elbow
#

!cookbook has a listener example for that I believe

frank driftBOT
nocturne elbow
#

Well it has something similar, check the player remove group whatever listener, but instead of that you can use either both NodeRemoveEvent and NodeAddEvent separately or both actions in a single NodeMutateEvent

red creek
#

So

#

I have this error

#

that pops up when I try to get a player prefix, it works in my test server, but on my client's server it's not working.

#

this is the method

#

and this is the starcase

#

Does anyone knows how to fix that

nocturne elbow
#

Tell them to update LuckPerms

red creek
#

We have the same version

#

5.2.76

#

Idk why it's not getting it

nocturne elbow
#

You sure he has that version? That method has existed ever since v5.1

red creek
#

OH ye ye ye

#

I read it wrong

#

it's 5.0.72

#

do you know how can I get it with this version

#

?

turbid solar
#

Update

nocturne elbow
#

I mean they should 100% update..

turbid solar
#

No reason not to

nocturne elbow
#

Not you doing workarounds lol

red creek
#

They already have over 45 groups with alot of thing set up

turbid solar
#

you delete the old jar

#

and put the new jar in

#

boom updated

nocturne elbow
#

If they don't delete the folder nothing will be lost

red creek
#

Are you sure that it won't harm the info

turbid solar
#

yes

#

just make sure they don't delete the folder

nocturne elbow
#

The data is stored in the folder, not the jar

#

All they have to do is replace the jar and that's it

neat holly
#

Hey peeps, if we use canAccess for the serverInfo interface for bungee.api to check if a player has the right right perm, would this work with LP?

nocturne elbow
#

¯\_(ツ)_/¯ I don't see why it wouldn't

turbid solar
#

What was the node thing called that didn't get saved to storage?

jaunty pecan
#

transient

nocturne elbow
#

Oh yeah yesterday I was talking with someone about transient fields & serialization and then it hit me "that's why the transient node map is called transient" :P

#

Took me a while 😆

turbid solar
#

How do you add them? Can't find anything on the wiki

jaunty pecan
#

instead of data() use transientData()

turbid solar
#

ah thanks didn't look good enough then :p

bold plinth
#

can anyone help me on how i would clear all players from a group using the api?

#

tried to look through but cant seem to find it think im just dumb

#

was thinking of this but the group.getdata clear doesnt seem right at all

nocturne elbow
#

That will clear the group's permissions :d

bold plinth
#

ye i c

#

xd

nocturne elbow
#

Groups don't contain their "members" because it's not a group of people

#

Users have the group as parent. What you'll have to do is build an InheritanceNode for the group you want, use the UserManager#searchAll method to find everyone who has that node, iterate through the UUIDs, modify the user and remove the node

#

That's a bit of a process lol

bold plinth
#

yikes

#

fun

nocturne elbow
#

Much

bold plinth
#

no easier way then? xd

nocturne elbow
#

I mean you could use a custom CommandSender class and make it run a bulkupdate command, record the output and run the confirm command ¯\_(ツ)_/¯ but that's hacky af and I wouldn't trust That to work all the time

buoyant moat
#

How do I get the UUID of a permission holder?

nocturne elbow
#

Check if it's a user, cast and get

buoyant moat
#

So there isn't a way to just get the uuid straight off of the PermissionHolder?

nocturne elbow
#

Well what if it's a group?

buoyant moat
#

How do I check if the a permission holder is a group?

nocturne elbow
#

a) instanceof
b) check the identifier (PermissionHolder.Identifier)

red creek
#

@nocturne elbow After I updated the luckperms

frank driftBOT
#

Hey Ayouub! Please don't tag helpful/staff members directly.

red creek
#

The commands are not working anymore

nocturne elbow
#

any commands?

red creek
#

Yes

nocturne elbow
#

Or just LuckPerms'?

red creek
#

just luckpers

#

When I do any lp command nothing happens

nocturne elbow
#

"nothing" as in..? Does it say no perms? Does it print any errors? Nothing prints anywhere but the action occurs successfully?

red creek
#

Nothing

#

I run the command

#

nothing shows

nocturne elbow
#

What about in console?

#

What client do you use?

#

MC client

#

What server & client version? Is ViaVersion installed on the server?

red creek
#

let me see rq

nocturne elbow
#

Loads of info :d

red creek
#

this starcase

nocturne elbow
#

is ViaVersion installed?
no
*Error is a VV error*

#

Tell them to update ViaVersion and modules

red creek
#

So only update viaversion to latest update?

turbid solar
#

Yes

red creek
#

Alright ty

alpine blade
#

Especially Spigot

red creek
alpine blade
#

Good luck to them making the server hold at least 1 player on 20TPS

nocturne elbow
#

How to get user prefix on bungeecord if luckperms is on spigot server and bungeecord

#

If everything is synced together you should be able to get it the same way you would do on Bukkit

#

!cookbook has an example command for getting the prefix

frank driftBOT
nocturne elbow
#

That example plugin is Bukkit oriented but the LuckPerms API itself is the same across all platforms!

trim olive
#

How would I get the player's prefix as an adventure component?

rustic laurel
#

you get it as a string and do the adventuring yourself

midnight escarp
#

Hello!

#

i am attempting to get the time remaining of a specific node. any idea how to do this?

#

please @ me if you respond. Thanks!

#

i am currently checking if they have the permission node if (api.getUserManager().getUser(p.getUniqueId()).data().contains(time2, NodeEqualityPredicate.IGNORE_EXPIRY_TIME).asBoolean())

#

but no idea how to get the permission node they have

nocturne elbow
#

You should get the set of distinct permissions, loop through it and compare the key to get the one you want

#

d;lp PermissionHolder#resolveDistinctInheritedNodes

slate deltaBOT
#
@NonNull SortedSet<Node> resolveDistinctInheritedNodes(@NonNull QueryOptions queryOptions)```
Description:

Gets a resolved and sorted view of the holders own and inherited distinct Nodes.

Effectively a sorted version of resolveInheritedNodes(QueryOptions), without duplicates. Use the aforementioned method if you don't require either of these attributes.

Inheritance is performed according to the platforms rules, and the order will vary depending on the accumulation order. By default, the holders own nodes are first in the list, with the entries from the end of the inheritance tree appearing last.

Parameters:

queryOptions - the query options

Returns:

a sorted set of the holders distinct inherited nodes

midnight escarp
#

hmm okay

#

ill give that a shot

#

and what would QueryOptions be @nocturne elbow

frank driftBOT
#

Hey CodingMachine! Please don't tag helpful/staff members directly.

nocturne elbow
#

d;lp PermissionHolder#getQueryOptions

slate deltaBOT
#
@NonNull QueryOptions getQueryOptions()```
Description:

Gets the most appropriate query options available at the time for the PermissionHolder.

For Users, the most appropriate query options will be their current active query options if the corresponding player is online, and otherwise, will fallback to the current static query options if they are offline.

For Groups, the most appropriate query options will always be...

This description has been shortened as it was too long.

Returns:

query options

rocky compass
#

I need to get a list of OfflinePlayers that belong to a LuckPerms group. So a list of UUID's of players who belong to a group would be best. I have no idea how to even get close though. My best attempt so far is: gm.getGroup("groupName").getNodes(NodeType.INHERITANCE) Where gm is GroupManager. I don't know what to do from there. Thanks

nocturne elbow
#

d;lp UserManager#searchAll

slate deltaBOT
hoary ermine
#

hello, how do i add time to expiring permission?

#

for example player has "group.vip" for 30 days, and i want to add 30 days more

nocturne elbow
#

Build the InheritanceNode with an expiry and use the NodeMap#add(Node, TemporaryNodeMergeStrategy) method with the strategy as ADD_NEW_DURATION_TO_EXISTING

hoary ermine
#

okay, thanks for help ❤️

untold cloud
#

can you get the prefix from a Group?

nocturne elbow
#

Group -> getCachedData -> getMetaData -> getPrefix

untold cloud
#

perfect ty

rocky compass
# nocturne elbow d;lp UserManager#searchAll

Thank you! here's the actual code if anyone's looking at this in the future.

try {
  UserManager lpUserManager = plugin.getLuckPerms().getUserManager();
  InheritanceNode node = InheritanceNode.builder("groupName").build();
  Map<UUID, Collection<InheritanceNode>> map = lpUserManager.searchAll(NodeMatcher.key(node)).get();
} catch (InterruptedException | ExecutionException e) {
  e.printStackTrace();
}```
Of course the actual list comes from map.keySet()
undone stream
#

Hello! I'm trying to hook LuckPerms into my plugin that uses Guice. It works 100% LuckPerms hook on plugins that doesn't uses Dependency Injection.

#

If I could receive help to this, it would be nice n.n

#

I'm doing this on my onEnable method:

        LuckPerms luckPerms = getServer().getServicesManager().load(LuckPerms.class);
        luckPermsLine.register(luckPerms);
#

And this it's my listener of LuckPerms:

public class LuckPermsLine {
    @Inject private PhoenixHub plugin;

//    @Inject
//    public LuckPermsLine(LuckPerms luckPerms) {
//        this.luckPerms = luckPerms;
//    }

    public void register(LuckPerms luckPerms) {
        EventBus eventBus = luckPerms.getEventBus();
        eventBus.subscribe(this.plugin, NodeAddEvent.class, this::onNodeAdd);
        eventBus.subscribe(this.plugin, NodeRemoveEvent.class, this::onNodeRemove);
    }

    private void onNodeAdd(NodeAddEvent e) {
        if (!e.isUser()) {
            return;
        }

        User target = (User) e.getTarget();
        Node node = e.getNode();

        this.plugin.getServer().getScheduler().runTask(this.plugin, () -> {
            Player player = this.plugin.getServer().getPlayer(target.getUniqueId());
            if (player == null) {
                return; // Player not online.
            }

            if (node instanceof InheritanceNode) {
                String groupName = ((InheritanceNode) node).getGroupName();
                player.sendMessage(color(String.format("&8&l* &fThe &b%s &frank has been added on you.", groupName)));
//                scoreboardAPI.setScoreboard(player, "normal");
            }
        });
    }
nocturne elbow
undone stream
#

Nope, I don't use any plugins of that style

#

It happens when I change of the parent on a Player, where I want to make an action

#

(For testing I commented line that injects dependency of another class)

#

I think it's the plugin instance on the task, but no idea about how to fix it

nocturne elbow
#

Does it work if you don't pass the plugin instance the eventbus subscribe method?

undone stream
#

Gotta try it rn

#

Still happens

nocturne elbow
#

I have no idea what's going on lmao

undone stream
#

Oops, it calls here too the plugin instance

rustic laurel
#

could the command need an explicit context for some reason

undone stream
#

And if I comment that I suppose wont work the listener

nocturne elbow
#

You can subscribe to events without passing a plugin

undone stream
undone stream
#

Uh, my bad

#

Sorry, gotta try it that

hybrid panther
#

Guice peepoClap

vocal gale
#

Does the plugin cache a player on all servers if they join one server

#

or would I need to use User#loadUser

rustic laurel
#

LP is per-server and afaik won't cache on others

#

i don't recall there being infrastructure for that but @nocturne elbow would know for sure

#

fefo has actually read the code

nocturne elbow
#

the other servers don't even know about the player

#

LP loads "on demand"

vocal gale
#

So loadUser is the only way?

nocturne elbow
#

what's so bad about it?

vocal gale
#

I hate futures

nocturne elbow
#

why lol

tribal wave
#

futures are... the future!

vocal gale
#

I need to return the players primary group weight

#

and returning in futures is.. annoying

nocturne elbow
tribal wave
#

if you don't mind bogging down your main thread a bit why not just .get() the future as soon as you call loadUser

#

i cant imagine it'll take too long anyways after the first call for any user

#

cuz caching

nocturne elbow
#

for API calls the user will be loaded for 5 minutes tops

vocal gale
#

I can just do it async right

tribal wave
#

yeah

#

it's meant to be done async XD

nocturne elbow
#

I mean.... futures are async

rustic laurel
#

future = async

vocal gale
#

.get blocks thread

rustic laurel
#

then don't .get

#

use as intended

vocal gale
#

ok larry

rustic laurel
#

😄

nocturne elbow
#

The idea with that is that you do

luckPerms.getUserManager().loadUser(uuid).thenAccept(user -> {
  // user & async :D
});
rustic laurel
#

.thenAcceptAsync why

#

what is the point

#

someone tell me

vocal gale
#

man I need to return the users group

rustic laurel
#

anyone

vocal gale
#

you cant return inside thenAccept its dogshit

nocturne elbow
#

what are you doing exactly?

#

why do you need it immediately?

nocturne elbow
# rustic laurel .thenAcceptAsync why

afaik thenAccept will run it on the same thread as the other CompletableFuture's method; thenAcceptAsync will run it on the specified executor (or on ForkJoinPool if none is specified I think)

vocal gale
rustic laurel
#
private String groupname(UUID uuid){
luckperms.getUserManager().loadUser(uuid).thenAccept(user -> {
LuckpermsGroupObjectThing group = user.getmethegroupPLEASELuckperms;
return group.pleaseGiveMeTheNameLuckPerms }
nocturne elbow
#

then... move everything in the future method?

tribal wave
#

if it were me i'd probably check a specific meta value rather than just the group weight

rustic laurel
#

there's the pseudocode kekw

nocturne elbow
#

larry that's not how futures work lmao

rustic laurel
#

you're not how futures work

vocal gale
#

you cant return inside a future

#

it gave me mental breakdowns

rustic laurel
#

yeah yeah yeah

vocal gale
#

i had to rewrite chunks of code

nocturne elbow
#

but where are you wanting the weight

vocal gale
#

it scared me

rustic laurel
#

you just instantiate the string outside and assign inside right?

vocal gale
nocturne elbow
#

then you can totally do everything inside the thenAccept consumer

#

heck, even the command itself

vocal gale
#

the thing is I’m trying to create a simple util for my core

#

and it should do PermissionUtil.getWeight(uuid) and compare it to another weight

#

ygm?

nocturne elbow
#

Then return a CompletableFuture<Integer> aPES_LulLaugh

vocal gale
nocturne elbow
#

I mean it's your call, either do things safe for the server and run them async or use CompletableFuture#join() every time it gets called

#

Your choice ¯_(ツ)_/¯

vocal gale
#

or quit developing

jaunty pecan
#

my totally super awesome beginners guide to completablefutures, in case you haven't stumbled across it already: https://luckperms.net/wiki/Developer-API#using-completablefutures

jaunty pecan
#

yes, that 😎

vocal gale
#

but its just

#

so shit compared to javascript’s one

jaunty pecan
#

I agree, it's not the best

jagged elbow
#

How can i get the group of a player in JoinListener?

turbid solar
#

!cookbook has examples

frank driftBOT
jagged elbow
#

tanks

turbid solar
#

Is LP on the server

ornate bay
#

Hello, I'm getting prefix always as null with code:

User permsUser = plugin.getPerms().getPlayerAdapter(ProxiedPlayer.class).getUser(player);
String prefix = permsUser.getCachedData().getMetaData().getPrefix();

when I perform command /lp group vip info it says prefix is set. Any help, please?

nocturne elbow
#

What does '/lpb user <user> info' say?

ornate bay
#

Thanks, through /lpb it's working.

zealous yacht
#

what is this code :

user.data().clear(NodeType.INHERITANCE::matches)

turbid solar
#

Removes every parent of a player

zealous yacht
#

Ok

#

And my code to remove grade work ?

turbid solar
zealous yacht
#

Yes

jaunty pecan
#

new javadoc \o/

nocturne elbow
zealous yacht
#

👍

dire remnant
#
        LuckPerms api = LuckPermsProvider.get();
        User u = api.getUserManager().getUser(p.getName());
        
        u.data().add(PrefixNode.builder(chatCode, Integer.parseInt(nc.getConfigValue("NickColor.Priority"))).build());
        api.getUserManager().saveUser(u);```
#

should that be adding a prefix node bc it isnt working for me

#

no errors, just no updates

nocturne elbow
#

What is "chatCode" exactly? Does it show in /lp user <user> meta info after saving the data?

dire remnant
#

Ignore chatCode its a string variable

#

But not, weirdly it isnt

nocturne elbow
#

but what are the contents of that string

dire remnant
#

An & code

#

such as &c

nocturne elbow
#

what LP version?

#

that works fine for me PES_SadShrug

#

keep in mind that "color codes" will be rendered in meta info and formatted so check you don't have something like this showing up:

#

if you hover over it it will show the raw data

dire remnant
#

Ahh

#

How do I convert that to an actual colour code

nocturne elbow
#

wdym

dire remnant
#

Wait sorry

#

ignore me

nocturne elbow
#

ok lol

hybrid panther
#

:)

dire remnant
#

tysm

#

How do I set instead of add a prefix node? it keeps adding ones at 7 priority

nocturne elbow
#

wdym?

dire remnant
#

like with /lp setprefix

#

instead of /lp addprefix

#

bc I end up with multiple at the same priority

nocturne elbow
#

I guess you could have something like hmm

user.data().clear(node -> NodeType.PREFIX.matches(node) && ((PrefixNode) node).getPriority() == 1233);
dire remnant
#

Ah yeah thats perfect

#

tyvm

dire remnant
nocturne elbow
#

Because you are not checking if the node is a prefix node

nocturne elbow
dire remnant
#

Ah right, sorry haha

jaunty pecan
#

You can also make it even nicer:

#
int i = Integer.parseInt(nc.getConfigValue("NickColor.Priority"));
user.data().clear(NodeType.PREFIX.predicate(node -> node.getPriority() == i));
#

does the casting for you :)

nocturne elbow
#

Luck himself SKHyperSweat

dire remnant
#

Tyvm sir haha

toxic gulch
#

Hi

toxic gulch
odd vapor
#

How I can set this permission use api?

#

with time and value == false

nocturne elbow
odd vapor
#

oke realy thanks

odd vapor
#

How I can remove permission?

#

I try this

Node node = Node.builder("ray.chat").value(false).build();
DataMutateResult result = user.data().remove(node);```
or this
```java
Node node = Node.builder("ray.chat").build();
DataMutateResult result = user.data().remove(node);```
but don't work
turbid solar
#

are you saving the user

odd vapor
#

save user?

turbid solar
#

Yes

odd vapor
#

how?

#

how I add permission I don't save this

turbid solar
#

UserManager#saveUser(User)

odd vapor
#

hmm I don't understand how this work ;/

turbid solar
#

d;lp UserManager#saveUser

slate deltaBOT
#
@NonNull CompletableFuture<Void> saveUser(@NonNull User user)
throws NullPointerException, IllegalStateException```
Description:

Saves a user's data back to the plugin's storage provider.

You should call this after you make any changes to a user.

Parameters:

user - the user to save

Throws:

NullPointerException - if user is null
IllegalStateException - if the user instance was not obtained from LuckPerms.

Returns:

a future to encapsulate the operation.

odd vapor
#
Node node = Node.builder("ray.chat").value(false).build();
Main.luckPerms.getUserManager().modifyUser(Bukkit.getOfflinePlayer(args[0]).getUniqueId(), (User user) -> {
                DataMutateResult result = user.data().remove(node);
            });```
turbid solar
#

that should work yes

odd vapor
#
            Node node = Node.builder("ray.chat").value(false).build();
            Main.luckPerms.getUserManager().modifyUser(Bukkit.getOfflinePlayer(args[0]).getUniqueId(), (User user) -> {
                DataMutateResult result = user.data().remove(node);
                if (result.wasSuccessful()) {
                    sender.sendMessage("§aWork");
                } else {
                    sender.sendMessage("§cError");
                }
            });```
#

and Error ;/

turbid solar
#

What is error

#

!paste error

frank driftBOT
#
Please use pastebin!

Seeing a paste of the problem makes everything so much easier! Use https://bytebin.lucko.me/ for easy pasting!

For console errors:

Pastebin any relevant segments of the console log. If it's a startup error, this includes the entire startup log!

Other errors:

Pastebin the entire LuckPerms config file (passwords removed) as well as any other relevant files!

odd vapor
#

no no send message §cError

#

I want remove this permission

nocturne elbow
#

remove will also remove the node that matches all of the qualities:

  • Node key (a.k.a "permission")
  • Node value (true/false)
  • Contexts
  • Expiry
odd vapor
#

oh

nocturne elbow
#

You should use clear(NodeMatcher.key(node)) or something similar

odd vapor
#

oke realy thanks

#

but question

#

I can get result this?

#

or I can only check before clear this?

nocturne elbow
#

You can use contains before clear I guess..?

odd vapor
#

user.data().contains()

#

yes?

nocturne elbow
#

yea

odd vapor
#

sorry but I don't understand parameters

turbid solar
#

It takes a Node no?

odd vapor
#

Node first

nocturne elbow
#

d;lp nodemap#contains

slate deltaBOT
#
@NonNull Tristate contains(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate)
throws NullPointerException```
Description:

Gets if this instance contains a given Node.

Returns Tristate.UNDEFINED if the instance does not contain the node, and the assigned value of the node as a Tristate if it is present.

Parameters:

node - the node to check for
equalityPredicate - how to determine if a node matches

Throws:

NullPointerException - if the node is null

Returns:

a Tristate relating to the assigned state of the node

odd vapor
#

oh intresting

#

Fefo💜 you are the best 😄

nocturne elbow
odd vapor
#

question how I can read time (Expiry) with permission player?

odd vapor
#

and where I can learn this? xD

odd vapor
#
long time = user.getNodes(NodeType.PERMISSION).stream()
                        .filter(Node->Node.getPermission().equals("ray.chat"))
                        .filter(Node::hasExpiry)
                        .filter(permissionNode -> !permissionNode.getValue())
                        .map(Node -> Node.getExpiry().get(INSTANT_SECONDS))
                        .mapToLong(Instant-> Instant)
                        .max()
                        .orElse(0);```
#

but this don't work

#

how I make bad?

nocturne elbow
odd vapor
#

@nocturne elbow You can help me? I want make mute and unmute work on luckperms

frank driftBOT
#

Hey Raymano! Please don't tag helpful/staff members directly.

odd vapor
#

and I try read time to end mute xD

fresh sonnet
#

Is it possible to do a BulkUpdate with the API? If so, how?

vocal adder
#

Is there any way to get the members of the group?

nocturne elbow
# odd vapor and I try read time to end mute xD

I mean... couldn't you just check for the permission if they want to chat with Player#hasPermission(String permission)? If it didn't expire it will evaluate to false, and if it did expire it got removed and it will evaluate to (presumably) true

nocturne elbow
nocturne elbow
odd vapor
#

but I want read time to end mute

nocturne elbow
#

Ah

nocturne elbow
odd vapor
#

moment I check again what this return

#

return null ;/

nocturne elbow
#

what's the code you're running exactly?

odd vapor
#
    @EventHandler
    public void chatEvent(AsyncPlayerChatEvent e) {
        final Player p = e.getPlayer();
        if (p.hasPermission("ray.chat")) {
            String message = Tab.Color(NonBukkitMethods.getTagPrefix(p)) + ChatColor.translateAlternateColorCodes('&', p.getDisplayName()) + "§r: " + translateColorFormat(filterChat(e.getMessage()), e.getPlayer());

            for (Player online : e.getRecipients()) {
                online.sendMessage(message);
            }
        } else {
            
             Main.luckPerms.getUserManager().modifyUser(p.getUniqueId(), (User user) -> {
             final Instant expiry = user.getNodes(NodeType.PERMISSION).stream()
             .filter(Node -> Node.getPermission().equals("ray.chat"))
             .filter(Node::hasExpiry)
             .filter(permissionNode -> !permissionNode.getValue())
             .collect(Collectors.toList()).get(0).getExpiry();
             System.out.println(expiry.get(ChronoField.INSTANT_SECONDS));
             long time = user.getNodes(NodeType.PERMISSION).stream()
             .filter(Node->Node.getPermission().equals("ray.chat"))
             .filter(Node::hasExpiry)
             .filter(permissionNode -> !permissionNode.getValue())
             .map(Node -> Node.getExpiry().get(ChronoField.INSTANT_SECONDS))
             .mapToLong(Instant-> Instant)
             .max()
             .orElse(0);
             p.sendMessage("§cYou have been muted on " + time);
             });
             
//            p.sendMessage("§cYou have been muted");
        }
        e.setCancelled(true);
    }```
vocal adder
nocturne elbow
odd vapor
#
final Instant expiry = user.getNodes(NodeType.PERMISSION).stream()
             .filter(Node -> Node.getPermission().equals("ray.chat"))
             .filter(Node::hasExpiry)
             .filter(permissionNode -> !permissionNode.getValue())
             .collect(Collectors.toList()).get(0).getExpiry();```==good value (2021-03-08T13:55:44Z)
but
```java
expiry= expiry.get(ChronoField.INSTANT_SECONDS)```==null
odd vapor
#

maybe posibble read this time as on website (luckperms editor)?

nocturne elbow
#

It works fine for me though, I'm doing the following

final User user = this.luckPerms.getPlayerAdapter(Player.class).getUser(player);
final Node node = PermissionNode.builder()
                                .permission("test.permission")
                                .value(false)
                                .expiry(5L, TimeUnit.MINUTES)
                                .build();
final Instant expiry = user.getNodes(NodeType.PERMISSION).stream()
                           .filter(Node::hasExpiry)
                           .filter(NodeMatcher.equals(node, NodeEqualityPredicate.IGNORE_EXPIRY_TIME))
                           .map(Node::getExpiry)
                           .findFirst().orElse(null);
manic osprey
#

Hey, I have a question not target at the API of LuckPerms but at the build process of LuckPerms itself. I am running a arch linux machine and I executed
./gradlew build. This doesn't output any thing inside of build besides build/loom_cache folder.
If I check bukkit/build/libs I find a bukkit-5.3-SNAPSHOT.jar and a luckperms-bukkit.jarinjar file. These files don't seem to be the final compile output since stuff like "plugin.yml"
are missing. Which steps do I have to complete the compiling process and end up with a LuckPerms-bukkit-5.3-SNAPSHOT.jar that is drag-and-drop ready for a minecraft server?

nocturne elbow
#

The final jars for Nukkit, BungeeCord, Bukkit and Bukkit Legacy are now located in the [platform]/loader/build/libs dir
The rest (Velocity, Fabric and Sponge) are located in their regulars [platform]/build/libs dir

manic osprey
#

Thank you! This works perfectly now!

hoary ermine
#

hello should i use

InheritanceNode.builder("vip")

or

InheritanceNode.builder("group.vip")

?

#

i didn't understand the meaning of "group"

nocturne elbow
#

it's just the group name

#

so just "vip"

hoary ermine
#

okay ty

fresh sonnet
#

@nocturne elbow are you sure I can't use anything to do a bulkupdate inside of my own plugin?

frank driftBOT
#

Hey ignPurple! Please don't tag helpful/staff members directly.

nocturne elbow
#

There is no API for it. Of course you can use internal classes and all

fresh sonnet
#

Yea

nocturne elbow
#

Which isn't advised :p

fresh sonnet
#

I didn't directly mean the API

nocturne elbow
#

you initially did lol

Is it possible to do a BulkUpdate with the API?

fresh sonnet
#

I meant is there something inside of the API to do it?

#

Or would I have to use other classes which aren't apart of the api

nocturne elbow
#

what are you trying to do exactly?

fresh sonnet
#

At the end of a season I want to clear playerdata and remove only certain permissions

nocturne elbow
#

I mean you could use UserManager#searchAll(NodeMatcher matcher) to find all players with a certain permission, loop through them and do the thing but that will run the operation for each individual user, not as an operation in bulk

#

Lately I was thinking of adding API for it but uuh yeah, can't and it would be due to v5.4 anyway so lol

fresh sonnet
#

        BulkUpdateBuilder builder = BulkUpdateBuilder.create();
        builder.dataType(DataType.USERS);
        builder.action(DeleteAction.create());

        QueryField field = QueryField.PERMISSION;
        Comparison comparison = StandardComparison.parseComparison("==");
        builder.query(Query.of(field, Constraint.of(comparison, "essentials.fly")));

        plugin.getStorage().applyBulkUpdate(builder.build()).whenCompleteAsync((v, ex) -> {
            if (ex == null) {
                plugin.getSyncTaskBuffer().requestDirectly();
            }
        }, plugin.getBootstrap().getScheduler().async());
    }```
#

@nocturne elbow

frank driftBOT
#

Hey ignPurple! Please don't tag helpful/staff members directly.

fresh sonnet
#

Wonder if that would work ya know

fresh sonnet
#

Sorry

#

I thought I could ping you because we were in a convo

#

😬

nocturne elbow
#

I'll eventually read it anyway though

#

and yeah that should work, although StandardComparison is an enum so you can just StandardComparison.EQUAL

fresh sonnet
#

Ah didn't realise it was an enum then

odd vapor
nocturne elbow
#

getExpiryDuration

#

returns a Duration

odd vapor
#

my source spam errors ;/

nocturne elbow
#

getExpiryDuration

#

Also collect(Collectors.toList()).get(0) can (and should) be replaced with findFirst().get()

odd vapor
odd vapor
#

I use max()

surreal tusk
#

Hi, I want to get group list as ArrayList, it is possible ?

nocturne elbow
#

whats the equivalent of pex user %player% add %permission% with luckperms ?

main dagger
#

to give a permission?

#

lp user <user> permission set <permission> <true/false>

turbid solar
#

wrong channel also

obtuse jolt
nocturne elbow
#

thanks

#

sorry

nocturne elbow
hoary ermine
#

are there like events (eg. LuckRankChangeEvent, or something in this type)?

turbid solar
#

NodeAddEvent

#

!cookbook might have examples for it

frank driftBOT
ancient sable
#

Hi

#

Can someone explain me how does luckperm sync messages work between server and server?

odd vapor
#

I think Vaulut read luckperms and other plugins read Vault

turbid solar
#

They are talking about something else

nocturne elbow
#

How can I get the hightest group of the player

fallen grotto
#

Hi, If i want to extend the expiry time of a Node I need to remove it and re-add it with the new time?

turbid solar
#

Is it me or did it not format the <>

nocturne elbow
#

mobile?

turbid solar
#

Yep

nocturne elbow
#

literally trash app lol

turbid solar
nocturne elbow
#

yeah it does that sometimes

#

for whatever reason

nocturne elbow
#
        RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
        if (provider != null) {
            return provider;
        }
    }```
#

Its not working, but why?

turbid solar
#

Send error

nocturne elbow
#

There is no error, I get with getLuckPermsAPI() the api, but he cannot find it

turbid solar
#

!api

frank driftBOT
nocturne elbow
#

Here, I mean that

turbid solar
#

bc your returning the registetedserviceprovider

#

not the LP api

nocturne elbow
#

And you are returning Object..

#

Ahh

#

I have it, thx 😄

cloud raptor
#

is there a way to quickly set a player's group instead of getting the NodeMap, remove the old group, then add the new group?

zenith scaffold
#

is there a way to set a user's group without running the command? So trough the luckperms api?

turbid solar
#

Yes

#

!cookbook has examples

frank driftBOT
zenith scaffold
#

Thanks, I will take a look

#

I see when he adds a user to a group. But I want to specify context world=(worldName)

#

@turbid solar

frank driftBOT
#

Hey Creatos! Please don't tag helpful/staff members directly.

zenith scaffold
#

Ah okay

zenith scaffold
#

Thanks sorry to bother you ♥

zenith scaffold
#

Another question, I am looping trough the nodes a player has and I want to check if the node is a group and if it has a certain name. How would I do that? I don't know what nodetype I should look for

turbid solar
#

InheritanceNode

zenith scaffold
#

Thanks btw, and how would I go about getting a list or collection of all users from a group?

zenith scaffold
#

Do I also get it from the InheritanceNode?

zenith scaffold
#

Thank you for your help, I will try this out!

#
        
        api.getGroupManager().searchAll(/* ??? */);```
#

This is what I currently have but I dont know what to put in the seachAll fucntion

nocturne elbow
zenith scaffold
#

NodeMatcher.key(node) ?

nocturne elbow
#

Ye

#

I mean it depends on use case but that's probably what you want

zenith scaffold
#

Well I want to get all users with the group node

#

I think this is it

#

api.getUserManager().searchAll(NodeMatcher.equals(node, NodeEqualityPredicate.EXACT));

nocturne elbow
#

Keep in mind that also takes into consideration the duration and the contexts of the node

zenith scaffold
#

Duration? Duration of what?

nocturne elbow
#

Expiry time

zenith scaffold
#

Ooh

nocturne elbow
#

Temporary permissions

zenith scaffold
#

I didn't know that luckperms had expiry times

#

I don't use any expiry times so I think thats okay

#

but do I convert the return value to users?

#

CompletableFuture<Map<UUID, Collection<Node>>>

#

and then loop trough the keys

nocturne elbow
#

Yeah and loadUser

zenith scaffold
#

Hmh, when Im on the docs and search for something I often get a page with no information. Is that normal?

nocturne elbow
#

Hm?

zenith scaffold
nocturne elbow
inland crag
inland crag
inland crag
nocturne elbow
inland crag
#

Dankje

#

so its necessary to add a constructor of the class to do the thing like

public MyListener(MyPlugin plugin, LuckPerms luckPerms) {
        this.plugin = plugin;

        EventBus eventBus = luckPerms.getEventBus();

        // 1. Subscribe to an event using an expression lambda
        eventBus.subscribe(this.plugin, LogPublishEvent.class, e -> /* ... */);

          // 2. Subscribe to an event using a statement lambda
        eventBus.subscribe(this.plugin, UserLoadEvent.class, e -> {
            // ...
        });

        // 3. Subscribe to an event using a method reference
        eventBus.subscribe(this.plugin, UserPromoteEvent.class, this::onUserPromote);
    }
nocturne elbow
#

well that's just an example, but you subscribe to an event through the event bus, yes

inland crag
#

i c thanks a lot 🙂

#

so i how do i register it from the main classs?

nocturne elbow
#

!cookbook you can check out this example plugin, see how it does event listeners; it doesn't contain an example of every single thing you can do because that is straight up not viable lol but you should get an idea on how it should be done

frank driftBOT
hoary ermine
#

hello how do i get prefix of a Group?

#

nvm

nocturne elbow
#

ok

obtuse jolt
#

are you coding a plugin?

#

!api

frank driftBOT
obtuse jolt
inland crag
#

!jd

frank driftBOT
#

Sorry! I do not understand the command !jd
Type !help for a list of commands.

inland crag
#

!javadocs

frank driftBOT
jagged parrot
bold glade
shadow silo
#

How can I check all groups of a player? (Primary and others)

#

using API (5.3)

turbid solar
#

!cookbook

frank driftBOT
turbid solar
#

Has example

shadow silo
brittle chasm
#

Hello

#

When I'm getting prefix of player with this:

user.getCachedData().getMetaData().getPrefix();

It provides an NPE

#

How fix it please ?

#

I'm using API 5.3

nocturne elbow
#

You'll need to share a fair bit more of code than just that; also consider closing the issue on GitHub if you will ask for help in here

brittle chasm
#

Ok nevermind

nocturne elbow
#

wat

main dagger
nocturne elbow
#

There is literally no person on earth capable of knowing what is causing that issue with just that single bit of code

#

My guess is that you are running UserManager#getUser on an offline/unloaded player but I just can't know

brittle chasm
#

which is = to getPrefix

main dagger
#

what is your "string variable"

#

what are you doing with that "string variable"

brittle chasm
#

It's to show prefix of rank in SB

nocturne elbow
#

You'll need to share a fair bit more of code than just that

brittle chasm
#
String prefix = AzoltAPI.getLuckPerms().getUserManager().getUser(board.getPlayer().getName()).getCachedData().getMetaData().getPrefix();

        board.updateLines(
                "",
                "§e"+ChatUtils.CharUtils.ARROW_RIGHT+" §f§l"+p.getName(),
                "§7Grade: "+prefix,
                "",
                "§7Joueurs: §a"+ BungeeUtils.getPlayersCount("ALL"),
                ""
        );
#

Here is my scoreboard

main dagger
#

doesnt UserManager.getUser() take a bukkit player

#

assuming your on bukkit

brittle chasm
#

No Purpur

#

(A fork of PaperSpigot)

nocturne elbow
#

It takes a UUID or a String (the player name)

brittle chasm
#

String

nocturne elbow
#

It wasn't a question lmao

#

There are a lot of things there that can be null

brittle chasm
#

Should I try with UUID ?

nocturne elbow
#

It wouldn't change a thing I reckon

main dagger
nocturne elbow
#

can you share the entire stack trace?

#

that will be also more helpful

brittle chasm
nocturne elbow
#

the error

brittle chasm
#
[23:35:42 WARN]: [AzoltHub] Task #12 for AzoltHub v1.0 generated an exception
java.lang.NullPointerException: null
        at fr.azoltcraft.hub.manager.ScoreboardManager.update(ScoreboardManager.java:15) ~[?:?]
#

The line 15 is the String prefix = ...

main dagger
#

the entire stack trace

nocturne elbow
#

The entire thing

brittle chasm
#
[23:35:42 WARN]: [AzoltHub] Task #12 for AzoltHub v1.0 generated an exception
java.lang.NullPointerException: null
        at fr.azoltcraft.hub.manager.ScoreboardManager.update(ScoreboardManager.java:15) ~[?:?]
        at fr.azoltcraft.hub.tasks.ScoreboardUpdateTask.run(ScoreboardUpdateTask.java:21) ~[?:?]
        at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:100) ~[patched_1.16.5.jar:git-Purpur-1012]
        at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:468) ~[patched_1.16.5.jar:git-Purpur-1012]
        at net.minecraft.server.v1_16_R3.MinecraftServer.b(MinecraftServer.java:1378) ~[patched_1.16.5.jar:git-Purpur-1012]
        at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:392) ~[patched_1.16.5.jar:git-Purpur-1012]
        at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1291) ~[patched_1.16.5.jar:git-Purpur-1012]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1017) ~[patched_1.16.5.jar:git-Purpur-1012]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:179) ~[patched_1.16.5.jar:git-Purpur-1012]
        at java.lang.Thread.run(Thread.java:834) [?:?]
nocturne elbow
#

Are you sure the player board.getPlayer() returns is online? I'm guessing getUser is returning null

#

Try printing what getUser returns

brittle chasm
#

I'm Online

main dagger
#

you dont know that its actually returning the player unless you print it

#

"it should be" != "it is"

brittle chasm
#

I understand nothing wtf

nocturne elbow
#

Try printing what getUser returns

main dagger
#

System.out.println(board.getPlayer())

nocturne elbow
#

getUser

brittle chasm
#

board.getPlayer is the Player object

#

from Bukkit

last merlin
#

anyone know how to get player's highest groups' prefix?

nocturne elbow
#

Not the final prefix the player has?

last merlin
#

@nocturne elbow The one they chat with

frank driftBOT
#

Hey Mal! Please don't tag helpful/staff members directly.

last merlin
#

:(

nocturne elbow
#

(:

last merlin
#

sorry for ping

#

im doing this cause i am making a custom tab

#

for my core

nocturne elbow
#

You can do that with a single line tbh

luckPerms.getPlayerAdapter(Player.class).getMetaData().getPrefix();

assuming luckPerms is a valid object of type LuckPerms
replace Player.class with the player type of the platform you're on (e.g. ProxiedPlayer.class on BungeeCord)

last merlin
#

Oh cool

#

ty

nocturne elbow
#

yw

last merlin
#

@nocturne elbow

frank driftBOT
#

Hey Mal! Please don't tag helpful/staff members directly.

nocturne elbow
#

ah right

#

you have to give it a player lmao

#

to getMetaData

#

totally didn't forget that, totally makes sense to not pass a player lol

last merlin
#

where

nocturne elbow
#

you have to give it a player lmao
to getMetaData

last merlin
nocturne elbow
#

Nonon

#

getMetaData(p)

last merlin
#

the error is in getUser

nocturne elbow
#

Right, because you don't getUser

last merlin
#

ah

nocturne elbow
#

Yee

last merlin
#

ty

nocturne elbow
#

Yw

last merlin
#

@nocturne elbow sorry for ping but to defaults not have a group perm node?

frank driftBOT
#

Hey Mal! Please don't tag helpful/staff members directly.

last merlin
#

like group.default

nocturne elbow
#

sorry for ping
*proceeds to ping*

#

Every player has at least one inheritance node

#

Not sure what kind of situation you are in so I can't really answer any specifics either

last merlin
#

@nocturne elbow I am trying to sort a tab list

frank driftBOT
#

Hey Mal! Please don't tag helpful/staff members directly.

last merlin
#

shit

nocturne elbow
#

Can you stop the pings? For real, I'll read the message anyway

last merlin
#

Ok

#

pls

nocturne elbow
#

Right... to which I say

Every player has at least one inheritance node
Not sure what kind of situation you are in so I can't really answer any specifics either

What is making you think that is not the case?

last merlin
#

Well how could I get a players every gorup

nocturne elbow
#

What?

fiery sapphire
#

How can I get the expiry time of a group, not permission node? I am coding a command which, given you have a specific rank, it will tell you the time left of you having it.

I can't find anything about checking when a group is going to expire in the docs

Code: https://pastebin.com/Jg7DWHEN

#

P.S. I am more or less still noobish at minecraft plugin development, so don't hate on me if my code is kind of sloppy. hmmmm

rustic laurel
#

!api as documented here, groups on players or other groups are stored as permission nodes group.groupname

frank driftBOT
rustic laurel
#

How can I get the expiry time of a group, not permission node?
you get the expiry time of the group node

fiery sapphire
#

Wouldn't that appear for operators though, or people with * it would be indefinite?

rustic laurel
#

people with * don't have all groups, nor ops. I am not quite sure how luck handles it, but it's handled

nocturne elbow
long violet
#

thanksluckythonk

long violet
#

@nocturne elbow that is correcly?```
OfflinePlayer player = Bukkit.getOfflinePlayer("oldplayer");
Player p = e.getPlayer();

api.getUserManager().modifyUser(player.getUniqueId(), (User oldP) -> {

User newP = api.getPlayerAdapter(Player.class).getUser(p);
Group group = api.getGroupManager().getGroup("time");
Node node = InheritanceNode.builder(group).build();
newP.data().add(node);
oldP.data().remove(node);

});```

frank driftBOT
#

Hey Amonly! Please don't tag helpful/staff members directly.

main dagger
fair glade
#

i have tryed looking to see how i would get the if statement to see if the user has a rank and then if so it sets the chat formating to be with the user prefix

#

public class ChatEvent implements Listener {
    @EventHandler
    public void onPlayerChat(AsyncPlayerChatEvent e){
        String format = LogicFlame.plugin.getConfig().getString("ChatFormat");
        Player pl = e.getPlayer();
        User user = LogicFlame.plugin.getLuckPerms().getPlayerAdapter(Player.class).getUser(pl);
        String uprefix = user.getCachedData().getMetaData().getPrefix();

        format = format.replace("{message}", "%2$s").replace("{DisplayName}", e.getPlayer().getName()).replace("{prefix}", uprefix);

        e.setFormat(LogicFlame.colorize(format));
    }
}

#

is there anything like, user.getCachedData().getMetaData().hasPrefix() to be used in the if statement

nocturne elbow
#

No, but getPrefix returns null if there is no calculated prefix, so you can check if it's null

fair glade
#

so like
if(user == null) //do smthing

nocturne elbow
#

getPrefix returns null
so...?

fair glade
#

fair enough my brain just doesnt wanna work

#

thanks

nocturne elbow
#

lmao

shadow silo
#

how to get all permissions of a player through the API ?

#

(or offline player)

nocturne elbow
shadow silo
#

thanks so I use .getPermissionMap() but it returns all permissions, i don't want "false" permissons :x

nocturne elbow
#

Why not lol

shadow silo
#

sorry if my english is bad :x

tribal wave
#

i can't remember if I already asked about this at some point but for transient permissions, do I need to

api.getUserManager().saveUser(luck_player);

after I give them a perm?
or is just adding the node enough since it'll disappear once they leave anyways?

shadow silo
#

i think you have to saveUser after adding the node

limber cypress
#
LuckPermsProvider.get().getUserManager().getUser(player.getUniqueId()).getInhertedGroups(queryOptions);
#

what's query options?

#

and how can i get it

slim willow
#

hello , its been a while since i used the luckperms in my plugins ..

#

how to use the api ? and how to get the primary group

#

using spigot 1.8.8 + using luckperms 5.3.0

#

i can upgrade if that will fix the problem ..

#

nvm i fixed it .. i downloaded the api ..

#

another error

turbid solar
#

!extensions

frank driftBOT
turbid solar
#

No need for the legacy extension, you should use 5.3

#

Also dont add the plugin, add the API

#

@slim willow

nocturne elbow
obtuse jolt
frail coral
#

I mean

#

its pretty cool

leaden iron
#

it's not lol

zenith scaffold
#

I use lp api to add players to their ranks uppon first joining the server but it does not add the prefix on the first time they join the server?

nocturne elbow
#

Does the prefix show in /lp user <user> info?

#

I really doubt it's anything to do with the API unless you're doing something very wrong lol

zenith scaffold
#

I will send my code in 5 min, currently afk

#

Its only after they change worlds that the prefix is displayed

leaden iron
#

hmm okay

zenith scaffold
#
                    String worldName = entry.getKey();
                    String groupName = entry.getValue();

                    Group group = api.getGroupManager().getGroup(groupName);

                    if (group == null)
                        continue;

                    plugin.getLuckPermsApi().getUserManager().modifyUser(event.getPlayer().getUniqueId(), (User u) -> {

                        Node node = InheritanceNode.builder(group).withContext("world", worldName).build();

                        if (u.data().contains(node, NodeEqualityPredicate.IGNORE_EXPIRY_TIME) == Tristate.TRUE) {
                            

                        } else {
                            u.data().add(node);
                        }
                    });

                }
#

I have default ranks per world

#

this is inside my PlayerJoinEvent listener

zenith scaffold
#

@leaden iron

nocturne elbow
#

Works fine for me, it's probably the chat plugin doing some caching before the data is available

#

So when someone changes worlds it re-fetches it

#

That's my guess anyway, a wild guess

carmine nova
#

Hi with the api it's possible with bungeecord to get the displayname of player

turbid solar
#

Depends what you mean with "displayname of player"

#

prefix + name + suffix?/

carmine nova
#

this but in all server

#

I have luckperms on the bungeecord and on the servers

nocturne elbow
carmine nova
#

okay 😉

#

i have this error :/

#

i imported in my plugin luckperms

nocturne elbow
#

Right.. you need a LuckPerms object

carmine nova
#

ho okay

#

how to ? 🙂

nocturne elbow
carmine nova
#

I need to create a bungeecord or spigot plugin to create a server-to-server globalchat?

nocturne elbow
#

isn't that what you're doing?

carmine nova
#

I try to connect the chat between server

#

x)

nocturne elbow
#

Right... which

isn't that what you're doing?

carmine nova
#

yes x)

#

i'm belgian sorry x)

nocturne elbow
#

I mean, it doesn't really change anything lmao

#

You still need an object of type LuckPerms

nocturne elbow
carmine nova
#

Obtaining an instance of the API ?

#

RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);

nocturne elbow
#

That one specifically is if you are on Bukkit

carmine nova
#

ho okay

#

i try this:
LuckPerms api = LuckPermsProvider.get();

nocturne elbow
#

That would work, yes

#

You can use that to get a LuckPerms object

carmine nova
#

i'm stuck x)

#

@nocturne elbow

LuckPerms luckPerms = LuckPermsProvider.get();

User user = (User) luckPerms.getPlayerAdapter(ProxiedPlayer.class).getUser(player);```

it's this ??
frank driftBOT
#

Hey shark_zekrom! Please don't tag helpful/staff members directly.

nocturne elbow
#

Yes, that will work

#

You shouldn't need to cast to User though...

carmine nova
#

String prefix = user.getCachedData().getMetaData().getPrefix();

#

for the prefix of player

nocturne elbow
#

Mhm

carmine nova
#

it's not good ? x)

nocturne elbow
#

It is, that is how you get the prefix lol

carmine nova
#

cool ! i want

#

x)

nocturne elbow
nocturne elbow
carmine nova
#

Using the singleton (static access) ?

#

not sponge or bukkit

#

but i'm in bungeecord

nocturne elbow
nocturne elbow
nocturne elbow
carmine nova
#

ok i put it in the chat event?

nocturne elbow
#

yes

carmine nova
#

public LuckPerms lp;
this I do not need?

nocturne elbow
#

You can have that, but you need to assign it a value

#

Java won't magically know what lp is

carmine nova
#

yes

nocturne elbow
#

You use LuckPermsProvider.get() on BungeeCord to tell it "hey, lp is LuckPermsProvider.get()"

carmine nova
#

the final code is```java
@EventHandler
public void onChat(ChatEvent event) {
ProxiedPlayer player = (ProxiedPlayer) event.getSender();

    LuckPerms api = LuckPermsProvider.get();
    User user = (User) api.getPlayerAdapter(ProxiedPlayer.class).getUser(player);
    
    String prefix = user.getCachedData().getMetaData().getPrefix();

    if (!event.getMessage().startsWith("/")) {
        ProxyServer.getInstance().broadcast("§b[" + player.getServer().getInfo().getName() +"§b] " + prefix + " §8» §f" + event.getMessage());
    }
}```
nocturne elbow
#

that should work, yes

carmine nova
#

i have a error :/

#

the same

#

it's weird

nocturne elbow
#

you are using the wrong jar

carmine nova
#

i have LuckPerms-Bungee-5.3.5 in bungeeplugin

nocturne elbow
#

don't import the LP plugin jar to your project

#

use the API jar

#

You don't import the plugin jar, you import the API jar and work with that, it's very different

carmine nova
#

api 5.3 ?

nocturne elbow
#

yes

carmine nova
#

okayyy

#

i see x)

#

does not work :/

nocturne elbow
#

You might need to look for the correct imports, idk what your imports look like rn

carmine nova
#

I imported it as the luckperm plugin before

nocturne elbow
#

I know

#

Don't

#

You might also need to do something in that "Libraries" tab, I'm not sure how that part works

carmine nova
#

it's done

#

it's the same like spigot

#

error :/

#

it's done

nocturne elbow
#

Because that's not the User you should use

#

You were importing the internal plugin User class

#

You should import the API User class

carmine nova
#

yes

nocturne elbow
#

import net.luckperms.api.model.user.User;

carmine nova