Executing console commands with a player's name

Discussion in 'Spigot Plugin Development' started by GeXyd, Jul 24, 2017.

  1. I'm trying to get my plugin to get it so when someone does /examplecommand it executes a command from console like /somethingsomething [player name]. Here's the code I have.
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "somethingsomething ");
    I don't know how to have the PlayerName after somethingsomething. Any ideas?
     
  2. ScarabCoder

    ScarabCoder Retired Resource Staff
    Retired

    It takes a string, so just add the player name after the string? It's pretty basic.
    Code (Text):
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "somethingsomething " + player.getName());
     
  3. Do you know java? All you have to do is combine a string, as said above.
     
  4. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "your command");
     
  5. Did you even read the thread?