#luckperms-api
1 messages Ā· Page 45 of 1
so .builder("Prefix", luckPerms.getGroupManager().getGroup(groupName).getPriority()) ?
also is luckPerms LuckPerms?
LuckPerms api = provider.getProvider(); i mean
You should probably put the actual Group object in a local variable, to add the node later and yes luckPerms is that
yw
Cannot resolve method 'getPriority' in 'Group' ?
oh
thats for nodes

fixed
'builder(java.lang.@org.checkerframework.checker.nullness.qual.NonNull String, int)' in 'net.luckperms.api.node.types.PrefixNode' cannot be applied to '(java.lang.String, java.util.@org.checkerframework.checker.nullness.qual.NonNull OptionalInt)' ?
PrefixNode newPrefixNode = PrefixNode.builder("[&#"+hexcode+":heart:&8]",sgroup.getWeight()).build(); just tryna do this
@nocturne elbow
Hey Lynx! Please don't tag helpful/staff members directly.
sry
Ah right, since groups can not have weight, Group#getWeight returns an OptionalInt
You can use OptionalInt#orElse(int default) to get the optional's value if present, or else the default/fallback value
so idk you can use 0 or 10 or whatever lol
As fallback
what
But if the group has a weight of its own, it will return that one
Yeah that will do
wait i just realized something very wrong; i said i had to change the group itself i meant the specific player's permission
jesus my brain
would getting the data from the group work same way with user?
do i need to get the player in a specific way with LP or does a bukkit Player do?
You need an LP User, there are three ways you can get one, two of them for online players
this would only be possible with online players
All of 'em shown and explained here https://luckperms.net/wiki/Developer-API-Usage#loading-data-for-players cuz I'm not gonna repeat what's already written
Yw
this is much later, but i have successfully edited an user and still after saving it nothing happens
i dont see nothing new on the editor
and in game
if a group has permisisons does the user have too?
is there some way i could have an event for changes in user permission nodes?
???
what
Those 2 Events
how'd i use them
!api
Learn how to use the LuckPerms API in your project.
!cokkbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Sounds dutch
Is that an insult?!
.
how would i check what node specifically got removed?
get..Node?
and
and what?
I can't read your mind
not sure what you want to check, but that's how you get the node you have all of it
i meant
sorry
i meant how do i get what group got removed
i need to know if a specific group got removed
wait
groups are nodes right?
Yes, InheritanceNodes
so
Check if the node type is NodeType.INHERITANCE, then you can cast to an InheritanceNode and get the group name
Node#getType
you can cast to an InheritanceNode and get the group name
wdym
still dont understand how to use it in this use case
cast to an InheritanceNode
InheritanceNode node = (Object)e.getNode() ??
ah
InheritanceNode node = (InheritanceNode)e.getNode()
would this count as a group?
that would count as an InheritanceNode
an InheritanceNode represents a parent group, but it is not a Group
you can get the group name from the inheritance node
use the group manager to get the group from it
Which event
noderemoveevent
d;lp NodeRemoveEvent
public interface NodeRemoveEvent
extends NodeMutateEvent```
NodeRemoveEvent has 2 super interfaces, 1 extensions, and 2 methods.
Called when a node is removed from a holder
Hey I“m an noob in developing with luckperms an i need some help ... with the following code i tried to add a group to a user ... but well obvisoly it didnt work so can anyone help me?
public void addPermission(UUID uuid, String perm) {
LuckPerms luckPerms = LuckPermsProvider.get();
User u = luckPerms.getUserManager().getUser(uuid);
Node n = Node.builder("perm").build();
DataMutateResult r = u.data().add(n);
luckPerms.getUserManager().saveUser(u);
if(r.wasSuccessful()) {
Bukkit.getPlayer(uuid).sendMessage("§3You recieved your rank!");
}
}
sry english not the best
Hi everyone, I wanted to ask how do I add a permission to a single player, thanks in advance!
with code or on an other way?
code
public void addPermission(UUID uuid, String perm) {
LuckPerms luckPerms = LuckPermsProvider.get();
User u = luckPerms.getUserManager().getUser(uuid);
Node n = Node.builder("perm").build();
DataMutateResult r = u.data().add(n);
luckPerms.getUserManager().saveUser(u);
if(r.wasSuccessful()) {
Bukkit.getPlayer(uuid).sendMessage("§3You recieved your rank!");
}
than this should work as Fefo says
Try printing the value of the DataMutateResult right before the if statement
does this not add permission to the node?
???
yes thats the thing you had to add i just copy and paste it from above
no it adds a permission defined in the String perm to a user
ok, thanks!
so like
DataMutateResult result = ...
System.out.println(result);
brr
how do i check if a user has a permission when a command is executed
the api docs arent that clear on how it should be implemented
i know thats how bukkit does it lol
does that also apply to luckperms?
LP injects its own Permissible into player objects (on Bukkit at least) so using that method will "redirect it" to LP
ok
so i shouldnt need a hashmap with permissions in it, since its injected directly into the player object?
????
nvm lmao
How?
is it NodeType?
cause i can't find something like a user type
okay
do i need to do anything more than create my listener class to have a luckperms listener?
!api look at this
Learn how to use the LuckPerms API in your project.
jeeee
did
can't see anything
do i just have to instance my class?
Show your code?
public class LuckPermsListener {
private THSupporterPerks main;
private LuckPerms api;
private LuckPerms lpapi;
private Group sgroup;
public LuckPermsListener(THSupporterPerks main, LuckPerms lpapi) {
main = main;
sgroup = main.api.getGroupManager().getGroup("supporter");
EventBus eventBus = lpapi.getEventBus();
eventBus.subscribe(this.main, NodeRemoveEvent.class, this::onNodeRemove);
}
private void onNodeRemove(NodeRemoveEvent e){
if (e.getNode().getType() == NodeType.INHERITANCE) {
InheritanceNode Inode = (InheritanceNode)e.getNode();
if(Inode.getGroupName() == "supporter"){
if(e.getTarget() instanceof User){
User user = (User) e.getTarget();
user.data().clear(NodeType.PREFIX.predicate(node -> node.getPriority() == 100));
main.api.getUserManager().saveUser(user);
}
}
}
}
}
im assuming i just have to instance it now since there's a constructor
Dont == for strings
oops
Well it might work idk
ah
Also I'm pretty sure you need to do this.main = main instead of main = main
Best to do getGroupName().equalsIgnoreCase or just equals
correct man
https://paste.helpch.at/ganepacode.apache why do i get this ?
you are passing null as something that should not be null
or the object you are passing is
THSupporterPerks v1.0-SNAPSHOT object is null I believe, right @nocturne elbow ?
Hey ValdemarF! Please don't tag helpful/staff members directly.
oop, sry
There should be something in error called caused by: though shouldn't there?
Not necessarily, exceptions can have a cause which is another exception, for example if within my plugin I have this method
public void someMethod() throws MyCustomException {
try {
// whatever
} catch (IOException exception) {
throw new MyCustomException(exception); // adding a causing exception, why this was thrown
}
}
In that case when printing the stack trace yes, a "caused by" will be present, but if you simply do throw new NullPointerException("object is null"); there is no exception that caused the NPE I just threw, so it has no underlying cause, it's the exception's origin so to speak
lol they left half an hour after asking
Is there LP context that checks playerdata?
meaning..?
the stock/provided contexts are listed here https://luckperms.net/wiki/Context#contexts-provided-by-luckperms
no like
if i want to check the playerdata of a file for contetxt
such as
"health"
anyone know why i get a java.lang.NoClassDefFoundError: net/luckperms/api/node/Node when loading my plugin?
String stmt = "INSERT INTO data (UUID, Balance, Tokens) VALUES (?,?,?)";
PreparedStatement statement = conn.prepareStatement(stmt);
statement.setString(1, player.toString());
statement.setString(2,"0.0");
statement.setString(3,"0.0");
statement.executeUpdate();
LuckPerms luckPerms = LuckPermsProvider.get();
User u = luckPerms.getUserManager().getUser(player);
try {
Node n = Node.builder(settingsConfig.getString("user-perms.balance")).build();
Node n1 = Node.builder(settingsConfig.getString("user-perms.token")).build();
DataMutateResult r = u.data().add(n);
DataMutateResult r1 = u.data().add(n1);
luckPerms.getUserManager().saveUser(u);
} catch (NullPointerException e) {
System.out.println("config is not setup!");
}
}```
thats the code^
- Make sure you have LP as a depend/softdepend of your plugin
- Make sure LP is installed..
- Make sure your targeted LP API version is 5.3 & the version you're running is also v5.3.x
!update in any case
You can download LuckPerms for Bukkit/Spigot/Paper, BungeeCord, Sponge, Fabric, Nukkit and Velocity.
how do i add it to the plugin.yml as a depend?
dependencies: LuckPerms ?
depend: [ LuckPerms ]
thanks
How do I update the prefixes/suffixes of a group object using the API?
!api
Learn how to use the LuckPerms API in your project.
https://luckperms.net/wiki/Developer-API-Usage#modifying-usergroup-data i believe, at least that's the basics
Sort of vague on the relation of context adapters to something such as prefixes given they even have their own meta commands rather than using a key like the rest?
is there a question somewhere in there because I can't extract one it is much too late
if you're looking for all available methods on a group object, you should check out the javadoc link
Hey, when I do Group rank = luckPerms.(whatever or tab something) nothing shows up. Tested LuckPerms.(whatever) as well. I looked at the docs and that's what it says. I have the API applied and I can use LuckPerms and import stuff from it
Show your code
hold on
package events;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.model.group.Group;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
public class MakeSign implements Listener {
@EventHandler
public void PlaceSign(BlockPlaceEvent e) {
if(e.getBlockPlaced().equals(Material.SPRUCE_SIGN)) {
Sign sign = (Sign) e.getBlockPlaced();
String[] lines = sign.getLines();
if(lines[0].equalsIgnoreCase("[claimrank]")) {
Group group = LuckPerms.
}
}
}
}
here pom.xml
Please use https://paste.lucko.me to send files in the future. I have automatically uploaded message.txt for you: https://paste.lucko.me/JPUI1H07hB
!api
Learn how to use the LuckPerms API in your project.
Oh also, I have an instance in the main class and I can't get it in the class i'm coding at. not even the static one
Thanks
How do I call the /lp sync command via api?
Can you explain me what is what?
/lp sync will only refresh the data from storage on the server you run the command on
/lp networksync does that and uses the messaging service to ping all other servers to do the same
Okay then I want to call networksync
okay then it kind of depends on context for it to actually work properly, run it after doing what exactly?
So I am setting a rank for a user om the proxy server but then the spigot server doesnt notices that and doesnt set the prefix for him. So I want to call the sync method so its synced with the proxy
ah, alright, then in that case see the pinned message š
should I execute this on proxy or on spigot?
wherever the code that adds the rank runs
alright I'll try that
do not ask in multiple channels
Hello i have been trying to add the luckperms event api to my project, However i don't know how to actually instannce it
won't work
!api
Learn how to use the LuckPerms API in your project.
These links (especially the first 2) have all the info u need
How to get this group in java?
thx
What is the NodeType of a group.<group> node being added to an user
NodeType.INHERITANCE
No, InheritanceNode#getGroup or getGroupName, I don't remember exactly but something like that
oh ok
getValue will get you the node value, true/false
Oh so I need to cast the node to InheritanceNode
Also what about this: what do I need to change to change the parent group in LuckPerms using the database?
On a network & propagate the changes?
Yep
This is if possible... if not I guess Im gonna need to use the panel API to send a command...
https://www.github.com/LuckPerms/api-cookbook/tree/master/src/main/java/me/lucko/lpcookbook/commands/SetGroupCommand.java
This + see the pinned message š do that on the modifyUser method
Hum the problem is... I cannot change this using LP api... The software is not a plugin its a discord bot and a spring project so...
The easy way would be host the bot inside the server but and if I dont want that, its impossible?
I mean as long as it's JVM code that runs on the same JVM as the server (in essence, the server or a plugin extension) you should be able to use the LP API regardless, there are two or three places I can think of that have links to platform dependent but even then not fully, it's like 95% platform agnostic
So lets see if I understand if the software is outside the minecraft server directory but it is inside the same dedicated server I can still use LP api? (Sry I didnt understand the first part of what you said...)
How are you giving the group node in the first place
Im not...
I think it's better if I explain what I want better so I made a discord bot for my server and I want it to basically sync things from LP to discord and the same but opposite. Now to do this I made a discord bot with a spring boot application and a minecraft plugin to listen for group changes so I can send a GET web request to the discord bot (spring app) in order to update the user in the discord server but I cannot thing a way to do the same think but changing in the server. I could use Pterodactyl API but I think there is a better way?
English is not my first language so sry if I didnt explain well
Well no, unless it's a plugin on the mc server, there is no /sane/ and safe way of doing it
If you modify the database directly you'd have to send a /lp networksync to any of the servers (one only) to refresh loaded data
But then for polling data from the database you'd have to do it almost constantly
So the best way
is to find a way to use Pterodactyl API to send a command in the console of one of the servers
to change the group
Best way would be to just dispatch good ol' LP commands on their own, they'll do all the syncing required
lp user luckperms parent set admin
getTarget?
d;lp PermissionHolder
public interface PermissionHolder```
PermissionHolder has 2 sub interfaces, and 13 methods.
Generic superinterface for an object which holds permissions.
!usage
Here's a guide to help users understand and use LuckPerms for the first time.
Hum when does the primary_group change in the database? How do I make it so I just do something after it changes using NodeAddEvent or something like that?
it changes whenever the primary group changes
by default the primary group is your direct parent group with highest weight
Hum I think the issue was with mysql connection not being instant
Im gonna add group as a parameter with the request like this it would not depend in the database to update the role in discord when its updated in the server
this should fix the issue
I mean yeah.. LuckPerms is not specifically designed to be operated with external non-plugin programs (or rather, not those that interact with it outside of the provided API.. especially if it's even outside of the java environment)
It's to be expected to do workarounds if you do that
xD ye this is not being easy, I think the part of me being dumb is not helping š¤¦āāļø anyways thx for helping.
How to get all players who have a specific group?
!cookbook there's an example for that in the example api usage plugin
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
ok thx
Hey, how can I get all Users in a specific Group
read 3 messages above
got it thanks!
api abuse
also is there a way to make a error message if the NodeMatcher has no result?
uh.. check if the resulting collection is empty?
size =0?
lol
MetaNode node = MetaNode.builder("chatcolor", postNode).build();
User user = lpAPI.getUserManager().getUser(player.getUniqueID());
user.getData(DataType.NORMAL).add(node);
lpAPI.getUserManager().saveUser(user);
how can I set a meta node instead of adding?
so like removing any other key on the user that has "chatcolor"
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Has an example for groups iirc
I think, I must move my question here...
#support-2 message
I'm on Bungeecord and have a Command to toggle a context value. Works fine with the Permissions but the TAB complete is a bit slow.
If I use the lpb command to give/take a permission of a command, it work instantly, so I missing a bit of code...
you probably need to signal the context update
ContextManager#signalContextUpdate(Object player)
Thanks again ā¤ļø
would i be using
user.setPrimayGroup(group.getName()) // group is an object
because
user.setPrimayGroup(group) gives an error
that method doesn't quite do what you probably want to do..
what do you want to do?
set a player's group
okay so how do I do it
alr
Hi!
Is it possible to get the weight from an PrefixNode?
Yeah I checked, but I do not find anything, for the group weight I tried this and it works:
LuckPermsProvider.get().getUserManager().getUser(player.getUniqueId()).getCachedData().getMetaData().getPrimaryGroup()
)).findFirst();
int weightInt = (99-(lpWeight.isPresent() ? (lpWeight.get().getWeight().isPresent() ? lpWeight.get().getWeight().getAsInt() : 0) : 0));```
wait
I wait
I get it
Optional<PrefixNode> pn = pUser.getNodes(NodeType.PREFIX).stream().findFirst();
pn.get().getPriority();
thats all
?
Looks good
wow, thanks, sometimes I am braindead xD
How to set "non set" a node?
can be via adding/removing PermissionNode.builder("perm").build() to/from data?
@teal hill do you want to remove a node (like with lp user .. permission unset) or to set it to false?
I added LuckPermsProvider.get().getContextManager().signalContextUpdate(player); to my command.
Permission to use the Command works instantly.
The Client TAB Complete don't update instantly...
Theres an option in the LP config to change that iirc
sync-minutes ? That for the Database-Sync not the sync to the client.
Can't find any other config that could match
Oh, that's in the bukkit config, I'm on bungee/waterfall and there is no update-client-command-list...
can i got help?
!ask
Please ask the question you have. Don't ask to ask, or ask to DM someone. There are people here to help you, but we need to know what to help you with, so please just ask the question you want to in as much detail as possible!
Luckperms editor restfull api?
No
How does luckperms do /lp user <user> parent set <rank>
Im trying to make an alias plugin for it, does it just set the users primary group to that group
I feel like there has to be more
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Thx @turbid solar works like a charm!
Hey JaydenIsAPig! Please don't tag helpful/staff members directly.
This methods gets everyone in the specified groups UUIDs, but how would i change it to getting their usernames instaid? ```String groupName = args[1];
// Get a group object for the group name.
Group group = api.getGroupManager().getGroup(groupName);
// Group doesn't exist?
if (group == null) {
sender.sendMessage(ChatColor.RED + groupName + " does not exist!");
return true;
}
// Create a NodeMatcher, matching inheritance nodes for the given group
NodeMatcher<InheritanceNode> matcher = NodeMatcher.key(InheritanceNode.builder(group).build());
// Search all users for a match
api.getUserManager().searchAll(matcher).thenAccept((Map<UUID, Collection<InheritanceNode>> map) -> {
// Get a set of the group members (their UUIDs)
Set<UUID> memberUniqueIds = map.keySet();
// Tell the sender.
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6" + group.getName() + " &2has&e " + memberUniqueIds.size() + " &2member(s)."));
sender.sendMessage(ChatColor.GOLD + memberUniqueIds.toString());
});```
@NonNull
CompletableFuture<String> lookupUsername(@NonNull UUIDĀ uniqueId)
throws IllegalArgumentException, NullPointerException```
Uses the LuckPerms cache to find a username for the given uuid.
a username, could be null
IllegalArgumentException - if the username is invalid
NullPointerException - if either parameters are null
uniqueId - the uuid
Or use your platform for it
I have a question. Before the API change there was a method in the Group.class isTemporary(). How I can check in the new API if the group is temporary?
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
So this way: group.getDistinctNodes().stream().filter(Node::hasExpiry) ...?
Do you want to check if a user' group is temp or..?
I mean yeah a group itself isn't temporary lol
I want to load from a user all tmp groups
Me again with my Question: #luckperms-api message
I also scanned the Git repo but can't find any code that helps me ...
oh you're updating spigot plugin permissions from the proxy
are you pushing updates?
you mean your /warp command is by a bungeecord plugin?
All Commands within my own Plugin I'm only on Bungeecord/Waterfall and Permissions works fine, But the Client don't know that he has the Permissions and my Users are confused for 1 to 5 minutes....
If the User execute the command, it works fine only shows "wrong"
https://cdn.discordapp.com/attachments/420538367986499585/831817884601942026/unknown.png
- Is the plugin a bungeecord plugin or a spigot plugin?
- So the issue is only with tab complete?
- BungeeCord
- Yes
There should a line of code that updates the TAB list of commands for the client, I only can't find it^^
It depends on how you coded tab complete for your plugin
Not realy, the TAB for the command don't work.. Argument based TAB is a diverent story...
afaik, luckperms doesnt touch that at all
There must a way to "push" a update to the Client oO
If I use lpb commands it works fine, only my code has a delay -.-
are you updating spigot plugin permissions from the proxy?
its a bungeecord plugin according to KleinCrafter
Give me a minute I write an example to understand the issue...
and from what I know, the TAB for the command don't tie to any permission unless you have custom code or use a command framework that does it.
how can I get users in a group ?
that doesn't answers to my question ._.
!API one of these links tells you how to get players in a group. And the trick is, you get players that have the group and not groups that have the players
Learn how to use the LuckPerms API in your project.
Ok, now I made a 2 min Video to show my problem and how it "works" with the lpb commands just to see it don't xD
What my code do:
User execute the Command /work to Add or remove his UUID from a List.
I wrote a ContextCalculator WorkCalculator to look if the user is in the list (true) ore not (false)
Is the User not Working the User don't have the /warp Command Permission /lpb group job permission set kleincraftbungee.command.warp work=true
If I use /lpb user KleinCrafter permission set kleincraftbungee.command.warp false the TAB vanish
And after /lpb user KleinCrafter permission unset kleincraftbungee.command.warp the TAB is visible again
In the Video #1:47 is a one time exception that TAB was not updated for the client fast enough but was updatet right after the command failed.
If I use my command it always need minutes to update not only seconds. And I can use the warp command multiple times without any update...
So I think there is an Update in the lpb command to force a TAB update...
hu
poggers
Is there an api that allows me to easily get functions of LuckPerms, such as a players prefix
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
!api
Learn how to use the LuckPerms API in your project.
I'd ask what about that didn't work but that is prone to failure due to * and operator status so yeah
that was the problem lol
ty for your assistance
How can I get when the Players highest role expires?
NodeRemoveEvent
Check that the target is a user and that the node is an InheritanceNode
No
I don't want to execute something when it expires.
I wanna get when it expires.
Oooohh
yeah you can, but if you want it to be the one with highest priority you're gonna have to do some sorting yourself
I guess you could do something like this
final User user = /* get user (player adapter or user manager) */;
final Instant expiry =
user.getNodes(NodeType.INHERITANCE)
.stream()
.filter(Node::hasExpiry)
.max(/* get groups from the inheritance node's group name, sort by group weight */)
.map(Node::getExpiry)
.orElse(null);
if (expiry == null) {
// There was no temp parent group
} else {
// There *was* a temp parent group, use the expiry
}
ok thx
I'll try
tbh you might be better off having a separate method for the sorting of the nodes based on group weights
instead of doing them right in there
And I can't get the expiry time easier?
well you want the one of the highest temp group, assuming that's based on weight
right?
Yes
well then you have to do sorting
Also api.getGroupManager().getGroup(api.getUserManager().getUser(player.getUniqueId()).getPrimaryGroup());
Gets already the highest group
If its temp or not
It gets the highest
by default yes, but that can be changed in config (something not super common but I've seen it)
Yes.
And I can't get the expiry time from this?
you can, you'd have to get the temporary inheritance nodes for that group
yw
How can I set a Player the group āadminā temporary with the API?
Learn how to use the LuckPerms API in your project.
someone help me plz
i'm trying to get user's primary group and then get group's prefix
but the user might be possibily offline
so it needs to be async the loadUser function
it dosnt work...
Hey yiatzz! Please don't tag helpful/staff members directly.
Dont ghost tag me

Seems like permissions set by plugin/api doesn't list in the editor?
what about it "doesn't work"? what is the result you are expecting and what is the actual result
wdym
When I open the editor it doesn't list any permissions set by my plugin.
But they works
above
Is this even LP related?
yeah that is explicitly not saved anywhere lol
I believe you'd have to send the message within the loop though, let me inspect this closely
there is the code
if i send the mssage within the loop it will send the message multiple times
eh I'm not exactly following what's going on but wouldn't it make more sense to build and send each line individually?
as a separate component instead of one larger single message
what do u mean?
I mean don't build the whole thing as a single message with \ns
Send each line individually as they are made
Hi!
How can i get/set/add user groups with api?
I figured out how to do this. Groups are represented by permissions started with group. BTW
You should use the InheritanceNode.Builder
See https://github.com/LuckPerms/api-cookbook for API usage examples
Thanks, it worked. One more question, how do i remove node from user?
user.data(). i should better read manuals..
how to get prefix (prefix.something) for spigot plugin
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
its "Loading data for players"?
returns null
prefix listener:
public class PrefixListener implements Listener
{
Main plugin;
LuckPerms luckPerms;
public PrefixListener(Main plugin, LuckPerms luckPerms) {
this.plugin = plugin;
this.luckPerms = luckPerms;
}
@EventHandler
public void Prefix(final AsyncPlayerChatEvent e)
{
final Player p = e.getPlayer();
CachedMetaData metaData = this.luckPerms.getPlayerAdapter(Player.class).getMetaData(p);
String prefix = metaData.getPrefix();
e.setCancelled(true);
String tocomawyslac = prefix + " | " + e.getPlayer().getName() + ": " + e.getMessage();
Bukkit.broadcastMessage(tocomawyslac);
}
}
main
this.luckPerms = getServer().getServicesManager().load(LuckPerms.class);
<other classes>
Bukkit.getPluginManager().registerEvents(new PrefixListener(this, this.luckPerms), this);
getLogger().info("- Prefix");
You are likely not implementing it correctly, or you're using an old version of luckperms. It's unfortunately not possible for us to know all your code and how you're using so please be sure to read the wiki pages on the API as well as that one cookbook example
!api
Learn how to use the LuckPerms API in your project.
First and second links
Invalid perm
using 5.3
prefix.<weight>.<Actual prefix>
how to blacklist some world? with luckperms and essentials, like if someone(A) in the nether then he /tpa | tpahere B the B are blacklist and the teleport cancelled
nvm
oki
Hello, this is a newbie question but I can't figure out what I did wrong.
I'm followind the documentation (https://luckperms.net/wiki/Developer-API-Usage#saving-changes) but my IDE is giving errors because apparently LuckPerms.getUserManager() cannot be referenced from a static context, even if it's not static. This is the part of code that I've wrote, and it's in the main class. https://paste.lucko.me/LHO4jMVJWA
ohh ty
!api
Learn how to use the LuckPerms API in your project.
I'm trying to fire a UserDataRecalculateEvent through the API.
Tracing the code it looks like
luckPerms.getContextManager().signalContextUpdate(getNativePlayer());
should work but that just fires a ContextUpdateEvent
I mean I don't mind that event being fired but I also need the UserDataRecalculateEvent to be fired
Only code I can find that triggers that is actually modifying user data, which is not quite what I want
And the underlying calls are all in common
why do you need to fire one if user data hasn't changed?
The Context Changed so the Permission the User has also Changed too...
(Could fix my problem as well)
well the data hasn't changed - but the effective permissions have
so, you probably need to add an extra listener for the ContextUpdateEvent
Hiiiii
I am making a plugin, i want to track the rank (group) the player gets after promotion
public void onPlayerPromote(UserPromoteEvent event){
String promotedTo = event.getGroupTo().toString();
Player player = Bukkit.getPlayer(event.getUser().getUniqueId());
}
Is this the right way
I just want to get the rank name
What does getGroupto return?
aight thanks a lot
Whut?
Not sure if this is the correct channel for this, but could someone look into this question? Because he is apparently waiting for an answer to a question. https://github.com/lucko/LuckPerms/issues/2236#issuecomment-813810352
sure, there ya go :)
also, worth pointing out my comment here again: https://github.com/lucko/LuckPerms/pull/2449#issuecomment-732500109
assuming floodgate still operates in mostly the same way, those two event listeners are all that is needed
Thanks :)
The main reason why I think that it's better to have Floodgate support in LuckPerms instead of LuckPerms support in Floodgate is that the check is from LuckPerms. We do for example have a hook for ProtocolSupport because the way Floodgate works breaks ProtocolSupport, so the issue is coming from Floodgate.
I could equally argue that screwing with authentication, allowing "non-standard" usernames and UUIDs is an issue that LuckPerms should not be expected to deal with
and in fact we do generally have that stance towards people running cracked/offline mode servers with weird auth / premium join plugins
Fair, but an username will always be <= 16 chars and an uuid always 32 or 36 chars
Yeah, it seems like another alternative could be refactoring so the config option isn't even needed? If that's even plausible. I'm happy to help in that regard.
I don't think that it's cracking though. Floodgate is using the xbox api just like premium Bedrock servers would and it's both Minecraft.
We don't need to argue about offline mode status or not. Luck's point about authentication screwing is valid.
I agree, and I wasn't saying the two were comparable in terms of morally right or wrong
but technically, they are doing the same thing
Yeah fair point
Btw do you guys need to have a way to do xuid / gamertag lookups? (I saw that mentioned in your reply on issue 2236)
Because that'll be in the Floodgate 2.0 api soon
With Luck's API suggestions, all I need is the prefix which you did implement in Floodgate's API.
yep, and there are events for uuid/username lookup too if you wanted to provide that integration
Besides package or name changes, this could be implemented verbatim.
I think logically the API fits better in Floodgate, but that does set a precedent for our plugin to support other plugins which is less-than-ideal. The ultimate solution, in my opinion, would be making LP more flexible to weird usernames in a generic manner.
well, the generic fix-all solution is for floodgate users to toggle the existing allow-invalid-usernames setting in the LP config
True.
but it would be nice if things just worked ā¢ļø and if the username -> xbox id lookups could be hooked in
I agree; toggling a config option is less than ideal.
if it could be handled neatly in floodgate then that would be my preference - the LP API is very very unlikely to change & is on maven central, it should be a case of writing once and then forgetting about it from your POV.
the other alternative is that we ask Paper to consider adding API for it similar to https://papermc.io/javadocs/paper/1.16/com/destroystokyo/paper/event/profile/package-summary.html - but I have a feeling that is unlikely to happen
Can you elaborate on the Paper option?
paper adds events similar to https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/event/player/lookup/package-summary.html and allows plugins to query / modify outcomes
as I said though, I imagine that is unlikely
Yeah.
The core of LP's issue is that usernames can be added while offline, or even if they never joined. Is that correct?
Which is also, if I am correct, why the web editor doesn't have such an issue.
Actually I believe there is a method to add a Username -> UUID to the uuid cache, UserManager#something something savePlayerData
In the UserCache class itself (of nms)?
Or in regards to LP?
No worries!
Correct
although I wouldn't say it's an issue -- more just what users expect to be able to do haha
Ah, yeah! xd
When does the bukkit jarinjar file get loaded?
Conclure you know LP is open source right? lol
Yeah but I mean cba heh
Apparently AdvancedLuckPermsGUI throws NCDFE because of LuckPermsPermissible in the bukkit module isnāt loaded. Even though it should be loaded right assume ALPGUI is hardly depending LuckPerms.
Hm well the LuckPermsPermissible is inside the jarred jar so ALPGUI's PluginClassLoader won't be able to find it
Yeah itās stupid that it doesnāt just depend on the api. Hmm I guess I will have to rewrite the thing then rip
Well idk what it does but non-API in general (not LP exclusively) has always been something that shouldn't be relied upon lol that's what the API is for
Indeed yeah it actually extends some of the lp bukkit classes bruh
Hello guys. How can i get all groups of player withouts they inheritance? I use the following method and it returns all intermediate groups to me, even if the player does not have them.
futureUser.thenAccept((user) -> {
groupNames.accept(user.getInheritedGroups(user.getQueryOptions())
.stream()
.map(Group::getName)
.collect(Collectors.toList()));
});
You have to explicitly disable inheritance resolving in the query options, this is what I do myself
user.getQueryOptions()
.toBuilder()
.flag(Flag.RESOLVE_INHERITANCE, false)
.build()
Thank you so much for your help, now everything works as expected.
yw!
hello im really enjoying the mod , but can`t seem to figure out why I can not set up prefixes ( they seem not to appear on my nickname ) maybe some one has a list of common mistakes š
Well, do you have a chat format plugin (which either supports vault or placeholderapi I think)
#support-1 / #support-2 for general support please
okay sorry
how would I remove all suffixes from a user at a specific priority, like the meta removesuffix command?
i have user.data().remove(SuffixNode.builder("", 500).build()); but that doesn't remove them all or anything
You can skip the "new node" part and just clear priority == 500 ig
Although it depends on your end goal ĀÆ\_(ć)_/ĀÆ
And it'd be suffix instead of prefix
You get the idea lol
yw :)
I am new to lp api
How to Hiw to change a users group using the Api, i am a lil confused
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
ty
why is it null (the api)
sender.sendMessage(ChatColor.RED + user.getUsername() + " is now in group " + group.getDisplayName());
d;lp Group#getDisplayName
@Nullable
String getDisplayName()```
Gets the groups "display name", if it has one that differs from it's actual name.
The lookup is made using the current servers active context.
Will return null if the groups display name is equal to it's actual name.
the display name
@unkempt rampart
tysm
why do i get nullpointer exception on this line?
CachedMetaData metaData = this.luckPerms.getPlayerAdapter(Player.class).getMetaData(p);```
no clue
send the whole stack trace
Please use https://paste.lucko.me to send files in the future. I have automatically uploaded message.txt for you: https://paste.lucko.me/6ACl8GuQ0R
and that's line 30?
yeah
this.luckPerms is null
i know but this.luckPerms gets set
well, it's null
you can share the whole class and point out where it gets set
package pl.lightblock.engine.managers;
import net.luckperms.api.*;
import net.luckperms.api.cacheddata.CachedMetaData;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.ScoreboardManager;
import pl.lightblock.engine.Main;
import pl.lightblock.engine.commands.admin.chatmenu.ChatItemsMenu;
import java.util.Arrays;
import java.util.List;
public class Scoreboard {
LuckPerms luckPerms;
public Scoreboard(LuckPerms luckPerms) {
this.luckPerms = luckPerms;
}
public void createScoreboard(Player p){
ScoreboardManager manager = Bukkit.getScoreboardManager();
org.bukkit.scoreboard.Scoreboard board = manager.getNewScoreboard();
Objective obj = board.registerNewObjective("Score", "dummy");
CachedMetaData metaData = this.luckPerms.getPlayerAdapter(Player.class).getMetaData(p); //line 30
String prefix = metaData.getPrefix();
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
obj.setDisplayName("§eLIGHT§fBLOCK§e.PL");
Score score2 = obj.getScore(" ");
score2.setScore(2);
Score score3 = obj.getScore("§7JesteÅ poÅÄ
czony z trybem: §eSkyBlock");
score3.setScore(3);
Score score4 = obj.getScore("§7Twój nick: §e" + p.getDisplayName());
score4.setScore(4);
Score score5 = obj.getScore("§7Twoja ranga: " + prefix);
score5.setScore(5);
/*
Score score5 = obj.getScore("§7Gracze online: §e" + p.get);
score5.setScore(5);
*/
Score score6 = obj.getScore(" ");
score6.setScore(6);
p.setScoreboard(board);
}
public void updateScoreboard(){
for(Player players : Bukkit.getOnlinePlayers()){
createScoreboard(players);
}
}
}
@nocturne elbow
Hey nolemretaW! Please don't tag helpful/staff members directly.
okay and how are you constructing your Scoreboard class
final Scoreboard s = new Scoreboard(this.luckPerms);```
...
how are you initializing that this.luckPerms
private FileConfiguration config;
LuckPerms luckPerms;
public JoinQuitListener(Main plugin, LuckPerms luckPerms)
{
this.plugin = plugin;
this.luckPerms = luckPerms;
}
Main plugin;```
sigh
main
Bukkit.getPluginManager().registerEvents(new JoinQuitListener(this, this.luckPerms), this);```
getLogger().info("Initalizing LuckPerms API...");
this.luckPerms = getServer().getServicesManager().load(LuckPerms.class);```
private LuckPerms luckPerms;```
okay finally
where is that? onEnable? onLoad? constructor?
onenable
it works for another listener
scoreboard gets called by joinquitlistener, and joinquitlistener gets called by main in onEnable
send the server log file please
^ can you delete logs above?
try adding LuckPerms to the depends list in your plugin.yml
I don't see why it shouldn't work but who knows
it is
:doubt:
[00:57:47] [Server thread/WARN]: [Engine] Loaded class net.luckperms.api.LuckPerms from LuckPerms v5.3.27 which is not a depend, softdepend or loadbefore of this plugin.
doesnt work
@nocturne elbow
Hey nolemretaW! Please don't tag helpful/staff members directly.
same error
Okay well let's see, share:
your main class
your plugin.yml
the latest log (you can use https://mclo.gs if you wish to censor IPs)
1052 lines | 6 errors | 1 problem automatically detected
https://pastebin.com/kXiHX8k6 plugin.yml
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
It's depends, not depend
Pretty sure
Yep
And the main class plss
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
i change to depends and same error
Huh.. strange
Does it happen if you use the static accessor? LuckPermsProvider.get()?
where
Well instead of loading it from the services manager
doesnt work
Does it throw an NPE in the same place or another error?
npe in this same place
Well shit I have no idea
Uuh
Try sysouting every step, function call return etc
So sysout luckPerms, sysout the result of getPlayerAdater, of getMetaData etc
guys, question, how do I get all of the groups on the server in the api?
like get all created groups and put them in a list
!api
Learn how to use the LuckPerms API in your project.
this is the exact method you probably looking for ^, but if you are new to the api, I suggest reading all the 3 links provided by clippy
hm ok
when i try to do System.out.println(Main.getLuckPermsApi().getUserManager().loadUser(p.getUniqueId())); then it just prints java.util.concurrent.CompletableFuture@251da86f[Not completed]
Its because UserManager::loadUser returns a CompletableFuture which is a tracker for another thread loading the user asynchronously.
read on "Using CompletableFutures"
@fickle pier
There are 2 things you can do:
If you're sure the player is online you can use: Main.getLuckPermsApi().getPlayerAdapter(Player.class).getUser(p); to just obtain the already loaded user.
Or if you're unsure or know the player is offline you can use the CompletableFuture like you did.
If you want to execute some code once the user was loaded by the CompletableFuture, you can choose one of these options:
Options by blocking the server Thread: (Try to avoid this path if possible)
CompletableFuture#getCompletableFuture#join
Options without blocking the server Thread:CompletableFuture#thenAccept: This would perform aConsumer<User>upon receiving a User object.CompletableFuture#whenComplete: Note that this one is not meant to use the resulting User object. But rather to parse through the right object. (Like if an exception was thrown)
Hope this steers you in the right direction for your desired end-goal.
Is there any way to get the prefix of a offline user ?
Learn how to use the LuckPerms API in your project.
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
How do I make it here so it waits for the loop to be done (with all the users picked up) and than yes send the message. Or is there any better way to do this?
Considering youāre modifying a not thread safe message object with multiple threads Iād recommend just calling loadUser(...).get() and processing every user sync instead of using thenAcceptAsync
Hum thx
So in the cookbook there is this code ``` if (args.length != 2) {
sender.sendMessage(ChatColor.RED + "Please specify a player & a prefix!");
return true;
}
String playerName = args[0];
String prefix = args[1];
// Get an OfflinePlayer object for the player
OfflinePlayer player = this.plugin.getServer().getOfflinePlayer(playerName);
// Player not known?
if (player == null ||!player.hasPlayedBefore()) {
sender.sendMessage(ChatColor.RED + playerName + " has never joined the server!");
return true;
}
// Load, modify & save the user in LuckPerms.
this.luckPerms.getUserManager().modifyUser(player.getUniqueId(), (User user) -> {
// Remove all other prefixes the user had before.
user.data().clear(NodeType.PREFIX::matches);
// Find the highest priority of their other prefixes
// We need to do this because they might inherit a prefix from a parent group,
// and we want the prefix we set to override that!
Map<Integer, String> inheritedPrefixes = user.getCachedData().getMetaData(QueryOptions.nonContextual()).getPrefixes();
int priority = inheritedPrefixes.keySet().stream().mapToInt(i -> i + 10).max().orElse(10);
// Create a node to add to the player.
Node node = PrefixNode.builder(prefix, priority).build();
// Add the node to the user.
user.data().add(node);
// Tell the sender.
sender.sendMessage(ChatColor.RED + user.getUsername() + " now has the prefix " + ChatColor.RESET + prefix);
});
return true;
}```
Nothing seems to be wrong with that, but why does it always return true?
I ALWAYS return false when coding, so why does this do different, under my impression if you return true in a method that means it will CONTINUE doing the method am I wrong?
Such as right here, // Player not known? if (player == null ||!player.hasPlayedBefore()) { sender.sendMessage(ChatColor.RED + playerName + " has never joined the server!"); return true; } // Load, modify & save the user in LuckPerms. this.luckPerms.getUserManager().modifyUser(player.getUniqueId(), (User user) -> {
why would you always return false in onCommand?
Do you know what the return value means in CommandExecutor#onCommand?
No, when you return from a method it just exits is and provides the caller with the returned value
If false is returned, then the "usage" plugin.yml entry for this command (if defined) will be sent to the player.
Basically you define the usage of the command in your plugin.yml, the core idea of it is that if the arguments sent don't match your cmd requirements (e.g. passing a name instead of a number when you need a number) you return false from onCommand and the usage text is sent
WHAT
THAT IS SO COOL
I have a question, if I define the usage as, "&4What is up"
Will it return as dark red?
§
How do you type that?
Some keyboard layouts have it uuh.. somewhere, I just Alt + 21
21 from the numpad
not the number row above
Anyway
Dang thats cool
But like 99.999% of the time you will often see it just return true because you will send a custom message based on which argument you failed to parse
So if you return true, whats the point of returning, because if you return false, then it stops but if you return true that just makes it so that it keeps going, so why just not return at all if you are going to return true?
when you return from a method it just exits is and provides the caller with the returned value
regardless of what value you return
Oh ok
when you return you exit the method completely
Ohhhhh
how can i use luckperms api in bungeecord?
!api
Learn how to use the LuckPerms API in your project.
yeah i figured it out, i had to use the singleton thingy :))
are changes automatically pushed via plugin messaging when data is altered via the api?
Is there a way to get a "dynamic" permission node like plugin.homes.limit.7 without just looping through 0-100 or something like that
Use meta nodes
Basically a key value pair
!cookbook there might be something about them here
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
I suggest you read the rest of the page too
The cookbook will surely help too
To add/give a meta node use the MetaNode.Builder
Hey gamers. So I wrote some code a fat minute ago to check dynamic perms (I know, please don't yell at me) based on a number in a permission system. Apparently this has been failing on and off when I'm using the player.getEffectivePermissions(). So, I figured I would switch over to using the LuckPerms API for this. Would I do this the same way I currently am, which is to get all the permissions of the player, check if the permission starts with a specific part of the string, get the last index of it, such as my.perm.2 and then parse that to return the 2 and go from there or does LuckPerms have some kind of better approach for this?
Hello gamer
Read 7 messages above yours
@dull rover owo
Meta is specifically made for this kind of thing
Without them you'll have to loop through all nodes, no way around it I believe
I guess you could implement your own cache but you'd have to update it on every event that may or may not change the "active nodes"
Lol I didn't even bother reading since I didn't realize the chance of someone else actually wondering the same thing.
Happens often
I don't mind looping through all the nodes unless it's intensive. The checks aren't ran super often.
Eh unless we're talking about potentially tens of thousands of nodes I don't see it being an issue lol
Hello, how to issue a group to a person via API
!cookbook has exactly what you need
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
!api I also suggest you go over those 2 pages + the very useful javadoc :)
Learn how to use the LuckPerms API in your project.
I got this error ```org.bukkit.plugin.InvalidPluginException: net.luckperms.api.LuckPermsProvider$NotLoadedException: The LuckPerms API isn't loaded yet!
This could be because:
a) the LuckPerms plugin is not installed or it failed to enable
b) your plugin does not declare a dependency on LuckPerms
c) you are attempting to use the API before plugins reach the 'enable' phase
(call the #get method in onEnable, not in your plugin constructor!)
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:739) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.Bukkit.reload(Bukkit.java:535) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at```
net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]
Caused by: net.luckperms.api.LuckPermsProvider$NotLoadedException: The LuckPerms API isn't loaded yet!
This could be because:
a) the LuckPerms plugin is not installed or it failed to enable
b) your plugin does not declare a dependency on LuckPerms
c) you are attempting to use the API before plugins reach the 'enable' phase
(call the #get method in onEnable, not in your plugin constructor!)
at net.luckperms.api.LuckPermsProvider.get(LuckPermsProvider.java:52) ~[?:?]
at me.jayden.toggle.Utils.<init>(Utils.java:24) ~[?:?]
at me.jayden.toggle.Commands.<init>(Commands.java:23) ~[?:?]
at me.jayden.toggle.Main.<init>(Main.java:10) ~[?:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_282]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_282]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_282]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_282]
at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_282]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
... 14 more```
I assume i have to do the Luckperms api = LuckPermsProvider.get
On enable, then get that api from other classes?
I could be wrong, (and yes i did softdeped btw)
!paste full startup log
Seeing a paste of the problem makes everything so much easier! Use https://paste.lucko.me/ for easy pasting!
Pastebin any relevant segments of the console log. If it's a startup error, this includes the entire startup log!
Pastebin the entire LuckPerms config file (passwords removed) as well as any other relevant files!
Hello, I've been having errors with LP api, specifically when checking for a permission.
A NullPointerException is thrown when player.hasPermission(permission); is done. This is the stacktrace and full start log: https://paste.lucko.me/BZWF11Ke4O
can you show the code for that rankup command?
it's really long ngl, what part would you want to check?
this is a little snippet, tell me if you need more.
private String perms;
perms = Rankups.getInstance().getConfig().getString("levels."+numerorank+".permission");
if(player.hasPermission(perms)){ //Exception here!
//check for points and checks applies permission.
}
looks like your perms variable is null
It shouldn't be
I wont know
Depends on your whatever this does Rankups.getInstance().getConfig().getString("levels."+numerorank+".permission");
it gets a string from the config, let me try with a "debug" step
I suggest you do some logging on these "levels."+numerorank+".permission" and perms variable
yeah exporting plugin now
yes it's null actually. Another issue with my bad coding. Sorry for bothering
How can I replace this piece of code with LuckPerms?
for (int length = (groups = PermissionsEx.getUser(player).getGroups()).length, i = 0; i < length; ++i) {
final PermissionGroup group = groups[i];```
!api
Learn how to use the LuckPerms API in your project.
Hello, how to get the prefix of a player with the api (version 5-3 )
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Thank
Can I get the username of a User with upper characters?
hum ok
Hi
I was using the api to detect when the player receives a position or loses
However, the NodeAdd event only works on normal servers, and I wanted a way to be able to do this verification by the bungee
I'm using syncnetwork
And it doesn't work
many events do not propagate throughout the network, your best bet tbh is to subscribe to events from these packages
https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/event/log/package-summary.html
https://javadoc.io/doc/net.luckperms/api/latest/net/luckperms/api/event/sync/package-summary.html
and "manually" parse the received log messages, there is no way for other LPs to know which data exactly to update;
You could potentially in a bit of an extreme case subscribe to UserDataRecalculateEvent but there is no before/after data to compare to, since it just discards everything and reloads the user from storage
In my case, I would need to know which groups he won or lost
Yeah you can get that info from the LogReceiveEvent, check that the action target type is a user and parse the description (probably something like "parent set <group>", play around with the event and check by yourself what you get)
!cookbook for me
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
this should work right?
Or is there a better way to check if the user already has a meta with that key
yeah that ain't gonna work
use a MetaNode in the for loop and check if the getMetaKey is the same
getKey gets the whole node key basically
Well you can since they are different keys (not meta keys)
The meta set command removes all meta nodes on the holder that don't have an expiry and match the meta key (and apply in the same context too) https://github.com/lucko/LuckPerms/blob/master/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java#L83-L84
What is the permission node/meta given to a user with a parent group of "owner"
Trying to get a list of groups without using the api
group.<group>
thank you
Hello, How can I load a user using only his name? I don't have the uuid
Feel free to mention if you know how
Solved, haven't seen the lookupUniqueID method
So I have this strange bug (or intended feature). When I run userManager.modifyUser() in an asynchronous thread, the inherited group is added to the user just fine, but as soon as I start querying all the inherited groups or run /lp user <username> info, that inherited group is gone. Does anyone have any idea why this happens?
Is it on the same server?
Yes
"as soon as"
how soon is "as soon as"?
The moment I call that method or command
It just vanishes and I no longer have the permissions
sample code?
hold on
UUID id = called.getUniqueId();
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
//...
UserManager userManager = plugin.luckPerms.getUserManager();
userManager.modifyUser(id, user -> {
//1. Check if admin is already assigned
Collection<Group> inheritedGroups = user.getInheritedGroups(user.getQueryOptions());
for(Group group : inheritedGroups) {
System.out.println(group.getName());
}
if(inheritedGroups.stream().anyMatch(g -> g.getName().equals("admin"))) {
plugin.getServer().getScheduler().runTask(plugin, new RankAPIRunnable(RankAPIStatusCode.RANK_ALREADY_HAVE, callback));
return;
}
Group adminGroup = plugin.luckPerms.getGroupManager().getGroup("admin");
//2. Assign to the group until logout
user.data().clear(NodeType.INHERITANCE::matches);
Node node = InheritanceNode.builder(adminGroup).build();
user.data().add(node);
//3. Log
plugin.getServer().getScheduler().runTask(plugin, new RankAPILogger(plugin, id, "added admin rank until logout"));
plugin.getServer().getScheduler().runTask(plugin, new RankAPIRunnable(RankAPIStatusCode.SUCCESSFUL_LOGIN_FINAL, callback));
});
return;
}
}
I mean that doesn't really show me the part you fetch the parent groups after calling modifyUser
userFuture.thenAcceptAsync(user -> {
//1. Check if we have admin
Collection<Group> inheritedGroups = user.getInheritedGroups(user.getQueryOptions());
if(!inheritedGroups.stream().anyMatch(g -> g.getName().equals("admin"))) {
plugin.getServer().getScheduler().runTask(plugin, new RankAPIRunnable(RankAPIStatusCode.RANK_DONT_HAVE, callback));
return;
}
or /lp user <username> info
I fail to see how that is "as soon as" but okay; what do the sysouts print? any errors? what lp version?
After the code adds the admin group, it works just as intended fine with all the permissions enable, but when the code or command in my previous message gets called, it just says that the default group is assigned and the admin priviliges are immediately taken away.
Also, default has some commands disabled, but those are still enabled even after the admin group is gone
lp is 5.3.27 and no errors came up
huh
well i guess i'll test
seems to be working fine for me
This is my code in a command https://paste.lucko.me/egRwJlwqZs
Then I ran /lp user <user> info and it showed just as expected š¤·āāļø
odd
i found the problem, the online-mode was set to false
Nope, that is not the problem
setting the primary group resolved my issue. thanks @nocturne elbow
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
i followed that, it didn't help
Hey Heisser_Kakao! Please don't tag helpful/staff members directly.
Look at the cookbook for examples
Node node = Node.builder("ray.chat").value(false).build();
Main.luckPerms.getUserManager().modifyUser(Bukkit.getOfflinePlayer(args[0]).getUniqueId(), (User user) -> {
if (user.data().contains(node, NodeEqualityPredicate.IGNORE_EXPIRY_TIME).asBoolean()) {
user.data().clear(NodeMatcher.key(node));
sender.sendMessage("§aPlayer unmuted");
} else {
sender.sendMessage("§cPlayer haven't mute");
}
});```
but
```java
user.data().contains(node, NodeEqualityPredicate.ONLY_KEY).asBoolean()```
always return false
I just want to see if the player has permissions ignore time
I mean that sounds about right
NodeMap#contains returns UNDEFINED if not set or the node value if otherwise
d;luckperms NodeMap#contains
@NonNull
Tristate contains(@NonNull NodeĀ node, @NonNull NodeEqualityPredicateĀ equalityPredicate)
throws NullPointerException```
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.
a Tristate relating to the assigned state of the node
node - the node to check for
equalityPredicate - how to determine if a node matches
NullPointerException - if the node is null
I check yea return UNDEFINED
but why
how I print user.data() I check and contains java ImmutableNode(key=ray.chat, value=false, expireAt=1619804185, contexts=ImmutableContextSet(contexts={}))
wants to check if the player has "ray.chat" with value false
Seeing a paste of the problem makes everything so much easier! Use https://paste.lucko.me/ for easy pasting!
Pastebin any relevant segments of the console log. If it's a startup error, this includes the entire startup log!
Pastebin the entire LuckPerms config file (passwords removed) as well as any other relevant files!
if (user.data().contains(node, NodeEqualityPredicate.IGNORE_EXPIRY_TIME).asBoolean())
Again... NodeMap#contains returns UNDEFINED if it's not set.... and if it is set it returns the node value
If it's set to false, it will return Tristate.FALSE, which when you get it as a boolean, it's false
I don't understand sorry
in essence, what you are doing is
if (false) {
// stuff that never runs
} else {
System.out...
}
this I don't understand but I don't understand why
how should he do it?
Check if it's not undefined
If it's not undefined, then it's set to something, either true or false
and how should he do to check if it has options from the false option settings
Oh my god
For the 3rd or 4th time, NodeMap#contains returns a Tristate
Tristate can be one of three possible values:
Tristate.UNDEFINED (not set)
Tristate.TRUE (set to true)
Tristate.FALSE (set to false)
Please make an effort
a how set?
What?
Holy shit
It is not returning undefined
It's returning Tristate.FALSE
Because the node is FALSE
Okay, finally something useful
Run and screenshot /lp user <user> permission check ray.chat
Screenshot the entire thing
good?
Okay we're getting somewhere
Do you change the code since then? If so, please send the updated code
no don't change
Okay, I'll test later when I can, seems strange
Node node = Node.builder("ray.chat").value(false).build();
Main.luckPerms.getUserManager().modifyUser(Bukkit.getOfflinePlayer(args[0]).getUniqueId(), (User user) -> {
if (user.data().contains(node, NodeEqualityPredicate.IGNORE_EXPIRY_TIME) == Tristate.FALSE) {
user.data().clear(NodeMatcher.key(node));
sender.sendMessage("§aPlayer unmuted");
} else {
sender.sendMessage("§cPlayer haven't mute");
}
});```
@nocturne elbow I change my code but didn't work
Hey Raymano! Please don't tag helpful/staff members directly.
@odd vapor From the javadoc for NodeEqualityPredicate.IGNORE_EXPIRY_TIME:
All attributes must match, except for the expiry time, which is ignored.
Note that with this setting, whether a node has an expiry or not is still considered.
In other words: the expiry time is ignored, but it has to be temporary
The check you should be looking to do is
if (user.data().contains(node, NodeEqualityPredicate.IGNORE_VALUE_OR_IF_TEMPORARY) == Tristate.FALSE)
oh ...
Realy thanks
Sorry it took so long, busy day
you're welcome
How can I give someone a temp role per API?
Look into InheritanceNode with expiry
What is the key?
Key where
Use InheritanceNode
!cookbook
The cookbook is a working example plugin which shows how to get/change data for users and groups, listen to LuckPerms events, and more.
Thx
Why does userOrRideop doesn't gets set to true?? (The player's group name is default)
Care to check the warning highlighted on ==?
You don't compare Strings with ==, you compare them with .equals (string1.equals(string2)) or .equalsIgnoreCase
(How) can I get how many people in a specific group are online rn?
Get users in the group then use your platform api to see if their online using uuid?
Was an example somewhere
How can I get the player's group expiry time?
If you have a answer for my question, Feel free to mention.
thx
help
Get the user nodes of type INHERITANCE, filter in those that have an expiry (see Node#hasExpiry()) and get the expiry Instant with Node#getExpiry()
thanks I will see
I am so incredibly confused
I've added luckperms as a dependancy
but I can't use it even after reloading gradle
nvm, I invalidated caches
I need to give a couple of Bungee perms sync on PostLogin. How do I do that?
How can i add permission to player with API?
Learn how to use the LuckPerms API in your project.
is this are going to return the high wight group ?
what about if the player have 2 groups with the same wight ?
is this are going to return the high wight group ?
by default, yes
what about if the player have 2 groups with the same wight ?
not super defined I believe, some times I've seen groups with the same weight being ordered alphabetically, some other times I have not ĀÆ\_(ć)_/ĀÆ
Thank you emilyy
probably just based on what comes first in the memory mapping ig
hello, i did try to use LuckPermis events and i load the example
but there is class named (MyPlugin) i didn't found any why to imported.
It's an example
You are supposed to take it as guidance, not copy/paste it lol
"MyPlugin" is your plugin class that extends JavaPlugin if you're on Bukkit
i understand now thank you and sorry for misunderstanding .
How can I add a parent to a player with the API?
dammit ben i just woke up was gonna paste it
š
does this add a group, or does this set the group as the only one?
Set as only one
And how can I add a parent / group?
Remove line 59
Should I
user.data().clear(NodeType.INHERITANCE::matches);remove this ^
Yes
Ok thx
why
LuckPermsProvider.get().getUserManager().getUser(p.getUniqueId()).setPrimaryGroup(args[0]);
not working ?
Changing the primary group ā changing the parent groups