Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to be hidden from jobs tops #1669

Merged
merged 3 commits into from
Nov 15, 2023
Merged

Conversation

MachiganMC
Copy link
Contributor

@MachiganMC MachiganMC commented Oct 7, 2023

Add a possibility for a player to be hidden from the jobs tops.

This pull request has made some change to perform that :

Change the way to hook Vault providers :

To check some permission (I'll explain later what), I have to add the provider of permissions. Accessible via Jobs#getVaultPermission().
To avoid some code repetitions (like logging or checking if Vault is enable) I created the abstract class HookVault<T> (where 'T' represent the class of the provider). And make the HookEconomyTask extends it.

Add 2 new permissions nodes :

  • jobs.hidetop.<job>: hide the player (if it has the perm) to be shown in the top of the specified job (replace <job> with * to hide the player from all jobs top).
  • jobs.hidegtop hide the player from the jobs global top.
    The two nodes are by default set to false for all players.

Make the use and creation of the list of jobs top asynchronous :

From the creation of the list of all players in the job tops and the moment where the top is shown to the player that performed the command, all of that is asynchronous.
This has been done because the check of a permission of a offline player (with Vault) has to be asynchronous if the server use LuckPerms and doesn't enable the vault-unsafe-lookups.

Also the Permission provider has been added to get permission of an
offline player.

This has be done to easily add more providers in the future but also
avoid code repetitions (like logging if Vault is enabled).
To do that, the part of the command 'top' and 'gtop' has been moved into
an asynchronous thread because of 'unsafe Vault lookups from LuckPerms'.
If it enable, LP prevent a plugin to check a perm of an online player on
the main thread.

Two new nodes perms have been added :
- `jobs.hidetop.<job>`: to be hidden from a specific job top (replace
  <job> by * to be hidden from all).
- `jobs.hidegtop`: to be hidden from the jobs global top.
Because of the new providers hookers, a use of the proviers class was
perform before checking if Vault was enabled. And if Vault was not
enabled there was a `NoClassDefFoundError`.
Now a first Vault check is done before the use of the providers class.
@Zrips Zrips merged commit 11972ff into Zrips:master Nov 15, 2023
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.

2 participants