LuckPerms

LuckPerms

1M Downloads

Straightforward Library Usage for Custom Platforms

mega12345mega opened this issue ยท 0 comments

commented

Description

I'm attempting to use LuckPerms as a permissions manager for a (Minecraft-related) standalone program. Right now, there is a lot of boilerplate (see the amount of code for LuckPerms/standalone).

Proposed Behaviour

Ideally, I would be able to do something like this after adding LuckPerms as a Maven dependency:

// StandaloneLuckPerms(String platformName, LuckPermsConfig config, Path dataFolder, Consumer<String> consoleOutput, BiConsumer<UUID, String> playerOutput)
// Ideally, the supplied config could be edited and created by code, rather than being loaded from a file
// The config could also just be a ConfigurationLoader like in the ConfigurateConfigAdapter to make this suggestion easier to implement
StandaloneLuckPerms lp = new StandaloneLuckPerms("Platform Name", config, Path.of("luckperms_data_folder"), System.out::println, (playerUuid, msg) -> ...);
lp.start();

lp.execFromConsole(List.of("user", "mega12345mega", "permission", "set", "*", "true")); // Commands would come from my own CLI
lp.execFromPlayer(playerUuid, List.of(...));

Tristate permTrisate = lp.getPermissionState(playerUuid, "permission.name");
boolean hasPerm = lp.hasPermission(playerUuid, "permission.name");
assert hasPerm == permTristate.asBoolean()

lp.close();

My current messy code that does essentially this is ~600 lines. Note that I also am currently relying on LuckPerms/common which itself could be made more straightforward by adding it to Maven: #3825

In my situation, I would also benefit from being able to embed all of the LuckPerms information in the SQLite database I'm already using instead of a data folder, so everything would be self-contained, but this isn't required. (Obviously this would significantly complicate things, especially considering the database will also have my own data in it)

Extra Details

Right now, the dependency management is also a bit messy for this use case. Ideally, when I depend on this, all of the other dependencies would come with it and be managed by Maven instead of having to be loaded separately by LuckPerms at runtime and stored in a separate folder.

Context: Why use LuckPerms for something that isn't a Minecraft server? (This is still a server that players will be able to login to with their Minecraft account)

  • Minecraft players are likely to already be familiar with LuckPerms
  • LuckPerms already provides a group system, wildcards, web editor, and handles usernames and uuids out of the box