[class] monospace fixed width fonts

Discussion in 'Resources' started by atesin, Apr 20, 2014.

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


    hi all

    i am writing a teleportation plugin (MyPortals) ... in the meanwhile i had the need to list all teleports with its data

    then i realized minecraft chat window have variable width fonts and there is no way to print tabbed data .. so i wrote a class to do it

    i am not a java expert, writing costed me a lot of tests and brain heating, but i want to share it with you if you have the same need i had and want to use it .. and improve it of course, just let me know




    VERSION 2: now has 2 methods for sort lines by field(s)
    VERSION 3: optimized code, better stability, improved methods
    VERSION 4: little bug fixes
    NEXT VERSIONS: bugfixes, new functions and optimizations

    now you can see the latest code at my github page:

  2. Offline


    This is great looks really nice, But I think this would be more useful in the resources section of bukkit.

    I will see about using this is my work in the future (I will give you credit of course)

  3. Offline


    I suggest putting it in a github gist where the formatting won't break.
  4. Offline

    Jade Retired Staff

    Moved to a more appropriate section.
    Garris0n likes this.
  5. Offline


    Jade, you killed this post by moving, but is ok

    i wish everybody use this class, and contribute to enhance it if you can
  6. Offline


    Had no idea what it was until you added pictures. I'll probably use this soon!
  7. Offline


    I think im going to use this... will let you know how it works!

    Hey, can you give us an example on how to use this? I see in the code "Usage", but can you give an example on some sample code, sample columns / tabs, and pages?


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


    see the 1st screenshot? .... suppose you have a portals plugin (like the one i am writing :) ) .. and your portals have the properties

    - portal location
    - portal name
    - destination portal name
    - owner player

    and you have a command "/portals list" or something ...then you need to iterate all portals and build a multiline string "mLString" like


    then you can create a TabText with this and get tabbed columns
    TabText tt = new TabText(mLString);
    and the result you already know it


    internals: the new TabText object holds and manages the multiline text passed, you can query how many pages they have, and when you request some page it "count" the font pixels and fill it with spaces until finds a field separator

    stay tuned because soon i think to upload a newer version

  9. Offline


    in response to Sleepydragn1 at http://forums.bukkit.org/threads/text-alignment-in-chat.83895/#post-2502117

    i found the problem !!

    i thought default behavior was consider variable width fonts, but it was monospace fonts ... you have 2 fixes for this, change default behavior or explicitly said everytime you are using variable width fonts, if you send this command raw from console it gets perfectly aligned

    - to change default behavior (recommended) edit line 50 to look "public boolean monospace = false;" (no quotes)
    - to be explicit, call getPage() with the monospace parameter: "sender.sendMessage(tt.getPage(1, false));" (no quotes)

    your plugin should detect if you are sending your command from console or from minecraft chat, and use "monospace" parameter properly
  10. Offline



    i uploaded version 3 and i feel very satisfied with it


    see details in starting post .. i pasted full class code too
Thread Status:
Not open for further replies.

Share This Page