#luckperms-api
1 messages · Page 14 of 1
are you saving afterwards?
btw whats going on with method invocation setpermission may produce nullpointer
i should cast user to player?
JasCore.lpapi.getUserManager().saveUser((User) p);
you need to check if getUser is returning null
it will do that when the player isn't online
but i doing that in inventoryClickEvent
so
player must be online
Node kill1 = JasCore.lpapi.getNodeFactory().newBuilder("JasCore.player.killparticles1").build();
if(e.getCurrentItem().getType().equals(Material.ANVIL)){
if(ec.getBalance(p) >= cfg.getInt("SkyWarsShop.Price.KillParticles1")){
if(ExpSystem.getLevelPlayer(p) >= cfg.getInt("SkyWarsShop.Lvl.KillParticles1")){
if(!JasCore.lpapi.getUser(p.getName()).hasPermission(kill1).asBoolean()){
ec.withdrawPlayer(p, cfg.getInt("SkyWarsShop.Price.KillParticles1"));
JasCore.lpapi.getUser(p.getName()).setPermission(kill1);
JasCore.lpapi.getUserManager().saveUser((User) p);
fYml.set("kp1", 1);
} else {
alreadyOwned.send(p);
p.closeInventory();
}
} else {
noLevel.send(p);
p.closeInventory();
}
} else {
noMoney.send(p);
p.closeInventory();
}
ok don't worry about checking then
also suggest using p.getUniqueId() instead of p.getName()
the method accepts both, but uuid is faster
maybe in this
I think I've found out how to do it, I really Wish User#addGroup was a thing, so much simpler! Do we need to save after every modification to a user/group?
@trail oar are you at home?
To send me your code
@sinful moat
User user = plugin.luckPermsApi.getUser(staff.getUniqueId());
try{
UserManager userManager = luckPermsApi.getUserManager();
MetaData metaData = user.getCachedData().getMetaData(Contexts.global());
String prefix = metaData.getPrefix();
String suffix = metaData.getSuffix();
//use the prefix, this is considering that the player is online and data is loaded
}catch (NullPointerException e){
plugin.console.sendMessage(ChatColor.RED+"[StaffBot] Error");
return;
}
if player is not online, then data is not loaded, you have to load it sth like this
User user = null;
try {
user = userManager.loadUser(UUID.fromString(uuid)).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
And use user as you want, like above.
Thats working for me, otherwise i get null cause user is not loaded
Thank you I will try this
but it still puts my in group.default while i dont have a rank
@grim pier using the right channel might help. This is #luckperms-api, not #support-1
new BukkitRunnable() {
public void run() {
CompletableFuture<User> logFuture = api.loadUser(playerUUID);
logFuture.thenAcceptAsync(log ->
{
//
});
}
}.runTaskAsynchronously(plugin);```
is that
how to use that
do I need the async runnable?
@frank drift do you know? 🙂
@sonic flare completable futures are already async
No need to start an async Action async
@crystal sonnet are they always async or just in the case of LuckPerms
Hey Aerocet! Please don't tag staff members.
how do I delete the bot's comment
You don't
You can’t. That’s the point
Also, it depends what runs the runnable
But you're using runTaskAsynchronously
So it's async
sooo if I make a method that returns a future is it async or not
Anyways. CompleteableFutures are designed to be async. The idea is that you can start an async task (or a task async (slight difference)) without a blocking call. It allows you to check if that task has been completed and the value is available
@Aerocet#0001
I'm still confused though... if my method returns a completablefuture from a database query, do I have to make it async manually
or not
does it automatically do it async
...
No, the future is because LP runs it async for you
Hi
I want to check if the weight of the player's group is superior to 40
How can I do it ?
I succeeded, for those who want:
LuckPermsApi api = LuckPerms.getApi();
if (api.getGroup(api.getUser(event.getName()).getPrimaryGroup()).getWeight().getAsInt() < 40) {
}
Heifer weight for higher groups, so you’d want the operator to be the other way around
@nocturne elbow don’t forget to save the changes. The wiki has tons of examples
Hey Luwie! Please don't tag staff members.
Hi, I want to check permissions of an offline proxiedplayer using the UUID.
is User#hasPermission(getNodeFactory().newBuilder(...).build()) enough? (Of course I get the user with #loadUser).
@near swallow should be enough
Is it possible to set a users group with User.setPrimaryGroup or is there some better way to add and remove user groups? Its not really mentioned on the wiki at all
Also using VaultAPI permission.playerAddGroup( player, ADMIN_GROUP ); seems to have no effect at all with LuckPerms, I cant find any into saying how compatible this is with vaults perm system.
looks ok to me
if you're wanting to remove default, you may have to add a call to remove that specifically after the user.setprimarygroup call
@nocturne elbow the wiki has examples on how to properly use the API. Including setting groups
Went with the lazy solution instead of just running a console command from code. Does the job 👌
Hi
Quick question
If a group inherits other group
i.e. group #1 and #2
Would player.hasPermission("group.1") return true for a player on group #2?
Considering that group #2 interits #1
also whats the event to listen to a parent change
Yes
@crude laurel there’s just a generic event. See the wiki on how to listen to it, as it is fired not using the platform’s event system
ic
The “yes” was answering the first question
hey people! super dumb question but i was just wondering if it's possible to access the luckperms api in python?
@wheat barn no
It's an API for plugins running on the server
So the only way would be to write an interfacing plugin that would communicate with your python scripts
Ah ok, ty anyway @crystal sonnet :)
Hey HewloThere! Please don't tag staff members.
Can i use the api with bungeecord too?
I'd assume so
@chrome tinsel You can
Although you have to obtain it statically, as described in the wiki
Ok, thanks!
"worldsPowerLossEnabled": {
"standard": true,
"exceptions": []
},
In "exceptions": [], I would like to add the following worlds: "MinaPobre" "MinaRica" and "MinaHeroica"
Should it be like this? ->
"worldsPowerLossEnabled": {
"standard": true,
"exceptions":
},
"worldsPowerLossEnabled": {
"standard": true,
"exceptions": [MinaPobre,MinaRica,MinaHeroica]
},
?
@soft wasp this is the LuckPerms Discord.
(x) doubt
oops sorry
Hello! How can I set a player into a group ( code ) ?
api.getUser("user name").setPermission("group.name", What is here ? );
Can anyone help me ?
Or set permission to a player using code
@fleet knoll check the wiki for examples
Please send me a link, because I'm not found it.
The wiki can be found in #welcome
Navigation is on the right and the API is the last menu element @fleet knoll
Hey,
With the API how to get a info of a offline user ?
Load their data first
Then use it normally
@earnest zodiac
Wiki contains examples on just that
In the wiki not tell or example about how to set permission to a player.
@ebon ether .setPermission(node, temporaryMergeBehaviour); What is temporaryMergeBehaviour?
I can't only .setPermission(node)
It's require temporaryMergeBehaviour
I actually cant tell you. I just corrected a error I made and changed the link
Hey,
I want to get the user prefix or if not set the user primary group prefix. I'am on LuckPermsBungee
I have look on the api documentation
Hello. How can i add a group to a player?
/lp user (user) parent set (group)
@rancid moss this is the API channel ;P
@fervent oracle the wiki has examples on exactly that.
@crystal sonnet I've already saw that, ty.
Hey KickPost! Please don't tag staff members.
Awesome 👍
@teal tartan I have see this on the API documentation but not working.
My code this is for testing / debuging :
@EventHandler
public void onChat(ChatEvent event)
{
if (!event.isCommand()) {
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
ContextManager cm = api.getLuckPermsApi().getContextManager();
User user = api.getUser(player.getUniqueId());
Group group = api.getGroup(user.getPrimaryGroup());
Contexts contexts = cm.lookupApplicableContexts(user).orElse(cm.getStaticContexts());
MetaData metaUser = user.getCachedData().getMetaData(contexts);
MetaData metaGroup = group.getCachedData().getMetaData(contexts);
System.out.print("USER: " + metaUser.getPrefix());
System.out.print("GROUP: " + metaGroup.getPrefix());
System.out.print("MESSAGE: " + (metaUser.getPrefix() != null ?metaUser.getPrefix():metaGroup.getPrefix()) + " " + player.getDisplayName() + " " + event.getMessage());
}
}
Hey! How do I set up the API for Bungee? The bukkit 'RegisteredServiceProvider' does not appear to exist in BungeeAPI
Grab the API statically, I believe it is LuckPerms.getApi() or LuckPermsApi.getApi() 😃
Alright. Thank you 🙂
Hey! Another thing..
Is it possible to load my plugin after LP?
Otherwise I won't be able to set up the API
plugin.yml - depend: [LuckPerms]
That doesn't seem to work either
Before
Yep
Perhaps it isn't called LuckPerms
Okay. I had a typo (actually depends: and not depend:)
However, It's still saying the API isn't loaded: https://files.modrealms.net/screenshots/15.11.09-14.10.18.png
I found it. I used compile before which it didn't like, using compileOnly fixed the problem
Ahhh yeah
Hey! So I'm trying to grab the prefix and suffix of some offline players
When in the userFuture.thenAcceptAsync(user -> {} lambda, It doesn't seem to add it to the list?
This works fine, but then when I want to send the message from an offline user (e.g. from a Discord bridge), It just throws a jolly load of nulls
That's using the original code ^
Here's the code: (With no offline playerdata gathering, the top piece of code was my attempt of that) https://gist.github.com/TheFlash787/c55e3193e4ef443ca7d3c88a6af7b062
@jaunty pecan ?
Hey TheFlash787! Please don't tag staff members.
yeah, the getUser method returns null when the player isn't online
explained in more detail here: https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage#obtaining-a-user-instance
@rain lodge
I gave that a go
But no success
Would you be able to draft a quick example for grabbing the meta data using that method?
The code above shows me trying to use what you send me already ^^
Hello Guys i work with the luckperm plugin for 1 Week and now i would like to know how to give a permission to a player with the API. Maybe you have an code example or something like this. Thank you
@tacit moon There's an example on the wiki https://github.com/lucko/LuckPerms/wiki/Developer-API:-Usage
I know but it doesnt work my code: https://hastebin.com/cinomadutu.apache Thank you.
please can you give an example how to give an player ther permissions test.*
It's on the wiki
but why doesnt work my code ?
you need to save your changes
And how?
Is there a method to get a loaded users group's displayname?
@jade vine Get a Users primary group and get the group name. There are a few methods to check for the name. The javadocs should tell you which is the right one
Is there perhaps a plugin that bridges the PEx api to the LuckPerms api?
I'd be doubtful if that exists, at least I've never seen or heard of one
nobody would happen to have a pre-done user group i could just copy paste would they
:')
No.
Lol could've guessed
Do the work yourself, lazy.
What's the best way to check if a player got a new permission?
remember that this is the #luckperms-api channel
I meant the API. 😂
@prime basin What do you mean by got a new permission?
You want your function to run every time a permission is added?
Or you want to get all permissions?
I want a function that runs every time a new permission is added.
You gotta listen to the LP events
I know, I am currently using the UserDataRecalculationEvent but there is no way to check what has changed.
I'm using the LP event system. The problem is that I don't know what the right event is for that what I wanna do.
@prime basin if you’re using an IDE you should be able to browse the LP API jar and look which events exist
But there is no event for that...
There's an event that has Node in it's name iirc @prime basin
Thanks! I'm going to test it tomorrow.
ERROR; API is not loaded
How can I fix that?
load the API
How
Is that a server Error or a coding software error?
Server error
Put LP on the server
Are you sure it is a LP error and not caused from another dependency?
Lp error
Whats the full error message, or even better a console log?
remember you have to load it in your onEnable method
It worked before
your plugin needs to declare a dependency or soft dependency on luckperms
but yeah, i can't really comment without the actual error message / seeing your code
Hmm ill try things out. Tyy
Do luckperms have a limit for maximal permission string length?
200 characters for sql storage types, others have no such limit
Is the limit on the column just a database constraint which i could simply remove, or are there any other validations in code.
Ahh uhh
I'm not too sure
can't remember off the top of my head
ok, thanks
Also is it posisble to attach to one permission node some more context?
Let's say i want to have a permission node which last part will be an incrementing integer.
some.permission.max.amount.of.something:1
some.permission.max.amount.of.something:2
some.permission.max.amountof.something:.n
And then with luckapi i would check if the player has a permission "some.permission.max.amountof.something" and if the permission is present in the player context then get the integer value
Im on sponge btw
You should be using options / "meta" nodes for that
I need fast lookups, so iterating over all nodes and checking whenever they start with "some...:"is not an option for me
Is this somewhere more documented?
yes, meta values are cached
uhh, here
see: "build a metadata node"
& then use this for the lookup
see: "Retrieving meta data"
if you're using sponge, you also have the option of using the native sponge APIs for this
What LuckPerms calls "metadata" or "meta nodes" - Sponge calls them options
What is relation between a permission node and an option/metadata value (in player context
is it 1:1 or 1:n
Can a single player have one permission value with more metadata/options?
yeah technically players can have more than one metadata "value" for each key
however, the lookup methods will only return one result - usually the one that was inherited first
so if you don't want that, it's down to you to ensure any existing values are cleared before setting a new value - unless you use the Sponge API, in which case that is done for you
How do I get all players from a specific group?
If I call event.isUser in NodeAddEvent I get this error: [LuckPerms] Unable to pass event $Proxy47 to handler eu.unusa.core.listener.LuckPermsListener$$Lambda$1941/753419349 java.lang.reflect.UndeclaredThrowableException at com.sun.proxy.$Proxy47.isUser(Unknown Source) at eu.unusa.core.listener.LuckPermsListener.onNodeAdd(LuckPermsListener.java:25) at me.lucko.luckperms.common.event.LuckPermsEventHandler.invoke(LuckPermsEventHandler.java:108) at me.lucko.luckperms.common.event.LuckPermsEventHandler.invoke(LuckPermsEventHandler.java:45) at me.lucko.luckperms.lib.eventbus.SimpleEventBus.post(SimpleEventBus.java:107) at me.lucko.luckperms.common.event.AbstractEventBus.post(AbstractEventBus.java:84) at me.lucko.luckperms.common.event.EventFactory.lambda$post$0(EventFactory.java:124) at me.lucko.luckperms.common.plugin.scheduler.AbstractJavaScheduler$WrappedRunnable.run(AbstractJavaScheduler.java:79) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) at java.util.concurrent.FutureTask.run(FutureTask.java) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) does anyone know how to fix it?
@jaunty pecan ready for your daily wtf? xD
java.lang.reflect.UndeclaredThrowableException
update your API target
that exception basically means that the method declares an exception that it didn't used too from what I recall
has slightly different behaviour in proxy classes
although it should have a Cause too, which is usually printed afterwards
Is that the full error message, or was there anything else before/after?
@prime basin
Where can I get info on how to use this api
The wiki
OK thanks
This comes afterwards: Caused by: java.lang.IllegalAccessException: no private access for invokespecial: interface me.lucko.luckperms.api.event.node.NodeMutateEvent, from me.lucko.luckperms.api.event.node.NodeMutateEvent/public at java.lang.invoke.MemberName.makeAccessException(MemberName.java:850) at java.lang.invoke.MethodHandles$Lookup.checkSpecialCaller(MethodHandles.java:1572) at java.lang.invoke.MethodHandles$Lookup.unreflectSpecial(MethodHandles.java:1231) at me.lucko.luckperms.common.event.gen.GeneratedEventSpec$EventInvocationHandler.invoke(GeneratedEventSpec.java:149) ... 16 more
@prime basin for the future:
Exceptions can have multiple Caused by: blocks. They are ironically more important than the messages above. So when copying an error message be sure to always copy the whole thing
Okay, I couldn't send it because of the discord character-limit.
Hastebin
😶
i installed luckperms on my server and while in the server i can only perform luckperms commands (i am OP and gave myself all luckperms commands through console) i cant even do /help. I made a group called admin and then gave it perms and then added myself to it but i still have no access to any permissions
it was fine before i installed luckperms
a girl is LOST
This should be in #support-1
oop
Hello Guys i have an problem in my plugin when a player gets there a permission it is going to remove it when the player leave why? i use setPermission
I saved the changes
Then they should stay
But they dont
Is the API for external messaging services incomplete?
While I can implement it I don't see how to force LuckPerms to use it?
You can create a message provider, register it and everything but there is no way to make LP use it as configured values for the messaging service are hard coded.
Besides the plugin that registers the messaging service would also need to register it BEFORE LP loads for it to be used.
Ahhh I see, LP has an undocumented "custom" messaging service configuration value.
@wicked shadow mind if I ask what you need a custom messaging service for?
I see
@wicked shadow I know a friend of merijilin has made a custom LP messaging service. I think they're KaiNoName on github, the project might be there
hello guys how can i fix this problem above
Showing us your code might be a start @tacit moon
luckPermsApi.getUser(p.getUniqueId()).setPermission(luckPermsApi.getNodeFactory().newBuilder(kitManager.getKitPermission(clickedSlot)).build());
luckPermsApi.getUserManager().saveUser(luckPermsApi.getUser(p.getUniqueId()));
this works but when the player leave it remove the perms
Try saving the user instance returned by luckPermsApi.getUser(p.getUniqueId()) in a variable
Ok i will try it later
Yeah @tacit moon there you're getting the user from the database, modifying your local copy of it, then doing nothing with it. Then you get it again, then save it
Ok thx i will try it
Also just for efficiency, cache objects in variables when you use them again
Why?
@faint geyser cloudflare is blocking your request
Probably because you've made too many
how can i solve it @thorny echo
No idea @faint geyser
ok Thanks @thorny echo
Hey JOz4! Please don't tag staff members.
ok
How can I solve: API is not loaded?
Im using Maven dep for LuckPermsAPI
And for some reason I have this: http://prntscr.com/le91lv
@normal hedge make sure LP is installed on the server
Its in all my plugins folders
And make sure you're shading it, therefore of type provided
No
ehm
?
The API must not be shaded!
LP implements the API. Shading it cannot work
I haven't used Maven but you have to compileOnly instead of compile in gradle. I just used the wrong word
Also make that your plugin declares a dependency on LP so LP loads first
While that is recommended, it’s not necessary @thorny echo
@normal hedge also don’t try to access it before onEnable
@crystal sonnet what do you mean? compile shades it right
No
shade shades it
Oh wait. That’s gradle. But it won’t get shaded in if you don’t have the shade plugin
🤔 what about if I've got the shadow plugin installed
Exactly
If you've got any other dependencies that need shading then you have to install the shadow plugin which means that things marked as compile will be shaded
Yeah. Shouldn’t be an issue though
Shading doesn’t relocate by default
So it’ll still work. At least the basics
Well I've used compile before on plugins that use the lp api and it hasn't worked
Worked as soon as I changed it to compileOnly
If I load the user, rather than getting them, is it guaranteed that that is up to date?
Uh.... turns out you can't access MetaData inside of a ContextCalculator
kind of makes sense but uh
kinda screws what I was about to make :9
Hey @jaunty pecan, I have a question, sorry for pinging you
Is there a way I can grab metadata inside of a contexts calculator? I'm working on a plugin that uses LP meta to store whether a staff member is in staff mode, and displays that as a context
But it causes a recursion stack overflow if I calculate contexts inside of a ContextCalculator
I can't believe you've pinged our God, our worthy one. God bless his soul
Oh wait nevermind me I can use Context.global()
I know 😮
Hey Void! Please don't tag staff members.
here's the "rules" for implementing context calculators
they're unwritten rules at the moment, but eventually will be added to the LP & Sponge javadocs
yeah that's ok
👌 thanks
Also I got errors longer than hastebin upload allows when I did recursive contexts accidentally 😰
I'm new here. Can i when the player change his rang update him(I mean the tablist...). Sorry for my bad English i'm from Germany
I’ve read it like 3 times
Even tried translating it back to German
But I still have no idea what you want to say
I would like if the edge of the player is changed to update his tabliste, is there an event for that? (Google translater)
@civic oxide nochmal auf deutsch bitte
Und versuche https://deepl.com
Use the free DeepL Translator to translate your texts with the best machine translation available, powered by DeepL’s world-leading neural network technology. Currently supported languages are English, German, French, Spanish, Italian, Dutch, and Polish.
Kannst du deutsch?
Nein. Ich tu nur so
Can someone help me how to check does player have temporary group with LP API?
Anyone?
Ich möchte wenn der Spieler einen Rang bekommt die Tablist und das Scoreboard updaten
@dull orchid you want to check for temporary groups only, or just groups in general?
@civic oxide es gibt ein Event, wenn sich Permissions eines Spielers ändern. Im Wiki steht mehr
kk
@jaunty pecan i know how to check for permanent group, but i need for temporary
Hey Lobenski! Please don't tag staff members.
Ops sry
@dull orchid Get the group Node object, there should be a method like .isTemporary()...
Yeah one sec
List<Node> nodes = user.getAllNodes();
Node found;
for (Node node : nodes) {
if (node.isTemporary() && node.isGroupNode() && node.getPermission() == "group.moderator") {
found = node;
}
}
// use found
@dull orchid
Ty 😃
Can you also use the api for bungeecord
yep
Hey iFlyinq! Please don't tag staff members.
How can i check if an group has an specific permission?
Myb
for (Node node : nodes) {
if (node.isGroupNode() && node.getPermission() == "perm.ission") {
//Return true?
}
}
@wispy harness
@dull orchid That won't work
They want to check if a Group has a permission. Your code will loop through a Users permissions, and that if statement is broken, a node can't be a group node and have a permission other than group.something
Kk 😆
How to get player's parent group name?
kk, ty
Your IDE's autocomplete is a powerful tool...
Is it possible to use the API through a Bungeecord plugin? As soon as I try to get an instance of the API I get an error that the API is not loaded.
@arctic moon yes it is. Make sure that’ your plugin depends on LP (soft or hard dependency is up to you) and make sure to not try to access it before your onEnable
How can I do register this LuckPermsAPI in my main as an instance? As soon as I tried it, I got an error called Caused by: java.lang.IllegalStateException: API is not loaded..
@nocturne elbow Make sure you're not shading it in and that you depend upon it in your plugin.yml
In my plugin.yml it says depends: [LuckPerms]. It's for BungeeCord
`ProxiedPlayer proxiedPlayer = (ProxiedPlayer) commandSender;
LuckPermsApi luckPermsApi = LuckPerms.getApi();
User user = luckPermsApi.getUserManager().getUser(proxiedPlayer.getUniqueId());`
Are you shading it?
I'm working with maven an I shade it, yes.
You're welcome!
Hullo
How can I change a rank/parent of an user via the API? I tried it by using this: `
User user = luckPermsApi.getUser(args[0]);
UserManager userManager = luckPermsApi.getUserManager();
user.setPrimaryGroup(args[1].toLowerCase());
userManager.saveUser(user);`
@nocturne elbow the wiki should have examples on how to change player groups. Setting the primary group is not the way to do it. I’d also recommend you read the java docs your IDE displays when hovering over methods.
Okay, thank you.
Is there a way to check if an user inherits a group from a string?
so if I had a rank called "admin", check if it matches a luckperm group called admin
Sure. Get all the players permission nodes and check if it contains group.admin
Or even easier just check if the player has the permission group.admin through the platforms permission system
That’ll only work with LP though @jade vine
That will give me a Tristate, won't it?
Because if I use hasPermission it needs a Node
Can I check if the permission is true or false with the tristate though? Looks like you can, just inspected the enum
I’d recommend you use the platform’s checks unless you need to check for offline staff
Yes you can. It has the respective conversion methods
Oh there's a asBoolean method
Yup. Will only return true when the tristate is true
Alright. Thank you for the help, appreciate it!
You’re welcome
How can i got rank time?
for how long it its
for specific player
I Want to check player group and time
@lone spoke check the examples on the wiki
Hello
What event should I use, when I want to check that player's temporary permission expired?
is there any event like onParentSetEvent ?
No. But a more generic event when permissions get changed
Hi, i've got an question,
wassup?
How is the messaging between multiple servers with Luckperms? 😮
Bcz in Console i see SQL Messaging
You want the code explanation or the overview?
Well basically there's a bunch of drivers that define how pings can be sent across servers
Each driver can put it's own config in the config.yml, for example the redis driver adds a redis host config option
yeah, but when i use MySQL;
Then each driver has to do it's job and send messages to any servers that need them
How did he ever made that 😮
The sql driver uses a message table I believe
Basically just a table each instance spams ARE DERE NEW MESSAGES?
Its lagging af isnt it?
Its pritty instant 😮
HMM
xD
Bcz i want to create a new Plugin to link discord accounts etc
And i want to use a Messaging channel to do that.
But..
Let LP deal with carrying messages
The linking part itsself.
Ah
Like that when you type in your MC name in DC its instant opening a book on the server.
Like that xd
And Bungee
Use HTTP requests
option a) Run a Spark http server from the bungee plugin and call it using your fav http library from a discord bot
option b) Run a redis server and ferry messages through it
And it's not great practice but you can run JDA from a bungee plugin
I've done it before 😛
I also do that xD
@wispy harness even at a rate of 0.1 ms you wouldn’t feel anything. As it’s async anyways
MySQL is pretty decent at handling a ton of connections
If the ping is low enough, absoltely not
Hmm
When i try to do each 60 seconds a check its allready in the Timings for lagg.
There should be plenty of tutorials for your platform
And you can do it with plain java too
^
Async is not magic
xd
command hey:
trigger:
execute unsafe "SELECT {@oyuncuadi} FROM {@database} ORDER BY {@tablo-satir} DESC LIMIT 0,1" in {murder} and store the result in {1::*}
set {_grup} to value of placeholder "luckperms_primary_group_name" from {1::playername::1}
broadcast "%{_prefix}% %{_grup}%"
He can't get any data at all. {1::playername::1} There is a problem with this section.
Can you help me?
Hello people, with which event can I query whether a user has changed the group? Please Tagg me with @frigid leaf
Aight so, I code SavageFactions, Im trying to use an async task in a method but I cannot actually return a value as the values have to be final if used in the actual code it self. So how about I be able to return a value?
public String getPrimaryGroup(OfflinePlayer player) {
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
return perms == null || !perms.hasGroupSupport() ? " " : perms.getPrimaryGroup(Bukkit.getWorlds().get(0).toString(), player);
});
}
Obviously you cannot do this because the lambda will take the return value not the actual method we wanna return for. Could anyone of the people give any ideas
Luck perms wont let my plugin perform lookups as theyre on the main thread
and I cannot do a async task
cuz
i cannot return
@jaunty pecan
Hey ProSavage! Please don't tag staff members.
ProSavage, you can use callbacks. Pass a Consumer<String> to the method
And then call that once the value in the async task is found
Awesome, Ill keep that in mind Luck!
Hei 😃 i know this is a really dump question but im new to it. who can i add a permission to a user which is only applyed to one world and only a specific time... hope anyone can help me 😃 thanks alot
Check the docs for NodeFactory
I believe there's something like .setContext("server", "lobby");
i ve looked there but i´ve not found something like this....
i think im too stupid to use luckperm...
can anyone just send me an example of this.... :/
no one? ok...
Wiki
i just looked there... the wiki is confusing
i want to set a permisson to an user for a specific time and only in one world...
Use the NodeBuilder. Set the time and the context
And for the context use the ContextBuilder
.. ok but my Problem is that my English is Not the best and i dont understand much of the explanation in the Wiki...
Then there’s really not much we can do
What's API? If anyone calls me a noob, I'm pulling out my .44 magnum and blowing your brain to bits.
Ofc I'm joking.
Google is a thing. And I’m mentioning this because you’ll find better answers there than I could here
pulls out glock
Jeez
Hey iFlyinq! Please don't tag staff members.
wiki is a thing @wispy harness
Cant find anything on the wiki.
I'm down
xd
OWHH
On the usage tab 😦
What is the event called when a player's parents are getting editted?
?
Hello?
@crystal sonnet sorry for mention
Hey iFlyinq! Please don't tag staff members.
@wispy harness there's only an event for when nodes change
You'll need to implement checks yourself if that meant a parent changed
& is that also getting fired when a players temp rank is gone?
Ill test.
You'll need to check
Thanks for responding & sorry for mention.
It isn't even working.
public ParentsUpdateListener(LuckPermsApi api) {
EventBus eventBus = api.getEventBus();
eventBus.subscribe(NodeAddEvent.class, this::onNodeAdd);
eventBus.subscribe(UserLoginProcessEvent.class, this::onShit);
}
private void onNodeAdd(NodeAddEvent e) {
System.out.print(e.getNode().getPermission());
System.out.print(e.getTarget().getFriendlyName() + " -> " + e.getNode().getPermission());
}```
are you sure the ParentsUpdateListener constructor is being called?
I know these events work because I use them myself in other projects :p
Strange
Bcz if i use eg UserLoginEvent
In that class
Its working.
& Its Bungee.
hello, can i check player's permission in AsyncPlayerPreLoginEvent?
there is way to get hasPermission() in ApiUser?
LuckPerms.getApi().getUserManager().loadUser(player.getUniqueId()).join().hasPermission("test")
Don’t use the join() also the wiki has examples @nocturne elbow
Check the wiki for examples
there is no example for permission 😦
only for groups
and for groups it works
but not for permission
There’s is an example for loading players
And certainly one to check permissions
You do it the same way for groups and players
Also your IDE should help you with the methods
And you should add the Javadocs of the API or the source so you can see the docs in your IDE
That’s incredibly useful
LuckPerms.getApi().getUserManager().loadUser(event.getUniqueId()).join().getPrimaryGroup()
it works
Why are you calling join()?
because player is offline
Doesn’t matter
and it doesn't work without join()
It certainly works for me without
But gimme a minute
And thanks for ignoring my comment above ^^
Oh my apologies
It returns a CompletableFuture
yes
So join() is needed.
i know
I mean all it does is wait for the user to load. Not making them join the server
And I’m certain there’s an example on the wiki showing how to do that
Does that example here help @nocturne elbow ?
@jaunty pecan Can you help me?
Hey PerryPlaysMC! Please don't tag staff members.
shush
No I can't, you haven't provided any information about what you want help with 😉
General rule is: don't ask to ask (even though you may see it as being polite, it just slows things down) - just ask your full question, give all the info you have, and wait patiently for a reply
;p
Your API Commodore won't work for me
I copied your Example
and it still didn't work
Can you join my server and I can show you?
@jaunty pecan
Hey PerryPlaysMC! Please don't tag staff members.
well, the library definitely works, I use it myself :p
so you're probably doing something wrong
I need to see your code / any errors you're getting to be able to help
PluginCommand command = getCommand("testa");
if (CommodoreProvider.isSupported()) {
// get a commodore instance
Commodore commodore = CommodoreProvider.getCommodore(this);
// register your completions.
registerCompletions(commodore, command);
}
}
private static void registerCompletions(Commodore commodore, PluginCommand command) {
commodore.register(command, LiteralArgumentBuilder.literal("testa")
.then(RequiredArgumentBuilder.argument("some-argument", StringArgumentType.string()))
.then(RequiredArgumentBuilder.argument("some-other-argument", BoolArgumentType.bool())
.argument("Hey", StringArgumentType.string()))
);
for(LiteralCommandNode<?> a : commodore.getRegisteredNodes()) {
System.out.println(a.getLiteral());
}
}```
PluginCommand command = getCommand("testa");
if (CommodoreProvider.isSupported()) {
// get a commodore instance
Commodore commodore = CommodoreProvider.getCommodore(this);
// register your completions.
registerCompletions(commodore, command);
}
}``` is in onEnable
Hey PerryPlaysMC! Please don't tag staff members.
It loads it as /minecraft:testa but it doesn't have the argument thing
saying "some-argument" or "some-other-argument"
that's because some-argument is nested under "testa"
however, that's an issue with your usage of brigadier, nothing wrong with commodore
you can view more info about how to use brigadier here: https://github.com/Mojang/brigadier#registering-a-new-command
literal means one of the options NEEDS to be present in order for the command to go through
If the first argument of a command is a literal and you supply the options ONE TWO and THREE then you must supply one of those when running the command
/testa ONE would be valid, /testa five would not.
How do I fix the CommandSyntaxException?
I don't understand it
CommandDispatcher<CommandSource> dispatcher = new CommandDispatcher<>();
LiteralArgumentBuilder<CommandSource> s = LiteralArgumentBuilder.literal("testa");
s.literal("testa").then(argument("aye", StringArgumentType.greedyString()))
.then(
argument("bar", integer())
.executes(c -> {
System.out.println("Bar is " + getInteger(c, "bar"));
return 1;
})
).executes(c -> {
System.out.println("Called foo with no arguments");
return 1;
});
dispatcher.register(s);
final ParseResults<CommandSource> parse = dispatcher.parse("", getConsole());
final int result = dispatcher.execute(parse);```
I have this
copied the stuff from the git
@jaunty pecan i secretly have feelings for you
Hey Vaughn! Please don't tag staff members.
Oh shit, sorry
@rancid moss gay
@rancid moss i have feelings for you
🏳️🌈
@fossil girder lmao
lol
@jaunty pecan @jaunty pecan we talked yesterday about working with permissions to our core... But the thing is...
We want to get the data before player joins.. Example you gave me an example about the whitelist.
But the player have first to join the server to get the whitelist data and then get kicked or how do you manage that?
Hey /home/UserRoot! Please don't tag staff members.
Sorry...
Lol apologising to a bot
use the PlayerLoginEvent
Dang... Sry
What if there's a human being typing all this shit?
It's me
Then tell it to stop saying the same thing every time it speaks
The staff joked long before I was a mod that I would be a good replacement for clippy
I'm real clip gang
He doesn't know other words, stop
how can i check a users group in luckperms using the api?
@keen rain the wiki has a lot of examples
How can I get the primarygroup of a user? Because if I go trough all the nodes I don't see a object like isPrimaryGroup.
@jaunty pecan do you know that? or is that not implemented in the API?
Hey NoPermission | Joël! Please don't tag staff members.
It's a method on User
Oh yea I forgot you can grab the name of the primarygroup and then get the group object through the getGroup method
Thanks
I use "user.setPrimaryGroup("default")" but it doesn't do anything.. can anyone explain me why and what to use?
As said before, check the wiki
how to get the parent from a user?
Did you check the examples on the wiki?
hey, how can i get duration on group ? (expiry time)
is it like in metadata or where ?
Did you check the example on the wiki @echo harness
im looking in developer api usage for like 15 minutes now
i think i can get it in user.getAllNodes()
because when i looked in javadocs i saw there getExpiry()
You can get the primary group of a user
user.getPrimaryGroup() like that ?
turn it into a group node and get it from the player, then check the time
ohhhh
Group nodes are literally just group.<group>
And if you can't get the node directly, get all nodes, stream them, filter by their name and bam
*permission
i dont think expiry time is in group instance
You need a node instance
Set<String> groups = user.getAllNodes().stream() like this ?
then filter it and get expire time ?
it must be there
because in javadocs theres getExpiry under node
If it's a xxx<String> then you have the wrong method
The user method needs to return xxx<Node>
And then use normal stream semantics on it
well getExpiry is date
so do i do like Date expiry = user.getAllNodes()......
?
i think i got it
Date expiry = user.getAllNodes().first().getExpiry();
oh this wont work am i right...
not quite
public Date getExpiryTime(User user, String group) {
return user.getOwnNodes().stream()
.filter(Node::isGroupNode)
.filter(Node::isTemporary)
.filter(n -> n.getGroupName().equals(group))
.map(Node::getExpiry)
.findFirst()
.orElse(null);
}
well i would not get that either :DDD
thank you
i wasted my time figuring it out 😄
ya it's just stream magic
but i was going the right direction 😄
the equivalent code just using java loop / selection constructs looks like
public Date getExpiryTime(User user, String group) {
for (Node n : user.getOwnNodes()) {
if (n.isGroupNode()) {
if (n.isTemporary()) {
if (n.getGroupName().equals(group)) {
Date expiry = n.getExpiry();
return expiry;
}
}
}
}
return null;
}
oh
im so dumb ...
i did this getExpiryTime(user, this.plugin.api.getGroupManager().getGroup(user.getPrimaryGroup()));
then saw it requires String....
👍
ye im making my own placeholder
nice!
ye i know
like u mean
primary will be default
and second one would be temporary ?
for example vip ?
i have addtemp
and that always sets the new one to primary one doesnt it ?
it does work
but i have question
if theres two temporary groups
and first one expires
will it set the second one to primary ?
i will make the code check if expiry is null and if it is it will make the tab just empty
your API is brilliant
yeah im not that terrible with java
Luck, when i want to check for permission expiry time
do it need to filter if its permission ?
like if u have isGroupNode
do i need to do something like that too ?
.filter(Node::isTemporary)
.filter(n -> n.getPermission().equals("cmi.command.fly"))
.map(Node::getExpiryUnixTime)
.findFirst()
.map(e -> formatTime((int) (e - currentTime)))
.orElse(null);
``` i have this atm, is there something wrong about it ?
Looks good
im little bit scared
what if GROUP get thru first filter
and then hits n.getPermission
that will do error wouldn't it ?
Though a small tip, have the filter like this n -> "cmi.command.fly".equals(n.getPermission())
whats the difference ?
It's NullPointer safe
a string constant can never be null
i have never though of that
But a method can return null, even if it promises it doesn't
this tip will solve the issue
if it hits non permission node
it will not throw nullpointer
Yes
oooohhh
well it will find random in array am i right ?
and it doesnt matter
because there will be only one thing
If you can only have one match at most (which is the case if you're looking for a specific node), findAny is the better option
well what does findAny do ?
Because it allows the stream to be processed parallel, if it wants to do that
While findFirst requires the stream to be sequential
"well what does findAny do ?"
It finds any one element in the stream
like random element ?
if there are multiple, it can be any
it's relevant when you have a parallel stream
findany is only in stream right ?
It's a method of stream
use it exactly as findFirst
As long as you don't need explicitly the first element in a stream, use findAny
It's either faster or equally fast
findAny gets random element from stream ?
No. The first it finds
oooh
but it doesn't necessarily have to be the first element in the stream
like if the stream is processed parallel, the order may become mixed up
ok ty
And can never be slower
return user.getOwnNodes().stream()
.filter(Node::isTemporary)
.filter(n -> "cmi.command.fly".equals(n.getPermission()))
.map(Node::getExpiryUnixTime)
.findAny()
.map(e -> formatTime((int) (e - currentTime)))
.orElse(null);
So if you don't need the first element that matches, but just one element that matches, it's the better use
cant be better now right ?
Not really
well its good enough
that#s as good as you get with streams
@crystal sonnet can u get all players in group ? even offline ones with API ?
Hey Poggik! Please don't tag staff members.
i have this list
but i made it with config
and u just set staff member
is there a way to make it with api ?
The wiki has examples on how to load offline players
Not by heart
i need to get all names from group
You can load all players (that's slow so only do it async. And cache the result) and check if they have the respective group.<group> node
load all players with luckperms ?
Yes
how do u make it in async ? u do async method or ?
The wiki has examples on how you can get all players known to LP and how to load the data of a single player
Don't run it on the main thread
well i can do for loop cant i ?
Bukkit should have methods for that
oohh
Streaming is better
with scheduler ?
Probably
theres async thing
What's so hard to understand that I don't know much about the Bukkit API?
its ok i understand
There's a thing called google
im googling already
good
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
// code goes here
}
));
that was easy
i knew it was in scheduler
With Java 8, you can even use lambdas
Google 🌈
i cant understand lambdas lol
For example in .filter(Node::isTemporary) the Node::isTemporary is a special type of lambda expression
I forget what that is called
But where the method exprects a runnable, you can pass a method
i cant really find getting all users in developer api guide
could you please redirect me ?
Then check the Javadocs
oh its only in javadocs ?
I have done it before, but I don't have the source handy
WIthout trying to be rude, it doesn't sound like it
Minecraft isn't known to be beginner friendly
well
i think i got it without even looking into javadocs
api.getUsers()
now i add .stream() right ,
?
Yes
ok nice
load their data
and then your can work with them
i want all users
like checking if they have the group permission you're looking for
oh right
well
this is not effective way
because look
i have like 7 groups
and i cant do 7 streams
that would be slow af
Or checking all their group permission nodes
how about storing all player names with group names ?
Then you need to turn into a map
then just handling that hashmap
Something like Map<User, List<String>>
yea
Or Group instead of String
yes
how about storing their name instead ?
because i dont need anything else
just name
If you just need their name, then sure
And how to turn a stream into a map can be found online
going to google it now
ehm
i think i got it
Map<String, String> fest = this.plugin.api.getUsers().stream().collect(Collectors.toMap(User::getName, User::getPrimaryGroup));
oh
And you don't need to worry about online players
If you try to load their data, nothing will happen
So if you can treat online players the same as offline players
lemme have a look
give me second
well i see UserManager#loadUser
which works on offline and online users
yup
should i use that one ?
yes
i think i got it
You still haven't checked the wiki,