#luckperms-api
1 messages · Page 12 of 1
Anyone know why this reset node resets when the player relogs
nodes[i] = luckPerms.buildNode(timedWEPermissions[i])
.setServer(server)
.setValue(true)
.build();
Assigning it, resets on logout when infinite is true:
User user = plugin.getLuckPerms().getUser(target.getUniqueId());
Node[] permissionNodes = infinite
? group.getWEPermissionsAsNodes(plugin.getLuckPerms(), "creative")
: group.getWEPermissionsAsNodes(plugin.getLuckPerms(), "creative", System.currentTimeMillis() + time);
for (Node node : permissionNodes) {
user.setPermission(node);
}
user.getCachedData().recalculatePermissions();
you need to save the user
plugin.getLuckPerms().getUserManager().saveUser(user)
you also don't need to call user.getCachedData().recalculatePermissions();
Thanks 😃
Hi, I need help with something, how to get the parent groups ? 😃
I need to know in which group is a player in a track
.filter(Node::isGroupNode)
.map(Node::getGroupName)
.collect(Collectors.toSet());
groups set will contain every group the user has
then search for the track that contains the group
Map<String, Track> h = new HashMap<>();
for(String g : groups){
for( Track t : api.getTrackManager().getLoadedTracks()){
if(t.getGroups().contains(g)){
h.put(g,t);
}
}
the h hashmap now should contain every group the player has and the corresponding track to each group
Thanks, i used another way 😃
Quick question, is the API on version 4.1 or 4.2? I assume it is on 4.2 but the Wiki says 4.1 is the latest version.
Could we update https://github.com/lucko/LuckPerms/wiki/Developer-API to match that?
@grim crag yeah. 4.2 is the current version
can someone help?
Player player = e.getPlayer();
UUID uuid = player.getUniqueId();
String name = player.getName();
String rank = this.plugin.playerRank.get(uuid.toString());
ContextManager cm = this.plugin.luckPermsApi.getContextManager();
Contexts contexts = cm.lookupApplicableContexts(this.plugin.luckPermsApi.getUser(uuid)).orElse(cm.getStaticContexts());
MetaData metaData = plugin.luckPermsApi.getUser(uuid).getCachedData().getMetaData(contexts);
String prefix = metaData.getPrefix();
if (prefix.equals("default")) {
player.setNameTag("§8[" + this.plugin.ranks.getString("ranks." + rank + ".prefix") + "§8] " + "§7 " + name );
} else {
player.setNameTag("§8[" + this.plugin.ranks.getString("ranks." + rank + ".prefix") + "§8] " + prefix + " | " + name);
```
the java if (prefix.equals("default")) { doesn't seem to work
java.lang.NullPointerException
@crystal sonnet
Hey fluorine! Please don't tag staff members.
getPrefix() can return null. So you should also do a null check
i didnt have "default" prefix xD
Not sure if this is a stupid question, but how would I use the API to get the color of a group and apply that color to another String?
Is it okay to tag people on a question?
do you mean color as in like group prefix or something? i have no idea btw but it'd help clarify to someone who does
Yes.
Group Prefix, sorry for not specifying.
@acoustic sapphire ^^ Sorry if tagging isn't allowed.
read my edited message lol sorry
Ah.
Not sure if this is a stupid question, but how would I use the API to get the color of a group prefix and apply that color to another String?
@proud crypt ^^ Sorry if tagging isn't allowed.
Hey ColtHale! Please don't tag staff members.
If you're attaching meta to the groups which define the color, you'd wanna use the meta stuff to grab that info
And getting the color from the group is easy. Just make sure the group prefixes all have a common format and then just extract it
Hm, alright. Not really understanding the Contexts. I'm not sure on how I would create or use a Contexts to get the players prefix.
How would I get the users current prefix? I'm assuming getting their current Contexts?
Am I just being stupid right now?
Never mind. Just had to add .get(); to the end of it. Thanks!
Is there any event or something to listen to when player data gets updated?
Like from bungee message?
nevermind, found it
@crystal sonnet How would I go about getting the color of the prefix? It's so late right now, I swear I can't think straight rn...
Hey ColtHale! Please don't tag staff members.
As I said
Make sure the prefixes have a common format and use string manipulation to get it
Okay, what the crap. I've been looking everywhere for something like you're talking about. What darn "string manipulation" are you talking about? I'm so confused of this one little thing.
sup
is this still what you're trying to do
ColtHale - Today at 06:07
Not sure if this is a stupid question, but how would I use the API to get the color of a group and apply that color to another String?
Yes.
It's 5:39 AM in the morning and I have been looking for a solution for 4 hours now.
/lp group admin meta set color &c
Then, request the meta using the cached data API
so instead of "some-key", you'd use "color"
If you scroll up from that point, it explains how you get to that stage
Alright. Thank you. I'll try that. So, what about the "default-value"? Just leave it how it is I'm assuming?
well, what color value do you want to use if nothing is set for the group?
that's what you should use for default value
Okay. Thanks.
the result of metaData.getMeta() is just a Map<String, String>
I know that there isn’t an explicit event
@lethal eagle
If you do the changes on the server, then there should be an event for changed nodes. However if the server only receives an update over the messaging service you need to use a different event
I updated LP api but for some reason this method does no longer work in legacy version but in sponge it still does:
user.getCachedData().getMetaData(Contexts.allowAll()).getMetaMultimap().get(PermissionOptions.DAILY_TOKENS).stream().mapToInt(Integer::parseInt).max();
Any ideas?
do you get an error?
no, it just doesn't execute any code below that line
LuckPerms.getApi().getUserManager().loadUser(player.getUniqueId()).thenAcceptAsync(user -> {
System.out.println("User: " + user.getName());
OptionalInt tokens = user.getCachedData().getMetaData(Contexts.allowAll()).getMetaMultimap().get(PermissionOptions.DAILY_TOKENS).stream().mapToInt(Integer::parseInt).max();
System.out.println("Tokens: " + tokens.isPresent());
});
user shows up, tokens doesn't
@jaunty pecan ^
Hey SirWill! Please don't tag staff members.
i'm guessing that getMetaMultimap is throwing an exception
the legacy version of LP has to shade guava, and the shaded classes are relocated
when you call getMetaMultimap, your code expects to receive a com.google.common.collection.Multimap (or whatever it is) but it actually gets a me.lucko.luckperms.lib.guava.collection.Multimap
i've thought quite a bit about ways to solve it
but haven't really found a nice solution
was that even changed? because I had the same method working before updating
you're using the 1.7 legacy version, right?
yes
oh wait, do I need to compile my plugin on the legacy version instead of the normal one?
yes that would probably fix it
yup, that was the issue, thanks
How would I get the Contexts of a Group?
It's the members of the group that have a context
@EventHandler
public void onGroup(UserPromoteEvent event) {
LuckPerms.getApi();
Bukkit.broadcastMessage("hey, thats pretty good!!");
} ```
what am I doing wrong(ikr im so dumb with this API, idk how 2 use it
Luckperms' events aren't based on the bukkit event api
https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#listening-to-luckperms-events
eg you will need something like this (api is your LP api instance plugin is your plugin instance):
public class MyClass {
public MyClass(){
EventBus eventBus = api.getEventBus();
eventBus.subscribe(UserPromoteEvent.class, this::onUserPromote);
}
private void onUserPromote(UserPromoteEvent event) {
Bukkit.getScheduler().runTask(plugin, () -> {
Bukkit.broadcastMessage("hey, thats pretty good!");
});
}
}
oh thank you
Is there a way to resolve the displayname via API?
getFriendlyName
Display names aren't friendly. )-:
They're just there to make it hard to message people.
Hello
How can I add a group to someone?
Bukkit.getOnlinePlayers().forEach(player -> {
User user = controller.getLuckPermsApi().getUser(player.getUniqueId());
Group group = controller.getLuckPermsApi().getGroup("mitgliedplus");
if(getPlaytime(player) >= 172800000L && !user.inheritsGroup(group))
{
// ADD GROUP HERE
}
});
explained here
Lol so I just need to add them the node "group.mitgliedplus"?
I'm not sure whats the best way. Players should get the memberplus rank after two day. Should I set it as primary or just add it with this node?
just add it with the node
Ok
So is there also a way to detect if they are in the group even if they inherit it?
So if I have a mod as example. He left team. I remove mod-group. He remains with mitgliedplus.
I don't understand your question
@nocturne elbow
So you have a user something like this:
default -> mitgliedplus -> mod -> exampleuser
and you'd like to remove them from mod, while keeping him in mitgliedplus
Yes
And I want to add the mitgliedplus even if he is in mod
And mod inherits mitgliedplus. So I cant use user.inheritsGroup(group)
I've got this now:
User user = controller.getLuckPermsApi().getUser(player.getUniqueId());
Group group = controller.getLuckPermsApi().getGroup("mitgliedplus");
if(getPlaytime(player) >= 172800000L && !user.inheritsGroup(group))
{
Node node = controller.getLuckPermsApi().getNodeFactory().makeGroupNode(group).build();
user.setPermission(node);
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 2.0F);
player.sendTitle("§6Vielen Dank", "§eDu erhältst §a$500 §efür deinen Vote!", 20, 60, 20);
}
But that will only apply if the user is not in a higher group (maybe temp).
so essentially you want to check if the user has mitgliedplus directly inherited, if not it sets the inheritance
Set<String> groups = user.getAllNodes().stream()
.filter(Node::isGroupNode)
.map(Node::getGroupName)
.collect(Collectors.toSet());
this code returns a set that contains every directly inherited group node, if that set contains mitgliedplus means mitgliedplus->user
Yeah, thats what I needed. Thank you 😃
np
Btw, what is the primary group needed for?
Looks like everything works if I leave primary group on default and add groups with nodes only
with default config, I don't really know a good usage
With prevent-primary-group-removal: true it can be used to prevent demoting out of a track
@jaunty pecan can i ask what is better?
Bungee messaging or SQL messaging?
Hey ! JohannesHQ! Please don't tag staff members.
sql is probably more reliable
alr
SQL as messaging, fancy
not very technically sensible (?!)
but it's pretty low throughput, and more reliable than the plugin messaging channels
it's bad
Welp
but not plugin messaging channel bad
Only argument 😂
messaging channel has many flaws, implementation wise and design wise
🤷♂️
Does anyone know the best way to get a group prefix? At least the 'highest' prefix it has?
this is what I use right now:
MetaData data = group.getCachedData().getMetaData(Contexts.global());
String prefix = data.getPrefix();
How to get a value from a node?
for (Node permission : user.getPermissions()) {
if (!permission.isGroupNode()) continue;
if (from <= sk && sk < to) {
String expiration;
try {
expiration = permission.getExpiry().getDay()+"d. "+permission.getExpiry().getHours()+"h. "+permission.getExpiry().getMinutes()+"m.";
} catch (Exception e) {
expiration = "Never";
}
String server;
try {
server = permission.getServer().get();
} catch (Exception e) {
server = "global";
}
String world;
try {
world = permission.getWorld().get();
} catch (Exception e) {
world = "global";
}
ItemStack item = Tools.button(Material.WOOL,
"&6"+permission.getGroupName(),
Arrays.asList(
"&cID: &e"+sk,
"&cExpires in: &e"+expiration,
"&cValue: &e"+permission.getValue(),
"&cServer: &e"+server,
"&cWorld: &e"+world,
"&eClick to remove"
), 1, Tools.randInt(0, 15));
myInventory.setItem(i, item);
i++;
}
sk++;
}
@crystal sonnet tagging just to get off from general to api
Hey AsVaidas! Please don't tag staff members.
Everything works till "&cValue: &e"+permission.getValue(),
What API version are you compiling against and what version of the plugin are you using?
plugin version - newest
Version numbers please
4.2.17
I'm getting the api with LuckPermsApi l = LuckPerms.getApi();
So don't know the api version
But I guess it should be correct
Well, it's not the latest, but your version and the latest use the same API version so it's fine
how is the api imported into your project
You must be using a jar when compiling your plugin
Either through a build system like maven or directly
what does the build path reference
the jar should contain the version number of the API
then make sure that LuckPerms.jar is the latest one
It is
I don't have an error when compiling and eclipse shows everything is okay
the error you're getting seems to suggest it's looking for the primitive wrapper method
java.lang.NoSuchMethodError: me.lucko.luckperms.api.Node.getValue()Ljava/lang/Boolean;
But in server, my plkugin cant get the value
which only existed on older versions
So I need to replace
It doesn't show an error because you are using an old version
And as a recommendation, don't remove the versions from the file names
Hello, how do i add someone to a group? 🤔
with the api?
Yes
you have to create a group node and then set that
Ty
hello all
I am trying to work out how to set perms for world edit so I can let my admins do some world editing
Do you need the permission node?
Does lucky perms work for spongeforge 1.12.2 ?
Wrong channel for this question, but yes it does
Greetings. How may I programmatically set a prefix of a user?
The nodes for prefixes look like this prefix.<priority>.<prefix> @alpine mountain
So for example prefix.1000.&4Owner
Ah, ok.
And I think the wiki explains how to add a node to a player
I've got that far. I was confuused on how to add prefixes.
However, I didn't read the wiki properly 😃
Great you figured it out 😃
Hello, i don't speak english. Sorry for my english.
Error: https://hastebin.com/rugoxowito.vbs
Class to get prefixes, and onEnable: https://hastebin.com/vapukiluco.swift
Oh boy
I don’t want to sound rude, but you should probably start learning programming/Java, reading error messages and documentation (and English too for that matter).
Making plugins is not suited for beginners. Especially when using external APIs
But in essence the error is telling you to use a player object instead of a string
Sorry, it's the first time I use the api of luck perms, actually I just met him.
That is ok. All I’m saying from what I see, you’re not familiar enough with Java to try working with plugins and other plugins’ APIs
I tried to use the Player object too, since it returned this error, however it returned to null, despite the check whether it is null or not.
I recommend reading this page
Has loads of examples
hi guys i keep getting these messages
[Server] INFO Caused by: java.lang.NoClassDefFoundError: me/lucko/luckperms/LuckPerms
[Server] INFO Caused by: java.lang.ClassNotFoundException: me.lucko.luckperms.LuckPerms
I'm just trying to give a player permissions
and remove them sometimes
tell me more about the plugin.yml
im kinda new to plugin development
do I need to like reference it in there?
Yes, under "depend"
yea I have like my commands in there and stuff
oh
alright thanks you just saved me
❤
so whats the name thing of luckperms?
LuckPerms
Yes
youre a life saver
One more question which is stupid. I have the API thing in onEnable() but how can I access it outside of onEnable?
im also new to java lol
anyone?
Like I have RegisteredServiceProvider<LuckPermsApi> provider = Bukkit.getServicesManager().getRegistration(LuckPermsApi.class);
if (provider != null) {
LuckPermsApi api = provider.getProvider();
}
in my onEnable
but now I cant use the api var in other stuff thats outside of onEnable()
@mint sparrow not trying to be rude. But to self yourself from pointless struggle, learn Java before even trying yourself with plugins. Let alone working with other plugins’ APIs
oof
I mean you're trying to fly fighter yet maneuvers, though you don't even know how to enter a plane (or fighter yet for that matter)
LMAO
this is the only problem ive had to ask help for tho lol
I didn't say it's impossible
Though you'll do yourself a massive favor first learning Java
The problem is "how do I make my variable available" though, which is pretty basic Java /-:
public Node makeNode(String permission) {
Node node = api.getNodeFactory().newBuilder(permission).build();
return node;
}
whats wrong with this? I get a null pointer exception here
@mint sparrow put you code in H E R Eto make it easier to read
Node node = api.getNodeFactory().newBuilder(permission).build();
return node;
}```
soz
https://www.codecademy.com/learn/learn-java <- I recommend these guys for onlin learning. There are others.
And there we go again. Proofing my point.
Anyways without the NPE we can't help you
imagine having a simple question about something. I'll figure it out without you damn
Sorry. You don't get to play the victim card here.
All we're saying is that you should learn Java first to avoid exactly these kinds of errors. Or at least to be able to fix them
While we/I still offer help
I still need the NPE, to be able to help you, as the code looks ok
👌 💯
Being told to learn something before using it and then storming off
They left the Discord?
yeah
brainstone is right though, it's really important that you learn the basics before diving into more complicated stuff
otherwise you'll never make any progress
lol damn
You gotta learn walking before you try to run. Else you're just gonna keep faceplanting the whole race track. But I'm guessing they enjoy smashing their face on the ground ¯_(ツ)_/¯
just learn the entirety of java bro! the tutorial is so easy if you have a degree!
/s
?
Never said that
All I said was that they should at least know the basics of a language @Orbit49#3298
Joining and leaving again. What a coincidence 👍🏻💯
and you are a know-it-all always.
people are leaving because you must always be right. @crystal sonnet
Hey JohannesHQ! Please don't tag staff members.
If the truth offends you, you’re in the wrong place here (not directed at anyone)
slightly rude ¯_(ツ)_/¯
@nocturne elbow I mean I could start talking bullshit instead. Or ignoring people
Though I don’t think that’s particularly nice
in the way you say it is also an important thing.
Not quite sure what you’re trying to say to be honest 🤔
I mean I’ve been programming for 10 years and earn my living with it. So pardon me for pointing out the issue being the person.
And I do realize it’s at least slightly rude to point out things like that. Doesn’t make them any less true. I try my best to not be a dick about it
I've been programming for over thirty years, and I agree with BrainStone's sentiment
I'm soo happy that you are doing this for 10 years. And like i said you need the last words again.
I’m at a complete loss too
And i end it right now.
hey who likes APIs??
I like well-written ones
I think everyone starts somewhere so no sense of putting anyone down about how bad they are when they first start. To some people saying"learn he basics" is definitely negative or a letdown.
If one does not learn the fundamentals of somthing they will always struggle. Sure you can make somthing happen in java, but do you understand why it happens. Sure you can turn a light on with a microprocessor but do you know what is happening internally to switch it. If you know basic code structure the change between langs really just becomes syntax. Same in electronics, the fundamentals have never changed just the application has. In a world of instant gratification people don't take the time to learn the basics anymore.
Is there a luckperms api wrapper for nodejs?
display player their groups and meta data
If you’re using a database, you can just read that
how i need to get the group of player with luckperms?
if (provider != null) {
LuckPermsApi api = provider.getProvider();
}
How am I suppose to use "api" outside the if statement?
cant you use it like a string define it at the top and once that code runs it will set the api to the provider? or am i being dumb
Once the If statement is true you can use whats inside of it
^^ not the best help lol
It's all about scope
If you want to access something outside of the if statement, you need to store it outside of the if statement
and then set api = luck;
This might help you a little more
https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage
I did try storeing it outside the if sattement
didnt work
so then I tried setting a global variable and then setting it equal to that and it didnt work lol
define "didn't work"
screenshot your code or something "luck." provides no context whatsoever to me
And you have properly imported the luckperms api into your project?
Yes, and I can confirm because inside the if statement it works fine
if it works fine inside of the if statement, then chances are you're writing the code improperly elsewhere; e.g. trying to write code outside of scope of that or in the class body itself
and this is why i never want to learn code
I didnt write the registerdServiceProvider part that ios from the api'
sI cant change that part
that part isn't wrong
Then I am sorry to say I do not get it
I have tried declaring the api variable outside of the if statement but it still does not work
The api variable has nothing to do with it
You could literally remove that api variable creation and replace it with luck = provider...
Thats basically what I did
Outside of that, we need to see where it's not working; as either you're doing something wrong, or your IDE has derp'd
My guess here is that you're not writing code inside of a method declaration and are trying to type into the class itself
And that’s why you learn Java first people
^
How do you query the primaryGroup() of a User in bungee?
The same as in any other software. The API is platform independent
@halcyon jewel
Hello, a question
First, I havent updated LP in a while, I am on 4.0.84 , I had a plugin using LP API, suddenly I started getting this error
https://pastebin.com/XqRxgQuA
This is the Main Class, what it does, it adds you to the A rank if you are not in any rank in the ladder prison
is getString returning null?
@late geode you don’t need a plugin for that
You can do the exact same thing with default assignments
Details can be found on the wiki page “Default Group”
maybe a stupid question but what is the permission node to not display /luckperms in the /help window
There is none
Depending on the software you're using and what's providing the help command, you can generally add plugins to the blacklist in there
ah alright thanks
another question, i just set up a rank and want a higher rank to inherit the permissions but i also want to add permissions to the higher rank that the lower rank has not access to. However when i set a permission for the higher rank i can not use the permission because it says i do not have permission to this command, thinking that it still inherits the lower rank permission aswell?
Make the higher rank inherit the lower (aka the lower becomes a parent of the higher) and add more perms to the higher
ah i see, now i am trying to do that but i stumbled upon a problem now. I have the admin rank and all of a sudden i cant use any commands anymore other than the luckyperms commands. What can be causing this?
nevermind i got it, i added myself to default by accident
@frigid radish as long as it either directly supports LP or supports Vault
Though admittedly, if it doesn't support vault (assuming Platform is Bukkit/Spigot) it's a bad chat plugin
We use your recommanded chat plugins
We use vault aswell
What do we change in order to get the prefix colored and working infront of yourname ?
We have vault and all the recommended plugins
You can use color codes the the prefixes
how ?
&1
and how to use the prefixes since I haven't managed to get one infrond of my name
For example
Also this question is better suited for #support-1. #luckperms-api is for plugin devs wishing to integrate with the LP API
Let continue there then
@jaunty pecan Hi Sir! How can I do Migretion for groupmanager is right?
Because I thing I have to do wrong command
my command is /lp migration groupmanager <worldname>
and command reply back to me is
"migration groupmanager" : starting
"migration groupmanager" : error -> was expecting true/false, but got Lobby instead.
The last parameter is whether you want the permissions to be global or not @balmy fog
And questions like that belong in #support-1
Can I check for backend-side perms in a bungeecord plugin as long as they link to the same db?
Hey
I'm trying to get a player's rank bungee side
But even if I get the api in a command, well after the server has initialised, it still says Api isn't loaded
Yeah @jaunty pecan
Hey VoidCrafted! Please don't tag staff members.
can you send me your proxies startup log?
Sure, it's kinda spammy
the only reason for that error being thrown is because the API just isn't registered
it's unlikely to be a bug in that code specifically
That is the log
Here's the code
It's kotlin, but that shouldn't make a difference
Ignore the line after val api, that's there for debugging
are you shading the API classes into your jar my mistake
or something like that
that's all I can think of really
Hmmmm I'm pretty sure I am
I'm not too great at gradle
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.2.50'
}
group 'me.voidcrafted.bungeeplugins'
version '1.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
maven {
url "http://jcenter.bintray.com/"
}
maven {
url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
}
}
apply plugin: "java"
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
compile 'khttp:khttp:0.1.0'
compile files("libs/PremiumVanishAPI.jar")
compile "org.java-websocket:Java-WebSocket:1.3.8"
compile "me.lucko.luckperms:luckperms-api:4.2"
compileOnly 'org.bukkit:bukkit:1.12.2-R0.1-SNAPSHOT'
compileOnly 'net.md-5:bungeecord-api:1.12-SNAPSHOT'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
lol flood
you should be using compileOnly for dependencies which are provided at runtime
such as LuckPerms and PremiumVanishAPI
Ok that's my issue? I'm building now
The strange thing is, Java-Websocket worked fine during runtime
Oooooh I understand now
Yeah
makes sense
@jaunty pecan It works now, thank you for your time! Love the plugin btw
Hey VoidCrafted! Please don't tag staff members.
no worries, glad you like it 😃
hey um so how can i use the api to check if a uuid has a permission? im struggling with this
hasPermission needs a node arguement and im struggling
@acoustic sapphire it’s recommended to use the platforms API for permission checks
Unless it’s for offline players
it is for offline players
im checking on asyncpreplayerloginevent to see if they have permission to join a full server
should i just listen on the bungeecord-side instead and cancel on the bungeecord side on serverconnectevent?
Use a login event where permissions are already loaded!
And do a regular permission check
How’s that more effort???
cause i have to change some other code for the thing
because i have asyncpreplayerlogin download custom user data from a mysql database, i have the preplayerlogin check if the user is banned and such
its fine
ty
Pick the right event (might have to ask luck) and run a simple hasPermission
playerloginevent is the one that has the player object, asyncpreplayerlogin just gives a uuid and a username
In general, let the platform handle permission checks. Only revert to the API if necessary
alright
And I mean LP loads their permissions very early. Maybe even during the same event
yeah thats what im assuming
Meaning you could cause it to load while it’s already loading. That’s bad
because it saves everything with uuids and the earliest possible event with uuids is asyncpreplayerlogin
alright yeah didnt think about that, thanks
I'll try playerloginevent but i honestly might just have bungeecord listen on serverconnectevent to check since luckperms is on bungee as well
In all honesty I think LP can handle something like that. It’s bad practice nonetheless
You can do the bungee thing too
alright thanks!
Though again, wait for LP to finish loading and use platform checks
yeah I'm going to use the bungeecord way, because im not going to have serverconnectevent listen if its any of the hub servers, because it's going to auto-balance servers, and they will never fill up, so LP info will load on bungeecord way ahead of time before a user even has time to switch servers
val api = LuckPerms.getApi()
var groups = arrayOf(
"mafia_don", "tech", "mcadmin", "capo", "evtorg"
)
var u = api.getUser(e.player.uniqueId)
if (u == null) return
u = u!!
fun removePerm(node: Node) {
u.clearMatching { it == node }
}
u.permissions.forEach { // Remove all group nodes that are admin groups
println(it)
println(it.permission)
if (it.isGroupNode && (groups.map { "group.$it" }.contains(it.permission))) removePerm(it)
}
u.setPermission(api.nodeFactory.newBuilder("group.${auth.rank}").build()) // set the right group
Hey there
Every time a user joins, I fetch their rank from discord
And I'm trying to make it remove them from all groups that are in that groups array
and add them to the one they should be in
But nothing is happening to my groups
(bungee works fine in terms of lp, I can update my perms with a command and it syncs to bukkit)
Wait nevermind I need to save them.....
Hello, I would like to know how I can check the permission of a player?
@hearty fern /lp user (username) permission info
I need it with the API
Thanks
Player player = (Player) sender;
try {
if (vaultHandler.getEcon().getBalance(player) > priceHandler.getRankPrices().get(nextRank)) {
System.out.print("NEXT RANK: " + nextRank);
user.setPrimaryGroup(nextRank.toLowerCase());
luckPermsApi.getUserManager().saveUser(user);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6&lSuccess! You've now been ranked up to " + nextRank));
Though this seems correct, nothing is printed to console nor appears to happen. Despite all of this, the "You've now been ranked up..." message gets sent, so the code is being executed. I've also been sure that there is a valid rank called "d" that it can access. On top of this, I've tested to see if anything's null, but my testing's shown that nothing is
It's essentially executing user.setPrimaryGroup("d"); with a valid rank it can access
I'd like to note that absolutely nothing appears in console besides my "NEXT RANK: " print
so just to clarify
when a user fires the command and has money these things happen:
-Console shows NEXT RANK: withouth thr rank name
-The player also gets a message Success! You've now been ranked up to also withouth thr rank name
- and the player doesn't gets the rank
No. For example, it sends "Success! You've been ranked up to D", but they don't get the rank
if an npe is your concern, nextRank isn't null
sponge or bukkit server?
PaperSpigot 1.8.8
Using 1.8.8 Spigot API
And i think latest version of LuckPerms in-game and API
I'd say instead of setting the primary group try building a group node and then set that node for the user
Node groupNode = luckPermsApi.getNodeFactory().makeGroupNode(nextRank.toLowerCase()).build();
user.setPermission(groupNode)
I need to do it by setting the primary group though
Well, that's how I've written my code
I just want to know why what I'm doing isn't working nor can I find proper documentation on it
sry I have no other idea, Luck will have to answer that
you need to actually add them to the group iirc, setPrimaryGroup doesn't work for groups they don't have iirc
oh
I'll give that a try then
Ok real question now
How tf do I remove someone from a group through the API?
No advertising other servers please @nocturne elbow
Hey SrFairyox! Please don't tag staff members.
@young hazel Same for all platforms
and how do I get the rank that the player has?
I'd suggest referring to the wiki, it pretty much has examples for everything you could ever want
How do I get all players in a group?
You can add the group as a parent of default @astral vortex
ah you mean online players?
Yea
oh wait this is api
xdd
so you'd get all online players (Bukkit.getOnlinePlayers iirc), get each of them from api.getUser, add the group node to each, save the user back to the backend storage
Or there might be a bulk update actually, I don't remember
but something like that
you know how to do each of those steps?
Why do i add player to node? 🤔
In LuckPerms groups are stored as permissions
so you give each player the group.moderator permission, for example
which is the same as adding them to the group
xd
sorry for being unhelpful 😂
np
You can use a for loop and go through Bukkit.getOnlinePlayers(), checking if player.hasPermission("group.moderator"), if so add them to another array of moderators
Well that's too much hassle
There would be an method for group.getMembers()
Why there's isn't one?
I'm not sure, you'd have to ask luck
Also I have to get them in a sorted way, so in list it's placed by their weight
Placed by what weight?
oh okay
This is why I love kotlin btw, makes stuff like that easier
I'm actually not sure how you get all groups
Well I'll wait for Luck, if he will come 🤔
I have a feeling he's here, he just came online and I'm pretty sure he has notifications on
aaaand he gone
There isnt a getMembers methof
Method
There is a method on the UserManager which lets you get all users with a certain permission
Which you can use with group.moderator
If you would add that method, cuz I can't hardcode what i'm doing
I need help
I made a plugin that allows you to select any groups you have to be the displayed prefix
it works but randomly it wont work...
Might wanna show your code or something? "it works but randomly it wont work" isn't really much to go off of.
Yea hold on I wanted to get a response first
Well I'm not going to be much help but someone else might, so post it :P
trying to debug everything rn
@sharp topaz show the code, plop it in a hastebin
I removed it all
I found a better alternative
I use console to switch primary groups
Sure
Is there a method in LuckPerms for getting a player's groups (in order)? Or would I have to loop through the all groups checking if they have it
You can loop through the players permission nodes looking for group.something nodes @gusty goblet
Then fetch each group to get its priority
And sort it
👍
how can i set player's primary group with temp?
/lp user <user> parent addtemp <group> adds group to parent group
I want to primary group
@gilded summit the primary group should be calculated automatically
It’s the group with the highest weight
Hello, I've got a question: How can I get the PrimaryGroup of a player who is offline?
got it: LuckPerms.getApi().getUserManager().loadUser
😎
help ????
hey
I use Luckperm in my server.
Why can not I benefit from the player's region when I throw wg with Worldguard?
help
When I use the command "/ rg def test" in a specific area, can not the players do anything?
?
help
???
HELPME MERJİLİN
Rank name, as in the prefix/suffix?
no, just the rank name
hi
guys a consultation, but first of all. they speak Spanish? Or does it only provide support in English?
English and German as far as I know
Is there a way to get the time remaining on a temp meta node?
I'm using them to track mutes
Yes, subtract the current time from the expiry time of the node
Ah cool thanks
Hey folks, having an issue trying to figure out what the API equivalent of /lp user Player parent set groupname is in the API
it's not setPrimaryGroup() I see
Yeah I'm using Node n = api.getNodeFactory().makeGroupNode(rank).build(); user.setPermission(n); userManager.saveUser(user); and I think it's not working
that's basically what I do here
I do call a "refreshCachedData" method after that, not sure if that's needed or not
Does anyone have an API to do the / timevip command?
It is to obtain the rank that the player has (Bungeecord)
public static String getPlayerGroup(ProxiedPlayer player) {
User user = MClass.lp.getUser(player.getUniqueId());
return user.getPrimaryGroup();
}
This should work
https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#getownnodes
Set<String> groups = user.getAllNodes().stream()
.filter(Node::isGroupNode)
.map(Node::getGroupName)
.collect(Collectors.toSet());
How would I use the given examples in kotlin?
I can't read any java, so it's kinda difficult for me to work with pretty much anything
The calls that they're doing are pretty trivial to work with, you'd basically need to find the kotlin equiv to work in some manner
Optional<ProviderRegistration<LuckPermsApi>> provider = Sponge.getServiceManager().getRegistration(LuckPermsApi.class); Best I can do here is Sponge.getServiceManager().getRegistration(LuckPermsApi::class.java)
not to mention not even knowing where I'm supposed to import LuckPermsAPI from because gradle sure isn't showing it
Hey
All my stuff is written in kotlin
I've got a working demo for bungeecord here if you like, gradle file should work with sponge with slight modification
@thorny echo The way I though of doing it was by using my Discordbot which runs as a separate java process. But I guess I could do it kind of the same way you did, but by sending the the login events + luckperms groups retrieve via the bungee/spigot API to the discordbot I assume, which would than handle the updates
and yes, I use Kotlin too. Come from Android, Kotlin > Java :p
Haha, thanks for the example though! Appreciated!
It's cool!
@thorny echo how much would you charge to port this project to Sponge? Since mine is completely messed up and all
@jade oracle I mean it depends, I've never used sponge before. DM me ☺
Hey anyone know how to set this up? ```java
public static String getPlayerGroup(Player player, Collection<String> possibleGroups) {
for (String group : possibleGroups) {
if (player.hasPermission("group." + group)) {
return group;
}
}
return null;
}
So put a collection of strings that you want to check if they have the permission for @candid gorge
Like this
Collection<String> possibleGroups = new ArrayList<>(); possibleGroups.add("owner");
why me? 😄
why are you writing me @thorny echo ?
@candid gorge sorry, I type @ and hit the top option which is normally the last person to message the channel but it wasn't this time, for some reason
@iron pawn I think so, that'd be correct if you wanted to check if they had owner
But i don't know java, only kotlin
Ok ive got it now
ah, okay 😄 thakns
Ive used the api
How do I create a gui menu showing the time it takes to finish the group the player is in?
Oooh, that's an interesting question (:
Use something like deluxemenu with placeholdersapi
So I'm used to PEX, and i'm working on it to migrate toLuckPerms. I've had a change prefix plugin for permissionsex hooked into it's api. Is it possible with the LuckPerms API? And can I get a push in the right direction? 👼
@autumn spear have a look at me.voidcrafted.bungeeplugins.CustomPrefixCommands on this repo:
It’s kotlin but it shows the base api calls etc
I actually set a meta node not a prefix node but you can change that easily enough
Thnx! I'm familiar with kotlin, so that won't be an issue
Luck, I tried to search for this in the old conversations(7 months ago), but what method would you use for making a Permission assigned by another plugin, output to false in Luckperms? Please and thank you. This is in regard to that negative permission inquiry I had a long time ago, where JobsReborn wouldn't do this naturally, and it would output to true when giving the player the permission. You had mentioned a method where you would need/to use to make the plugin output a permission flagged as false.
I appreciate the response and have a wonderful day!
I don't know what you mean
JobsReborn. Gives Permissions.
It acts like PEX in the sense you have to use a negative permission to deny the permission from JobsReborn.
-permissionhere.here.perm
It still outputs it to LuckPerms.
However, it puts it in Luckperms as a "True" permission, with the -negative, ignoring it altogether. (I know this, as LuckPerms doesn't recognize it because LP doesn't use the deprecated feature of PEX.)
So I am trying to figure out how to make his permissions output it to Luckperms as a "False" permission, thus denying the permission to the player.
You gave me a formula to use in the past, to output a false perm to LPs, but I could not find it in the chat logs.
/lp user <you> permission set permissionhere.here.perm false
When I use
Set<String> groups = userManager.getUser(uuid).getAllNodes().stream()
.filter(Node::isGroupNode)
.map(Node::getGroupName)
.collect(Collectors.toSet());
there's an error on Set<String> groups = userManager.getUser(uuid).getAllNodes().stream()
even tho the user has groups
Sadly that is a command, Luck. The permissions do not have the option to execute a command. I'm trying to make it where his permissions handler, makes LP recognize the permission as false. Because any permission granted by the plugin itself is output to true. He does not have a :true or :false feature.
(ie a hook of JB, more less.) Since he neglects to address the issue first, or make his permission handler execute first.(Which would fix the issue.)
Pretty much need the means for JB to communicate with LP, to output a false permission, instead of making even negative permissions output to true.
Oh right
Well it depends on what API that plugin is using to set the permission
But both Vault and Bukkit itself allow you to specify the "value" of the permission as a Boolean when you set it
There's not really anything I can to do help, you just need to speak to the plugin author
@civic pollen maybe User is null? What error are you getting exactly
Player player = (Player) sender;
String uuid = player.getUniqueId().toString();
The player has no reason to be null
Yes it does
The method you're using is doing a lookup by username
But you are passing it a UUID
Remove the toString call, and pass the actual UUID object
That seems odd, but I'll try
oh well xd that worked
And I get what you mean now, sorry for being a moron xd - thanks
Hey, the weight of admin should be 1 or something like 999?
thx ❤
Np
/lp group admin permission set minecraft.command.op true
I have the admin permission but when I try to op someone
(!) Sorry, command could not be executed
anyone know what the problem is
@thorn ember first of all #support-1 and second by default LP disables the OP system for security reasons
ohh makes sense.
sorry for the dumb questions
never had a server before or programmed and now trying to learn permissions on day 2 is a bit confusing, but your program is awesome and very intuitive.
Glad to hear. And be prepared that a proper permissions setup can take days
@here hello! help me please!
I need Permissions for SecurityCraft mod?
I need add permissions for this mod in LuckPerms
@tribal kelp you can use the LP verbose feature to figure them out. See our wiki for details
your mod help pages should list its permissions in whatever help/doc they provide. use those permissions verbatim, such as if the plugin's perms look like
SecurityCraft.doThis SecurityCratt.doThat SecurityCraft.doSomethingElse
then you can do
`/lp group default permission set SecurityCraft.doThis
/lp group member permission set SecurityCraft.doThat
/lp group moderator permission set SecurityCraft.doSomethingElse
/lp group owner permission set SecurityCraft.*`
and if you have your groups set up to inherit from the prior parent correctly, this means that "members" will have perm for 'doThis' and 'doThat', and that "moderator" will have all three permissions, while "owner" has errythang possible including permissions not explicitly mentioned in the prior 3 groups
Hi lads, where can I find the permissions for the commands?
@deep forge on the wiki. Also #support-1 is the better place to ask. #luckperms-api is for plugin devs wishing to integrate into LP
my apologies, and thank you
yeah i missed that too, in my last response
When i've setup LuckPerms like this
private void setupLuckPerms() {
RegisteredServiceProvider<LuckPermsApi> provider = Bukkit.getServicesManager().getRegistration(LuckPermsApi.class);
if (provider != null) {
LuckPermsApi api = provider.getProvider();
}
}
Can i just call LuckPermsAPI in each class like this LuckPerms.getApi() or my var in my code as to be in static and called ?
And event UserJoinGroupEvent do not exist ? 🤔
Hi, it's the first time I use LuckPerms and the plugins and the api are really good but after I had a look in the wiki I would know what is the best Event to call when we set the parent to an User ? For the moment I use UserDataRecalculateEvent
@dense harbor do u know whats the event when a user has his roles updated ?
For me UserDataRecalculateEvent is called 3 times when I change the parent of the user so I think this event can works for you
I would've thought that event was fired when luckperms needs to recalculate their primary group.
Another way to go is to use the NodeAddEvent and filter out group.*
I'd say NodeMutate event could also work, depending on what you want to do, it might be more useful
The recalculate event should fire multiple times if you set a parent, if I'm interpreting the code right setting a parent causes at least 2 recalculations in the background (removing then adding)
Hey? Is it possible to use the .inheritsGroup for groups that are parented?
So lets say the ladder is like this:
Gold Silver Bronze
So Bronze is a parent of Silver, Silver is a parent of Gold etc
If the user has Gold, It'll also do the functions of Silver, And Bronze
This is what I have:
It only seems to use the group if it's a direct parent of the user
Instead of an indirect parent
Any solutions?
Just use a permission check instead
Ah, That should work
We need a wiki bot 🤔
Most everything in luckperms is actually stored as a permission
In fact I don’t know about a single group or player setting that isn’t a permission
Why my event dont print message when i change group https://i.gyazo.com/a4375bf7c879be59643f136fe5a24137.png
... ?
Hi guys ! I have in server.properties exposed gamemode 2 . After installing luckPerms , players began to be issued gamemode 1 . Who knows what the reason is ? And yet , how to solve to open chests, etc.?
Server core :SpongeForge
Is there a way to sort a group Node by weight?
I want to get a player's group ordered in terms of weight
Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
someone ideas?
hm?
Also #support-1 for questions about the plugin
This channel is for devs having issues or questions about the API (code stuffs)
Nodes don't have weight @tropic cipher
(at least there is no method in the Node interface)
@tropic cipher you can iterate over all effective permissions the user has and filter for group.<group> (like check if the node starts with group.) nodes and then determine the weight of the group and sort by that
Should all be possible with streams fairly easy
@crystal sonnet thank you very much this works great 😃
Hey Thund3rst0rm89! Please don't tag staff members.
that time when you type out a very long question with a detailed explaination only to get to the end of typing it to find the issue you were asking about.....
Rubber duck debugging:D
Well seems I spoke too soon. @jaunty pecan @rapid egret Zidane and I are attempting to get GP and LP loaded into our intellij developer environments for Almura. We have a coremod dependency on SpongeForge which is loading properly. We have nucleus and economy lite working too. When I logged into the single player world LP/GP generated this error: https://gist.github.com/Dockter/8560b27cc49802a0fb592093c18e6905 We have dependencies on LP and GP API's in our gradle configs AND we have LP and GP jars in our /run/mod directories. LP's API = 4.2, jar = 4.2.40, GP's is both 1.12.2-4.3.0.646. Our SpongeForge version is 3353
Hey Dockter! Please don't tag staff members.
that's a GP error
That was our initial thought but wasn't sure since lp was generating the stack trace
ya, that's because it's calling griefpreventions context calculator
instead of propagating the exception back to the permission check call, LP just prints the exception and continues
Oh I'll bet I know whats going on, this is likely bloods silly SF build check
nope, not that, wtf.
latest version of GP?
LuckPerms-Sponge-4.2.40
can guarantee that's the first thing he'll ask you :p
I wonder if this will only run in a dedicated server environment
Shouldn’t affect things, that’s what the jvm was designed to counteract
I mean no one in their right mind would run GP on a single player world and it wouldn't be the first time we have seen issues with SF in a SSP enviro
Void, "dedicated server" means running as a standalone minecraft server in this instance
not the "server" code that runs as part of the client
Oh sorry, wasn’t reading the convo
I thought he meant dedicated box vs shared hosting etc
nah this is all in an local intelliJ enviro
Nothing in the log makes me believe that GP isn't registered properly except that non of the commands work.
lp seems to be working as expected.
Interesting, this.permissionService = Sponge.getServiceManager().provide(PermissionService.class).orElse(null);
thats returning null
class load order not respected in-dev I wonder?
It saying LP 4.2 was designed for API 8
it's compiled against API 8, but works with API 5-8
we use a similar lookup for PermissionService.class, trying to figure out why GP would be having an issue with the same call.
well Im getting further. He does a client check too.
Ok, got it, had to remove his client checks and the hard-coded SF checks
How to check if a name exists in user data base?
plugin.luckPermsApi.getUser(name) in try and catch NullPointException?
Someone?
thanks, one question
is there a way to know what group the player was before he was promoted or sth
I'm using:
user.setPrimaryGroup("admin");
plugin.luckPermsApi.getUserManager().saveUser(user);
but it stills have mod rank, not assign to admin, why?
You need to actually give them the group, setPrimaryGroup just points towards an existing group they've got assigned that should be considered their main group
thank you
How to add a player to a group? cant find the method in the api
The wiki is a glorious thing
I read it, i suppose there is no setGroup or addGroup
No
Groups are assigned through permission nodes. Nodes in the format group.<group>
Adding that permission will set a group for that user? What about the other permission they have, like group.premoderator, if i add group.moderator they will still be in premoderator group, i have to remove it manually?
@trail oar Yes a user can have multiple groups so you have to remove the old group
Gimme a sec
@trail oar See an example here
I believe there's a problem with updating ranks w/ the API and storing the ranks through a database. Meaning, when using LuckPerms to store the ranks in a database and then using the API to promote a player. If the server is to restart for example the player is reverted back to the original rank that they had before using the external plugin to promote them to the next rank. This however doesn't happen when using LP to store ranks on a local file. Here's the code being used to promote a player to a rank, let me know if I'm doing something wrong here.
public void inheritNewGroup(Group group){ Node node = LuckPerms.getApi().getNodeFactory().makeGroupNode(group).build(); LuckPerms.getApi().getUser(player.getUniqueId()).setPermission(node); update(); }
you need to save the user afterwards
Onto the database, like what do you mean by saving the player?
Unless there's something I don't understand, if I'm suppose to have my plugin store the player's rank/data etc. the same way your plugin does onto the database then I'd need to understand how your plugin likes to save the data so that it can read it, however this doesn't make sense to me since why couldn't your plugin just do it? I would assume the method used to promote the player to another rank would use the same method your plugin would handle promotional/parent set commands to promote the player and save the changes. I'm using the API to promote players, the plugin registers the changes when I debug however it apparently doesn't save it which is what confuses me.
just a second, I'll link you to the method you need
you need to call this method after you make your changes
explained here
Ah alright thanks. I'll take a look in the morning.
Is there a evet that gets called when a player changes from group?
How to check if a player is in a group temporarely of if its permanent?
check if the node is temporary
and to detect if a player group changed? i check NodeAddEvent and check if the permission starts with group. ?
You can call node.isGroupNode
and then if that's true, call node.getGroupName
i assume you're looking to listen for when a temporary group expires?
i want to check if someone is added to a group and check if it's temporal or permanent
I want to add Discord support for my bungeecord plugin
and for that i need to know when a player is added to a group, and when a player is removed from it because of it expires
okay
here's some code you can look at / use
i'm not quite sure how you want to handle things, but I'm sure you'll be able to work out the rest 😃
ehmm i got lost xD I understand what you sent a bit, but not how to properly use
can i use NodeRemoveEvent
and then if(e.getNode().isGroupNode()){
and then if(e.getNode().isPermanent()){
?
Yes
Fine! 😄
the name of the class
if NodeRemoveEvent is called for users and groups, how do i check
instanceof
getTarget?
Sorry Luck, how to register luckperms events? Tries as normal but i think its not being called
Currently using in constructor
EventBus eventBus = luckPermsApi.getEventBus();
eventBus.subscribe(NodeAddEvent.class, this::onNodeAdded);
eventBus.subscribe(NodeRemoveEvent.class, this::onNodeRemoved);
and for the class
private void onNodeAdded(NodeAddEvent e){
plugin.console.sendMessage("NodeAddEvent fired!");
}
private void onNodeRemoved(NodeRemoveEvent e) {
plugin.console.sendMessage("NodeRemoveEvent fired!");
}
console is my ConsoleSender (Bungeecord) Tag me when you read it
Update: It register only when group is removed, why? Or i can register only one event per class? Edit: I can register more than one.
Update2: NodeAddEvent is not called when using /lp user {USER} parent set {GROUP} or addtemp {GROUP}. Only when setting group permission using the api. Why?
Update3: Currently using "LuckPerms-Bungee-4.1.16" in Bungeecord. Dunno if newer versions supports bungee?
Luck
Greetings,
recently I've decided to migrate our liveserver to LuckPerms from PermissionsEx.
However I've run into a problem with temporary permissions.
When the command is run ingame to manually add the permission it works as expected:
/lp user ostylk permission settemp my.sick.permission true 2d
However when I try to do the same in a plugin by using the LuckPerms API things get weird.
The permission gets added, however it is not shown under /lp user ostylk permission info and magically disappears when I reconnect.
This is the code I use to set the permission.
Optional<User> user = RoninHome.LUCK_PERMS.getUserSafe(target.getUniqueId());
Node permission = RoninHome.LUCK_PERMS.buildNode("my.sick.permission")
.setExpiry(2, TimeUnit.DAYS)
.setValue(true)
.build();
user.ifPresent(u -> {
u.setPermission(permission);
sender.sendMessage("\u00a7aThe player was granted a temporary permission");
});
Did I forget to set some flag?
Any help is appreciated.
Not sure, but maybe plugin.luckPermsApi.getUserManager().saveUser(user) is needed
Yeah, you're right. Well, that was simple.
Thank you very much!
np, glad to help.
Luck i have a problem here, i try to set primary group with command, an it doesnt work at all. Do i need sth else?
EDIT: nvm, just set weight for each rank
Luck, /lp user {USER} parent set/add/remove {GROUP} doesnt call NodeAddEvent in latest version? I need that to check when player are assigned to a group
Difference between NodeMutateEvent and NodeRemoveEvent?? Y tried with NodeMutateEvent to check data before and after but there is no difference in nodes, so result is empty list of Nodes.
@hard veldt srry to tag you but .setExpiry(2, TimeUnit.DAYS) working for you? i can only use long
No I changed that code up. I had a variable of type int there. There was probably an implicit conversion.
Well, I now I tried to put .setExpiry(2, TimeUnit.DAYS). No error.
No idea whats up with your ide
nvm, i fix it xD
what happened? 😄
was using lastest version on server, but not in the project xD
oufff ^^
If i use:
if(user.unsetPermission(plugin.luckPermsApi.buildNode("group."+group1).setServer(servertoremove).setValue(true).build().wasSuccess()){
user.unsetPermission(plugin.luckPermsApi.buildNode("group."+group2).setServer(servertoremove).setValue(true).build();
plugin.luckPermsApi.getUserManager().saveUser(user);
}
it means that the group 1 was removed?? or only group 2?
Your code shows that you are calling the same methods in both cases (the one in the logical statement is calling just a tad more). Just because it is in a logical statement (if) doesn't mean the methods aren't run. You're not writing out the location of where to call the method that is last written on the line. You are calling each individual method that each return a class value. Therefore the method that set's the value to true does it and then returns a class that contains the method build which you call that returns wasSuccess() which returns a Boolean to determine if everything was successful. So yes you're removing group 1 and group 2 if the method wasSuccess is returning true. Perhaps I totally misunderstood the question?
I solved that already, the main issue is that /lp user {USER} parent add {GROUP} doesnt fire NodeAddEvent
Yeah I can't help you there 😛 I myself have also recently just started out with the API.
xDDDD thanks >w<
So you have listened for the event and debugged to see when it fires if at all?
yes, its fired when i use the api in my plugin, not with the command in game.
mmm yeah sounds like either there's a more specific one then for the commands or Luck forgot to fire the event when one of those commands are run.
to be specific, system works. But my listeners are in bungeecord plugins, and the command is performed in a bukkit plugin
i suppose if i add a permission and all data is connected by mysql
and bungee messaging system, should also be fired in bungeecord
or sth like that
Worst case scenario, register a listener for the AsyncPlayerCommandEvent event or whatever it is called and read the command/parameters to see if a player is running the command you're listening for.
I had that idea. I just made a command for bungeecord called /rank which works the same way /lp does add/addtemp/remove
anyways, i hope this gets implemented in futures updates maybe with an option:
Listen-bungeecord-events: true
or similar
So wait your bungeecord doesn't pick up on any of the LuckPerm's events?
it does, only if the events are fired using the api from a plugin in bungeecord
but if i use a command to add a node to an user or group in bukkit using bungee messaging channel
event is not fired in bungeecord, even if it IS a NodeAddEvent
it has logic, but i think it should fire those events
Can i get the name of the player with lower and upper case?
Capitalization only works for online players iirc
What you could do as well is access the player name cache of the server. I’m fairly certain you can access it in both Spigot and Sponge
Anyone know why this doesn't work
public Node[] getWEPermissionsAsNodes(LuckPermsApi luckPerms, String server, long expirationTime) {
Node[] nodes = new Node[timedWEPermissions.length];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = luckPerms.buildNode(timedWEPermissions[i])
.setServer(server)
.setExpiry(expirationTime)
.setValue(true)
.build();
}
return nodes;
}
but this one does work
public Node[] getWEPermissionsAsNodes(LuckPermsApi luckPerms, String server) {
Node[] nodes = new Node[timedWEPermissions.length];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = luckPerms.buildNode(timedWEPermissions[i])
.setServer(server)
.setValue(true)
.build();
}
return nodes;
}
Only difference is the setExpiry
define: doesn't work
hey, i cant quite figure out how to get a user's prefix and suffix using the api. i have looked through all methods that look right but still cant figure out. can anyone help
@merry widget do you use bukkit or spigot?
spigot
Okay, try using the vault api
oh god havent used that in ages
Ok so...
If I wanted to get a List<String> of every group that a player has, how would I go about doing that?
I tried doing the vault hook "getPlayerGroups()" but it always returns empty
I'm using spigot and OfflinePlayer btw
@halcyon pebble you can get a list of all active permissions of the player and filter that for all nodes starting with group.
How might I ascertain all the groups a player is in?
Directly.
Ah. Thank you old boy.
Sorry should have been more specific, when I try apply a temporary permission node it doesn't apply (doesn't show up in /lp user <name> permission info) but when I assign a permanent permission it works just fine
what's the value of expirationTime
So ranks are perms....
Literally every other perms plugin has a working Vault hook....
I guess I'll use a filter then
Vault Hook? Do you mean that you can use Vault to read ranks? If so then: https://github.com/lucko/LuckPerms/issues/101
According to this, there is a vault integration
https://www.spigotmc.org/resources/luckperms-an-advanced-permissions-plugin.28140/ also in the chart you can see it
@halcyon pebble the luckperms vault implementation doesn't support offline players
that's why it's not working
Ah, any chance you could update it in the future? I'm creating a prison top plugin and it would have been easier to just use vault api 1.6 instead of separate apis for each plugin
the reasoning is explained here
i'm open to suggestions about better approaches to the issue
thnx for the info, I'll forward this to the person that requested it
if I want to use offline players I can just use your API instead of vault, correct?
indeed, but you still have to take the considerations about being main thread friendly into account
the difference with the LP API is that it forces you to make that decision
by returning futures
kk, so, for example, if I want to calculate prison top values for every offline player?
would I be allowed to do that async?
That's the ideal outcome, yes
kk, thnx for being so helpful 😃
I'm still learning a bunch of stuff about java and plugins
I just want to be 100% sure
would this be correct?
permissions.stream().filter(node -> node.getPermission().startsWith("group.")).forEach(node -> list.add(node.getPermission().substring(6)));
or would that be better?
you can use node.isGroupNode and node.getGroupName
also, if they're offline, you need to use api.getUserManager().loadUser(...)
relevant wiki pages are:
thnx
so what exactly do i compile?
Run those 3 commands in order 😃
You just compile them all, and there will be multiple jars
So once you've done that, the target/ folder should have the jars in
Yw!
Java 8 - Java Development Kit
no idea what that is since I use windows and just use the installer, but probably