{"action":"created","comment":{"url":"https://api.github.com/repos/Terasology/ServerMOTD/pulls/comments/171978443","pull_request_review_id":100931290,"id":171978443,"diff_hunk":"@@ -16,30 +16,55 @@\n package org.terasology.servermotd;\n \n import org.terasology.context.Context;\n+import org.terasology.entitySystem.entity.EntityManager;\n+import org.terasology.entitySystem.entity.EntityRef;\n import org.terasology.entitySystem.systems.BaseComponentSystem;\n import org.terasology.entitySystem.systems.RegisterMode;\n import org.terasology.entitySystem.systems.RegisterSystem;\n-import org.terasology.network.NetworkMode;\n-import org.terasology.network.NetworkSystem;\n+import org.terasology.logic.console.commandSystem.annotations.Command;\n+import org.terasology.logic.console.commandSystem.annotations.CommandParam;\n+import org.terasology.logic.console.commandSystem.annotations.Sender;\n import org.terasology.registry.CoreRegistry;\n-import org.terasology.registry.Share;\n+import org.terasology.registry.In;\n+\n+\n+@RegisterSystem(RegisterMode.AUTHORITY)\n+public class ServerMOTDSystem extends BaseComponentSystem {\n+    @In\n+    private EntityManager entityManager;\n \n-@Share(ServerMOTD.class)\n-@RegisterSystem(RegisterMode.ALWAYS)\n-public class ServerMOTDSystem extends BaseComponentSystem implements ServerMOTD {\n     private Context context = CoreRegistry.get(Context.class);\n \n-    @Override\n+    private EntityRef MOTDEntity;\n+    private MOTDProvider renderMOTD = new MOTDProvider();\n+\n     public void initialise() {\n-        String motd = \"default\";\n \n-        NetworkSystem networkSystem = context.get(NetworkSystem.class);\n+    }\n \n-        if (networkSystem.getMode() == NetworkMode.CLIENT) {\n-            if (motd != null && motd.length() != 0) {\n-                MOTDProvider renderMOTD = new MOTDProvider();\n-                renderMOTD.display(motd, context);\n-            }\n+    @Override\n+    public void postBegin() {\n+        MOTDEntity = renderMOTD.getMOTDEntity(entityManager);\n+    }\n+\n+    @Command(shortDescription = \"Edit server MOTD\", helpText = \"Edit the current server MOTD if you are admin.\" +\n+            \" Use \\'a\\' - to append to current MOTD\" +\n+            \" 'w' for a new one\", runOnServer = true)\n+    public String editMOTD(@CommandParam(value = \"a/w\") String type, @CommandParam(value = \"New Message\") String message, @Sender EntityRef admin) {","path":"src/main/java/org/terasology/servermotd/ServerMOTDSystem.java","position":52,"original_position":52,"commit_id":"c4a45b82aa2b4e25a76f09676f893309476f7279","original_commit_id":"c4a45b82aa2b4e25a76f09676f893309476f7279","user":{"login":"Cervator","id":1063833,"avatar_url":"https://avatars3.githubusercontent.com/u/1063833?v=4","gravatar_id":"","url":"https://api.github.com/users/Cervator","html_url":"https://github.com/Cervator","followers_url":"https://api.github.com/users/Cervator/followers","following_url":"https://api.github.com/users/Cervator/following{/other_user}","gists_url":"https://api.github.com/users/Cervator/gists{/gist_id}","starred_url":"https://api.github.com/users/Cervator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cervator/subscriptions","organizations_url":"https://api.github.com/users/Cervator/orgs","repos_url":"https://api.github.com/users/Cervator/repos","events_url":"https://api.github.com/users/Cervator/events{/privacy}","received_events_url":"https://api.github.com/users/Cervator/received_events","type":"User","site_admin":false},"body":"You'll probably want to move this command into the client system, as otherwise a *headless* server will never be able to have the MOTD edited. Having this command in an authority system means it'll only ever be available if a player is hosting a game directly via the game client. Instead you can use command permissions to ensure only admins can run it (for now: easiest to just require CHEAT level permission to execute)\r\n\r\nAlso: you might want to accept a single String argument version of the command that assumes the edit mode to be overwrite. You can make a two-arg command variant that accepts a boolean or the existing a/w thing to then select explicitly whether to overwrite or append","created_at":"2018-03-02T22:21:49Z","updated_at":"2018-03-02T22:29:40Z","html_url":"https://github.com/Terasology/ServerMOTD/pull/5#discussion_r171978443","pull_request_url":"https://api.github.com/repos/Terasology/ServerMOTD/pulls/5","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/Terasology/ServerMOTD/pulls/comments/171978443"},"html":{"href":"https://github.com/Terasology/ServerMOTD/pull/5#discussion_r171978443"},"pull_request":{"href":"https://api.github.com/repos/Terasology/ServerMOTD/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/Terasology/ServerMOTD/pulls/5","id":171313732,"html_url":"https://github.com/Terasology/ServerMOTD/pull/5","diff_url":"https://github.com/Terasology/ServerMOTD/pull/5.diff","patch_url":"https://github.com/Terasology/ServerMOTD/pull/5.patch","issue_url":"https://api.github.com/repos/Terasology/ServerMOTD/issues/5","number":5,"state":"open","locked":false,"title":"Custom MOTD commands","user":{"login":"Naman-sopho","id":23008871,"avatar_url":"https://avatars0.githubusercontent.com/u/23008871?v=4","gravatar_id":"","url":"https://api.github.com/users/Naman-sopho","html_url":"https://github.com/Naman-sopho","followers_url":"https://api.github.com/users/Naman-sopho/followers","following_url":"https://api.github.com/users/Naman-sopho/following{/other_user}","gists_url":"https://api.github.com/users/Naman-sopho/gists{/gist_id}","starred_url":"https://api.github.com/users/Naman-sopho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Naman-sopho/subscriptions","organizations_url":"https://api.github.com/users/Naman-sopho/orgs","repos_url":"https://api.github.com/users/Naman-sopho/repos","events_url":"https://api.github.com/users/Naman-sopho/events{/privacy}","received_events_url":"https://api.github.com/users/Naman-sopho/received_events","type":"User","site_admin":false},"body":"- FIxes #1 , added .gitignore and readme.\r\n- A part of the suggestion as mentioned in #3 has been implemented, the MOTD is now being handled as a Component in an Entity.\r\n- editMOTD and displayMOTD commands are working as expected.\r\n\r\n**How to test**\r\n- Add the `@API` annotation to the [MessagePopup](https://github.com/MovingBlocks/Terasology/blob/develop/engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/MessagePopup.java) class.\r\n- Start a game instance, use the `Host Game` option to run a game with the ServerMOTD module activated.\r\n- Start another game instance, use the `Join Game` option and select the game hosted in the previous step(it would be `localhost` under the `Custom` tab). A default MOTD(if not edited by the host before the client joins) would be displayed while the game loads.\r\n- Run the `editMOTD` command in the console with the any of the `a/w` parameters, a message confirming the change would be displayed.\r\n- Run the `displayMOTD` in the client as well as the host instance to test.","created_at":"2018-02-26T08:56:08Z","updated_at":"2018-03-02T22:29:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d35ac00b9b8109ada6417cf2a92f2e24ba1415d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Terasology/ServerMOTD/pulls/5/commits","review_comments_url":"https://api.github.com/repos/Terasology/ServerMOTD/pulls/5/comments","review_comment_url":"https://api.github.com/repos/Terasology/ServerMOTD/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Terasology/ServerMOTD/issues/5/comments","statuses_url":"https://api.github.com/repos/Terasology/ServerMOTD/statuses/c4a45b82aa2b4e25a76f09676f893309476f7279","head":{"label":"Naman-sopho:Custom-MOTD-edit-command","ref":"Custom-MOTD-edit-command","sha":"c4a45b82aa2b4e25a76f09676f893309476f7279","user":{"login":"Naman-sopho","id":23008871,"avatar_url":"https://avatars0.githubusercontent.com/u/23008871?v=4","gravatar_id":"","url":"https://api.github.com/users/Naman-sopho","html_url":"https://github.com/Naman-sopho","followers_url":"https://api.github.com/users/Naman-sopho/followers","following_url":"https://api.github.com/users/Naman-sopho/following{/other_user}","gists_url":"https://api.github.com/users/Naman-sopho/gists{/gist_id}","starred_url":"https://api.github.com/users/Naman-sopho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Naman-sopho/subscriptions","organizations_url":"https://api.github.com/users/Naman-sopho/orgs","repos_url":"https://api.github.com/users/Naman-sopho/repos","events_url":"https://api.github.com/users/Naman-sopho/events{/privacy}","received_events_url":"https://api.github.com/users/Naman-sopho/received_events","type":"User","site_admin":false},"repo":{"id":120989978,"name":"ServerMOTD","full_name":"Naman-sopho/ServerMOTD","owner":{"login":"Naman-sopho","id":23008871,"avatar_url":"https://avatars0.githubusercontent.com/u/23008871?v=4","gravatar_id":"","url":"https://api.github.com/users/Naman-sopho","html_url":"https://github.com/Naman-sopho","followers_url":"https://api.github.com/users/Naman-sopho/followers","following_url":"https://api.github.com/users/Naman-sopho/following{/other_user}","gists_url":"https://api.github.com/users/Naman-sopho/gists{/gist_id}","starred_url":"https://api.github.com/users/Naman-sopho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Naman-sopho/subscriptions","organizations_url":"https://api.github.com/users/Naman-sopho/orgs","repos_url":"https://api.github.com/users/Naman-sopho/repos","events_url":"https://api.github.com/users/Naman-sopho/events{/privacy}","received_events_url":"https://api.github.com/users/Naman-sopho/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Naman-sopho/ServerMOTD","description":null,"fork":true,"url":"https://api.github.com/repos/Naman-sopho/ServerMOTD","forks_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/forks","keys_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/teams","hooks_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/hooks","issue_events_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/issues/events{/number}","events_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/events","assignees_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/assignees{/user}","branches_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/branches{/branch}","tags_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/tags","blobs_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/git/refs{/sha}","trees_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/statuses/{sha}","languages_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/languages","stargazers_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/stargazers","contributors_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/contributors","subscribers_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/subscribers","subscription_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/subscription","commits_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/commits{/sha}","git_commits_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/git/commits{/sha}","comments_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/comments{/number}","issue_comment_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/issues/comments{/number}","contents_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/contents/{+path}","compare_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/merges","archive_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/downloads","issues_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/issues{/number}","pulls_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/pulls{/number}","milestones_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/milestones{/number}","notifications_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/labels{/name}","releases_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/releases{/id}","deployments_url":"https://api.github.com/repos/Naman-sopho/ServerMOTD/deployments","created_at":"2018-02-10T06:11:15Z","updated_at":"2018-02-10T06:11:17Z","pushed_at":"2018-02-26T08:25:10Z","git_url":"git://github.com/Naman-sopho/ServerMOTD.git","ssh_url":"git@github.com:Naman-sopho/ServerMOTD.git","clone_url":"https://github.com/Naman-sopho/ServerMOTD.git","svn_url":"https://github.com/Naman-sopho/ServerMOTD","homepage":null,"size":12,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Terasology:Custom-MOTD-edit-command","ref":"Custom-MOTD-edit-command","sha":"9e74947d5ca85c92d8a530b4fd0afc53ef9fde3d","user":{"login":"Terasology","id":4554375,"avatar_url":"https://avatars1.githubusercontent.com/u/4554375?v=4","gravatar_id":"","url":"https://api.github.com/users/Terasology","html_url":"https://github.com/Terasology","followers_url":"https://api.github.com/users/Terasology/followers","following_url":"https://api.github.com/users/Terasology/following{/other_user}","gists_url":"https://api.github.com/users/Terasology/gists{/gist_id}","starred_url":"https://api.github.com/users/Terasology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Terasology/subscriptions","organizations_url":"https://api.github.com/users/Terasology/orgs","repos_url":"https://api.github.com/users/Terasology/repos","events_url":"https://api.github.com/users/Terasology/events{/privacy}","received_events_url":"https://api.github.com/users/Terasology/received_events","type":"Organization","site_admin":false},"repo":{"id":120338062,"name":"ServerMOTD","full_name":"Terasology/ServerMOTD","owner":{"login":"Terasology","id":4554375,"avatar_url":"https://avatars1.githubusercontent.com/u/4554375?v=4","gravatar_id":"","url":"https://api.github.com/users/Terasology","html_url":"https://github.com/Terasology","followers_url":"https://api.github.com/users/Terasology/followers","following_url":"https://api.github.com/users/Terasology/following{/other_user}","gists_url":"https://api.github.com/users/Terasology/gists{/gist_id}","starred_url":"https://api.github.com/users/Terasology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Terasology/subscriptions","organizations_url":"https://api.github.com/users/Terasology/orgs","repos_url":"https://api.github.com/users/Terasology/repos","events_url":"https://api.github.com/users/Terasology/events{/privacy}","received_events_url":"https://api.github.com/users/Terasology/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Terasology/ServerMOTD","description":null,"fork":false,"url":"https://api.github.com/repos/Terasology/ServerMOTD","forks_url":"https://api.github.com/repos/Terasology/ServerMOTD/forks","keys_url":"https://api.github.com/repos/Terasology/ServerMOTD/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Terasology/ServerMOTD/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Terasology/ServerMOTD/teams","hooks_url":"https://api.github.com/repos/Terasology/ServerMOTD/hooks","issue_events_url":"https://api.github.com/repos/Terasology/ServerMOTD/issues/events{/number}","events_url":"https://api.github.com/repos/Terasology/ServerMOTD/events","assignees_url":"https://api.github.com/repos/Terasology/ServerMOTD/assignees{/user}","branches_url":"https://api.github.com/repos/Terasology/ServerMOTD/branches{/branch}","tags_url":"https://api.github.com/repos/Terasology/ServerMOTD/tags","blobs_url":"https://api.github.com/repos/Terasology/ServerMOTD/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Terasology/ServerMOTD/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Terasology/ServerMOTD/git/refs{/sha}","trees_url":"https://api.github.com/repos/Terasology/ServerMOTD/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Terasology/ServerMOTD/statuses/{sha}","languages_url":"https://api.github.com/repos/Terasology/ServerMOTD/languages","stargazers_url":"https://api.github.com/repos/Terasology/ServerMOTD/stargazers","contributors_url":"https://api.github.com/repos/Terasology/ServerMOTD/contributors","subscribers_url":"https://api.github.com/repos/Terasology/ServerMOTD/subscribers","subscription_url":"https://api.github.com/repos/Terasology/ServerMOTD/subscription","commits_url":"https://api.github.com/repos/Terasology/ServerMOTD/commits{/sha}","git_commits_url":"https://api.github.com/repos/Terasology/ServerMOTD/git/commits{/sha}","comments_url":"https://api.github.com/repos/Terasology/ServerMOTD/comments{/number}","issue_comment_url":"https://api.github.com/repos/Terasology/ServerMOTD/issues/comments{/number}","contents_url":"https://api.github.com/repos/Terasology/ServerMOTD/contents/{+path}","compare_url":"https://api.github.com/repos/Terasology/ServerMOTD/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Terasology/ServerMOTD/merges","archive_url":"https://api.github.com/repos/Terasology/ServerMOTD/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Terasology/ServerMOTD/downloads","issues_url":"https://api.github.com/repos/Terasology/ServerMOTD/issues{/number}","pulls_url":"https://api.github.com/repos/Terasology/ServerMOTD/pulls{/number}","milestones_url":"https://api.github.com/repos/Terasology/ServerMOTD/milestones{/number}","notifications_url":"https://api.github.com/repos/Terasology/ServerMOTD/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Terasology/ServerMOTD/labels{/name}","releases_url":"https://api.github.com/repos/Terasology/ServerMOTD/releases{/id}","deployments_url":"https://api.github.com/repos/Terasology/ServerMOTD/deployments","created_at":"2018-02-05T17:29:25Z","updated_at":"2018-02-05T17:30:35Z","pushed_at":"2018-02-26T08:56:09Z","git_url":"git://github.com/Terasology/ServerMOTD.git","ssh_url":"git@github.com:Terasology/ServerMOTD.git","clone_url":"https://github.com/Terasology/ServerMOTD.git","svn_url":"https://github.com/Terasology/ServerMOTD","homepage":null,"size":6,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":1,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Terasology/ServerMOTD/pulls/5"},"html":{"href":"https://github.com/Terasology/ServerMOTD/pull/5"},"issue":{"href":"https://api.github.com/repos/Terasology/ServerMOTD/issues/5"},"comments":{"href":"https://api.github.com/repos/Terasology/ServerMOTD/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/Terasology/ServerMOTD/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/Terasology/ServerMOTD/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Terasology/ServerMOTD/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/Terasology/ServerMOTD/statuses/c4a45b82aa2b4e25a76f09676f893309476f7279"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"Cervator"}}