#luckperms-api
1 messages · Page 28 of 1
this is now the main thing under need there will be createt a scoreboard
well sorry for bad spelling
It's all good. Move this into either your createBoard method or a separate method
Do you have an instance of the LuckPermsAPI loaded yet? https://github.com/lucko/LuckPerms/wiki/Developer-API#obtaining-an-instance-of-the-api
It's fine 😛 In the code I gave, this.luckperms is your API instance
It should be in your onEnable method
I just wrote this little thing if it helps https://gist.github.com/RJHaytree/302eca7ea1cb400f46b450f85196efa5
man you are the best if this works
That is only the luckperms stuff, none of your scoreboard stuff
I see
only I get one error
CachedMetaData metaData = this.luckperms.getPlayerAdapter(Player.class).getMetaData(player);
String prefix = metaData.getPrefix();
on the underlind thing I get a error
Are you using gradle or maven?
yeah, does your plugin have a build.gradle or a pom.xml file?
Can you screenshot your file explorer in eclipse? Should be on the right and show all of your plugin files
That error means you're using an outdated version of the API, so we need to change it wherever you're downloading the dependency
Oh okay, did you manually download the API jar?
Ah, is there anyway you can update to the latest? API 5.1 is better in terms of functionality
well than I will donwoald that one
This is the API jar for the latest version https://repo1.maven.org/maven2/net/luckperms/api/5.1/api-5.1.jar
It is possible with API 5, it's just a lot more work
well downloaded the 5.1
and error is gone
now to set the prefix of a player just do + prefix
in the score
It does not work 😂
somone help 🙀
What's it not doing exactly?
Did you insert the API or are the actual LuckPerms-Bukkit jar?
both
Can you show me a screenshot of your LuckPerms jar in your plugins folder? Also remove the API jar, it does nothing on the server
Remove it and replace it with this one https://ci.lucko.me/job/LuckPerms/1115/artifact/bukkit/build/libs/LuckPerms-Bukkit-5.1.47.jar
well that I need to discuse with the server team but when I replace it will al config's stay?
lil groups and that
everything will stay
ok
No storage and configs are ever wiped by updates, we simply overhaul some internal to make it more performant
ok well I discustet it with the team and it is good only befor I can insert the new verion I need to wait a little they are busy making a MySQL for a plugin
it works man thanks 👍
3 days of self trying and losing a headset
Oooof, no problemo 🙂
I honestly haven't a clue on that one. I found this thing you can investigate but I could be outdated https://gist.github.com/amhokies/7309869
I found that one to but don’t know how to import that to a score and not as title
Is there a maven where you can grab the LP sponge/spigot/velocity artifacts or is that published on central?
here you can find all api info https://github.com/lucko/LuckPerms/wiki/Developer-API#obtaining-an-instance-of-the-api
@timid hearth Its on central. https://github.com/lucko/LuckPerms/wiki/Developer-API#adding-luckperms-to-your-project
@timid hearth why do you need those artifacts
How I do temporarily give someone a group through the API?
Add an InheritanceNode and add an expiry time
Here's an example @boreal eagle
@cold panther Thank you
Hey SuprexDE! Please don't tag helpful/staff members directly.
The idea was I could have the impl artifacts so I can test in dev
But only as runtime
I'd still depend on api for compile
sorry, they aren't published anywhere
you can get them into your maven local tho ofc with gradle install
how do i check what permissions there in
What?
Yeah, what exactly do you mean by 'what permissions there in'?
how do i check what permissions they have
im trying to check if they don't got any permissions i setup then they open a gui. It's bungee
Are you trying to do that with the LP API?
yes
And if you manage to open a GUI on the bungee, let me know how you do it
I haven't found a way except using a bridge
But in any case check their nodes
There should always be one: the default group inheritance node
So you need to account for that
!api
Learn how to use the LuckPerms API in your project.
What is it under?
public boolean hasPermission(User user, String permission) {
ContextManager contextManager = api.getContextManager();
ImmutableContextSet contextSet = contextManager.getContext(user).orElseGet(contextManager::getStaticContext);
CachedPermissionData permissionData = user.getCachedData().getPermissionData(QueryOptions.contextual(contextSet));
return permissionData.checkPermission(permission).asBoolean();
}``` Where do i put the permissions at
It is a method
Hey can some one help me out? i made my own plugin, a custom join plugin, But LP is doing something weird to the custom plugin, (If some one joins it takes a couple of seconds to load their prefix idk why, but that ruines my custom plugin idea, because i have it like
"welcome back "displayed name"
but if they join they get "welcome back jeffry"
and if they leave its "good bye Owner Jeffry" so? Idk why the leave works but the welcome not ? if they join, Can i do something about this or ?
Not an expert, but I suspect display name isn't being calculated before it fires the join event. Try sticking some delay before getting the display name, and see if that works
but i search and search but no one or nothin lead me to the my destany, so. does some one know a code to let the welcome message later ?
Do you use displayname from the Spigot APi?
i use just from LP, with placeholder and vault, (ess also)
This is my code of the welcome message, But idk how to let the message com 5 seconds later, or something, or let LP think faster ?
public class PlayerJoin implements Listener{
@EventHandler (priority = EventPriority.LOWEST)
void onPlayerJoin(PlayerJoinEvent e){
Player player = e.getPlayer();
e.setJoinMessage(ChatColor.GOLD + "" + ChatColor.BOLD + " Welcome to our Skyblock Comunity ! " + ChatColor.WHITE + " " + ChatColor.BOLD + player.getDisplayName());
}
}
Maybe try the LuckPerms API directly?
ohw do you mean ?
What makes you think this is happening because of LuckPerms? LuckPerms loads the player data before the PlayerJoinEvent is fired, meaning that whenever any plugin attempts to query a user's data, data is always ready
What you mean it's a method? ```java
public boolean hasPermission(User user, String permission) {
ContextManager contextManager = api.getContextManager();
ImmutableContextSet contextSet = contextManager.getContext(user).orElseGet(contextManager::getStaticContext);
CachedPermissionData permissionData = user.getCachedData().getPermissionData(QueryOptions.contextual(contextSet));
return permissionData.checkPermission(permission).asBoolean();
}```
What makes you think this is happening because of LuckPerms? LuckPerms loads the player data before the PlayerJoinEvent is fired, meaning that whenever any plugin attempts to query a user's data, data is always ready
@cold panther Ahh dev. forum wat i am waiting for 2 days, they told me that it might be this, but idk ?
Hey JeboyDylan! Please don't tag helpful/staff members directly.
What you mean it's a method?
https://docs.oracle.com/javase/tutorial/java/javaOO/methods.html
Trying to use the luckperms api using kotlin
Why use the LP API for permissions checks when player.hasPermission("permission.node"): exists?
but running into an issue
val provider: RegisteredServiceProvider<LuckPerms> = Bukkit.getServicesManager().getRegistration(LuckPerms.class));
katsumag
Anyone know how to fix this?
Well yeah, that's not going to work on bungee. Though I'm fairly sure their ProxiedPlayer has a similar method. If not then yeah use the API, it's just simpler not to on Bukkit servers at least
what you mean proxiedplayer?
well yeah but its a spigot plugin
🤦 so why mention Bungeecord then?
well ill send you the error if you want me to
Just use Player.hasPermission on bukkit/spigot/paper, and ProxiedPlayer or another one of Connection's child classes .hasPermission on Bungee. No, if you're making a spigot plugin, why do I want to see a Bungeecord error?
well i it's null and i heard that it was because of permissions so i assuemed that was because of luckperms being bungeecord
it's null in spigot
Uh how
¯_(ツ)_/¯
The only way a hasPermission check can throw an NPE is if your player object is null
Which is very hard to achieve
Show me your code
@EventHandler
public void join(PlayerJoinEvent event) {
Player player = event.getPlayer();
boolean Europe = !player.hasPermission("Continent.Europe");
boolean Asia = !player.hasPermission("Continent.Asia");
boolean Africa = !player.hasPermission("Continent.Africa");
boolean Australia = !player.hasPermission("Continent.Australia");
boolean NorthAmerica = !player.hasPermission("Continent.NorthAmerica");
boolean SouthAmerica = !player.hasPermission("Continent.SouthAmerica");
boolean Antarctica = !player.hasPermission("Continent.Antarctica");
if (Europe && Asia && Africa && Australia && NorthAmerica && SouthAmerica && Antarctica) {
player.openInventory(gui);
} else player.sendMessage("" + ChatColor.RED + ChatColor.BOLD + "You already picked a contienect");
}```
Why are you inversing every permission check?
Also read the error, which line of that throws the NPE
Hold on let me boot back up the server and delete the other code to check
Why im inversing ever permission check is because i want to check if they don't got any permission that i setup. Then they need to pick a Continent
Yeah but you could just inverse the check, not each individual permission.
you could also nitpick on the fact that he's capitalising java variable names rather than camel casing
or the second else not having brackets even though the if does
😛
@wicked kiln why is ur line so weird
} else player.sendMessage("" + ChatColor.RED + ChatColor.BOLD + "You already picked a contienect");
shouldnt be like that
at all
@EventHandler
public void join(PlayerJoinEvent event) {
Player player = event.getPlayer();
boolean Europe = !player.hasPermission("Continent.Europe");
boolean Asia = !player.hasPermission("Continent.Asia");
boolean Africa = !player.hasPermission("Continent.Africa");
boolean Australia = !player.hasPermission("Continent.Australia");
boolean NorthAmerica = !player.hasPermission("Continent.NorthAmerica");
boolean SouthAmerica = !player.hasPermission("Continent.SouthAmerica");
boolean Antarctica = !player.hasPermission("Continent.Antarctica");
if (Europe && Asia && Africa && Australia && NorthAmerica && SouthAmerica && Antarctica) {
player.openInventory(gui);
} else {
player.sendMessage("" + ChatColor.RED + ChatColor.BOLD + "You already picked a contienect");
}
}
this is how it should be
it's valid syntax but no one writes java code that way so it's just confusing that's all
i meant not using brackets
that's confusing?
blocks are required there if there is more than one line of code
maybe not confusing, just unorthodox lol
you can easily read over it but it's not standard java formatting
especially having a mix of brackets / no brackets
Hello. I have a problem with newest version of LuckPerms. This plugin crashed my server. I'm from Russia. Sorry for my English...
Please, help!!!
My server on 1.12.2
This is the 3/4 time i ask and I couldn’t find a fix or a way around it ..
How to give player a rank for sepcfic time with command ( in my plugin ) or using api ..
Really helped thx!
Add a ); at the end
my whole code
is broken
thx allot for who ever told me to upgrade 😄
to latest api
this error
this error
- iam not that good with the new api
:L
anyone help me pls ?
i must open my network today
anyone could give me an example for this?
but 4.4.1 ?
i tried make it with 4.4.1 ver but didnt have any luck ..
And luck is here 😐
Still waiting for help ..
This is an example for how to add a temp group on 4.4. However, you need to get your code to work on 5.1 eventually. 4.4, and the legacy extension, will not be around forever.
Hi, I'm trying to change players prefix color with a command and I was wondering if there's a function that allows me to change the prefix.
Thanks! one more question, is it possible to save it on restart?
If you're saving changes, or you're using a method which automatically saves changes (Such as UserManager#modifyUser), there should be no risk of data being reverted on restart
Alright thanks!
I don't know where to ask this, so I'll just ask here. I am working on a plugin and want to change the way I store data. I want to move from multiple .json files to a single .db file. I have seen a couple of plugins using such files but haven't found any tutorial about it anywhere, but I know Luck Perms uses this data storage system. It would be quite cool if anyone could help me learn how to create such a data storage system/tell me how Luck Perms did it. Ty =D
So just change from JSON to SQLite?
yeah, but what I've seen so far always required a web part and where the data would be stored online, or it would require something else downloaded.
O.o
maybe I just didn't find the right sources, but I would be interested in how luck perms did solve this.
Well the web stuff you might see in LP is probably due to the Web Editor.
If you're trying to just change JSON stuff to MySQL, load in the objects in JSON and then serialize what you need to SQL
I have to work out how the SQL things work first before I move the data over from JSON, which is my problem rn.
No idea how SQLite works, but if speaking about SQL in general, it are all just tables with columns and rows.
{
"some_table": {
"key": "value"
}
}
Could be a table called some_table with column key and a row with value value
SQL even has a JSON datatype.
It does, yes. I use it.
I've heard about the basic layout of SQL and I'm sure I'll be able to find tutorials about all of it, but I'm not that far yet sadly.
As long as you don't need to pull the data from another location at the same time, you should be able to use that.
I'm trying to change the prefix color with a GUI I made but for some reason it doesn't change the prefix color and removes it from the tab list. Any of you might know why?
User user = luckPerms.getUserManager().getUser(uuid);
CachedDataManager cachedData = user.getCachedData();
CachedMetaData metaData = cachedData.getMetaData();
String prefix = metaData.getPrefix();
if (prefix == null) {
sendMsg(p, "errors.noPrefix");
}
String newPrefix = "";
String[] validColorCodes = {"&f", "&6", "&d", "&b", "&e", "&7", "&3", "&9", "&a", "&c", "&8", "&6", "&5", "&4", "&2", "&1"};
for (String s : validColorCodes) {
if (prefix.contains(s)) {
UserManager userManager = luckPerms.getUserManager();
newPrefix = prefix.replaceAll(s, rankColor);
user.data().clear(NodeType.PREFIX::matches);
Map<Integer, String> inheritedPrefixes = user.getCachedData().getMetaData(QueryOptions.nonContextual()).getPrefixes();
int priority = inheritedPrefixes.keySet().stream().mapToInt(i -> i + 10).max().orElse(10);
Node node = PrefixNode.builder(newPrefix, priority).build();
user.data().add(node);
userManager.saveUser(user);
break;
}
}
sendMsg(p, "rankColor.messages.done", "%rank%", newPrefix);
Hi there I am making a scoreboard that shows rank and money and a date and time But this scoreboard need to update every sec how can I do thath
https://paste.md-5.net/lisepugitu.java this is the link to my code
this is not for help with developing plugins
this is for help with working with LuckPerms Developer API©
ok sorry man I only trying to make a plugin
Hi, i try to get a user permission from a user but only from the group it is in and without the parent groups.
someone an idea
User#data and then NodeMap#toMap maybe?
hey
so I have the vanish plugin on my server...how could i give the /gmsp command for staff members?
(Please mention me if you need me/if you need my attention) I dont mind
I have a question what database manager would you prefer MySQL or mariaDB ?
For a bungeeCord server 1.15.2
Spigot
@polar walrus If you have a choice on which package to install go with mariadb
but if not don't worry, either is fine
Is there anyway of setting a prefix/suffix. I can get it but I want to set it now through the api because right now I'm just making console run the command in my plugin
This should be useful for you https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/commands/SetPrefixCommand.java
Hello there 🙂 i have a Question how can i add a player do a group?
this is what i tried so far
public void addGroup(LuckPerms luckPerms, Player p){
Group verified = luckPerms.getGroupManager().getGroup("bürger");
UUID id = p.getUniqueId();
User u = luckPerms.getUserManager().getUser(id);
Bukkit.getServer().broadcastMessage("1");
DataMutateResult r = u.data().add(Node.builder("group.bürger").build());
Bukkit.getServer().broadcastMessage("a");
luckPerms.getGroupManager().saveGroup(verified);
Bukkit.getServer().broadcastMessage(luckPerms.getGroupManager().getGroup("bürger").getWeight().toString());
}
Thank you @cold panther :D
Hey Colink02! Please don't tag helpful/staff members directly.
@opal temple you aren't saving the user with luckperms.getUserManager().saveUser(u);
Also, remove all your group stuff. You don't need to mess with actual groups when adding a group to a user
I tried this but this dosent work too
i swear xD
public void addGroup(LuckPerms luckPerms, Player p){
Group verified = luckPerms.getGroupManager().getGroup("bürger");
UUID id = p.getUniqueId();
User u = luckPerms.getUserManager().getUser(id);
Bukkit.getServer().broadcastMessage(luckPerms.getGroupManager().getGroup("bürger").getWeight().toString());
DataMutateResult r = u.data().add(Node.builder("group.bürger").build());
Bukkit.getServer().broadcastMessage(luckPerms.getGroupManager().getGroup("bürger").getWeight().toString());
luckPerms.getUserManager().saveUser(u);
luckPerms.getGroupManager().saveGroup(verified);
Bukkit.getServer().broadcastMessage(luckPerms.getGroupManager().getGroup("bürger").getWeight().toString());
}
Bukkit.getServer().broadcastMessage(luckPerms.getGroupManager().getGroup("bürger").getWeight().toString());
That's what's printing that
And you should use an InheritanceNode to add a group
The question is why are you printing it?
And why are you printing it thrice?
And as mentioned before you're not modifying the group so don't save it
i dont really know why
Me neither
🙂
Is there a new api update or something because looking at the cookbooks setprefixCommand has java api.getUserManager().modifyUser(player.getUniqueId(), (User user) -> {
but modifyUser doesn't exist? I'm using maven with the api version 5.0 if that matters
Yeah, API 5.1 now exists
oh ok well that wiki page is out of date xD
!help
!advanced
!api
!argumentbased
!ask
!bulkupdate
!bungee
!cauldron
!chat
!colours
!commandequivalents
!commands
!config
!context
!default
!downloads
!editor
!errors
!essentials
!extensions
!extracontexts
!faq
!helpchat
!inheritance
!install
!locale
!meta
!migration
!notworking
!nowildcard
!pasteit
!permissions
!placeholders
!selfhosting
!stacking
!storage
!suggestions
!switchstorage
!sync
!tracks
!upgrade
!usage
!userinfo
!verbose
!weight
!whyluckperms
!wiki
!bungee
If you run a Bungeecord network, learn how to correctly setup LuckPerms on all server instances (including Bungee).
Syncing data between servers
https://github.com/lucko/LuckPerms/wiki/Syncing-data-between-servers
!api
Learn how to use the LuckPerms API in your project.
hello. so i'm using luck perms in a global way, and I was wondering if it is possible to get a player's group who is in a different server to the one that is requesting the group?
Just load the user instance with the user mananger
that's what im doing
user instance then using cachedmetadata
unless i shouldn't use cachedmetadata?
That's fine
yeah but its throws an error when the player aint in the server saying there is no value present
i told you the error
and the code is
public static String getPlayerPrefix(UUID player) {
User u = getLuckPermsUser(player);
CachedMetaData metaData = u.getCachedData().getMetaData(LuckPermsProvider.get().getContextManager().getQueryOptions(u).get());
return (metaData.getPrefix() == null ? "§7" : ChatColor.translateAlternateColorCodes('&', metaData.getPrefix()));
}
I mean the full error message
I need that method getLuckPermsUser(player);
LuckPermsProvider.get().getUserManager().getUser(player);
player being a UUID
in this case
and you would do that how?
getUser(player); -> loadUser(player);
thank you
Which line is 113 in that file btw?
CachedMetaData metaData = u.getCachedData().getMetaData(LuckPermsProvider.get().getContextManager().getQueryOptions(u).get());
i know i should use the orelse methid
instead of get
but ¯_(ツ)_/¯
yeah i know
If you're using the v5.1 API there's a better method to get the query options
oh yeah?
And if you know why are you asking then?
The User object should have a getter for query options
yeah i know
and
no please tell me
Are polar opposites
...
i said yeah i know too why my error was being thrown
and no please tell me to the better method
You're welcome
@crystal sonnet
?
Nothing. Just my phone again, I apologize
kills phone
It's a new one, and bigger than my last one. So where on my last one was so called air, is now the send button
But I'm going #general
I'm trying to use the luckperms api:
//onEnable:
val perms: LuckPerms? = getRegistration()
if (perms != null) {
Bukkit.getPluginManager().registerEvents(OnMessageHandler(perms), this)//Register async chat event.
}
//getRegistration:
private inline fun <reified T> getRegistration(): T? {
return Bukkit.getServicesManager().getRegistration(T::class.java)?.provider
}
it's never registering the chat event.
so somehow the api is null
import me.minideathstriker.plugin.handlers.OnJoinHandler;
import me.minideathstriker.plugin.handlers.OnMessageHandler;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import me.minideathstriker.plugin.commands.cmd.*
import net.luckperms.api.LuckPerms```
imports
I'm hard depending on LuckPerms
if you know a solution, please @ me. I'm off to bed
with LP dev api or?
#support-1 for non developer LP questions
oow sowwy
with LP dev api or?
@obtuse jolt yes
Hey miniDeathStriker! Please don't tag helpful/staff members directly.
@near oracle sorry about the confusion; the person ben was talking to very strangely deleted their messages
if i knew id tell ya
BrainStone might, when he comes online. We'll see
I believe luckperms is being transitively included in the output jar.
If luckperms is present in the plugin jar I believe the class loader will prefer the local copy rather than checking the parent classloader
Solved
PermissionNode node = PermissionNode.builder("group.skyblock-islandcreated").withContext(DefaultContextKeys.SERVER_KEY, "skyblock").build();
User user = api.getUserManager().getUser(String.valueOf(event.getPlayer()));
user.data().add(node);
api.getUserManager().saveUser(user);```
Is this the correct way to add a permission node to someone?
screams
getUser(String.valueOf(event.getPlayer()))
This is wrong on so many levels!
Alright. First of all use the InheritanceNode, not the normal PermissionNode
Second, load the user by their UUID, not their name
Not only is that faster but also more reliable.
Hey can someone help me? Im extremly new and I have no clue what Im doing
Im trying to make a server for a couple friends so we can play survival but I need to know how to give their groups permissions to do certain things
screams
BrainStone I remember you used to be so serious, like absolutely unbreakable. Sometimes I really do think you're on something in these rare glimpses of emotion
being serious isn't a bad thing, in fact the thing that i probably most like about brainstone is that he can be taken so seriously
you gotta remember that he's also a person though like anyone else lol (not a 🤖 )
discord differentiates between the two with the BOT tag
they do!
i'm referring to discord bots (like the ones in Paper etc) which send messages between discord and an irc channel
oh i see what you're saying
you think that there are people who actually use IRC?
no thats just the bot
(jk of course lol)
Did you know that... LuckPerms has it's own IRC channel?
let me be clear that i dont hate irc i just like making dumb jokes
Larry where can I get your finest whale tranquilizer
Also a wild Luck
A rare sight
What have we done to deserve this honour
@azure latch I try to be serious when necessary. But I joke around quite a lot
I mean I almost typed
THE ONLY EMOTION I KNOW IS FEAR
But wasn't quite in the mood for that
Oh come on, like the PAPI server has clips and cubes pings, we need BrianStone and Lucks pings
I'd sub to that
Additonally I have a very very German sense of humor. Which consists of lots of sarcasm. Issue with sarcasm is that it often doesn't come across online
Which makes me seem even more serious xD
True
We still need a dedicated channel for you to release your feelings while your on Larry's whale tranquilizer ( I'm sticking with this ok), it can be quite a ride
This is as close as it gets
Or well
#general is more like it
Which we should use to be fair
Geez guys
Did you just tell me to use that channel and make a point at the same time? Omg, his admin side is truly growing
👌🏼
How can I check if a player is in the group "abc"?
!API should have what you need- if you try what is there and cannot figure it out, please provide what you tried and what you want it to do
Learn how to use the LuckPerms API in your project.
Man, I feel dump now. Its legit the first entry in the wiki....
Thx for bringing that up 👍
I'm trying to use a method to identify that the player is a staff, but am I in doubt about this method that I created it is correct?
https://pastebin.com/GjEDd0yU
hi
!ask @nocturne elbow
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!
How to make luckperms know about sub command permissions? They might be created dynamically like warps (warp.hub or warp.house)
Just check them
How?
By performing normal permission checks
luckperms indexes them as they are used, you can pre-register any static ones by listing them in plugin.yml
Is this the right way to add roles? I didn't found more simple way to do this.
user.data().add(Node.builder("group." + group.getName()).build());
api.getUserManager().saveUser(user);
api.getGroupManager().saveGroup(group);
Hi,
I used Jobs plugins and Luckperms for add and remove permission, a friend have created a plugin but when i add a permission i have world context, sorry for my language i am french
I need to post a pastebin with the class inside ?
@dapper jetty you don’t need to save the group and use an InheritanceNode (just put the group name in the builder)
@manic kraken I mean yes. How else are we gonna help you?
We’re not psychic
Hi, thx for your help i post pastebin now
So when i leave a jobs they can't delete permission of Luckperms
If i join, the create a permission with a context: world=world
Like that
So, i can delete perm only with context world: world
@crystal sonnet Thx for you help
Hey Bossbirdyman! Please don't tag helpful/staff members directly.
I’ll take a look shorty
Thx ^^
@manic kraken so you are asking how to implement perms.playerRemove(p, s);?
I want to add perm yes but it's was automaticly add the context of the world
Add and remove perm
Learn how to use the LuckPerms API in your project.
I am not a developer so i can learn little
So you were expecting me to write the code for you?
Can you ? ^^
If you could it would be really cool
That's not how this works
I know but i am not a developer :/ Not a good
Doesn't mean you can just go to support Discords expecting people to code the stuff you need for you
I know, so for the context i need to see the api ?
Yes
!api
Learn how to use the LuckPerms API in your project.
Hello guys, I am looking for something. I just updated my luckperms from really old api to the v5 api. and I am trying to get my old methods to work. I was wondering how I can check if user is in a track.
My old method was
@Override
public boolean isStaff(UUID uuid) {
User user = this.getPermissionUser(uuid);
if (user == null || user.getAllNodes().isEmpty()) {
return false;
}
return user.getAllNodes().stream()
.filter(Node::isGroupNode).anyMatch(node -> getLuckPermsApi().getTrackManager().getTrack(node.getGroupName()).getName().equalsIgnoreCase("staff"));
}
@Override
public boolean isDonator(UUID uuid) {
User user = this.getPermissionUser(uuid);
if (user == null || user.getAllNodes().isEmpty()) {
return false;
}
return this.getPermissionUser(uuid).getAllNodes().stream()
.filter(Node::isGroupNode).anyMatch(node -> getLuckPermsApi().getTrackManager().getTrack(node.getGroupName()).getName().equalsIgnoreCase("donator"));
}
this is what I have now but doesn work.
public static Boolean isDonator(UUID uuid) {
LuckPerms plugin = LuckPermsProvider.get();
User user = plugin.getUserManager().getUser(uuid);
Objects.requireNonNull(uuid, "uuid");
Set<String> groups = user.getNodes().stream()
.filter(NodeType.INHERITANCE::matches)
.map(NodeType.INHERITANCE::cast)
.map(InheritanceNode::getGroupName)
.collect(Collectors.toSet());
return groups.contains("donator");
}```
@swift sand what doesn't work about this?
Somehow its not getting the the track donator
I am trying to check if user is in track donator or not
InheritanceNodes are group assignments
So why would checking if a user has a group called "donator" be checking if they are in a certain track?
In any case if you can use API v5.1, then there are better methods to get the groups of a player
Can you give me an example? I am not really a dev. I am just fixing some issues on a plugin of mine
That a dev made for me once
Get the groups in the track and see if any of the groups a player has are in that list
One message removed from a suspended account.
One message removed from a suspended account.
That's the old API. For API 5+, it's LuckPermsProvider.get();
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
You just need to use getGroupManager().getGroup(name); instead. Similar to using the UserManager when dealing with users
One message removed from a suspended account.
One message removed from a suspended account.
LuckPerms luckperms = LuckPermsProvider.get();
final Group group = luckperms.getGroupManager().getGroup(luckperms.getUserManager().getUser(player.getUniqueId()).getPrimaryGroup());
Or something similar to that
One message removed from a suspended account.
yall where can I find the Java Docs?
Pinned
Is there a way to give a player a certain permission?
Something like api.Addpermission(player, "Permission"); ?
Yes, but the luckperms api is lower level than that. if you're using API 5.1, you should check this example out https://github.com/LuckPerms/api-cookbook/blob/master/src/main/java/me/lucko/lpcookbook/commands/AddPermissionCommand.java
is "this" the main class? @cold panther
Hey SolarPulse! Please don't tag helpful/staff members directly.
You kinda should know what this means in Java
^
Yeah ik it's a really stupid question, but i just can't really fix the problem.
if you don't understand basic java, don't dive straight into a bukkit plugin right away
I really don't want to be rude, but MC plugins are not the place to learn Java
And using the LP API requires an even better understanding
Though in any case if you explain the issue we can try to help
^
Start with basic java and OOP tutorials, once you understand that, then work your way up to using bukkit and eventually LP's api
Else it's gonna be hard
I do know the basics, but i just got a little bit frustrated and asked it out of certainty.
this always refers to the current class instance
So if you're trying to figure out how the variable was initialized, check either the declaration or the constructor
Because im working in a other class than the main-class, I tried main.luckPerms. but it was no succes.
nor plugin.luckPerms
Then either access the API statically or do the same: Add a variable to the class you're working in and initialize it in the constructor
Can't i just do like main.getPermissions().getUserManager()?
It depends on your code
Like c'mon
That stuff is basic Java
How you get the objects is irrelevant
As long as you get them somehow
There's no helping you, sorry.
You're clearly lacking basic Java knowledge and experience
The best way I can explain this is that you've just recently started walking and now you want to run a marathon.
I mean you can do it. But you'll either need significant assitance or it's going to take forever
Is it possible to do this with vault?
Nvm i already fixed it with vault.
Hey! So I'm using the API on a Bungee instance, and I'm trying to see if a player has a permission, whilst respecting server contexts
(i.e. if the player is loaded on the server, and has permissions through a group set with the server= context)
Currently, it's only passing if the player has the group/permission globally, not given with a server context
However that's using player#hasPermission, I was wondering if it's possible to use the LuckPerms API to instead work with the contexts set
There is CachedPermissionData#.checkPermission, but would that check if the player is on the server with the server context?
You need to construct the context yourself
I did something similar a little while ago:
@rain lodge
Alright, thank you.
If the context issue bothers you like me feel free to support it here: https://github.com/lucko/LuckPerms/issues/1668 @rain lodge ❤️
Oh, so it does take contexts into account, but it just has the wrong ones for what we need?
Does player.getPermission also take those contexts into account?
Alright
Thank you
Although the contexts are set via server= and are specified in each LP server's config
Not necessarily the server inside Bungee itself, but the server that LP uses
(Example)
And then the permissions are set with:
/lpb user <user> permission set <node> server=rlcraft
But when I'm using player.hasPermission(node) through Bungee, it doesn't seem to think they have the permission, even if they're online on RLCraft
@crystal sonnet Is that the same?
Hey Ally! Please don't tag helpful/staff members directly.
@rain lodge that’s because for the bungee those are world permissions. Determined by the server names in the bungee config.yml
Check the contexts when running /lpb user <user> info
server= is the world context that doesn't use the server set in LP?
Interesting
When checking if the player has the permission, it doesn't seem to pass, even though they have the permission applied through the server context that is set in the luckperms configuration (and online, through bungee, on that server)
Running it on that server, the contexts is server=rlcraft
And all their permissions are fine on there, in that group with the context.
It's just when checking through Bungee
hh
Any ideas?
@rain lodge bcu bungee context is server=bungee and world=servername
@obtuse jolt Is that servername specified in the LP config, or in the config.yml of Bungee?
Hey Ally! Please don't tag helpful/staff members directly.
lp config, always
LP config ofc
Great, thank you. ❤️
@rain lodge @obtuse jolt @rustic laurel no!!
The world context on the bungee is derived from the config.yml of the bungee!
Not the LP configs on the backend
?!
And Ally I meant you should do the command on an online player.
@rustic laurel if you don't believe me, try it
I'm appalled at how little most people know about LPB
You're by far not the only one that gets most things wrong routinely
I've hardly seen anyone that gets it right
Don't get me wrong
no, me wrong 😛
I'm neither calling you out, nor blaming you for not knowing
I just find it shocking that so many people just spout out wrong info about bungee with 100% certainty
for me at least, it's that LP checks the server name based on the LP config when checking per-server perms
That is correct
Well the LP instances don't communicate with eachother
So how could bungee know what the backend servers have in their configs
Yes but the database contains no info about the connected servers
It's just a storage for nodes, groups and users
It just didn't cross my mind
Now it did
yep
@crystal sonnet can you maybe help me out with that part. Like the anymatch line
Hey OptifineUser! Please don't tag helpful/staff members directly.
Oh sorry
Do you still want to check tracks?
yes
hello humans
i've been having fun learning the luckperms api, but I'm having a hard time understanding something
I add a node meta.example.RED to a player, but when the player leaves and reconnects to the spigot server it seems to disappear
additionally as soon as I run /lp user example meta info, the meta in question also seems to vanish into thin air and the plugin which relies on it immediately stops working
I was thinking that I'm somehow only temporarily saving the meta or something, is that the case?
the line i'm using to apply the meta is User.data().Node.builder("meta.example.RED").build());
(wink wink nudge nudge ```java
code here
``` for a nice code block i.e. java if (this.bored()) { this.program(); }
)
ooooooooo i'll keep that in mind :3
but yeah it's really strange; i have a task which prints out once a second the value of the meta I set, and as soon as i run a command like /lp user Ivan8or info the meta immediately changes and begins printing null
i know so little about this that I hesitate to say anything but I'm pretty sure you have to save it deliberately to the user (?) or something
oooh that's what I was suspicious of, do you know how to do that? 😮
ah wait i think i just found it in the wiki
i thank you for your services 😄
holy crap did I actually just help in #luckperms-api wtf no problem! ❤️
lol larry
larry is evolving
with the luckperms developer api? you can't. Another plugin must handle that
#general please, this is not related to the luckperms developer api
can i get some 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!
its not a big help
Gotta ask your question before anyone can help you
Hello!
I need help implementing the luckperms prefixes before player names in a tab plugin
are you making this tab plugin yourself?
I'm using this plugin's source code, because it's allowed: https://github.com/CodeCrafter47/GlobalTablist?files=1
i recently used this feature of the api to get prefixes myself 🙂
i have to say the api is very well documented
Okay, so the String prefix = metaData.getPrefix(); does works, but I've got 0 ide how to put this before the player names....
well that really depends on the code of that plugin you're modifying
Can you please take a look? 👀
i'll take a small peek but i can't say i'll be able to figure anything out lol
Thank you
i think i found something
Oh, I'm all ears.
@mellow shadow in the GlobalTabListHandler17, theree's a function private PlayerListItem.Item createBasicItem(ProxiedPlayer player) {
it grabs the player's display name and assigns it to an item
there are also more spots where getName() is called on the player within the plugin
i suggest trying to insert the prefix before the text returned by getName() in all of those instances and see which one works
sure thing
I'm a little bit worried because I'm not an expert
if you want an easy alternative, i can suggest the TAB plugin which has an API that lets you show / edit the player's prefix and suffix in the tab menu while keeping the tab menu minimal
i don't know if you have full customization of the tab menu there though
I've tryed it today but it has a lot features that I don't need, and some of them was very hard to disable.
I just need a bungee plugin that only displays prefixes before player names in the tab. That's it. No collision, priopirty, header, footer stb
you can pretty easily disable all the extra features for TAB in the config, though in a roundabout way
you can add your world names to the 'disabled worlds' sections of all the features you don't want
anyways let's shift this to #general
Hey I need help with automatically setting a Default role/rank to a new and existing players that join the server, I can't find any information about this.
No need to ask in several channels. Already answered in g1
can someone send me a PaperLib?
Can you add multiple permissions in 1 permission node? Or do I need to make separate
Discover some of the more advanced concepts of LuckPerms, such as permission calculation, shorthand permissions and more.
So PermissionNode node = PermissionNode.builder("test.{a,b,c}").build();
i think so?but dont take my word, never really used the lpAPI before
it works 😛
haha thx!
Got a new problem now:
When I create a group with
api.getGroupManager().createAndLoadGroup("test");
and directly after that
Group group = api.getGroupManager().getGroup("test"); this one will return null (it doesn't exist) but if I run the code again it exists?
Any idea's to do this?
I found this way:
try {
g = api.getGroupManager().createAndLoadGroup("test").get();
g.data().add(node);
api.getGroupManager().saveGroup(g);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
But if there is a better way would love too hear
i think that's the correct way to do it 👍
That’s how you do it
Okay great 👍
hey, i've been having trouble refering to LP via java nashorn.
here's a simple error java.lang.RuntimeException: java.lang.ClassNotFoundException: net.luckperms.api
and how i refer to it var lp = Java.type("net.luckperms.api"); same with var lp = Java.type("net.luckperms.api.LuckPermsProvider").get();
For referance some other classess that work:
var JURL = Java.type("java.net.URL");
var Channels = Java.type("java.nio.channels.Channels");
var rbc = Java.type("java.nio.channels.ReadableByteChannel");
var API = Java.type("noppes.npcs.api.NpcAPI").Instance();
prbbly my dumb ass deosn't get something...
Any idea how to rewrite it?
well access the object within MC using CNPC to run scripts.
RN i only have plugin itself installed and running, dunno if downloading this would help https://github.com/lucko/LuckPerms/tree/master/api/src/main/java/net/luckperms/api
Do you have LP installed?
yes, it's included as a plugin.
Alright
In that case reach out to the dev of the plugin that let's you run the scripts
They are most likely usinging their own classloader for the scripts and that's why you can't access the LP classes
Btw net.luckperms.api is a package, not a class
well as i wrote above typying Java.type("full.class.here") was enough so kinda lost here
though it's mostly mods and java classes
Again, this has nothing to do with LP itself
If the class is there or not doesn't depend on LP, but rather the script plugin
Now make sure you have a LP version that's 5.x.x
Else you don't have the new API available @final orbit
hey, with the api how would i go about getting a users prefix?
!api
Learn how to use the LuckPerms API in your project.
Cookbook has a good example too (repo is linked in the pins)
Is there a simple way to check if a player has permissions in another context to what the server is running?
There's the command to check
Nah you're fine, most people just ignore channels and today I'm apparently guilty of it haha
Have you had a look at the javadocs/wiki combo?
!api
Learn how to use the LuckPerms API in your project.
I don't know exactly how, but I know it's almost definitely possible because the plugin itself has that function
There's a section called "performing a permission check" or something like that on the wiki, cookbook may also have something
How can I see what groups there are?
!commands
Find all of the available LuckPerms commands on the wiki.
Learn how to use the LuckPerms API in your project.
thanks
Is there an equivalent in the api for /lp user <user> meta clear prefix
yes
check out the javadocs and the usage guide
linked riiight above your message
I've got them pulled up already sorry but the lp api is pretty confusing to me, can I get a point in the right direction? Should I use clearMeta(Context) from User?
I see in the usage api how to retrieve user meta but not how to act on it.
Meta is generally stored as a node
You can do something like user.data().clear(NodeType.META::matches)
ok great! so just for my understanding, why does this only clear meta inherited from self and not groups?
hopefully that question makes sense, let me know if not
Because you are acting with user not group
User#data is the data the user has directly, not inherited nodes.
Same with Group#data as they share (some) things
why when im trying to add bukkit/minecraft perms it does not work but with other plugins it works fine ?
?
?
I mean perms are just perms there is no difference between built-in perms and added perms.
Why do you guys provide a fake method in the API to check if a user is in a group or not?
How is that helpful?
What are you referring to??
Idk, maybe I'm dumb but I could've sworn on the wiki there's an example method that's commented saying it doesn't actually exist
Nvm ignore me
Apologies
I can't read a wiki properly at 6 am. ( I totally didn't see the "in an ideal world" comment above the example )
how to show the prefix of a group in the scoreboard like what is the placeholder for it
Ohaiglare
Sup
And yeah Luck, it could be.
At least he sees where I was coming from with that.
If you miss that small comment there, it's easy to think that's just in there for whatever reason.
Hey,
how do I set a player's PrimaryGroup with the API?
Do you mean specifically the primary group in the database?
I mean the PrimaryGroup...
I want to set this group of the player from default to prime
Unless you change that
Then just set their group, and make prime have a higher weight
Manually setting a primary group is only useful if you need to read that value from the database for a non-LP function
!API has some info on setting groups
Learn how to use the LuckPerms API in your project.
Hi can i use Luck Perms with Essentials?
Yes, but please use #support-1 or 2 for non-devapi stuff
okay thank you
DataMutateResult result = user.data().add(Node.builder("group.prime").build());
Is this the right usage to set the group?
Think so, best to give it a shot too though ;)
I want to do it with a method, beacuse I don't like it to use a command is executed...
I got a problem: The group the player got is just temporary. So after he has reconnected the group is the old...
in my case: default
You can use InheritanceNode.builder("prime").build() too. Shouldn't make any big difference, but just saying.
And you have to save the user, using UserManager#saveUser
Thanks. But do I still have to remove the user's group default after or before the user got the prime group?
You can use
InheritanceNode.builder("prime").build()too. Shouldn't make any big difference, but just saying.And you have to save the user, using
UserManager#saveUser
And, is it possible to remove the parent groupdefaultafter the user got the groupprime?
Hey TurtleSkills! Please don't tag helpful/staff members directly.
Yes, you can do user.data().remove(/*...*/) the same way
hey is this where i ask questions?
Depends, is it a question about the API?
api?
programmy stuff
#support-1 then
okey thank you 😄
@obtuse jolt
Hey Dog Lover! Please don't tag helpful/staff members directly.
wot
Are you not able to edit the ranks of offline players?
you can
How would I go about that? My user object is null
Not familiar with the specifics but I'm pretty sure you have to load the user first
because offline players don't need to be loaded usually, so load em up and then do the thing, then save the user and unload them basically
also i think you need to/should use the player UUID instead if playername
with the api? either afaik, so long as they're consistent (I could be wrong though so if you're less unsure than me ben, I trust you)
im prob as unsure as you, but i think usually UUID is more reliable (assume its an online-mode=true server haha)
I was able to do it with names, since that is all I have access to
Thanks!
Also, just for future reference make sure you use .get() after you load the user instead of loading and then getting since that messed me up a bit before.
Anyone know how to fix "An internal error occurred when trying to perform this command" when doing /papi ecloud luckperms then /papi reload.
Cheers Larry
what plugins is needed for luckperms?
you dont need other plugins for lp to work
okay thx
API? if not the dev-api please discuss in #support-1 (read the channel topics)
i reading topics but my english is bad
Also, just for future reference make sure you use .get() after you load the user instead of loading and then getting since that messed me up a bit before.
get turns the async method into sync, and should be avoided unless absolutely necessary
Or make sure you're running the code async in the first place
Then it doesn't matter
Hey, I am trying to understand exactly how contexts works(I did read this https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#important-classes about contexts) and how to add your own contexts.
So I made a ContextCalculator but as far as I know you can only do those for online players? I would like to me able to set some context for a uuid maybe? isnt that possible ? I did try to make a class that would implement it like this implements ContextCalculator<UUID> however it tried to cast the uuid to a craftplayer, ofcause without success, is there anyway to achieve this within luckperms ?
I believe you need to load the user and and then do things to them
(and then save them)
So things that only work for online players should work if the user is loaded first
hm so load and then immediately save before getting the context? in my test i already loaded the user
Ill try
Load, get the context, do the things, save
nah it still returns an empty set
hm, I'm not sure then. Leave your question here for sure and when luck or someone else knows they'll answer ya!
Also, code snippets would be useful
Especially to show what you're trying to do
So I should note that I am using a pretty old build of luckperms - we currently cant update as we have quite a few plugins that depend on that API version I think - we are using version 4.3.17
here is the code snippet of trying to get the context of both an online player and offline player
Player p = (Player) sender;
OfflinePlayer p1 = Bukkit.getOfflinePlayer(args[0]);
User offlineUser = LPUtils.getLuckPermsApi().getUserManager().loadUser(p1.getUniqueId()).get();
LPUtils.getLuckPermsApi().getUserManager().saveUser(offlineUser);
User u2 = LPUtils.getLuckPermsApi().getUserManager().loadUser(p.getUniqueId()).get();
Contexts offlineContext = LPUtils.getLuckPermsApi().getContextManager().lookupApplicableContexts(offlineUser).orElse(LPUtils.getLuckPermsApi().getContextManager().getStaticContexts());
Contexts onlineContext = LPUtils.getLuckPermsApi().getContextManager().lookupApplicableContexts(u2).orElse(LPUtils.getLuckPermsApi().getContextManager().getStaticContexts());
and the registering of the Calculator
public class BandeCalculator implements ContextCalculator<Player> {
@Override
public MutableContextSet giveApplicableContext(@NotNull Player player, @NotNull MutableContextSet mutableContextSet) {
Bande b = bandeCache.getBande(player.getUniqueId());
mutableContextSet.add("bande", "" + b.getId());
return mutableContextSet;
}
}
public void init() {
LPUtils.getLuckPermsApi().getContextManager().registerCalculator(new BandeCalculator());
}
Well I can tell you the v5API javadocs aren't gonna work for v4 😛
yea I looked up the old commits
Read about upgrading LuckPerms from v4 to v5.
You can find instructions on that here
alright however the wiki says the same thing back then and now about online players, so before upgrading I would like to know if it is possible to do what I am trying to do
the link to the old commit: https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage/cd4403865c754ffb1737c5b4e24abf30441915fa#registering-contextcalculators
to add a bit more context to what i want to do: I am trying to make all who is member of a group(in my case called "bande") to have the ContextSet with the key "bande" and value <id of group>. This is because I want to remove all of the permissions nodes from a user(player) when he leaves/gets kicked from a group(bande) but only those nodes that is in the context with the key called "bande"
If i could get the contextset I would be able to use the User#clearNodes to remove all the permissions in that context after i filtered it.
sorry, what are you trying to do?
From what I can understand, you want to, when a player is removed from a group, you want to remove all user nodes that match a ContextSet?
not a permission group but its like a team of players
but otherwise yes thats what I want to do
What is the broad purpose you are trying to fulfill?
Just so I can understand the situation a bit better
so the server has a lot of different teams(what I called group before - for the players those teams are called "bande"), when you are added to a team you get some permissions depending on what the team have unlocked so far. When you leave the team or get kicked from the team I need to remove those permissions. I could just remove each node depending on the what the team has unlocked but I thought that if I add each team permission in the context (key = team, value = id of team) I could just use User#clearNodes(ContextSet) instead to clear all of them without going through each node added
I hope that makes sence @short fossil
Why don't you just create a parent given to the group? Are there different tiers of permissions given to the groups?
But yes you can stream through a user's nodes and filter them according to your specifications and remove them at a will, so you are able to do what you wish.
what do you mean by different tiers ?
and no I cant just stream through the nodes, since the context isnt loaded and thats what i want to filter on
I just tried to check if the offline player had any nodes with a context and he didnt
Are you sure context is being filtered correctly?
oh nvm yea you are right I could actually do that, though the User#clearNodes(ContextSet) seems like a bit cleaner way to do it
Yeah I honestly haven't had the need to mess around with ContextSets that much as most of my projects/requests don't require it, so not the most knowledgeable on it
I have always just had a parent I could apply / remove from a user
yea I cant really do that in this case though
Do groups differ depending on player?
yep
Learn how to use the LuckPerms API in your project.
^ (for myself)
Yea I hope Luck has some ideas 🙂
When you register the Calculator, is it on version 4?
yea
Yes it can
So pretty new to bukkit mods/java. Recompiled LuckPerms ExtraContexts to target api-version 1.15 with mvn and adoptopenjdk 11 hotspot. Seems like it worked okay, just making sure I'm not doing something insane.
seems reasonable
but why?
you don't need to compile against newer versions in order to use the plugin
the api doesn't change that much
especially the bits used by extracontexts
Spigot was complaining, let me find the log message.
It was just a warning, but figured it'd be easy to squash.
Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
Legacy plugin ExtraContexts v2.0-SNAPSHOT does not specify an api-version.
I don't know why the second error, because master shows 1.13
cool cool
Looks like the commit that fixed it was 25 days ago, but build 13 was 30ish days ago.
Or maybe I'm wrong
bump for my previous question
Just reask?
alright
ill copy the latest message and add a bit
Here is what im trying to do
so the server has a lot of different teams(for the players those teams are called "bande"), when you are added to a team you get some permissions depending on what the team have unlocked so far. When you leave the team or get kicked from the team I need to remove those permissions. I could just remove each node depending on the what the team has unlocked but I thought that if I add each team permission in the context (key = team, value = id of team) I could just use User#clearNodes(ContextSet) instead to clear all of them without going through each node added but when I try to get the context for an offline player it doenst work? Im not sure why though because each node does have the context so it should be able to get it for the offline player too no ?
feels like im spamming if i copy paste the code too so if you need code examples scroll up a bit
Hi,
I started learning Spigot not that long ago, and the Luckperms API is a pain for me to understand, but is it possible to get the metadata of a offline player?
yeah you just need to load the user first
would it work like this? I don't rly understand the API:
UserManager userManager = api.getUserManager();
CompletableFuture<User> userFuture = userManager.loadUser(player.getUniqueId());
userFuture.thenAcceptAsync(user -> {
return user.getCachedData().getMetaData(getQueryOptions(Optional.ofNullable(api.getUserManager().getUser(user.getUniqueId())))).getMetaValue("color");
});
:/
i'm not sure, leave your question here and when someone who knows can answer, they will 😄
can i change prefix of a user with api
Learn how to use the LuckPerms API in your project.
how i give SuffixNode to Player
follow this example pretty much but for suffixes
Thanks 🙂
public void onVanish(PlayerHideEvent e) {
Player p = e.getPlayer();
String oldname = p.getDisplayName();
UUID aydi = p.getUniqueId();
myMap.put(aydi, oldname);
p.setCustomName(ChatColor.GRAY + "[V]" + p.getName());
p.setCustomNameVisible(true);
this.luckPerms.getUserManager().modifyUser(p.getUniqueId(), (User user) {
Node node = SuffixNode.builder("[V]", 150 ).build();
user.data().add(node);
});
}```
what is the problem here
Dont you have to save the user?
Yep
so ?
save the user
No, you don't have to
Or you have to, but not when using modfiyUser
Maybe use SuffixNode node = SuffixNode.builder("V", 150).build(); instead
Nvm, found itNode.builder(permission).value(thing).build(); is the value wether the permission is true or false?
i dont understand the problem
Did you import User?
it is not import thing
What API version are you using?
Try each of those and see when the red line goes away. User doesn't exist in that class or something like that so u gotta make it
try this.luckPerms.getUserManager().modifyUser(p.getUniqueId(), (User user) -> {
try
this.luckPerms.getUserManager().modifyUser(p.getUniqueId(), (User user) -> {
@turbid solar xd
Check your brackets and semicolons
and do i need to do Map thingh
i didnt add any suffixes to any group or person so ?
I'm unsure at this point
why are you getting the prefixes but setting a suffix btw?
i deleted that section
public void onVanish(PlayerHideEvent e) {
Player p = e.getPlayer();
String oldname = p.getDisplayName();
UUID aydi = p.getUniqueId();
myMap.put(aydi, oldname);
p.setCustomName(ChatColor.GRAY + "[V]" + p.getName());
p.setCustomNameVisible(true);
this.luckPerms.getUserManager().modifyUser(p.getUniqueId(), (User user) -> {
SuffixNode node = SuffixNode.builder("[V]", 150 ).build();
user.data().add(node);
});
}```
my code is this now
public void onVanish(PlayerHideEvent e) {
Player p = e.getPlayer();
String oldname = p.getDisplayName();
UUID aydi = p.getUniqueId();
myMap.put(aydi, oldname);
p.setCustomName(ChatColor.GRAY + "[V]" + p.getName());
p.setCustomNameVisible(true);
SuffixNode node = SuffixNode.builder("[V]", 150 ).build();
this.luckPerms.getUserManager().modifyUser(p.getUniqueId(), (User user) -> {
user.data().add(node);
});
}```
i did smt
okay i did it
thank you to all for helping
i didn't do it xd
any others to help pls
Remove the , so (User user)
Just to double check, is it the right User import?
Did you import net.luckperms.api.model.user.User?
yes
That's the wrong on
how i clear suffixes
public void onVanish(PlayerHideEvent e) {
Player p = e.getPlayer();
String oldname = p.getDisplayName();
UUID aydi = p.getUniqueId();
myMap.put(aydi, oldname);
this.luckPerms.getUserManager().modifyUser(p.getUniqueId(), (User user) -> {
SuffixNode node = SuffixNode.builder("&7[V]", 150 ).build();
user.data().add(node);
});
}
@EventHandler
public void onReappear(PlayerShowEvent event) {
Player p = event.getPlayer();
String oldName = myMap.get(p.getUniqueId());
this.luckPerms.getUserManager().modifyUser(p.getUniqueId(), (User user) -> {
user.data().clear(NodeType.SUFFIX::matches);
});
}```
ok one last thing
it works sometimes
but it doesn't work sometimes
How can I send a player command from a spigot plugin, that will run a bungee cord luck perms command?
I'm wanting to run "lpb user <name> parent add <rank>" when a player joins the server using a player join event
Wondering if I can just do that through luckperms and luckpermsbungee
or I will need to make my own bridge
@solemn moss If your permission data is the synced to a common sql database correctly, either will be fine
you are prob better off syncing your perm data @solemn moss
Here's my issue.
Had a server for a year. Not bungee. Has loads of local ranks. Lots of people with different perms etc.
Now I need to make a bungee network. I installed BungeeChat, which only reads "LuckPermsBungee" config / perms etc.
The main issue is, I have multiple servers with the same rank names like, take "King".
But a player may be a lower rank on one server, "Lord", but "King" on another.
And so I need to add the player to a rank on LuckPermsBungee called "KingSurvival" but also "LordCreative". So when they talk, depending on the server they will get a different prefix in BungeeChat format.
Issue is, all my players are in "King" and "Lord" on Survival Spigot LuckPerms. And I wanna shift them over to "KingSurvival" on LuckPerms Bungee.
Can you explain how syncing would work for this situation?
@obtuse jolt
Hey .Zeus.! Please don't tag helpful/staff members directly.
Sorry to ping.
With the dev api!?
Read the channel topic
We were talking about the API
I was asking how to use the API to send a packet to Luck Perms Bungee
The conversation then moved on
public void onVanish(PlayerHideEvent e) { Player p = e.getPlayer(); String oldname = p.getDisplayName(); UUID aydi = p.getUniqueId(); myMap.put(aydi, oldname); this.luckPerms.getUserManager().modifyUser(p.getUniqueId(), (User user) -> { SuffixNode node = SuffixNode.builder("&7[V]", 150 ).build(); user.data().add(node); }); } @EventHandler public void onReappear(PlayerShowEvent event) { Player p = event.getPlayer(); String oldName = myMap.get(p.getUniqueId()); this.luckPerms.getUserManager().modifyUser(p.getUniqueId(), (User user) -> { user.data().clear(NodeType.SUFFIX::matches); }); }```
@fading nebula
it works but not everytime
i tested event it works
but suffix is not working to good
there could be problem with bungee i guess
Make a string list of all the group names. Make it so the highest is first.
check if player.haspermission("nameFromList"+".group");
I got it now cheers
!bungee
If you run a Bungeecord network, learn how to correctly setup LuckPerms on all server instances (including Bungee).
Syncing data between servers
https://github.com/lucko/LuckPerms/wiki/Syncing-data-between-servers
for devapi or ?
gays i have a vps and i cant use mysql for luckyperms bungee
Does this relate to the developer API for LP
think it was a typo 😂
im sry
Hi there, I'm trying to find the permission group "admins" in my plugin, is this code correct? ("plugin" is my main class):
Group adminGroup = new Group("admins", (LuckPermsPlugin) plugin);
And if yes, how can I get all the users in that group?
Use the search function of Discord
have a problem, i created an owner rank, assigned it, then i couldn't get it away and when i uninstall the plugin the ranks are still visible
can anyone help me? my English is very bad
!api
Learn how to use the LuckPerms API in your project.
@raven nebula use bukkit#hasPermission
Permission nodes for groups are (groupname).group
Or maybe group.(groupname)
Check wiki
@gritty ice if you didn’t make the plugin go to general help
@short fossil Thank you, I got that to work. I have another question though: if I want anything to work, I need to obtain an instance of LuckPermsApiProvider, right? The problem is that I don't know which argument to pass in its constructor, I tried passing in a LuckPermsPlugin-cast of my main file (which extends JavaPlugin), but that didn't work (got an error "cannot be cast to LuckPermsPlugin)
And I may be blind, but I did not find any javadocs on LuckPermsPlugin, did I just miss those or aren't they out (yet)?