{"action":"created","comment":{"url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/comments/37695840","id":37695840,"diff_hunk":"@@ -234,6 +251,63 @@ public static Text of(Object... objects) {\n             }\n         }\n \n+        if (builder.children.size() == 1) {\n+            // Single content, reduce Text depth\n+            return builder.children.get(0);\n+        }\n+        return builder.build();\n+    }\n+\n+    /**\n+     * Builds a {@link Text} from a given array of content objects. This method\n+     * assumes, that all elements of the array are content and not formatting.\n+     *\n+     * <p>This will create the correct {@link Text} instance if the input object\n+     * is the input for one of the {@link Text} types or convert the object to a\n+     * string otherwise.</p>\n+     *\n+     * @param separator The separator to be inserted between elements\n+     * @param objects The object array\n+     * @return The built text object\n+     */\n+    public static Text joinOf(Text separator, Object... objects) {\n+        TextBuilder builder = builder();\n+        boolean first = true;\n+\n+        for (Object part : objects) {\n+            if (!first) {\n+                builder.append(separator);\n+            }\n+            first = false;\n+            builder.append(Texts.of(part));","path":"src/main/java/org/spongepowered/api/text/Texts.java","position":162,"original_position":146,"commit_id":"2e46a31f375beef68363ed05ef396182f2a9b59d","original_commit_id":"915f660bd82dd7d179ae19a1d82d8c92dc81dcd0","user":{"login":"ST-DDT","id":1579362,"avatar_url":"https://avatars.githubusercontent.com/u/1579362?v=3","gravatar_id":"","url":"https://api.github.com/users/ST-DDT","html_url":"https://github.com/ST-DDT","followers_url":"https://api.github.com/users/ST-DDT/followers","following_url":"https://api.github.com/users/ST-DDT/following{/other_user}","gists_url":"https://api.github.com/users/ST-DDT/gists{/gist_id}","starred_url":"https://api.github.com/users/ST-DDT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ST-DDT/subscriptions","organizations_url":"https://api.github.com/users/ST-DDT/orgs","repos_url":"https://api.github.com/users/ST-DDT/repos","events_url":"https://api.github.com/users/ST-DDT/events{/privacy}","received_events_url":"https://api.github.com/users/ST-DDT/received_events","type":"User","site_admin":false},"body":"Yeah, I know what you mean, but your usecase is very unlikely (IMO).\r\nBecause you can't distinguish each team, because its flatten away.\r\n\r\n````\r\nThe teams are Player1, Player2, Player3, Player4, Player5, Player6, Player7, Player8, Player9\r\n````\r\n\r\nWhich player belongs to which team?\r\nSo you would probably send a message/line per Team or at a separator between the teams:\r\n````java\r\nList<Text> texts = List.newList();\r\ntext.add(Texts.of(\"The teams are \"));\r\nfor (Set<Player> members : teams) {\r\n    text.add(Texts.join(Texts.of(\", \"), members));\r\n}\r\nplayer.sendMessage(Texts.join(Texts.of(\"\\n\"), texts));\r\n````\r\nWhich results in:\r\n````\r\nThe teams are \r\nTeam1: Player1, Player2, Player3\r\nTeam2: Player4, Player5, Player6\r\nTeam3: Player7, Player8, Player9\r\n````\r\nDo you actually want to use that method or do you just think it could be useful?\r\nIn the first case I would add it, until discussed away.\r\nThe the second case I would wait until we decided on its usefulness.","created_at":"2015-08-22T13:41:44Z","updated_at":"2015-08-22T13:41:44Z","html_url":"https://github.com/SpongePowered/SpongeAPI/pull/808#discussion_r37695840","pull_request_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/808","_links":{"self":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/comments/37695840"},"html":{"href":"https://github.com/SpongePowered/SpongeAPI/pull/808#discussion_r37695840"},"pull_request":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/808"}}},"pull_request":{"url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/808","id":42517129,"html_url":"https://github.com/SpongePowered/SpongeAPI/pull/808","diff_url":"https://github.com/SpongePowered/SpongeAPI/pull/808.diff","patch_url":"https://github.com/SpongePowered/SpongeAPI/pull/808.patch","issue_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/808","number":808,"state":"open","locked":false,"title":"Improve Texts.format(...) method","user":{"login":"ST-DDT","id":1579362,"avatar_url":"https://avatars.githubusercontent.com/u/1579362?v=3","gravatar_id":"","url":"https://api.github.com/users/ST-DDT","html_url":"https://github.com/ST-DDT","followers_url":"https://api.github.com/users/ST-DDT/followers","following_url":"https://api.github.com/users/ST-DDT/following{/other_user}","gists_url":"https://api.github.com/users/ST-DDT/gists{/gist_id}","starred_url":"https://api.github.com/users/ST-DDT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ST-DDT/subscriptions","organizations_url":"https://api.github.com/users/ST-DDT/orgs","repos_url":"https://api.github.com/users/ST-DDT/repos","events_url":"https://api.github.com/users/ST-DDT/events{/privacy}","received_events_url":"https://api.github.com/users/ST-DDT/received_events","type":"User","site_admin":false},"body":"This PR improves the changes made in #779.\r\nImplementation: https://github.com/SpongePowered/SpongeCommon/pull/129\r\n\r\n**Additions**\r\n- `Texts.format(Text, Function<String,?>)`\r\n  - Allows lazy fetching of replacements\r\n    - Example: Directly fetch player prefixes from a permission plugin without being bound to just `prefix` or similar. `{world}{faction}{foobar}{prefix}{player}: {message}`\r\n\r\n**Changes**\r\n- `Texts.of(Object...)` now supports `Translatable` as arguments\r\n- `Entity` extends `Translatable` + `TextRepresentable`\r\n- `User` extends `TextRepresentable`\r\n- `Text.Style#toString()` now only shows set/present values or `NONE`\r\n\r\n**[TextRepresentables](https://github.com/SpongePowered/SpongeAPI/blob/master/src/main/java/org/spongepowered/api/text/TextRepresentable.java)**\r\n- `Achievement`\r\n- `Entity`\r\n- `ItemStack`\r\n- `Player`\r\n- `User`\r\n\r\nIf I have missed something with a special text representation like `ItemStack` or `Achievement` please post a comment.\r\n\r\n**Suggestion**\r\n@zml2008 \r\nWith this changes it would be possible to further improve the [PlayerChatEvent](https://github.com/SpongePowered/SpongeAPI/commit/e1e77b90a19bf5404926082bc860fda82301a8f4) by adding a replaceable `Function<String,?>` to the event, that allows plugins to inject their own variables in there and allowing a chat plugin to decide on the final order and appearance.\r\n\r\n````java\r\n// Arena Plugin\r\n@Subscribe\r\npublic void onArenaChat(PlayerChatEvent event) {\r\n    Arena arena = getArenaForPlayer(event.getPlayer);\r\n    if (arena != null) {\r\n        event.addVariable(\"arena\", arena);\r\n        event.addVariable(\"arenaTeam\", arena.getTeamForPlayer(event.getPlayer));\r\n    }\r\n}\r\n\r\n// Permission Plugin\r\n@Subscribe\r\npublic void onPermissionChat(PlayerChatEvent event) {\r\n    Subject subject = event.getPlayer().getSubject();\r\n    Function<String,?> prefixResolver = { key -> return subject.getOptionValue(key).orNull() };\r\n    Function<String,?> variableResovler = event.getVariableFunction();\r\n    Function<String,?> newVariableResovler = new FallbackFunction(variableResovler, prefixResolver);\r\n    event.setVariableFunction(newVariableResovler);\r\n}\r\n\r\n// Chat Plugin\r\n@Subscribe\r\npublic void onChatChat(PlayerChatEvent event) {\r\n    Function<String,?> fallback = Functions.constant(Texts.of());\r\n    Function<String,?> variableResovler = event.getVariableFunction();\r\n    Function<String,?> newVariableResovler = new FallbackFunction(variableResovler, fallback);\r\n    event.setVariableFunction(newVariableResovler);\r\n    event.setMessageFormat(getMessageFormat());\r\n    // Format: {world}{prefix}{arena}{player}: {message}\r\n    // Result: [MOD][TTT]MrCT: The bomb has been defused!\r\n}\r\n\r\n// API Util\r\npublic class FallbackFunction<F, T> implements Function<F, T> {\r\n\r\n    @Override\r\n    public T apply(F input) {\r\n        T result = main.apply(input);\r\n        if (result == null) {\r\n            return fallback.apply(input);\r\n        }\r\n        return result;\r\n    }\r\n\r\n}\r\n````\r\nhttps://gist.github.com/ST-DDT/d48b1947525e9f1cdfb4","created_at":"2015-08-15T10:05:18Z","updated_at":"2015-08-22T13:41:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"473723b30f91112c994191926430add5ef4e1601","assignee":{"login":"Minecrell","id":3035868,"avatar_url":"https://avatars.githubusercontent.com/u/3035868?v=3","gravatar_id":"","url":"https://api.github.com/users/Minecrell","html_url":"https://github.com/Minecrell","followers_url":"https://api.github.com/users/Minecrell/followers","following_url":"https://api.github.com/users/Minecrell/following{/other_user}","gists_url":"https://api.github.com/users/Minecrell/gists{/gist_id}","starred_url":"https://api.github.com/users/Minecrell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Minecrell/subscriptions","organizations_url":"https://api.github.com/users/Minecrell/orgs","repos_url":"https://api.github.com/users/Minecrell/repos","events_url":"https://api.github.com/users/Minecrell/events{/privacy}","received_events_url":"https://api.github.com/users/Minecrell/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/808/commits","review_comments_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/808/comments","review_comment_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/808/comments","statuses_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/statuses/2e46a31f375beef68363ed05ef396182f2a9b59d","head":{"label":"ST-DDT:TextFormatExt","ref":"TextFormatExt","sha":"2e46a31f375beef68363ed05ef396182f2a9b59d","user":{"login":"ST-DDT","id":1579362,"avatar_url":"https://avatars.githubusercontent.com/u/1579362?v=3","gravatar_id":"","url":"https://api.github.com/users/ST-DDT","html_url":"https://github.com/ST-DDT","followers_url":"https://api.github.com/users/ST-DDT/followers","following_url":"https://api.github.com/users/ST-DDT/following{/other_user}","gists_url":"https://api.github.com/users/ST-DDT/gists{/gist_id}","starred_url":"https://api.github.com/users/ST-DDT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ST-DDT/subscriptions","organizations_url":"https://api.github.com/users/ST-DDT/orgs","repos_url":"https://api.github.com/users/ST-DDT/repos","events_url":"https://api.github.com/users/ST-DDT/events{/privacy}","received_events_url":"https://api.github.com/users/ST-DDT/received_events","type":"User","site_admin":false},"repo":{"id":23807335,"name":"SpongeAPI","full_name":"ST-DDT/SpongeAPI","owner":{"login":"ST-DDT","id":1579362,"avatar_url":"https://avatars.githubusercontent.com/u/1579362?v=3","gravatar_id":"","url":"https://api.github.com/users/ST-DDT","html_url":"https://github.com/ST-DDT","followers_url":"https://api.github.com/users/ST-DDT/followers","following_url":"https://api.github.com/users/ST-DDT/following{/other_user}","gists_url":"https://api.github.com/users/ST-DDT/gists{/gist_id}","starred_url":"https://api.github.com/users/ST-DDT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ST-DDT/subscriptions","organizations_url":"https://api.github.com/users/ST-DDT/orgs","repos_url":"https://api.github.com/users/ST-DDT/repos","events_url":"https://api.github.com/users/ST-DDT/events{/privacy}","received_events_url":"https://api.github.com/users/ST-DDT/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ST-DDT/SpongeAPI","description":"A Minecraft plugin API (not including an implementation)","fork":true,"url":"https://api.github.com/repos/ST-DDT/SpongeAPI","forks_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/forks","keys_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/teams","hooks_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/hooks","issue_events_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/issues/events{/number}","events_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/events","assignees_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/assignees{/user}","branches_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/branches{/branch}","tags_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/tags","blobs_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/git/refs{/sha}","trees_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/statuses/{sha}","languages_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/languages","stargazers_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/stargazers","contributors_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/contributors","subscribers_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/subscribers","subscription_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/subscription","commits_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/commits{/sha}","git_commits_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/git/commits{/sha}","comments_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/comments{/number}","issue_comment_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/issues/comments{/number}","contents_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/contents/{+path}","compare_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/merges","archive_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/downloads","issues_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/issues{/number}","pulls_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/pulls{/number}","milestones_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/milestones{/number}","notifications_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/labels{/name}","releases_url":"https://api.github.com/repos/ST-DDT/SpongeAPI/releases{/id}","created_at":"2014-09-08T20:37:00Z","updated_at":"2015-04-13T18:38:02Z","pushed_at":"2015-08-22T13:24:57Z","git_url":"git://github.com/ST-DDT/SpongeAPI.git","ssh_url":"git@github.com:ST-DDT/SpongeAPI.git","clone_url":"https://github.com/ST-DDT/SpongeAPI.git","svn_url":"https://github.com/ST-DDT/SpongeAPI","homepage":"http://www.spongepowered.org/","size":5226,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"SpongePowered:master","ref":"master","sha":"41572db0b1cc37d77b084214e31363119fc70ccc","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}","created_at":"2014-09-07T20:39:25Z","updated_at":"2015-08-20T10:32:17Z","pushed_at":"2015-08-22T13:24:58Z","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":24908,"stargazers_count":789,"watchers_count":789,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":345,"mirror_url":null,"open_issues_count":99,"forks":345,"open_issues":99,"watchers":789,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/808"},"html":{"href":"https://github.com/SpongePowered/SpongeAPI/pull/808"},"issue":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/808"},"comments":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/808/comments"},"review_comments":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/808/comments"},"review_comment":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/808/commits"},"statuses":{"href":"https://api.github.com/repos/SpongePowered/SpongeAPI/statuses/2e46a31f375beef68363ed05ef396182f2a9b59d"}}}}