[LIB] Fanciful: pleasant chat message formatting

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

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


    Could you possibly make a Javadoc?
    Some of the methods in the FancyMessage.class seem a bit obscure.
  2. Offline


    Hey, mind doing that PR? :p
  3. Offline


    Naw, for best results, use Version!
  4. Offline


    Yup, this has been a known issue for a little while now. Fixing it is probably my highest priority in ongoing development at the moment, but it's been incredibly painful to track down so far and I've been very busy with schoolwork lately.

    It's definitely something I'd like to get around to doing. Of course, pull requests that add doc comments for individual public methods are also welcome.

    I think he did actually make that PR – you can find it here. Unfortunately, it doesn't fix the issue as it currently stands, though it does serve as a good jumping-off point for experimenting with possible fixes.
  5. Offline


    Is there ever going to be support for multiple lines (in the tooltips that shows when hovering over text)? I love the simplicity, but I want to make some pixel art and I need multiple lines for that.

    If there is already a way to do this, please let me know.
  6. Offline


    The API to do this exists already – you can pass more than one string into the FancyMessage.tooltip() method, with each string being treated as a separate line in a multiline tooltip. Alternatively, you can also pass in a Collection<String> (again, with each string being treated as a separate line) or a single string containing newline characters ("\n") where you want the line breaks to be.

    Unfortunately, there's a bug in the Minecraft JSON parser that seems to be breaking multiline tooltip functionality. I'm actively looking for a fix, but right now you can't make use of multiline tooltips in your plugins even though the API is there.
  7. Offline


    Ok, thanks for telling me this. Looking forward for it to work. ;)
  8. Offline


    For some werid reason i cant get the to show right.

    I have:

    To send the message to the player

    new FancyMessage(SpawnerLocation(p, cs.name, cs.location)).send(p);
    The FancyMessage setup

    static String SpawnerLocation(Player p, String spawnerName, Location loc)
            return new FancyMessage("Spawner - ")
                        .tooltip("Click Me To Teleport.")
                        .command(String.format("/tp %s %s %s %s",p, loc.getBlockX(), loc.getBlockY() + 1, loc.getBlockZ())
                    .then(String.format("Located at: X:%s Y:%s Z:%s", loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
    But i just get the raw in the text in minecraft. Not the text that I want.

    Am I missing something here?

  9. Offline


    ABUDoctor Why are you creating one, creating a second one, turning the second one into a string, putting the string into the first one, and then sending the first one? That will just send the JSON. Send the actual message, not a message containing the json of another message.
  10. mkremins .itemTooltip is just a wee bit useless. Can you make it accept an ItemStack instead?

    Also, I am using it with the newest release and the tooltips appear to not work at all.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Oct 29, 2015
  11. maybe try to make a simple ingame JSON string and test it and compare it to the output of your program. It helps to debug where the problem is.

    I will do some testing myself to see what the limits are of tellraw.
  12. Offline


  13. Offline


    Is it possible to serialize/deserialize a FancyMessage?
  14. Offline


    Seeing as the entire point of the library is to generate JSON, I'd imagine that's possible.
  15. Offline


    But I can't seem to find a way (at least through a method the library provides) to go from JSON to a FancyMessage. Going from a FancyMessage to JSON is easy.
  16. Offline


    There's not currently a way to do this in the Fanciful API, though implementing message deserialization probably wouldn't be too terribly difficult. If there's a specific use-case for it, I could do some exploratory hacking and see whether it'd be plausible to include.
    Garris0n likes this.
  17. Offline


    I meant it shouldn't be too hard to implement, not that it was actually in the library. Sorry :p
  18. Offline


    Awesome setup! Can't wait to start playing with it >=3 Is it possible to nest a fancy message inside a fancy message? That is, could I hover over one text to display a new text, then hover over the next text to display another new text?

    EDIT: Just found someone who asked the same thing and you asked for a usage. The usage I had in mind would be to display large volumes of info from a single command. So the player does the command and gets like 6 or 7 fancy messages, and those messages would each contain a number of fancy messages which would then display the Baseline info. This could be very useful to display information about things like quests (of which there could be hundreds) and team/alliance configurations.
    For a more concrete example, say you do a command to display the alliances. Then by hovering over each alliance, you can see what teams are in that alliance. Then by hovering over the teams, you can see what players are in each team. This beats having to type 3 commands to try and find a particular player.
    That's only one example but it should demonstrate how this library could be used to effectively display information for users.
  19. Offline


    That'd be really neat, but I don't think it's possible to implement in terms of Minecraft's underlying chat message protocol. Tooltip text doesn't seem to have access to the full range of available features for styling chat messages – you can add colors and tweak the font style using the old ChatColor control characters, but there's no way to assign text within a tooltip another tooltip of its own.

    You might be able to build a similarly user-friendly interface using another feature of the chat protocol: click actions on top-level message text. In your example use-case, you could assign each alliance's name a click action to send the chat command /alliance <alliance-name> on the player's behalf. This command would in turn print a list of the teams in the alliance, within which each team's name could similarly be made to send the command /team <team-name> when clicked. Combine this with hover text to display a preview of information one level down and more clickable text "buttons" to move "up a level" in the simulated menu, and you should be able to present complex information to players without forcing them to type any additional commands.

    (Typing this up made me sort of curious: how difficult might it be to build a reusable API for text menu creation on top of the basic model described above? Sounds like I might have another side project on my hands...)
  20. Offline


    That was sort of along the lines of what I was thinking for a backup plan, but I didn't think of having a button to go up a level!

    Also, I'm new to maven and having issues getting the maven shade plugin to work. I'm working off your example from a page or two back and no matter what I put in for "YOUR_PLUGIN_MAIN_PACKAGE_HERE" I don't seem to get anything in the resulting jar when I look around. Maven says it installs correctly but when I go to run the fanciful code I get a Class Not Found Exception. Is there anything I have to do to install the shade plugin other than the plugin entry in the pom.xml?
  21. Offline


    Some good news: thanks mostly to glen3b, we've recently been able to merge fixes for every outstanding issue, including the long-running problem with multiline tooltips, into the library. Version 0.2.0-SNAPSHOT is now available from the Fanciful Maven repository for anyone who wants to preview the changes prior to the proper 0.2.0 point release.

    I'll write up a proper changelog describing all of the new features in a bit.
  22. Offline


    Other new features (not bugfixes) worth noting that I've added are the ability to deserialize a FancyMessage from JSON and the ability to serialize and deserialize a FancyMessage to YAML configuration (they are ConfigurationSerializable).

    In addition to the tooltips newline fix, tooltips now support formatted messages (colors, styles, and more all in tooltips).

    Text in FancyMessages supports other types of text. Previously only string literals were supported, but as pointed out here, other forms of text, such as localized messages, exist in the client. The library currently has support for all those in the vanilla client and even some that are in snapshots (which throw exceptions on call due to not being supported).
    I hope all the new features are useful to API users! :D
    mkremins and Garris0n like this.
  23. Offline


    Did any usage change?
  24. Offline


    As far as I know, there were no backwards-incompatible changes to the existing API. If you find something that doesn't work but did before, let me know so I can document it prior to the point release.
  25. Offline


    darkness1999 You can check the source, but I think that (except for internal classes that aren't in the API) I kept all the string overloads performing operations on raw text.
  26. Offline


    I'm getting a ClassNotFound exception while making a new FancyMessage. I am using Maven. Anyone know how to fix that?
  27. Offline


    Have you shaded the classes in?
  28. Offline


    I might sound like an idiot but I'm not sure what shaded means in java
  29. Offline


    Are you using maven?
  30. Offline


    Yes, I am using Maven and It downloaded the FancyMessage class and stuff. But when I run the code that constructs FancyMessage it causes the Execption
Thread Status:
Not open for further replies.

Share This Page