Making a command work differently for different PEx groups?

Discussion in 'Spigot Plugin Help' started by takatalvi, Oct 10, 2016.

  1. Hi, I would like to make the /warp command work the following way:
    For players with permission (using PEx) to use /warp, it would work as a warping command.
    For players without the permission to use /warp, it would run a specific /customtext command.

    The reason behind this is that only staff have access to warps, players have different ways of getting around. And since many new players try to use /warp and they can't, I would like to give them an explanation using /customtext when they try /warp.

    I would like to do this without adding any new plugins, let's try to make this work only using Spigot's commands.yml, PermissionEx and Essentials. I don't think any other plugins I have apply.

    Any ideas/experience?
     
    #1 takatalvi, Oct 10, 2016
    Last edited: Oct 10, 2016
  2. I'm not sure this is something that will work natively without additional plugins (as I don't use essentials warps and the commands.yml) but there are warp plugins that have per warp permissions.
    (Shameless plug)
    I have a plugin called SpawnJoin that adds warps and a ton of other features with per warp permissions. As in you can only access a warp if you have permission, and if you don't it says "You do not have permission to use that command" or something similar (Custom messages, you can set it to whatever you want). Here's a link if you want to check it out: https://dev.bukkit.org/bukkit-plugins/teleport-spawn-join/
     
    • Informative Informative x 1
  3. I was thinking I'd try messing around with commands.yml first. The way I see it, the command aliases have the first priority among all commands, but they trigger only commands lower in the hierarchy (after aliases it's plugin commands, spigot commands and then vanilla commands). For default players I would define an alias for /warp, that would run /customtext warp. Then for staff I'd define an alias let's say /ewarp or /swarp, that would run actual /warp. It would look like this:

    Code (Text):
    aliases:
      warp:
      - essentials:customtext warp
      ewarp:
      - essentials:warp $$1 $1
    If this doesn't work as intended, or the change from warp to ewarp would be too much of a nuisance for our 2-member staff, I'll definitely look into SpawnJoin, although I fear I would only use 5% of its possibilities. Thanks for your suggestion!

    Edit: I added the explicit expression essentials: to the destination commands, so that there is no room for error.
     
  4. Vault is your friend in this.
     
  5. You can always edit the error message when a player does not have the permission to use the command.

    For example, if you saw this in your config:
    No-permission-to-warp: '&cYou don't have permission to use this command!'

    You could change it to:
    No-permission-to-warp: '&cOnly staff may use /warp! &aType &e/<YOURTEXTCMD> &ato see why.

    <YOURTEXTCMD> could be any command that would simply tell a player why with a simple message.
     
  6. Please explain, to which plugin's config are you referring? I didn't find this in PEx, nor Essentials, but it would be the easiest solution to what I need.
     
  7. EasyWarp

    I don't use essentials, but I use EasyWarp for quite a few things on my server.
    It allows per-warp-permissions, configurable messages (allowing you to do what I said), and multiple other things.
     
    • Informative Informative x 1
  8. Cool, I will definitely give it a try. For now, I did it without adding plugins, just using commands.yml and Essentials. When players try /warp, it will give them a message from customtext.txt. For the A-team, /ewarp is a working replacement for /warp.