{"action":"created","comment":{"url":"https://api.github.com/repos/Minecolonies/minecolonies/pulls/comments/90834163","pull_request_review_id":11348183,"id":90834163,"diff_hunk":"@@ -96,23 +120,131 @@ public String getJobName()\n      */\n     @NotNull\n     @Override\n-    public AbstractJob createJob(CitizenData citizen)\n+    public AbstractJob createJob(final CitizenData citizen)\n     {\n         return new JobBuilder(citizen);\n     }\n \n     /**\n+     * Get the needed resources for the current build.\n+     * @return a new Hashmap.\n+     */\n+    public Map<Block, Integer> getNeededResources()\n+    {\n+        return new HashMap<>(neededResources);\n+    }\n+\n+    /**\n+     * Add a new resource to the needed list.\n+     * @param res the resource.\n+     * @param amount the amount.\n+     */\n+    public void addNeededResource(Block res, int amount)\n+    {\n+        int preAmount = 0;\n+        if(this.neededResources.containsKey(res))\n+        {\n+            preAmount = this.neededResources.get(res);\n+        }\n+        this.neededResources.put(res, preAmount + amount);\n+        this.markDirty();\n+    }\n+\n+    /**\n+     * Reduce a resource of the needed list.\n+     * @param res the resource.\n+     * @param amount the amount.\n+     */\n+    public void reduceNeededResource(Block res, int amount)\n+    {\n+        int preAmount = 0;\n+        if(this.neededResources.containsKey(res))\n+        {\n+            preAmount = this.neededResources.get(res);\n+        }\n+\n+        if(preAmount - amount <= 0)\n+        {\n+            this.neededResources.remove(res);\n+        }\n+        else\n+        {\n+            this.neededResources.put(res, preAmount - amount);\n+        }\n+        this.markDirty();\n+    }\n+\n+    /**\n+     * Resets the needed resources completely.\n+     */\n+    public void resetNeededResources()\n+    {\n+        neededResources = new HashMap<>();\n+        this.markDirty();\n+    }\n+\n+    @Override\n+    public void readFromNBT(@NotNull final NBTTagCompound compound)\n+    {\n+        super.readFromNBT(compound);\n+        final NBTTagList neededResTagList = compound.getTagList(TAG_RESOURCE_LIST, Constants.NBT.TAG_COMPOUND);\n+        for (int i = 0; i < neededResTagList.tagCount(); ++i)\n+        {\n+            final NBTTagCompound neededRes = neededResTagList.getCompoundTagAt(i);\n+            final IBlockState state = NBTUtil.readBlockState(neededRes);\n+            final int amount = neededRes.getInteger(TAG_AMOUNT);\n+            neededResources.put(state.getBlock(), amount);\n+        }\n+    }\n+\n+    @Override\n+    public void writeToNBT(@NotNull final NBTTagCompound compound)\n+    {\n+        super.writeToNBT(compound);\n+        @NotNull final NBTTagList neededResTagList = new NBTTagList();\n+        for (@NotNull final Map.Entry<Block, Integer> entry : neededResources.entrySet())\n+        {\n+            @NotNull final NBTTagCompound neededRes = new NBTTagCompound();\n+            NBTUtil.writeBlockState(neededRes, entry.getKey().getDefaultState());\n+            neededRes.setInteger(TAG_AMOUNT, entry.getValue());\n+\n+            neededResTagList.appendTag(neededRes);\n+        }\n+        compound.setTag(TAG_RESOURCE_LIST, neededResTagList);\n+    }\n+\n+    /**\n+     * Method to serialize data to send it to the view.\n+     *\n+     * @param buf the used ByteBuffer.\n+     */\n+    @Override\n+    public void serializeToView(@NotNull ByteBuf buf)\n+    {\n+        super.serializeToView(buf);\n+\n+        buf.writeInt(neededResources.size());\n+\n+        for (@NotNull final Map.Entry<Block, Integer> entry : neededResources.entrySet())\n+        {\n+            ByteBufUtils.writeUTF8String(buf, entry.getKey().getLocalizedName());\n+            buf.writeInt(entry.getValue());\n+        }\n+    }\n+\n+    /**\n      * Provides a view of the builder building class.\n      */\n     public static class View extends AbstractBuildingWorker.View","path":"src/main/java/com/minecolonies/colony/buildings/BuildingBuilder.java","position":171,"original_position":171,"commit_id":"50295dfe1697fa6b1c2a4d8f6898edea00bad512","original_commit_id":"50295dfe1697fa6b1c2a4d8f6898edea00bad512","user":{"login":"MinecoloniesSonar","id":19393044,"avatar_url":"https://avatars.githubusercontent.com/u/19393044?v=3","gravatar_id":"","url":"https://api.github.com/users/MinecoloniesSonar","html_url":"https://github.com/MinecoloniesSonar","followers_url":"https://api.github.com/users/MinecoloniesSonar/followers","following_url":"https://api.github.com/users/MinecoloniesSonar/following{/other_user}","gists_url":"https://api.github.com/users/MinecoloniesSonar/gists{/gist_id}","starred_url":"https://api.github.com/users/MinecoloniesSonar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MinecoloniesSonar/subscriptions","organizations_url":"https://api.github.com/users/MinecoloniesSonar/orgs","repos_url":"https://api.github.com/users/MinecoloniesSonar/repos","events_url":"https://api.github.com/users/MinecoloniesSonar/events{/privacy}","received_events_url":"https://api.github.com/users/MinecoloniesSonar/received_events","type":"User","site_admin":false},"body":"![MAJOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-major.png) Reduce this class from 51 to the maximum allowed 50 or externalize it in a public class. [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](http://home.kk-sc.de:9000/coding_rules#rule_key=squid%3AS2972)\n","created_at":"2016-12-05T10:09:46Z","updated_at":"2016-12-05T10:09:46Z","html_url":"https://github.com/Minecolonies/minecolonies/pull/320#discussion_r90834163","pull_request_url":"https://api.github.com/repos/Minecolonies/minecolonies/pulls/320","_links":{"self":{"href":"https://api.github.com/repos/Minecolonies/minecolonies/pulls/comments/90834163"},"html":{"href":"https://github.com/Minecolonies/minecolonies/pull/320#discussion_r90834163"},"pull_request":{"href":"https://api.github.com/repos/Minecolonies/minecolonies/pulls/320"}}},"pull_request":{"url":"https://api.github.com/repos/Minecolonies/minecolonies/pulls/320","id":96499475,"html_url":"https://github.com/Minecolonies/minecolonies/pull/320","diff_url":"https://github.com/Minecolonies/minecolonies/pull/320.diff","patch_url":"https://github.com/Minecolonies/minecolonies/pull/320.patch","issue_url":"https://api.github.com/repos/Minecolonies/minecolonies/issues/320","number":320,"state":"open","locked":false,"title":"Release/0.6","user":{"login":"Kostronor","id":644950,"avatar_url":"https://avatars.githubusercontent.com/u/644950?v=3","gravatar_id":"","url":"https://api.github.com/users/Kostronor","html_url":"https://github.com/Kostronor","followers_url":"https://api.github.com/users/Kostronor/followers","following_url":"https://api.github.com/users/Kostronor/following{/other_user}","gists_url":"https://api.github.com/users/Kostronor/gists{/gist_id}","starred_url":"https://api.github.com/users/Kostronor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kostronor/subscriptions","organizations_url":"https://api.github.com/users/Kostronor/orgs","repos_url":"https://api.github.com/users/Kostronor/repos","events_url":"https://api.github.com/users/Kostronor/events{/privacy}","received_events_url":"https://api.github.com/users/Kostronor/received_events","type":"User","site_admin":false},"body":"Added the guard with new patrolling options and fixed lots of code style and other minor bugs.\r\n\r\n(We should release more often)","created_at":"2016-12-05T10:03:50Z","updated_at":"2016-12-05T10:09:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ff7c3fecc857b345c987f0dcb594bcfa19894900","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Minecolonies/minecolonies/pulls/320/commits","review_comments_url":"https://api.github.com/repos/Minecolonies/minecolonies/pulls/320/comments","review_comment_url":"https://api.github.com/repos/Minecolonies/minecolonies/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Minecolonies/minecolonies/issues/320/comments","statuses_url":"https://api.github.com/repos/Minecolonies/minecolonies/statuses/50295dfe1697fa6b1c2a4d8f6898edea00bad512","head":{"label":"Minecolonies:release/0.6","ref":"release/0.6","sha":"50295dfe1697fa6b1c2a4d8f6898edea00bad512","user":{"login":"Minecolonies","id":5167336,"avatar_url":"https://avatars.githubusercontent.com/u/5167336?v=3","gravatar_id":"","url":"https://api.github.com/users/Minecolonies","html_url":"https://github.com/Minecolonies","followers_url":"https://api.github.com/users/Minecolonies/followers","following_url":"https://api.github.com/users/Minecolonies/following{/other_user}","gists_url":"https://api.github.com/users/Minecolonies/gists{/gist_id}","starred_url":"https://api.github.com/users/Minecolonies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Minecolonies/subscriptions","organizations_url":"https://api.github.com/users/Minecolonies/orgs","repos_url":"https://api.github.com/users/Minecolonies/repos","events_url":"https://api.github.com/users/Minecolonies/events{/privacy}","received_events_url":"https://api.github.com/users/Minecolonies/received_events","type":"Organization","site_admin":false},"repo":{"id":65616760,"name":"minecolonies","full_name":"Minecolonies/minecolonies","owner":{"login":"Minecolonies","id":5167336,"avatar_url":"https://avatars.githubusercontent.com/u/5167336?v=3","gravatar_id":"","url":"https://api.github.com/users/Minecolonies","html_url":"https://github.com/Minecolonies","followers_url":"https://api.github.com/users/Minecolonies/followers","following_url":"https://api.github.com/users/Minecolonies/following{/other_user}","gists_url":"https://api.github.com/users/Minecolonies/gists{/gist_id}","starred_url":"https://api.github.com/users/Minecolonies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Minecolonies/subscriptions","organizations_url":"https://api.github.com/users/Minecolonies/orgs","repos_url":"https://api.github.com/users/Minecolonies/repos","events_url":"https://api.github.com/users/Minecolonies/events{/privacy}","received_events_url":"https://api.github.com/users/Minecolonies/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Minecolonies/minecolonies","description":"Minecolonies minecraft mod","fork":false,"url":"https://api.github.com/repos/Minecolonies/minecolonies","forks_url":"https://api.github.com/repos/Minecolonies/minecolonies/forks","keys_url":"https://api.github.com/repos/Minecolonies/minecolonies/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Minecolonies/minecolonies/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Minecolonies/minecolonies/teams","hooks_url":"https://api.github.com/repos/Minecolonies/minecolonies/hooks","issue_events_url":"https://api.github.com/repos/Minecolonies/minecolonies/issues/events{/number}","events_url":"https://api.github.com/repos/Minecolonies/minecolonies/events","assignees_url":"https://api.github.com/repos/Minecolonies/minecolonies/assignees{/user}","branches_url":"https://api.github.com/repos/Minecolonies/minecolonies/branches{/branch}","tags_url":"https://api.github.com/repos/Minecolonies/minecolonies/tags","blobs_url":"https://api.github.com/repos/Minecolonies/minecolonies/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Minecolonies/minecolonies/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Minecolonies/minecolonies/git/refs{/sha}","trees_url":"https://api.github.com/repos/Minecolonies/minecolonies/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Minecolonies/minecolonies/statuses/{sha}","languages_url":"https://api.github.com/repos/Minecolonies/minecolonies/languages","stargazers_url":"https://api.github.com/repos/Minecolonies/minecolonies/stargazers","contributors_url":"https://api.github.com/repos/Minecolonies/minecolonies/contributors","subscribers_url":"https://api.github.com/repos/Minecolonies/minecolonies/subscribers","subscription_url":"https://api.github.com/repos/Minecolonies/minecolonies/subscription","commits_url":"https://api.github.com/repos/Minecolonies/minecolonies/commits{/sha}","git_commits_url":"https://api.github.com/repos/Minecolonies/minecolonies/git/commits{/sha}","comments_url":"https://api.github.com/repos/Minecolonies/minecolonies/comments{/number}","issue_comment_url":"https://api.github.com/repos/Minecolonies/minecolonies/issues/comments{/number}","contents_url":"https://api.github.com/repos/Minecolonies/minecolonies/contents/{+path}","compare_url":"https://api.github.com/repos/Minecolonies/minecolonies/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Minecolonies/minecolonies/merges","archive_url":"https://api.github.com/repos/Minecolonies/minecolonies/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Minecolonies/minecolonies/downloads","issues_url":"https://api.github.com/repos/Minecolonies/minecolonies/issues{/number}","pulls_url":"https://api.github.com/repos/Minecolonies/minecolonies/pulls{/number}","milestones_url":"https://api.github.com/repos/Minecolonies/minecolonies/milestones{/number}","notifications_url":"https://api.github.com/repos/Minecolonies/minecolonies/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Minecolonies/minecolonies/labels{/name}","releases_url":"https://api.github.com/repos/Minecolonies/minecolonies/releases{/id}","deployments_url":"https://api.github.com/repos/Minecolonies/minecolonies/deployments","created_at":"2016-08-13T12:45:38Z","updated_at":"2016-12-05T09:26:28Z","pushed_at":"2016-12-05T10:04:01Z","git_url":"git://github.com/Minecolonies/minecolonies.git","ssh_url":"git@github.com:Minecolonies/minecolonies.git","clone_url":"https://github.com/Minecolonies/minecolonies.git","svn_url":"https://github.com/Minecolonies/minecolonies","homepage":"http://minecolonies.com/","size":13733,"stargazers_count":13,"watchers_count":13,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":75,"forks":16,"open_issues":75,"watchers":13,"default_branch":"develop"}},"base":{"label":"Minecolonies:master","ref":"master","sha":"3a9d3129794c45475f8e038bf814a16b20a5f451","user":{"login":"Minecolonies","id":5167336,"avatar_url":"https://avatars.githubusercontent.com/u/5167336?v=3","gravatar_id":"","url":"https://api.github.com/users/Minecolonies","html_url":"https://github.com/Minecolonies","followers_url":"https://api.github.com/users/Minecolonies/followers","following_url":"https://api.github.com/users/Minecolonies/following{/other_user}","gists_url":"https://api.github.com/users/Minecolonies/gists{/gist_id}","starred_url":"https://api.github.com/users/Minecolonies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Minecolonies/subscriptions","organizations_url":"https://api.github.com/users/Minecolonies/orgs","repos_url":"https://api.github.com/users/Minecolonies/repos","events_url":"https://api.github.com/users/Minecolonies/events{/privacy}","received_events_url":"https://api.github.com/users/Minecolonies/received_events","type":"Organization","site_admin":false},"repo":{"id":65616760,"name":"minecolonies","full_name":"Minecolonies/minecolonies","owner":{"login":"Minecolonies","id":5167336,"avatar_url":"https://avatars.githubusercontent.com/u/5167336?v=3","gravatar_id":"","url":"https://api.github.com/users/Minecolonies","html_url":"https://github.com/Minecolonies","followers_url":"https://api.github.com/users/Minecolonies/followers","following_url":"https://api.github.com/users/Minecolonies/following{/other_user}","gists_url":"https://api.github.com/users/Minecolonies/gists{/gist_id}","starred_url":"https://api.github.com/users/Minecolonies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Minecolonies/subscriptions","organizations_url":"https://api.github.com/users/Minecolonies/orgs","repos_url":"https://api.github.com/users/Minecolonies/repos","events_url":"https://api.github.com/users/Minecolonies/events{/privacy}","received_events_url":"https://api.github.com/users/Minecolonies/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Minecolonies/minecolonies","description":"Minecolonies minecraft mod","fork":false,"url":"https://api.github.com/repos/Minecolonies/minecolonies","forks_url":"https://api.github.com/repos/Minecolonies/minecolonies/forks","keys_url":"https://api.github.com/repos/Minecolonies/minecolonies/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Minecolonies/minecolonies/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Minecolonies/minecolonies/teams","hooks_url":"https://api.github.com/repos/Minecolonies/minecolonies/hooks","issue_events_url":"https://api.github.com/repos/Minecolonies/minecolonies/issues/events{/number}","events_url":"https://api.github.com/repos/Minecolonies/minecolonies/events","assignees_url":"https://api.github.com/repos/Minecolonies/minecolonies/assignees{/user}","branches_url":"https://api.github.com/repos/Minecolonies/minecolonies/branches{/branch}","tags_url":"https://api.github.com/repos/Minecolonies/minecolonies/tags","blobs_url":"https://api.github.com/repos/Minecolonies/minecolonies/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Minecolonies/minecolonies/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Minecolonies/minecolonies/git/refs{/sha}","trees_url":"https://api.github.com/repos/Minecolonies/minecolonies/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Minecolonies/minecolonies/statuses/{sha}","languages_url":"https://api.github.com/repos/Minecolonies/minecolonies/languages","stargazers_url":"https://api.github.com/repos/Minecolonies/minecolonies/stargazers","contributors_url":"https://api.github.com/repos/Minecolonies/minecolonies/contributors","subscribers_url":"https://api.github.com/repos/Minecolonies/minecolonies/subscribers","subscription_url":"https://api.github.com/repos/Minecolonies/minecolonies/subscription","commits_url":"https://api.github.com/repos/Minecolonies/minecolonies/commits{/sha}","git_commits_url":"https://api.github.com/repos/Minecolonies/minecolonies/git/commits{/sha}","comments_url":"https://api.github.com/repos/Minecolonies/minecolonies/comments{/number}","issue_comment_url":"https://api.github.com/repos/Minecolonies/minecolonies/issues/comments{/number}","contents_url":"https://api.github.com/repos/Minecolonies/minecolonies/contents/{+path}","compare_url":"https://api.github.com/repos/Minecolonies/minecolonies/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Minecolonies/minecolonies/merges","archive_url":"https://api.github.com/repos/Minecolonies/minecolonies/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Minecolonies/minecolonies/downloads","issues_url":"https://api.github.com/repos/Minecolonies/minecolonies/issues{/number}","pulls_url":"https://api.github.com/repos/Minecolonies/minecolonies/pulls{/number}","milestones_url":"https://api.github.com/repos/Minecolonies/minecolonies/milestones{/number}","notifications_url":"https://api.github.com/repos/Minecolonies/minecolonies/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Minecolonies/minecolonies/labels{/name}","releases_url":"https://api.github.com/repos/Minecolonies/minecolonies/releases{/id}","deployments_url":"https://api.github.com/repos/Minecolonies/minecolonies/deployments","created_at":"2016-08-13T12:45:38Z","updated_at":"2016-12-05T09:26:28Z","pushed_at":"2016-12-05T10:04:01Z","git_url":"git://github.com/Minecolonies/minecolonies.git","ssh_url":"git@github.com:Minecolonies/minecolonies.git","clone_url":"https://github.com/Minecolonies/minecolonies.git","svn_url":"https://github.com/Minecolonies/minecolonies","homepage":"http://minecolonies.com/","size":13733,"stargazers_count":13,"watchers_count":13,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":75,"forks":16,"open_issues":75,"watchers":13,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Minecolonies/minecolonies/pulls/320"},"html":{"href":"https://github.com/Minecolonies/minecolonies/pull/320"},"issue":{"href":"https://api.github.com/repos/Minecolonies/minecolonies/issues/320"},"comments":{"href":"https://api.github.com/repos/Minecolonies/minecolonies/issues/320/comments"},"review_comments":{"href":"https://api.github.com/repos/Minecolonies/minecolonies/pulls/320/comments"},"review_comment":{"href":"https://api.github.com/repos/Minecolonies/minecolonies/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Minecolonies/minecolonies/pulls/320/commits"},"statuses":{"href":"https://api.github.com/repos/Minecolonies/minecolonies/statuses/50295dfe1697fa6b1c2a4d8f6898edea00bad512"}}}}
{"actor":{"display_login":"MinecoloniesSonar"}}