How to make new line?

Discussion in 'Plugin Development' started by Ktos94852, Aug 17, 2012.

Thread Status:
Not open for further replies.
  1. Hello! I am working on my first, light bukkit plugin, and i am stuck :p . How to make in one message some text, then new line, and more text? Sorry for nooby explaining my problem, but my english is not good :(

    Ktos94852
     
  2. Offline

    nisovin

    Send multiple messages?
     
  3. So simple :O thanks :p hope i will make it correctly...
     
  4. Offline

    Timr

    You can do one of two things (I would suggest the second):

    Code:
    p.sendMessage("Line 1\nLine 2\nLine 3");
    Code:
    p.sendMessage("Line 1");
    p.sendMessage("Line 2");
    p.sendMessage("Line 3");
     
  5. Timr Your first solution shouldn't work, or did I miss something new? :confused:

    Ktos94852 you could also try this:
    Code:java
    1. public void sendMultipleMessages(String messages, Player p)
    2. {
    3. p.sendMessage(messages.split("\n");
    4. }

    Then just do: sendMultipleMessages("This s one line\nAnd this the second\nand the third...", player);
    But please note that this is out of my mind and maybe won't work. But IIRC correctly sendMessage accepts a string array.
     
  6. Offline

    JDigital1337

    The regular sendMessage has an overload that takes an array of strings...

    I'd suggest you go that route... (from memory)

    player.sendMessage(new String[] {
    "message 1",
    "message 2",
    "message 3"});
     
    com. BOY likes this.
  7. Offline

    Timr

    You must be missing something.. I'm using this:

    Code:
    if(args[0].equalsIgnoreCase("nltest")) {
        p.sendMessage("Command: nltest");
        p.sendMessage("(1) New line\n(2) New line\n(3) New line");
        return true;
    }
    Which gives me this:

    [​IMG]
     
  8. Offline

    JDigital1337

    Timr, that only works if your text is really short... theres still a max line limit per line no matter how many new lines are in it. You should use an array of strings for best performance.

    /thread
     
  9. Timr Wow, then I really must have missed something, cause I wanted to implement the use of \n into bukkit some time ago but they rejected it with the reply "this can be done with plugins, no need to implement this into bukkit". Do you know the CB build where this was implemented?
     
  10. Thanks for many suggestions, but after reading nisovin's reply, i did it :) I use that:
    Code:
    {
                    sender.sendMessage("1");
                    sender.sendMessage("2");
                    sender.sendMessage("3");
                    sender.sendMessage("4");
                    sender.sendMessage("5");
                    return false;
     
Thread Status:
Not open for further replies.

Share This Page