{"action":"created","issue":{"url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/1210","repository_url":"https://api.github.com/repos/SpongePowered/SpongeAPI","labels_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/1210/labels{/name}","comments_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/1210/comments","events_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/1210/events","html_url":"https://github.com/SpongePowered/SpongeAPI/pull/1210","id":152036435,"number":1210,"title":"Add Key bindings API","user":{"login":"Cybermaxke","id":1364375,"avatar_url":"https://avatars.githubusercontent.com/u/1364375?v=3","gravatar_id":"","url":"https://api.github.com/users/Cybermaxke","html_url":"https://github.com/Cybermaxke","followers_url":"https://api.github.com/users/Cybermaxke/followers","following_url":"https://api.github.com/users/Cybermaxke/following{/other_user}","gists_url":"https://api.github.com/users/Cybermaxke/gists{/gist_id}","starred_url":"https://api.github.com/users/Cybermaxke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cybermaxke/subscriptions","organizations_url":"https://api.github.com/users/Cybermaxke/orgs","repos_url":"https://api.github.com/users/Cybermaxke/repos","events_url":"https://api.github.com/users/Cybermaxke/events{/privacy}","received_events_url":"https://api.github.com/users/Cybermaxke/received_events","type":"User","site_admin":false},"labels":[{"id":191298971,"url":"https://api.github.com/repos/SpongePowered/SpongeAPI/labels/client","name":"client","color":"7D2F73","default":false},{"id":191287981,"url":"https://api.github.com/repos/SpongePowered/SpongeAPI/labels/low%20priority","name":"low priority","color":"bfe5bf","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-04-30T15:27:33Z","updated_at":"2016-11-01T20:16:19Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/1210","html_url":"https://github.com/SpongePowered/SpongeAPI/pull/1210","diff_url":"https://github.com/SpongePowered/SpongeAPI/pull/1210.diff","patch_url":"https://github.com/SpongePowered/SpongeAPI/pull/1210.patch"},"body":"API | [Common](https://github.com/SpongePowered/SpongeCommon/pull/682) | [Forge](https://github.com/SpongePowered/SpongeForge/pull/661) | [LiteMod](https://github.com/Cybermaxke/LiteSpongeClient/releases/)\n\nThis PR adds a key bindings api that will allow plugin developers to create custom key bindings. The api is always available, on both client and server versions, this is because the server will send packets to register the key bindings on joining the server and cleaned up afterwards, but this is a implementation detail.\n\nI am not sure if I should have waited for the client-phase-1, but since the client isn't required for players to join and the api impl does not require any client. The impl will only send packets to the client and recieve them back.\n\nI am also also only going to implement this in the minecraft versions 1.9+, depending on which version should be supported at that time.\n\nThere is already a small LiteLoader mod I made for the client features, it won't work in combination with  Forge. Most of the keyboard code will be able to be reused for the Forge implementation.\n\nTest plugin:\n\n``` java\n@Plugin(id = \"keyboardtest\")\npublic class TestKeyboardPlugin {\n\n    private KeyBinding myTestKey;\n    private KeyBinding myOtherTestKey;\n\n    @Listener\n    public void onGameInit(GameInitializationEvent event) {\n        this.myTestKey = KeyBinding.builder()\n                .id(\"keyboardtest:test\")\n                .displayName(Text.of(\"Test Binding\"))\n                .category(KeyCategories.GAMEPLAY)\n                .build();\n        KeyCategory testCategory = KeyCategory.builder()\n                .id(\"keyboardtest:test_category\")\n                .title(Text.of(\"My Test Category\"))\n                .build();\n        Sponge.getRegistry().register(KeyCategory.class, testCategory);\n        this.myOtherTestKey = KeyBinding.builder()\n                .id(\"keyboardtest:other_test\")\n                .displayName(Text.of(\"Other Test Binding\"))\n                .category(testCategory)\n                .build();\n        Sponge.getRegistry().register(KeyBinding.class, this.myTestKey);\n        Sponge.getRegistry().register(KeyBinding.class, this.myOtherTestKey);\n    }\n\n    @Listener\n    public void onRegisterKeyBinding(RegisterKeyBindingsEvent event) {\n        System.out.println(String.format(\"onRegisterKeyBinding: %s keyBindings, player %s\",\n                event.getKeyBindings().size(), event.getTargetEntity().getName()));\n    }\n\n    @Listener\n    public void onInteractKeyPress(InteractKeyEvent.Press.Pre event) {\n        if (event.getKeyBinding() == this.myTestKey) {\n            event.getTargetEntity().sendMessage(Text.of(\"Ow, that hurt...\"));\n        } else if (event.getKeyBinding() == this.myOtherTestKey) {\n            event.getTargetEntity().sendMessage(Text.of(\"And... Nothing...\"));\n        }\n    }\n\n    @Listener\n    public void onInteractKeyRelease(InteractKeyEvent.Release.Pre event) {\n        if (event.getKeyBinding() == this.myOtherTestKey) {\n            event.getTargetEntity().sendMessage(Text.of(\"Nope still nothing...\"));\n        }\n    }\n}\n```\n"},"comment":{"url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/comments/257682206","html_url":"https://github.com/SpongePowered/SpongeAPI/pull/1210#issuecomment-257682206","issue_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/1210","id":257682206,"user":{"login":"Cybermaxke","id":1364375,"avatar_url":"https://avatars.githubusercontent.com/u/1364375?v=3","gravatar_id":"","url":"https://api.github.com/users/Cybermaxke","html_url":"https://github.com/Cybermaxke","followers_url":"https://api.github.com/users/Cybermaxke/followers","following_url":"https://api.github.com/users/Cybermaxke/following{/other_user}","gists_url":"https://api.github.com/users/Cybermaxke/gists{/gist_id}","starred_url":"https://api.github.com/users/Cybermaxke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cybermaxke/subscriptions","organizations_url":"https://api.github.com/users/Cybermaxke/orgs","repos_url":"https://api.github.com/users/Cybermaxke/repos","events_url":"https://api.github.com/users/Cybermaxke/events{/privacy}","received_events_url":"https://api.github.com/users/Cybermaxke/received_events","type":"User","site_admin":false},"created_at":"2016-11-01T20:16:19Z","updated_at":"2016-11-01T20:16:19Z","body":"The implementations will be updated later, I already updated the api for further discussion.\r\n"}}
{"actor":{"display_login":"Cybermaxke"}}