{"action":"opened","number":1117,"pull_request":{"url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/1117","id":60993983,"html_url":"https://github.com/SpongePowered/SpongeAPI/pull/1117","diff_url":"https://github.com/SpongePowered/SpongeAPI/pull/1117.diff","patch_url":"https://github.com/SpongePowered/SpongeAPI/pull/1117.patch","issue_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/1117","number":1117,"state":"open","locked":false,"title":"Changes to MessageEvent","user":{"login":"windy1","id":755713,"avatar_url":"https://avatars.githubusercontent.com/u/755713?v=3","gravatar_id":"","url":"https://api.github.com/users/windy1","html_url":"https://github.com/windy1","followers_url":"https://api.github.com/users/windy1/followers","following_url":"https://api.github.com/users/windy1/following{/other_user}","gists_url":"https://api.github.com/users/windy1/gists{/gist_id}","starred_url":"https://api.github.com/users/windy1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/windy1/subscriptions","organizations_url":"https://api.github.com/users/windy1/orgs","repos_url":"https://api.github.com/users/windy1/repos","events_url":"https://api.github.com/users/windy1/events{/privacy}","received_events_url":"https://api.github.com/users/windy1/received_events","type":"User","site_admin":false},"body":"[**API**](https://github.com/SpongePowered/SpongeAPI/pull/1114) | [Common](https://github.com/SpongePowered/SpongeCommon/pull/548) | [Vanilla](https://github.com/SpongePowered/SpongeVanilla/pull/229) | [Forge](https://github.com/SpongePowered/SpongeForge/pull/559)\r\n\r\nThis PR makes some substantial changes to how MessageEvents are handled. Instead of passing around a `Text` object, the event now contains a `MessageFormatter` which can be used to modify the event's message in a more reliable and modular fashion. This will make interactions and compatibility between chat plugins a lot easier. Previous methods like `getOriginalMessage`, `getRawMessage`, `getMessage`, and `setMessage` still behave as expected except instead of Optionals, a non-null Text is always returned. Developers should use `setMessageCancelled` to cancel the sending instead of setting the message to null.\r\n\r\n----\r\n\r\nSome example uses:\r\n\r\nLet's say I would like to insert a \"group\" prefix to the message but I also would like to keep existing prefixes that other plugins may or may not have already applied. I can do something like:\r\n\r\n```java\r\nclass GroupApplier extends SimpleTextTemplateApplier {\r\n    public GroupApplier() {\r\n        super(of('[', arg(\"group\"), \"] \"));\r\n    }\r\n}\r\n```\r\n\r\n```java\r\n@Listener\r\nvoid onChat(MessageChannelEvent.Chat event) {\r\n    GroupApplier applier = new GroupApplier();\r\n    applier.setParameter(\"group\", Text.builder(\"admin\").color(TextColors.RED));\r\n    event.getFormatter().getHeader().insert(0, applier);\r\n}\r\n```\r\n\r\nOn an unaltered message, this will produce something equivalent to:\r\n\r\n`[<red>admin</red>] <NAME> MESSAGE`\r\n\r\nNow lets say another plugin wants to override that prefix and make it say \"mod\" instead of \"admin\". Well then they can do:\r\n\r\n```java\r\nevent.getHeader().forEach(GroupApplier.class, applier -> applier.setParameter(\"group\", Text.builder(\"mod\").color(TextColors.AQUA));\r\n```\r\n\r\nThese are only a few of the many uses this PR will provide.\r\n\r\n**Note:** This PR depends on https://github.com/SpongePowered/SpongeAPI/pull/1079. https://github.com/SpongePowered/SpongeAPI/pull/1079 should be merged into master *and then into bleeding* before this PR is merged.","created_at":"2016-02-28T14:56:42Z","updated_at":"2016-02-28T14:56:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1ffdd412a3b7d395aa98e4a36528f0e53c3a9b9c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/1117/commits","review_comments_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/1117/comments","review_comment_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/1117/comments","statuses_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/statuses/b108ef81fefd60404984634a5cc7069e60cafb6a","head":{"label":"SpongePowered:feature/messages","ref":"feature/messages","sha":"b108ef81fefd60404984634a5cc7069e60cafb6a","user":{"login":"SpongePowered","id":8683473,"avatar_url":"https://avatars.githubusercontent.com/u/8683473?v=3","gravatar_id":"","url":"https://api.github.com/users/SpongePowered","html_url":"https://github.com/SpongePowered","followers_url":"https://api.github.com/users/SpongePowered/followers","following_url":"https://api.github.com/users/SpongePowered/following{/other_user}","gists_url":"https://api.github.com/users/SpongePowered/gists{/gist_id}","starred_url":"https://api.github.com/users/SpongePowered/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpongePowered/subscriptions","organizations_url":"https://api.github.com/users/SpongePowered/orgs","repos_url":"https://api.github.com/users/SpongePowered/repos","events_url":"https://api.github.com/users/SpongePowered/events{/privacy}","received_events_url":"https://api.github.com/users/SpongePowered/received_events","type":"Organization","site_admin":false},"repo":{"id":23770421,"name":"SpongeAPI","full_name":"SpongePowered/SpongeAPI","owner":{"login":"SpongePowered","id":8683473,"avatar_url":"https://avatars.githubusercontent.com/u/8683473?v=3","gravatar_id":"","url":"https://api.github.com/users/SpongePowered","html_url":"https://github.com/SpongePowered","followers_url":"https://api.github.com/users/SpongePowered/followers","following_url":"https://api.github.com/users/SpongePowered/following{/other_user}","gists_url":"https://api.github.com/users/SpongePowered/gists{/gist_id}","starred_url":"https://api.github.com/users/SpongePowered/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpongePowered/subscriptions","organizations_url":"https://api.github.com/users/SpongePowered/orgs","repos_url":"https://api.github.com/users/SpongePowered/repos","events_url":"https://api.github.com/users/SpongePowered/events{/privacy}","received_events_url":"https://api.github.com/users/SpongePowered/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SpongePowered/SpongeAPI","description":"A Minecraft plugin API","fork":false,"url":"https://api.github.com/repos/SpongePowered/SpongeAPI","forks_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/forks","keys_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/teams","hooks_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/hooks","issue_events_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/events{/number}","events_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/events","assignees_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/assignees{/user}","branches_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/branches{/branch}","tags_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/tags","blobs_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/git/refs{/sha}","trees_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/statuses/{sha}","languages_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/languages","stargazers_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/stargazers","contributors_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/contributors","subscribers_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/subscribers","subscription_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/subscription","commits_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/commits{/sha}","git_commits_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/git/commits{/sha}","comments_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/comments{/number}","issue_comment_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/comments{/number}","contents_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/contents/{+path}","compare_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/merges","archive_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/downloads","issues_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues{/number}","pulls_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls{/number}","milestones_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/milestones{/number}","notifications_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/labels{/name}","releases_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/releases{/id}","deployments_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/deployments","created_at":"2014-09-07T20:39:25Z","updated_at":"2016-02-28T04:07:10Z","pushed_at":"2016-02-28T14:56:42Z","git_url":"git://github.com/SpongePowered/SpongeAPI.git","ssh_url":"git@github.com:SpongePowered/SpongeAPI.git","clone_url":"https://github.com/SpongePowered/SpongeAPI.git","svn_url":"https://github.com/SpongePowered/SpongeAPI","homepage":"http://www.spongepowered.org/","size":21250,"stargazers_count":843,"watchers_count":843,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":347,"mirror_url":null,"open_issues_count":126,"forks":347,"open_issues":126,"watchers":843,"default_branch":"master"}},"base":{"label":"SpongePowered:master","ref":"master","sha":"9b5d6c4ccd48b2a90843c9c0d17a0bbf037b4eee","user":{"login":"SpongePowered","id":8683473,"avatar_url":"https://avatars.githubusercontent.com/u/8683473?v=3","gravatar_id":"","url":"https://api.github.com/users/SpongePowered","html_url":"https://github.com/SpongePowered","followers_url":"https://api.github.com/users/SpongePowered/followers","following_url":"https://api.github.com/users/SpongePowered/following{/other_user}","gists_url":"https://api.github.com/users/SpongePowered/gists{/gist_id}","starred_url":"https://api.github.com/users/SpongePowered/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpongePowered/subscriptions","organizations_url":"https://api.github.com/users/SpongePowered/orgs","repos_url":"https://api.github.com/users/SpongePowered/repos","events_url":"https://api.github.com/users/SpongePowered/events{/privacy}","received_events_url":"https://api.github.com/users/SpongePowered/received_events","type":"Organization","site_admin":false},"repo":{"id":23770421,"name":"SpongeAPI","full_name":"SpongePowered/SpongeAPI","owner":{"login":"SpongePowered","id":8683473,"avatar_url":"https://avatars.githubusercontent.com/u/8683473?v=3","gravatar_id":"","url":"https://api.github.com/users/SpongePowered","html_url":"https://github.com/SpongePowered","followers_url":"https://api.github.com/users/SpongePowered/followers","following_url":"https://api.github.com/users/SpongePowered/following{/other_user}","gists_url":"https://api.github.com/users/SpongePowered/gists{/gist_id}","starred_url":"https://api.github.com/users/SpongePowered/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpongePowered/subscriptions","organizations_url":"https://api.github.com/users/SpongePowered/orgs","repos_url":"https://api.github.com/users/SpongePowered/repos","events_url":"https://api.github.com/users/SpongePowered/events{/privacy}","received_events_url":"https://api.github.com/users/SpongePowered/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SpongePowered/SpongeAPI","description":"A Minecraft plugin API","fork":false,"url":"https://api.github.com/repos/SpongePowered/SpongeAPI","forks_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/forks","keys_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/teams","hooks_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/hooks","issue_events_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/events{/number}","events_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/events","assignees_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/assignees{/user}","branches_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/branches{/branch}","tags_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/tags","blobs_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/git/refs{/sha}","trees_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/statuses/{sha}","languages_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/languages","stargazers_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/stargazers","contributors_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/contributors","subscribers_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/subscribers","subscription_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/subscription","commits_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/commits{/sha}","git_commits_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/git/commits{/sha}","comments_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/comments{/number}","issue_comment_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/comments{/number}","contents_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/contents/{+path}","compare_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/merges","archive_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/downloads","issues_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues{/number}","pulls_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls{/number}","milestones_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/milestones{/number}","notifications_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/labels{/name}","releases_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/releases{/id}","deployments_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/deployments","created_at":"2014-09-07T20:39:25Z","updated_at":"2016-02-28T04:07:10Z","pushed_at":"2016-02-28T14:56:42Z","git_url":"git://github.com/SpongePowered/SpongeAPI.git","ssh_url":"git@github.com:SpongePowered/SpongeAPI.git","clone_url":"https://github.com/SpongePowered/SpongeAPI.git","svn_url":"https://github.com/SpongePowered/SpongeAPI","homepage":"http://www.spongepowered.org/","size":21250,"stargazers_count":843,"watchers_count":843,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":347,"mirror_url":null,"open_issues_count":126,"forks":347,"open_issues":126,"watchers":843,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/1117"},"html":{"href":"https://github.com/SpongePowered/SpongeAPI/pull/1117"},"issue":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/1117"},"comments":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/1117/comments"},"review_comments":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/1117/comments"},"review_comment":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/1117/commits"},"statuses":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/statuses/b108ef81fefd60404984634a5cc7069e60cafb6a"}},"merged":false,"mergeable":true,"mergeable_state":"unstable","merged_by":null,"comments":0,"review_comments":0,"commits":55,"additions":5423,"deletions":1254,"changed_files":163}}