{"id":16378454,"url":"https://github.com/foxfirecodes/JSONMessage","last_synced_at":"2025-03-21T01:32:34.396Z","repository":{"id":45397996,"uuid":"69299821","full_name":"rayzr522/JSONMessage","owner":"rayzr522","description":"A modern version of Fanciful","archived":false,"fork":false,"pushed_at":"2022-10-28T23:50:25.000Z","size":59,"stargazers_count":30,"open_issues_count":5,"forks_count":14,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-12T03:45:24.618Z","etag":null,"topics":["actionbar","bukkit","single-class","subtitle","title","utility"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rayzr522.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":"rayzr522","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2016-09-26T23:03:16.000Z","updated_at":"2023-08-01T19:12:26.000Z","dependencies_parsed_at":"2023-01-20T05:54:45.125Z","dependency_job_id":null,"html_url":"https://github.com/rayzr522/JSONMessage","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rayzr522%2FJSONMessage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rayzr522%2FJSONMessage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rayzr522%2FJSONMessage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rayzr522%2FJSONMessage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rayzr522","download_url":"https://codeload.github.com/rayzr522/JSONMessage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221811391,"owners_count":16884305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actionbar","bukkit","single-class","subtitle","title","utility"],"created_at":"2024-10-11T03:45:27.173Z","updated_at":"2025-03-21T01:32:29.085Z","avatar_url":"https://github.com/rayzr522.png","language":"Java","funding_links":["https://patreon.com/rayzr522"],"categories":[],"sub_categories":[],"readme":"# JSONMessage\n\nA modern version of Fanciful\n\nThis library aims to completely replace [Fanciful](https://bukkit.org/threads/lib-fanciful-pleasant-chat-message-formatting.195148/), which sadly has stopped being updated. I figured I'd take a stab at re-creating it, and even making it better.\n\n## Installation\n\n### Maven\nFor those of you using Maven, just add the following to your `pom.xml` file:\n\n```xml\n\u003crepository\u003e\n    \u003cid\u003erayzr-repo\u003c/id\u003e\n    \u003curl\u003ehttps://rayzr.dev/repo/\u003c/url\u003e\n\u003c/repository\u003e\n```\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eme.rayzr522\u003c/groupId\u003e\n    \u003cartifactId\u003ejsonmessage\u003c/artifactId\u003e\n    \u003cversion\u003e1.3.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\nIf you're using Gradle, add this to your `build.gradle` file:\n\n```gradle\nrepositories {\n    maven { url 'https://rayzr.dev/repo/' }\n}\n```\n\n```gradle\ndependencies {\n    compile 'me.rayzr522:jsonmessage:1.3.0'\n}\n```\n\n### Other\n\nJSONMessage **no longer is drag-and-droppable**. You *must* use Maven or Gradle. This was a necessary measure as having everything in one class had become unmaintainable.\n\n## Usage\n\nThis library is extremely easy to use! It uses a nearly identical system as Fanciful. Example:\n\n```java\nJSONMessage.create(\"Hello!\").color(ChatColor.RED);\n```\n\nThis creates a simple message saying \"Hello!\", with red text. Now you might say to yourself, why use this? I can easily make red text and send it to the player! Well my friend, there are many more features. Be patient :wink:\n\nHere's a more complicated example, showing the true power of JSONMessage:\n\n```java\nJSONMessage.create(\"Go to the \")\n              .color(ChatColor.GOLD)\n            .then(\"best website ever!\")\n              .color(ChatColor.BLUE)\n              .tooltip(\"Click to go\")\n              .openURL(\"http://www.youtube.com/\");\n```\n\nThis example creates a message in two parts, one gold, one blue, and gives the second part a tooltip as well as an action! When you click on this, it will open YouTube.\n\nOne thing to note about tooltips is that they *themselves* can actually take a JSONMessage as a parameter:\n\n```java\nJSONMessage.create(\"This has a fancy tooltip!\")\n              .color(ChatColor.GOLD)\n              .tooltip(JSONMessage.create(\"Green text!\")\n                                    .color(ChatColor.GREEN)\n                                    .style(ChatColor.BOLD)\n                                  .then(\"\\nUse the newline character to\\nadd lines to the tooltip\")\n                                    .color(ChatColor.YELLOW))\n```\n\nYou can also make text which runs commands when you click on it:\n\n```java\nJSONMessage.create(\"Click\")\n              .color(ChatColor.GOLD)\n            .then(\" here \")\n              .color(ChatColor.RED)\n              .runCommand(\"/warp spawn\")\n            .then(\"to go to spawn\")\n              .color(ChatColor.GOLD);\n```\n\nTo send a JSONMessage, it's quite simple:\n\n```java\nJSONMessage.create(\"Hello!\")\n              .tooltip(\"World!\")\n            .send(player);\n```\n\nYou can pass as many players as you want into `send`, meaning you could send this to huge groups of players.\n\n\u003e Note: If you don't have the following features then please make sure to download the latest version of the class file\n\nYou can now send titles and subtitles too. It's actually very much like send:\n\n```java\nJSONMessage.create(\"I am a title\")\n              .color(ChatColor.GREEN)\n              .style(ChatColor.ITALIC)\n            .title(10, 20, 10, player);\n```\n\nExplanation time. What are those numbers? They are quite simply the `fadeIn`, `stay`, and `fadeOut` variables. These control various aspects of the timing of the title, and they're measured in ticks. So for this example it fades in over 0.5 seconds, stays visible for 1 second, then fades out again over 0.5 seconds.\n\nAdding a subtitle to this is just as easy:\n\n```java\nJSONMessage.create(\"I am a title\")\n              .color(ChatColor.GREEN)\n              .style(ChatColor.ITALIC)\n            .title(10, 20, 10, player);\n```\n\n```java\nJSONMessage.create(\"A wild subtitle has appeared!\")\n              .color(ChatColor.GOLD)\n            .subtitle(player);\n```\n\nThe only thing to note is that for subtitles you don't pass in times, as that's completely handled by the original title.\n\n\u003e Note: If you don't have the following features then please make sure to download the latest version of the class file\n\nActionbar messages can be sent as well, however there's some oddities with them. They don't use the new JSON format, they actually use the legacy format which uses actual color codes. As such, they don't support click events, hover events, that sort of thing.\n\nThere are two ways that JSONMessage allows you to send action bars; a static method:\n\n```java\nJSONMessage.actionbar(\"Hello\", player);\n```\n\nTo add coloring to this you can use `\u0026` color codes:\n\n```java\nJSONMessage.actionbar(\"\u00266I got \u0026ccolors!\", player);\n```\n\nThe other way to send action bars is by creating a JSONMessage like you normally would and then send it to the player:\n\n```java\nJSONMessage.create(\"I am a title\")\n              .color(ChatColor.GREEN)\n              .style(ChatColor.ITALIC)\n            .actionbar(player);\n```\n\nThis will convert the JSON format to the legacy format and then send it to the player.\n\nIf you want to see all the available methods, you can find them just below this.\n\n## Methods overview\n\n### Text/Styling\nMethod             | Description\n------------------ | -----------\n`bar()`            | Creates a horizontal divider bar 53 characters long. This is perfect for the default chat window width\n`bar(int)`         | Creates a horizontal divider bar of the given length\n`create(String)`   | Creates a new JSONMessage with the given text as a starting point\n`color(ChatColor)` | Sets the color of the current message part\n`color(String)`    | Same as `color(ChatColor)` but allows the usage of HEX colors in 1.16 and newer\n`font(String)`     | Changes the font used for the text. Only usable in 1.16 and newer\n`newline()`        | Inserts a newline. It really isn't necessary, you can just use `\\n` if you want\n`style(ChatColor)` | Adds a style to the current message part\n`then(String)`     | Adds another part to the message\n\n### HoverAction\nMethod                 | Description\n---------------------- | -----------\n`achievement(String)`  | Shows an achievement with the given ID\n`tooltip(JSONMessage)` | Shows the given JSON as text (works just like the rest of this system)\n`tooltip(String)`      | Shows the given text\n\n### ClickAction\nMethod                   | Description\n------------------------ | -----------\n`changePage(int)`        | Changes the page of a book to the given page\n`copyText(String)`       | Copies the provided text into the Player's clipboard (1.15+ only. Will default to `suggestCommand(String)`)\n`openURL(String)`        | Opens the given URL\n`runCommand(String)`     | Runs the given command\n`suggestCommand(String)` | Suggests the given command by inserting it into the player's chat area\n\n### Sending\nMethod                                  | Description\n--------------------------------------- | -----------\n`actionbar(Player...)`                  | Converts the JSONMessage to the legacy format and sends it to one or multiple players\n`(static) actionbar(String, Player...)` | Sends an action-bar message to one or multiple players\n`send(Player...)`                       | Sends the JSONMessage to one or multiple players\n`subtitle(Player...)`                   | Sends the JSONMessage as a subtitle to one or multiple players\n`title(int, int, int, Player...)`       | Sends the JSONMessage as a title to one or multiple players. Int parameters are `fadeIn`, `stay`, and `fadeOut`\n\n### Others\nMethod       | Description\n------------ | -----------\n`toJSON()`   | Converts the JSONMessage to a `JsonObject` (Google's Gson library, comes with Bukkit)\n`toString()` | Converts the JSONMessage to a String, usable in things like `/tellraw`. This is an alias of `toJSON().toString()`\n\n### Method Notes\n\n- `color(ChatColor)` and `style(ChatColor)` both use ChatColors but require different types. Attempting to pass the wrong type in (e.g. doing `style(ChatColor.GREEN)`, or doing `color(ChatColor.BOLD)`) will result in an IllegalArgumentException.\n- `tooltip(JSONMessage)` takes another JSONMessage instance, allowing you to create fancy text for your tooltips.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxfirecodes%2FJSONMessage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoxfirecodes%2FJSONMessage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxfirecodes%2FJSONMessage/lists"}