LuckPerms

LuckPerms

41.4k Downloads

Resolve command selectors for command blocks

YJJcoolcool opened this issue ยท 2 comments

commented

Description

Some time back, I asked in the LuckPerms Discord whether there was a way to use target selectors like @p (link to Discord message).

A user sent me a link to the LuckPerms config.yml which had a setting named resolve-command-selectors. After adding that line with the true option and restarting my server, I realised that target selectors worked when executed by players, but not when executed by command blocks.

The command that I wanted to run: /lp user @p parent add <groupname> (I also tried other commands, like /lp user @p promote <track>, which also had the same issue). Additionally, I couldn't find any error messages from LuckPerms in my server's console.

Screenshot of command successfully run by player:
image

Screenshot of failed command when run by a command block:
image

Reproduction Steps

  1. In your LuckPerm's config.yml, ensure you have the following option set: resolve-command-selectors: true (older versions of LP may not have came with this option, so you might have to add it manually)
  2. Restart your server for the changes to apply.
  3. After restarting, execute a LP command with a target selector (e.g., /lp user @p parent add <groupname>) as a player and then with a command block.
  4. When executing as a player, the command should work with no problems (you can verify by going to the WebUI using /lp editor). However, when using the command block, the command fails to run.

Expected Behaviour

The command should work with no errors when run by a command block.

Server Details

git-Paper-388 (MC: 1.18.2)

LuckPerms Version

v5.4.30

Logs and Configs

No response

Extra Details

No response

commented

Yeah, this is somewhat intended (the resolving of command selectors was only implemented for players)

Would accept a PR to add it for other command executor types, but it's not a priority for me

commented

I also want the player to join and exit a privilege group by activating the command block, it must Target Selector can be used in Luckperm command XD