Ehm.. Allow a certain player to use a command? :)

Discussion in 'Plugin Development' started by Wituz, Aug 13, 2014.

Thread Status:
Not open for further replies.
  1. Hey bukkit'ers :)
    I've ran into a problem. I'm making a plugin where you can specify what commands each player can use (each individual player, not groups).

    If I want to assign for example /tp to a player, and the player isn't OP, he won't (as far as I can see) use it. I was wondering if there is any way to bypass this, with any command, so it executes even if the player isn't OP?

    Here's a cake [cake]
  2. Offline


  3. Offline


    It is possible to give a player a permission node instead of a group.
  4. Offline


  5. Thanks. I guess my solution will be to hook into a permissions plugin :)
  6. Offline


    Wituz you don't need to hook to one. Just use player.hasPermission, then assign the permission to user though permission plugin.
  7. Does that work if I need to specify a command?

    For example
    The player bob plays on the server
    The admin wants to give bob the command /give
    The admin types /givecommand bob give

    Or does it need to be the permissions?
  8. Offline


    Wituz you can listen for PlayerCommandPreprocessEvent to get the command before the command is ran. Then you can look to see if the player can actually use that command otherwise cancel the event
  9. Offline


    Wituz ah, so you want to write a plugin that basically works like a permission plugin? Why not just use that?

    Goblom look how? What if another plugin controls command?
  10. Offline



    Lets say i registered the listener and done everything correctly..

    The example only allows the use of 5 commands. (help, pm, msg, tp, tell)

    If i were to run any of those commands then they would run fine, but as soon as i ran /op the event would be cancelled and the command would have never been passed to the plugin that runs the command.
  11. Offline


    Goblom permission node would still be needed.
    Wituz likes this.
  12. Offline


    There is no way to bypass the TP requirement without either an external modification to Minecraft or a plugin. No commands can bypass this, however Permission Nodes can.

    Using PermissionsEx, you can allow Player2 to use TP if he's not OP by giving him the "" permission node using "/pex user Player2 add". I'd do that while they're online and then reload the plugin using "/pex reload" so you can test it as the same time.
    Wituz likes this.
  13. Thanks for helping.
    Here's another cake: [cake]
Thread Status:
Not open for further replies.

Share This Page