[LIB] Fanciful: pleasant chat message formatting

Discussion in 'Resources' started by mkremins, Nov 15, 2013.

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

    MiniDigger

    This working fine for me, except one message:
    The Code:
    Code:
    FancyMessage msg = Prefix.getByGameType(getGame().getType()).getPrefix().then("Es werden noch ").color(ChatColor.GOLD).then("" + needed).color(ChatColor.YELLOW).then(" Spieler zum starten benötigt.").color(ChatColor.GOLD);
    getGame().broadCastMessage(msg);
    System.out.println(msg.toJSONString());
    The JSON String:
    Code:
    {"text":"","extra":[{"text":"[","color":"aqua"},{"text":"GetTheDrop","color":"blue","hoverEvent":{"action":"show_text","value":"Made by MiniDigger\nmore Infos:\[email protected]"}},{"text":"] ","color":"aqua"},{"text":"Es werden noch ","color":"gold"},{"text":"5","color":"yellow"},{"text":" Spieler zum starten ben÷tigt.","color":"gold"}]}
    The Output: [​IMG]

    Does this happen because of the char 'ö'?
     
  2. try to replace ö with \u00f6

    i have not tested this and i don't know how minecraft handles it i hope it fixes it!
     
  3. Offline

    MiniDigger

    killje That did not help, same result.
    Even spliting the word with the 'ö' did not help, everything abter the number is just with instad of gold....
    Code:
    FancyMessage msg = Prefix.getByGameType(getGame().getType()).getPrefix().then("Es werden noch ").color(ChatColor.GOLD).then("" + needed).color(ChatColor.YELLOW).then(" Spieler zum starten ben").color(ChatColor.GOLD).then("\u00f6").color(ChatColor.GOLD).then("tigt.").color(ChatColor.GOLD);
    EDIT: Just copied the json output into a commandblock and executed it via tell raw and it worked fine. So there is something wrong with fancyfull when using special chars...
     
  4. does \u00f6 make it a ö?
     
  5. Offline

    MiniDigger

    Yes, its displayed as an ö using bukkit and vanilla, but in bukkit the color doesn't get applied for the text part with the ö. But I think this is a bukkit issue since fancyfull produces the right json string
     
  6. Offline

    Bammerbom

    The achievement part doesnt work, it just doesnt show anything for me.
     
  7. Offline

    DevRosemberg

    How could i do this each time a player chats so others can hover over his name and get information or perform actions?
     
  8. by catching the player chat event. getting what he said and then resend it with the name added in front of it
     
  9. Offline

    Foorack

    mkremins Hey, if I have this string in my config:
    How would I do to translate that to a fancymessage?
     
  10. Offline

    MiniDigger

    Foorack You should save your messages using the json format. Using what you did above is much more difficult.
     
  11. Offline

    Foorack

    MiniDigger Can't. I'm currently reading that as the player prefix from pex, (permissions-ex).
     
  12. Offline

    Dragonphase

    I've started using this resource in all of my plugins. It's really easy to understand and use. Here's an example of what I would use it for:

    • Displaying a description of a command, as opposed to displaying it alongside the command and creating a cluster of information. It also lets me add functionality for players to issue these commands by clicking on them in the chat.
    • Displaying custom information such as:
      • Custom player information (such as the custom player info in my Battlegear project which is still under development.)
      • Custom object information (such as the amount of items in a kit, and all kit settings (overwrite, delays, etc.))
    I can imagine there being so much more I would use this for in the future. Thanks for this amazing resource mkremins!
     
    mkremins likes this.
  13. Offline

    BlackBeltPanda

  14. Offline

    mkremins

    You'd have to parse the color codes and translate them into FancyMessage.color() calls yourself. Splitting the string around occurrences of the & character (likely using regular expressions) will probably get you 80% of the way there.

    Are you using Maven? If so, have you shaded the Fanciful classes into your plugin jar?
     
  15. Offline

    BlackBeltPanda

    Should be. Here's my pom: http://pastebin.com/raw.php?i=uhNRHvu0
    Edit: I just copied the classes to my plugin instead, which is working so far. =)
     
  16. Offline

    Foorack

    mkremins Nah, it's ok. ;) Got bored on the train and wrote a "kind-of-compiler" that translate's that kind of string ^ to a fancymessage-object.. I could post the code if someone's intrested..
     
  17. Offline

    MiniDigger

    Foorack if would be interested since I also get my users prefixes from pexs database. Currently only using the first color in the prefix, but having the hole prefix would be cool :D
     
  18. Offline

    ProjectInfinity

    So I was looking at using this in my plugin ReportRTS for showing the full message of a shortened message in a tooltip. However, the first thing I noticed was that after implementing it the command that normally would take 0.40ms to 0.72ms to execute, took a whopping 2.598ms to 10.047ms to display a few lines of messages (by default 5 lines).

    My question is, is there any trick you can do to attempt to shave off a few milliseconds?
     
  19. Offline

    MiniDigger

    ProjectInfinity using json without fancyfull will speed things up. But does this realy matter?
     
  20. Offline

    ProjectInfinity

    MiniDigger it does when the majority of my users are large Networks where performance is Paramount.

    So what do you suggest? Using json without fanciful and creating the packets myself?
     
  21. Offline

    MiniDigger

    ProjectInfinity this will be faster. Just create a chat packet, don't know how it's actualy called. It takes a json string as constructor argument. Send that to your player " ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);"
    I usually use http://ezekielelin.com/tellraw/ for generating json strings
     
  22. Offline

    Goblom

    ProjectInfinity You could use Fanciful to create the JSON chat format, then use packets to send the json message to the player.

    Doing it that way makes it so that the JSON message is not generated every time you send the json message to a player.
     
  23. Offline

    ProjectInfinity

    Thanks. Rather than doing that I decided to soft-depend on ProtocolLib and the command now takes roughly 1.5ms to fire. That's reasonable.
     
  24. Offline

    mkremins

    ProjectInfinity MiniDigger

    Incidentally, I'm definitely interested in improving Fanciful's performance, but I'm kind of flying blind with regards to the sort of problems you're experiencing. If you (or anyone else) could provide any kind of profiling data or benchmarks illustrating the slowdown, it'd be much appreciated :)
     
  25. Offline

    ProjectInfinity

    mkremins Sadly this was all measured through my own plugin by taking the time in nanoseconds for start and end time then converting it to milliseconds.

    I wish I could tell you what exactly the cause was.
     
  26. It might be because for every player it converts the FancyMessage to a JSON string when sending instead of saving the JSON string. I have put a pull request on the github to address this issue
     
  27. Offline

    TimTheAmazing

  28. Offline

    IDragonfire

  29. Offline

    TimTheAmazing

  30. Offline

    extended_clip

    I just wanted to say thank you very much for this resource! I am working on a private project and this did just what I needed to do!
     
Thread Status:
Not open for further replies.

Share This Page