LuckPerms

LuckPerms

41.4k Downloads

Additional placeholders, including for other users and offline players

GenSecrets opened this issue ยท 1 comments

commented

Description

This would come in 2 parts:

  • Introduce a new wave of placeholders that returns data from other users. This is kind of like the "parseother" PAPI expansion, except this would be done via internal luckperms placeholders only. For instance: %luckperms_{otherusername}_meta_key%. This would return the meta_key for the specified player. Another example that would benefit us greatly: %luckperms_{otherusername}_in_group_{group}%. We are a decently sized server (roughly 150-250 players a day ish) and we have a lot of custom commands and content that we've been developing. This would help tremendously because it lets us customize user experience with the custom commands
  • These new placeholders would also work on offline players! For instance, if I ran was a player and was running a custom command to find someone's favorite color(which we, as an example, store in meta data), currently the other other player would have to be online. But if I wanted to run something like "/favcolor Lucko" when Lucko was not online then ideally, our custom command would return %luckperms_Lucko_meta_favcolor%. It would be built in a way that simply took the input, and checked it against the database and return the meta value. If not set it would return blank. If player not found, it would return blank.

This is doable for plugin-side internal placeholders since a lot of those placeholders are run against plugin data itself and not against the target player. This is not doable for papi expansions such as the above mentioned "parseother" because all parseother does is run the placeholder on the other online player without alerting them and return the value it finds, it has no way to run it against the plugin's data instead of the player itself.

Proposed behaviour

Participating luckperms placeholders would allow for an optional {username} input as the second variable in the placeholder string. So instead of saying %luckperms_meta_key% we could say %luckperms_{Lucko}_meta_key% which would return Lucko's key instead of my own. The reason we use {brackets} is to treat it like an internal placeholder (since some usernames have underscores in them). The reason it's the second variable in the placeholder is for ease of developing and checking input.

commented

Hey, this is an interesting idea.

Unfortunately, it's not possible to easily implement placeholders for offline players because loading their data requires I/O - and can potentially happen on the main server thread.

It's the same reason why Vault queries for offline players do not happen by default.

If PlaceholderAPI ever introduced the idea of an async placeholder - this would be possible - but until then, unfortunately it's not.

Thanks for the suggestion nonetheless :)