PrisonTeam / Prison

The home of the Prison project, a Minecraft plugin to provide mining and ranking gameplay experience.
https://www.spigotmc.org/resources/prison.1223/
Other
131 stars 48 forks source link

Remove commands from tab complete if there's no permission to use it #241

Closed Josh65-2201 closed 1 year ago

Josh65-2201 commented 1 year ago

Which module are you submitting this issue for?

Core

Describe the issue you are experiencing.

I want to have a clean command list in chat and with Prison I'm disabling a lot of them. However there still visible in the tab complete.

Describe the steps to reproduce the problem.

  1. Enable the use of permission on ranks GUI
  2. Use a permission plugin to disable ranks GUI
  3. Restart server
  4. See that /gui still will show ranks

Anything else we need to know?

rbluer commented 1 year ago

I can make modifications to the prison command handler to selectively respond to commands where the player does not have the permission to use the command.

Upon thinking about this issue in greater detail, there will be some commands that cannot be suppressed through perms alone while the Prison Command Handler is processing commands in general, since the perms are calculated as the command is being ran (after the command handler passes control to the code to run the command). For those situations, the command handler will not be able to identify if a player would be able to use the command or not.

A great command to explore to better understand why this is not possible would be /rankup help.

Notice that under the "Permissions" that is shown, there are actually two kinds of perms. The first kind are whole words, and some are with periods. Examples are: access-by-rank mines.tp.

The second type of listed perms are actually just plain text as far as the prison command handler is concerned, so no perms can be checked. Those perms are listed with square brackets most of the time, to indicate that there is a programmatic intervention needed to generate the dynamic permission, and that happens within the command itself, and is outside of the prison command handler. An example is: mines.tp.[mineName]. The command handler will never be able to resolve what that perm will be since the logic for it's generation has nothing to do with the command handler.

Another command that can illustrate this would be: /mines tp help. With the listed perms being access-by-rank mines.tp mines.tp.[mineName]

Overall there are many commands within prison that have calculated perms, so the prison command handler will never be able to filter out those commands for common players.

rbluer commented 1 year ago

I'm just thinking out loud here, but what I'm considering is the following.

I will setup the prison command handler to use the perms it has access to, to filter out access to the commands, as you have suggested.

But for those commands that cannot be filtered because of the lack of perms, what I may setup is a new section under the config.yml file's prisonCommandHandler. I don't know what I will call it, but maybe something like prisonCommandHandler.exclude-commands to be consistent with exclude-worlds.

Within that section, I will have a perms listing where one or more perms can be defined. Then any player who is not OP'd and they have that perm, then all commands listed will be excluded from their access.

This may provide the most flexibility, but at the risk of one perm controlling all excluded commands.

I may figure out a better way to allow an arbitrary number of groupings.

Josh65-2201 commented 1 year ago

I don't quite understand what your saying, but couldn't sub commands from the accessbyrank be ignored if the perm plugin has denied the root of the command it needs. Or if accessbyrank enabled just add a permission entry for each of them to be checked.

rbluer commented 1 year ago

I don't understand what you're asking either... LOL

Maybe it would be easier to discuss on discord?

But basically prison has hundreds of commands, and each command is actually a single "word", but all commands are order by a hierarchy.

So if you take the command /mines set mineAccessByRank, there are no "sub commands" to that specific command. So I'm not understanding what you mean by "couldn't sub commands from the accessbyrank be ignored".

Normally, on discord, I would ask for more information about your problem, including screen prints when some of the details are not too clear. So yeah, let's continue this on discord and please provide examples of which commands you are talking about. Now that you are mentioning sub commands to the mineAccessByRank command, I'm totally lost with understanding where your perspective is right now.

I just reread your original post... are you trying to disable prison's GUI for players?

You're trying to disable prison feature by using another plugin to control permissions? I don't see that working. If you are wanting to disable the GUIs in prison, but use the setting within config.yml just set prison-gui-enabled: false and those GUIs will be disabled.

LOL... this back-and-forwards is why I'd rather deal with issues in discord... it's a hell of a lot easier. LOL

rbluer commented 1 year ago

Not all commands within prison have perms, or the perms are within the code and are more than a simple calculation.

I added a new feature that will allow the configuration of locking a player out of a command based upon settings within the config.yml. If your config.yml does not show the settings, then rename it and restart the server. The latest config.yml will be auto generated, then copy over your prior configs.

This new feature may not be 100% as what you requested, but it's getting closer and may help address other issues too.

By using this feature, you can lock players out of a command based upon permissions. This does not apply to OPs.

For example, the following illustrates the settings to lock out players on the command /mines tp which is based upon the permission prison.exclude.test.

prisonCommandHandler:
  exclude-non-ops:
    exclude-related-aliases: true
    commands:
      mines:
        tp:
          perms:
          - prison.exclude.test

This takes priority over any permission on a command. It suppresses the listing of the command to the player, and it also prevents them from seeing the help for that command too. It also has the ability to apply to all related command aliases.

I'm closing this ticket since this new feature should be able to help shutdown almost any command that you do not want players to see. This new feature is in the current alpha that is available for download on the Prison discord server under the #Alpha-Versions channel.

I have added this to my to do list to enable auto rejection of commands. ETA is unknown right now, and many commands may not be able to handle the rejection on their own. I'll have to figure out a better way to modify the Prison Command Handler to meet this requirement.

rbluer commented 1 year ago

As an additional note...

After closing this ticket, I noticed the tab-complete was not working correctly. So that is now fixed and will be included in the next alpha release.