How to make a Command able to be used on a Player

Discussion in 'Spigot Plugin Help' started by HoverTechV2, May 29, 2017.

  1. I have learned how to make commands that players can use that will effect themselves, but how do I make it so another player/console can use a command ON another player?
    Say for example I had a /troll command, and if a player used it, the command would message them "Trollololol". How would I edit the code so it could be used by another player, like this: /troll (playername)?
     
  2. You have to use command arguments
    Code (Text):
    // /command [target]
    Player target = Bukkit.getServer().getPlayer(args[0]);

    //check if is not online online
    if (target == null) {
    /code