Force player to run command without permission ?

Discussion in 'Spigot Plugin Development' started by Drawethree, Apr 14, 2017.

  1. Question is above. How can I force player to run a command without permission ? I need player, not console
  2. WAS


    What do you mean exactly? You just don't check for permissions? Do you mean for another plugin?
  3. Yes, dont check for player permissions. Just allow player to run it.
  4. I don't think that is possible, you can try to op the player before executing the command and deop the player after the command has been executed. Or you can try bukkit.dispatchcommand
  5. You can give OP, do"something"); and then de-op
  6. Other way, take the command and dispatch it from console.
    • Agree Agree x 1
  7. Rather than op a player, its much better to simply give the player the permission for the specific command, run it and then take the permission away.

    There is however a plugin called runas I believe...
    • Agree Agree x 1
  8. Its a setwarp command so it couldnt be executed from console.
  9. depending on your permission system do something like
    run first: /pex user [player] add [permission] (assuming since you said /setwarp it could be like essentials.setwarp)
    run second: /setwarp [warpname] (if you want the warp to be a custom name per player i got no clue xD)
    run last: /pex user [player] remove [permission]
    well actually it would require a little more work but you could get a "PermissionsTimer" type of plugin and add the correct setwarp permission to the player's per permissions only and then after like 5 minutes you could set it up to auto remove the said permission that was added. Maybe like adding a chat notification in chat telling them they are on a time limit etc. That's all I got :3
    #9 Swiftlicious, Apr 14, 2017
    Last edited: Apr 14, 2017
  10. would /sudo work with dispatchCommand? or does sudo run a dispatchCommand?

    otherwise maybe, java.lang.String)

    Force player to run command.
    Bukkit.getServer().dispatchCommand(player, "setwarp " + wName);

    To add and remove the perms.
    Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "pex blah, blah, blah " );

    Otherwise"/setwarp name");

    player.performCommand("setwarp name");
    #10 Stuperfied, Apr 14, 2017
    Last edited: Apr 14, 2017