Probably a dumb question

Discussion in 'Plugin Development' started by jtc883, May 19, 2012.

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

    jtc883

    Ok i'm sorry that this is probably such a simple question I just can't find the right answer. I have a command that when i execute it, the SERVER sends 3 lines of text to the player. What command can I use to insert a hard return(ie. move to the next line) to print the text. Thanks ahead of time.
     
  2. Offline

    SirTyler

    You mean send multiple messages or?
     
  3. Offline

    r0306

    jtc883
    If you are using a loop, then 'continue'
     
  4. Offline

    jtc883

    No i wanna use player.sendMessage() to display 3 lines of text but only using one player.sendMessage
     
  5. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Just do three sendMessage.
     
  6. Offline

    r0306

    jtc883
    I've never tried this but you can try using
    Code:
    System.getProperty( "line.separator" )
     
  7. Offline

    jtc883

    I dont want to use 3, my problem is im using 3 now, but i have a command class on its own and each time i use a different command it is still getting part of the other command i need the 3 lines for.

    Line separator didnt work either
     
  8. Offline

    russjr08

    Hmm, just a shot in the dark since I've never used it... but maybe "\n" the new line character?
     
  9. This won't work. sendMessage does not split the message at \n for you and bukkit don't want to implement this.

    Anyway, you could simply write your own function:
    Code:java
    1. void sendMessage(Player player, String msg)
    2. {
    3. for(String toSend: msg.replaceAll("\r", "").split("\n"))
    4. player.sendMessage(toSend);
    5. }

    then, instead of player.sendMessage("Line1\nLine2"); use plugin.sendMessage(player, "Line1\nLine2");
    :)
     
    Acrobot likes this.
  10. Offline

    Acrobot

    V10lator
    Or simply

    player.sendMessage(msg.split("\n"))
     
    V10lator likes this.
  11. Offline

    jtc883

    ok maybe im going about this the wrong way, here is what i have.

    if (cmd.getName().equalsIgnoreCase("votes"))
    player.sendMessage(ChatColor.GREEN + "http://tinyurl.com/7crsfhs");
    player.sendMessage(ChatColor.GREEN + "http://tinyurl.com/6qourun");
    player.sendMessage(ChatColor.GREEN + "http://tinyurl.com/887lmt7");

    if (cmd.getName().equalsIgnoreCase("cw"))
    player.sendMessage(ChatColor.LIGHT_PURPLE + "CrusherWorld");


    This is my code for my commands. If i do the /votes command it works fine. But if i do the /cw as a test command, it displays the the last two links from the /votes command. Any help
     
  12. Offline

    Acrobot

    Well, that's not how you code at all...

    Here's a statement in 1 line:

    if (cmd.getName().equalsIgnoreCase("votes")) player.sendMessage("something");

    Here's normal statement:

    if (cmd.getName().equalsIgnoreCase("cw")) {
    player.sendMessage("something");​
    }

    As you can see, what you're doing is - you're sending ONE message MORE if command name equals "votes".

    You need parenthesis.
     
  13. Offline

    jtc883

    WOW stupid, I'm so sorry for wasting everyone's time
     
Thread Status:
Not open for further replies.

Share This Page