Run all commands in a list

Discussion in 'Plugin Development' started by TotallyNotWalshy, Oct 2, 2014.

Thread Status:
Not open for further replies.
  1. Just as the title says, how can I run all the commands that are in a list.
     
  2. Offline

    adam753

    Code:
    for(String s : myList) {
        getSever().dispatchCommand(getServer().getConsoleSender(), s);
    }
    Assuming you want the server console to run the commands.
     
  3. Offline

    Funergy

    TotallyNotWalshy Create an arraylist of strings
    then do <arraylist name>.add("<yourcommand withoud the slash>");
    for(String i : <arraylist name>)
    then do a for loop and in the loop you do Bukkit.dispatchCommand(<the player>,i)//i is the string/command you wanna run
     
  4. adam753 Brilliant, I should of thought of that. But please next time don't spoon feed me.
     
  5. Offline

    adam753

    TotallyNotWalshy I usually don't, but when it's just one line of code, I hardly see a point in trying to lead you to find it. For all I know you were just asking how to do it. Glad you got it sorted anyway.
     
Thread Status:
Not open for further replies.

Share This Page