Skip to content

Add minestom platform support#1

Draft
TheMeinerLP wants to merge 4 commits into
masterfrom
feature/minestom
Draft

Add minestom platform support#1
TheMeinerLP wants to merge 4 commits into
masterfrom
feature/minestom

Conversation

@TheMeinerLP
Copy link
Copy Markdown
Owner

Description

This pr adds basic minestom support into luckperms.

Developers on minestom side need following to code changes:

public class CustomPlayer extends Player implements PermissionChecker {

    private final @NotNull Pointers pointers = CustomPlayer.super.pointers().toBuilder().withDynamic(PermissionChecker.POINTER, this::getPermissionChecker).build();

    private @NotNull PermissionChecker getPermissionChecker() {
        return this;
    }

    public CustomPlayer(PlayerConnection playerConnection, GameProfile gameProfile) {
        super(playerConnection, gameProfile);
    }

    @Override
    public Pointers pointers() {
        return super.pointers();
    }


    @Override
    public @NotNull TriState value(@NotNull String permission) {
        QueryOptions queryOptions = LuckPermsProvider.get().getContextManager().getQueryOptions(this);
        User user = LuckPermsProvider.get().getUserManager().getUser(this.getUuid());
        return CompatibilityUtil.convertTriState(user.getCachedData().getPermissionData(queryOptions).checkPermission(permission));
    }
}
final class CompatibilityUtil {
    private CompatibilityUtil() {
    }

    static TriState convertTriState(Tristate tristate) {
        return switch (tristate) {
            case TRUE -> TriState.TRUE;
            case FALSE -> TriState.FALSE;
            case UNDEFINED -> TriState.NOT_SET;
        };
    }
}

Yeah its right, CompatibilityUtil lays on package level for package private access.

With MinecraftServer.getConnectionManager().setPlayerProvider(CustomPlayer::new); you can register your custom player class.

There is still one thing to do, the implementation needs be published to maven central or similar, so minestom users can shade the implementation into there big fat jar deployment.
Why ? Because minestom decided long time ago to remove permission interface from there and also the plugin alternative: extensions.

Todo

  • Add basic implementation
  • Publish to maven central
  • Test with real minestom server
  • Add documentation to wiki

Note

This pr remains in draft state until the implementation is published to maven central or similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant