Solved Multiple Lines In zero args

Discussion in 'Plugin Development' started by Kyle MC, May 17, 2014.

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

    Kyle MC

    How would I do Mulitple lines in a place where i do /cp (cp is an alias of craftingsplus)
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    2. Player p = (Player) sender;
    3. if (cmd.getName().equalsIgnoreCase("craftingsplus"));
    4. if (args.length == 0){
    5. Inventory inv = p.getInventory();
    6. p.sendMessage(ChatColor.RED+"["+ChatColor.BLUE+"Craftings+"+ChatColor.RED+"]"+ChatColor.GREEN+" Arguments: version = Shows the version,");
    7. }

    There is more but, it haas nothing to do with this
     
  2. Offline

    DxDy

    What exactly do you mean by multiple lines? If you're trying to send multiple lines to the player, there is a version of sendMessage which takes a String Array. Or you could just call it multiple times.
     
  3. Offline

    jthort

    Kyle MC I don't really understand your question but take this example

    Code:
     @Override
            public boolean onCommand(final CommandSender sender, Command command, final String speak, final String[] args) {
                   
           
                   
                    if(speak.equalsIgnoreCase("starhunt") || (speak.equalsIgnoreCase("sh"))){
                   
                           
                    switch (args.length){
                   
                    case 0:
                   
                           
                            break;
                           
                    case 1:
                               break;
    
     
  4. Offline

    Kyle MC

    Like this:
    Code:java
    1. p.sendMessage(ChatColor.RED+"Something");

    and
    Code:java
    1. p.sendMessage(ChatColor.RED+"Something Else");

    inside the args[0].equalsIgnoreCaseVersion("CraftingsPlus")

    DxDy I want it to be multiple lines in an argument space and it will not go to another argument

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  5. Offline

    TGRHavoc

    Kyle MC
    Please make your question clear.. Are you wanting to send the player a message after they do "/cp"?
     
  6. Offline

    Kyle MC

    TGRHavoc yes, I am. Multiple lines that won't go to any arguments cause it did.
     
  7. Offline

    MrSparkzz

    Kyle MC
    Are you asking how to make your code work with multiple arguments? for example if you were to type "/cp blah blox blum" ?
     
  8. Offline

    Kyle MC

    No, I am simply asking for something that would send multiple messages as:

    Code:
    Some random text
    Some random text.
    and it will not go anywhere else, like another argument
     
  9. Offline

    Azubuso

    Kyle MC
    Um, just add another .sendMessage right below the other? Having a bit of a hard time understanding your question :p
    PHP:
    p.sendMessage("Message 1");
    p.sendMessage("Message 2");
    // etc.?
    Otherwise you could always do
    PHP:
    p.sendMessage("Message 1 \n" "Message 2 \n" "Message 3"); //etc
     
  10. Offline

    Kyle MC

    @Azubuso I tried it before but, it showed it with the next argument :p. Now it works. :)
    I have also never used PHP
     
Thread Status:
Not open for further replies.

Share This Page