Solved Show horizontal line in chat

Discussion in 'Plugin Development' started by MisterErwin, Nov 13, 2012.

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

    MisterErwin

    Hello together,

    how can I send a horizontal line to a player. (Not ---------). In html it would be </hr>

    thanks,
    MisterErwin
     
  2. Offline

    Zidkon

    I don't think is possible, since the chat is not for visual purpose, but for CHARACTERS showing, so if you can't do it with characters, then it's impossible.
     
  3. Offline

    desht

    Zidkon likes this.
  4. Offline

    MisterErwin

    desht: Yes, it works, but I have to do it in a loop -> It's a littlebit tall...
     
  5. Offline

    Zidkon

    Why in a loop?
     
  6. Offline

    MisterErwin

    Cause you see - But I need a not interrupted line.
     
  7. Offline

    Zidkon

    Can send just one by line?
     
  8. Offline

    MisterErwin

    No, I tried do it like in html -> one character for the whole line, but you need 20 or more for one line...
     
  9. Offline

    desht

    Right, you'll need to send multiple characters to form a complete line. There is no way around that. The chat window is just a dumb terminal where you send characters - there's no concept of any kind of drawing beyond what you can do with Unicode graphics characters.

    You need 64 "\u2500" characters to make a whole line. The good news is that this is very easy to do using StringUtils from the Apache commons library included with Bukkit:
    PHP:
    player.sendMessage(StringUtils.repeat("\u2500"64));
    (if you're doing this a lot, probably best to create a reusable String constant to avoid running StringUtils.repeat() all the time..)
    The bad news is that the Minecraft client still renders this as a broken line, since the glyph it ships (font/glyph_25.png) for \u2500 doesn't appear to span the full character cell (either that or the client is adding some horizontal spacing to all characters). Nothing we can do about that on the server side, sadly.

    Update: Some screenshot analysis suggests that (at least for the default horizontal resolution of 854) the client draws the glyph as an 8-pixel wide horizontal line, followed by 2 pixels of space.
     
  10. Offline

    MisterErwin

    Thanks, but my friend told me about the servers from mcctf.com and asks me, how o make a line like they have it. Their line is not broken...
     
  11. Offline

    desht

    /facepalm

    Just realised you can do this:
    PHP:
    public static final String HR ChatColor.STRIKETHROUGH StringUtils.repeat(" "80);
     
    // ....
    player.sendMessage(HR);
    :)
     
  12. Offline

    MisterErwin

    desht: Also colored line?
     
  13. add a ChatCOlor.red in front of it to make it red, just realy easy
     
    MisterErwin likes this.
  14. Offline

    MisterErwin

    ferrybig: Yes, but not so:
    Code:
    p.sendMessage(ChatColor.RED + ChatColor.STRIKETHROUGH + StringUtils.repeat(" ", 80));
    cause:

    , so

    Code:
    ChatColor.RED + "" + ChatColor.STRIKETHROUGH
    
    ?
     
  15. Offline

    fireblast709

    yes, should work
     
  16. Offline

    desht

    Yes, that will work, as will using .toString() after the second ChatColor.
     
  17. Offline

    leiger

    Hmm, this is an interesting discussion - didn't even know this was possible.

    It might come in useful for a future project.
     
  18. Offline

    MisterErwin

    leiger: future?!?:)

    But thanks to all...
     
Thread Status:
Not open for further replies.

Share This Page