Using a string in a command, help?

Discussion in 'Plugin Development' started by dakooldog, Feb 5, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    dakooldog

    I am having a major brainfart here. Here is what I am trying to do:

    /askquestion (string entered by player)

    Will the spaces in-between the words tell the plugin that there is however many args? Or if I set it as one arg will it accept the string properly for me to use as I please?
     
  2. Offline

    bitWolfy

    Whitespaces serve as argument separator. You can do this, though:

    Code:
    String question = "";
    for(String arg : args) question += args + " ";
     
  3. Offline

    Tog

    If the command is registered in your plugin.yml all the following words will be put into the args array, you can then easily build together args[1]-args[args.length] as a string again.
     
  4. Offline

    Brian_Entei

    You can concat the args together in the message, like I've done for my plugin:

    Code:
                        String mess = "";
                        String displayName = ((Player)sender).getDisplayName();
                        int x = 0;
                        do{mess = mess.concat(args[x] + " "); x++; }while( x < args.length );
                        mess = displayName + ChatColor.RESET + " " + mess;
    Just be sure to incorporate this code to meet your plugin's needs. Hope this helps!

    -Brian_Entei
     
Thread Status:
Not open for further replies.

Share This Page