#luckperms-api

1 messages · Page 55 of 1

muted acorn
#

but what type of variable should it be

#

on docs

#

for api users

#

says like

nocturne elbow
#

private bro

muted acorn
#

LuckPerms api = LuckPermsProvider.get()

nocturne elbow
#

well this is up to you

muted acorn
#

no not in that way

nocturne elbow
#

and your preferences

muted acorn
#

well what should be the best

nocturne elbow
#

getting it as a local variable is not recommended

muted acorn
#

why

nocturne elbow
#

since this can fuck up things if you're working on different threads

#

not sure if luckperms has thread safety

muted acorn
#

goddamn it

#

AHHAHAHA

#

so many things

#

okay

#

and how should i get player rank for example

nocturne elbow
#

User#getPrimaryGroup()

#

then use GroupManager#getGroup(String primaryGroupName)

muted acorn
#

yeah

#

ill figure it out first to find user hahahtard

nocturne elbow
#

it explains that very clearly

muted acorn
#

i will

nocturne elbow
muted acorn
#

ty for helping me out ❤️

nocturne elbow
nocturne elbow
rustic mirage
#

!extracontexts

frank driftBOT
nocturne elbow
#

@fringe torrent Is there anyway can i get use of the DateMutateResult

fringe torrent
nocturne elbow
gloomy panther
#

!hack

frank driftBOT
#
Has LuckPerms been exploited/hacked?

Most certainly: no. In most cases a 'LuckPerms exploit' is a simple case of human error, which can be avoided easily. Look below for some tips to be on the safe side.

Don't give random people full ( * ) permissions / admin permissions

While this should be obvious, a lot of times a exploit can be traced back to faulty permission settings. You should always take your time with permissions and read the plugin documentations. In 99% of all cases the plugins have documentations explaining each permission, in the rare case that the plugin you are using does not have a documentation, you could still:
A: Ask the plugin developer for help
B: Use LuckPerms verbose functionality ( !verbose )
C: Select a different plugin with proper documentation.

Do not run your server/network in offline mode

If you are running your server or network in offline mode, hackers have it really easy to steal your, or any other admins identity. While the server is in offline mode, certain checks ( which exist to prevent exactly this ), are being skipped, and the server does not verify if the person joining actually is the person they claim to be. While there may be plugins which increase the security of offline mode servers by adding things such as admin codes, you should just switch it to online to prevent the issue in the first place.

Do not download plugins from shady websites / sent by friends

You should never put anything on your server which has not been downloaded by yourself from official sources. Plugins can be infected with malware which injects itself into all other plugins, and thus is hard to remove. While it may look like a plugin has been hacked, you most certainly downloaded a modified version of it and it is not the plugin authors fault. In case your server has been infected by such malware:

  1. Stop the server
  2. Delete all plugins in your plugins folder, and just to be safe also the server jar file
  3. Re-Download all plugins and server jar files from official websites such as SpigotMC or official plugin websites ( luckperms.net for example ).
  4. Check if there have been any modifications to the permission system and remove unknown users and wrong permissions.
    if you follow these steps you should have a clean server by the end, without exploits.
nocturne elbow
#

Hey guys

#

when i try to load a user

#

from LuckPerms

#

and the user is offline

#

it can't load it

#

it returns null

#
@Override
    public @NonNull Group getPrimaryGroup() {

        AtomicReference<Group> group = new AtomicReference<>(null);
        this.toLuckPermsUser().whenComplete((user, throwable) -> {
            if (throwable != null) {
                throwable.printStackTrace();
                return;
            }
            if(user != null) {
                Group g = LuckPermsProvider.get().getGroupManager().getGroup(user.getPrimaryGroup());
                group.set(g);
            }
        });

        return Objects.requireNonNull(group.get());
    }
#

does anyone know the issue ?

fringe torrent
#

LuckPerms unloads offline users

nocturne elbow
#

this method shouldn't get it from the memory

fringe torrent
#

Sure seems like it's unloaded still

nocturne elbow
#

it loads in a separate thread

#

and the operation might finish in the future

#

but you try to return immediately

#

i ain't putting that in the main thread 😛

#

how can i like sort the tasks

#

even if they're being executed in different threads

#

return a CompletableFuture<Group>

#

or block the main thread until the operation completes shrug

nocturne elbow
#

your call, not mine, i'm just giving you options

#

is there a way to make a future callback ?

#

you could also make that function take a Consumer<Group> instead of returning a future<group>

nocturne elbow
#

thenAccept, thenApply, whenComplete etc

#

ye but like returns the value when it's completed somehow lol

#

nvm

#

if you return a Group, you need to wait until it's completed

#

either return a future or take a consumer which you call in whenComplete

#

is this fine @nocturne elbow

frank driftBOT
#

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

nocturne elbow
#

yeah that looks fine, what's the impl for getPrimaryGroup?

nocturne elbow
#

still modifying the impl

nocturne elbow
#

looks fine, I don't think user can be null but it's okay

nocturne elbow
#

it worked !

#

loaded the use successfully

#

btw do you have any good resources to get more deeply into Completable Futures

vapid thicket
#

Hello everyone! Im doing a plugin whitelist-like.

When i do the comparison from a COFNIG PERMISSION and a LP PERMISSION

As you can see from minecraft they are the same,

But "hasAccess" never turn on true, you know why?

#

Yellow = config
Green = Luckperms

turbid solar
#

don’t == strings

#

use .equals

#

.equalsIgnoreCase etc

vapid thicket
#

🙂

#

Imma shot myself

#

thanks

main dagger
nocturne elbow
#

it would kinda improve performance

#

and skip unnecessary iterations

vapid thicket
#

Yes i know

#

I have toggled the break just for test

#

Thanks anyway, awesome community

nocturne elbow
# nocturne elbow btw do you have any good resources to get more deeply into Completable Futures

(apparently I left this message here since yesterday without sending it lol)

Mmh Baeldung's guide to CF's is nice https://www.baeldung.com/java-completablefuture and the javadoc can be useful too, although a bit too wordy https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/CompletionStage.html
There are a few conference talks online about how to use them, why they're nice etc etc, the ones from this speaker are quite good IMO https://www.youtube.com/results?search_query=venkat+subramaniam+completablefuture

clever zodiac
ebon vault
#

Hello! I'm trying to connect LP to my server's site where users can assign themselves a LP group by clicking a button. So what the best approach to do something like this? Now I'm adding group.some permissions to the lp_user_permissions table. This works fine, but I'm curious how bad this practice is

wild whale
#

Well in an ideal world, you'd add the node via our API, LP isn't really designed with external DB modification in mind. I suspect it'll mostly work, but you'd probably need to also send a message via whichever messaging service, or otherwise trigger a resync

ebon vault
#

Ah, I see, so the best way is to write a small plugin that can be triggered externally and send updates to the LP API?

wild whale
#

that's the ideal method, yes

ebon vault
#

OK, thanks

nocturne elbow
late owl
#
net.luckperms.api.LuckPermsProvider$NotLoadedException: The LuckPerms API isn't loaded yet!
This could be because:
  a) the LuckPerms plugin is not installed or it failed to enable
  b) the plugin in the stacktrace does not declare a dependency on LuckPerms
  c) the plugin in the stacktrace is retrieving the API before the plugin 'enable' phase
     (call the #get method in onEnable, not the constructor!)
        at net.luckperms.api.LuckPermsProvider.get(LuckPermsProvider.java:53) ~[?:?]
        at cz.gennario.minecraftdiscordsync.Main.onEnable(Main.java:49) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:599) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:298) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-794]
        at java.lang.Thread.run(Thread.java:833) [?:?]```
Anyone know what's causing this? I've checked depends and luckperms is installed and loads before this plugin
wild whale
#

Have you checked all 3 things the error lists

late owl
#

I have yes

late owl
nocturne elbow
#

Make sure you are not shading the LP API inside your jar file

late owl
#

I have no idea what that means haha, I'm not a dev just had this plugin made and the dev is now MIA. If any of you guys are freelancers I'd be more than happy to pay for you to take a look at it and fix whatever is causing that error

wild whale
#

Not a marketplace

#

Open up your built jar with any tool that can open .zips, see if there's LP files in there (net/luckperms/...)

wild whale
#

Yup ok you're shading LP (including it in your built jar)

late owl
#

folder called "api"

wild whale
#

What build tool are you using?

late owl
#

I used winrar to look at it if that's what you're asking?

wild whale
#

Nope, what tool are you using to build the jars? Maven? Gradle?

#

(put differently, how are you building jars?)

late owl
#

I am not, I had a developer make the plugin for me and they went MIA after payment, unfortunately.

wild whale
#

wonderful...do you have the source code?

late owl
#

I do

wild whale
#

ok root directory, is there any files pom.xml, build.gradle, build.gradle.kts?

late owl
#

None of those

wild whale
#

could you show what is in the root project directory?

late owl
wild whale
#

That's not source, that looks like the result of unzipping it

late owl
#

Ah, that's unfortunate

#

I only have this and then the jar

#

Let me decompile the jar

wild whale
#

wonderful...all right long shot that may or may not work:
make a copy of the jar, and unzip it. Delete the luckperms folder in net (if there's nothing else in net, you can delete it too)
rezip the files and rename it back to a .jar.

I'm not 100% sure that'll work, but without source code that's the best I can really do short of having to rebuild the entire plugin

jaunty pecan
#

deleting the luckperms folder from the zip should work :]

#

you may also need to delete META-INF

wild whale
#

ok good, wasn't 100% on that

late owl
#

Starting the server now

#

Worked! Thank y'all

#

I appreciate it

urban barn
#

how to check if the player is, for example, in a vip group

#

????????????????????????

fringe torrent
#

??????????????????????

#

Have a bit of patience and don't crosspost, when someone who knows is available they will, if they want, help

turbid solar
#

iterate over groups and check the name

#

!cookbook

frank driftBOT
craggy surge
turbid solar
#

that’s not api

unkempt mortar
#

yo i need help because i can't use luckperms in my plugin. i have it in project structure

turbid solar
#

well you need to get the instance first

#

also idk if adding that constructor works for bukkit plugins

wild whale
#

and that error at the end of the ctor is you trying to set the luckperms variable to itself

native tartan
#

Hello i have a question i updated my plugin from 1.16.5 to 1.18.1 and i had a luckperms code in it for my scoreboards. And now i updated the dependencies & everything and now it says that on the pic can anyone help me pls?

#

And on the server is the newest version of luckperms

wild whale
#

that error gives possible causes, have you checked all of them?

native tartan
#

what i know yes

#

but now idk what it can be more then the error says

wild whale
#

have you shaded LP?

native tartan
#

no bc i used it for my tablist and scoreboards and before i updatet it to the 1.18.1 version it worked fine

#

The error comes from this code

wild whale
#

what build tool are you using?

native tartan
#

maven, the luckperms version i have in my pom.xml is the 5.4 and the plugin version from the luckperms plugin is 5.4.35

wild whale
#

in your pom do you have the LP dependency set to scope provided?

native tartan
#

provided

native tartan
#

Idk what i can do know bc of the errors it doesnt load the tablist and sb

turbid solar
#

when are you calling updateRang

native tartan
#

On my second server it works with errors so idk what i did false 😅 (the same errors i already sent)

native tartan
native tartan
#

Anyone knows how to fix it?

harsh bolt
night pier
#

UserPromote/DemoteEvent should only be fired when they're promoted/demoted on a track according to the javadocs