{"action":"created","comment":{"url":"https://api.github.com/repos/pop4959/PopCraft/pulls/comments/156016673","pull_request_review_id":82422330,"id":156016673,"diff_hunk":"@@ -1,71 +1,64 @@\n package org.popcraft.popcraft.commands;\r\n \r\n-import org.bukkit.Bukkit;\r\n+import com.google.inject.Inject;\r\n+import io.netty.handler.logging.LogLevel;\r\n import org.bukkit.OfflinePlayer;\r\n+import org.bukkit.Server;\r\n import org.bukkit.command.Command;\r\n import org.bukkit.command.CommandExecutor;\r\n import org.bukkit.command.CommandSender;\r\n-import org.bukkit.entity.Player;\r\n+import org.popcraft.popcraft.newCode.PopCommand;\r\n import org.popcraft.popcraft.utils.Message;\r\n+import org.slf4j.event.Level;\r\n \r\n import java.io.BufferedWriter;\r\n import java.io.File;\r\n import java.io.FileWriter;\r\n import java.io.IOException;\r\n \r\n-@Deprecated\r\n+@PopCommand(\"listgen\")\r\n public class Listgen implements CommandExecutor {\r\n \r\n+    private final Server server;\r\n+\r\n+    @Inject\r\n+    public Listgen(Server server) {\r\n+        this.server = server;\r\n+    }\r\n+\r\n     @Override\r\n     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {\r\n-        if (cmd.getName().equalsIgnoreCase(\"listgen\")) {\r\n-            try {\r\n-                generatePlayerList();\r\n-                generatePlayerCount();\r\n-            } catch (IOException e) {\r\n-                e.printStackTrace();\r\n-            }\r\n-            if (sender instanceof Player) {\r\n-                Message.normal((Player) sender, \"List generation complete.\");\r\n-            } else {\r\n-                Message.generic(\"List generation complete.\");\r\n-            }\r\n+        OfflinePlayer[] playerList = this.server.getOfflinePlayers();\r\n+        try {\r\n+            generatePlayerList(playerList);\r\n+            generatePlayerCount(playerList);\r\n+        } catch (IOException e) {\r\n+            Message.error(sender, \"IOException\");\r\n             return true;\r\n         }\r\n-        return false;\r\n+        Message.normal(sender, \"List generation complete.\");\r\n+        return true;\r\n     }\r\n \r\n-    public void generatePlayerList() throws IOException {\r\n-        OfflinePlayer[] playerlist = Bukkit.getServer().getOfflinePlayers();\r\n+    public void generatePlayerList(OfflinePlayer[] playerList) throws IOException {\r\n         File players = new File(\"players.txt\");\r\n-        if (!players.exists()) {\r\n+        if (!players.exists())\r\n             players.createNewFile();\r\n-        }\r\n-        FileWriter fw = new FileWriter(players.getAbsoluteFile());\r\n-        BufferedWriter bw = new BufferedWriter(fw);\r\n-        int playerlistlength = playerlist.length;\r\n-        int n = 0;\r\n-        while (n < playerlistlength) {\r\n-            OfflinePlayer currentplayer = playerlist[n];\r\n-            String username = currentplayer.getName();\r\n-            bw.write(username);\r\n+        BufferedWriter bw = new BufferedWriter(new FileWriter(players.getAbsoluteFile()));\r","path":"src/main/java/org/popcraft/popcraft/commands/Listgen.java","position":75,"original_position":75,"commit_id":"d79bfe7a3239b123715f6b5997e563ed3d1b25b6","original_commit_id":"d79bfe7a3239b123715f6b5997e563ed3d1b25b6","user":{"login":"JonnyFrey","id":14628585,"avatar_url":"https://avatars3.githubusercontent.com/u/14628585?v=4","gravatar_id":"","url":"https://api.github.com/users/JonnyFrey","html_url":"https://github.com/JonnyFrey","followers_url":"https://api.github.com/users/JonnyFrey/followers","following_url":"https://api.github.com/users/JonnyFrey/following{/other_user}","gists_url":"https://api.github.com/users/JonnyFrey/gists{/gist_id}","starred_url":"https://api.github.com/users/JonnyFrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JonnyFrey/subscriptions","organizations_url":"https://api.github.com/users/JonnyFrey/orgs","repos_url":"https://api.github.com/users/JonnyFrey/repos","events_url":"https://api.github.com/users/JonnyFrey/events{/privacy}","received_events_url":"https://api.github.com/users/JonnyFrey/received_events","type":"User","site_admin":false},"body":"Wrap AutoCloseable resource within a Try-With-Resource block. For example:\r\n```\r\ntry (final BufferedWriter bw = new BufferedWriter(new FileWriter(players.getAbsoluteFile()))) {\r\n   //Other Stuff Goes Here\r\n} catch (final IOException e) {\r\n   plugin.log(Level.WARN, \"Failed to Write out player list file\", e);\r\n}\r\n```\r\nAlso consider checking out try (final BufferedWriter bw = Files.newBufferedReader(Paths.get(\"players.txt\"))...","created_at":"2017-12-11T09:18:08Z","updated_at":"2017-12-11T09:38:29Z","html_url":"https://github.com/pop4959/PopCraft/pull/4#discussion_r156016673","pull_request_url":"https://api.github.com/repos/pop4959/PopCraft/pulls/4","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/pop4959/PopCraft/pulls/comments/156016673"},"html":{"href":"https://github.com/pop4959/PopCraft/pull/4#discussion_r156016673"},"pull_request":{"href":"https://api.github.com/repos/pop4959/PopCraft/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/pop4959/PopCraft/pulls/4","id":157509185,"html_url":"https://github.com/pop4959/PopCraft/pull/4","diff_url":"https://github.com/pop4959/PopCraft/pull/4.diff","patch_url":"https://github.com/pop4959/PopCraft/pull/4.patch","issue_url":"https://api.github.com/repos/pop4959/PopCraft/issues/4","number":4,"state":"open","locked":false,"title":"Fixed some command stuff","user":{"login":"pop4959","id":17698576,"avatar_url":"https://avatars2.githubusercontent.com/u/17698576?v=4","gravatar_id":"","url":"https://api.github.com/users/pop4959","html_url":"https://github.com/pop4959","followers_url":"https://api.github.com/users/pop4959/followers","following_url":"https://api.github.com/users/pop4959/following{/other_user}","gists_url":"https://api.github.com/users/pop4959/gists{/gist_id}","starred_url":"https://api.github.com/users/pop4959/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pop4959/subscriptions","organizations_url":"https://api.github.com/users/pop4959/orgs","repos_url":"https://api.github.com/users/pop4959/repos","events_url":"https://api.github.com/users/pop4959/events{/privacy}","received_events_url":"https://api.github.com/users/pop4959/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-12-11T09:07:08Z","updated_at":"2017-12-11T09:38:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1b419ecf28e6babe9146e271d97d31cbe9af08b2","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/pop4959/PopCraft/pulls/4/commits","review_comments_url":"https://api.github.com/repos/pop4959/PopCraft/pulls/4/comments","review_comment_url":"https://api.github.com/repos/pop4959/PopCraft/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pop4959/PopCraft/issues/4/comments","statuses_url":"https://api.github.com/repos/pop4959/PopCraft/statuses/d79bfe7a3239b123715f6b5997e563ed3d1b25b6","head":{"label":"pop4959:cb-refactor","ref":"cb-refactor","sha":"d79bfe7a3239b123715f6b5997e563ed3d1b25b6","user":{"login":"pop4959","id":17698576,"avatar_url":"https://avatars2.githubusercontent.com/u/17698576?v=4","gravatar_id":"","url":"https://api.github.com/users/pop4959","html_url":"https://github.com/pop4959","followers_url":"https://api.github.com/users/pop4959/followers","following_url":"https://api.github.com/users/pop4959/following{/other_user}","gists_url":"https://api.github.com/users/pop4959/gists{/gist_id}","starred_url":"https://api.github.com/users/pop4959/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pop4959/subscriptions","organizations_url":"https://api.github.com/users/pop4959/orgs","repos_url":"https://api.github.com/users/pop4959/repos","events_url":"https://api.github.com/users/pop4959/events{/privacy}","received_events_url":"https://api.github.com/users/pop4959/received_events","type":"User","site_admin":false},"repo":{"id":76714723,"name":"PopCraft","full_name":"pop4959/PopCraft","owner":{"login":"pop4959","id":17698576,"avatar_url":"https://avatars2.githubusercontent.com/u/17698576?v=4","gravatar_id":"","url":"https://api.github.com/users/pop4959","html_url":"https://github.com/pop4959","followers_url":"https://api.github.com/users/pop4959/followers","following_url":"https://api.github.com/users/pop4959/following{/other_user}","gists_url":"https://api.github.com/users/pop4959/gists{/gist_id}","starred_url":"https://api.github.com/users/pop4959/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pop4959/subscriptions","organizations_url":"https://api.github.com/users/pop4959/orgs","repos_url":"https://api.github.com/users/pop4959/repos","events_url":"https://api.github.com/users/pop4959/events{/privacy}","received_events_url":"https://api.github.com/users/pop4959/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pop4959/PopCraft","description":null,"fork":false,"url":"https://api.github.com/repos/pop4959/PopCraft","forks_url":"https://api.github.com/repos/pop4959/PopCraft/forks","keys_url":"https://api.github.com/repos/pop4959/PopCraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pop4959/PopCraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pop4959/PopCraft/teams","hooks_url":"https://api.github.com/repos/pop4959/PopCraft/hooks","issue_events_url":"https://api.github.com/repos/pop4959/PopCraft/issues/events{/number}","events_url":"https://api.github.com/repos/pop4959/PopCraft/events","assignees_url":"https://api.github.com/repos/pop4959/PopCraft/assignees{/user}","branches_url":"https://api.github.com/repos/pop4959/PopCraft/branches{/branch}","tags_url":"https://api.github.com/repos/pop4959/PopCraft/tags","blobs_url":"https://api.github.com/repos/pop4959/PopCraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pop4959/PopCraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pop4959/PopCraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/pop4959/PopCraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pop4959/PopCraft/statuses/{sha}","languages_url":"https://api.github.com/repos/pop4959/PopCraft/languages","stargazers_url":"https://api.github.com/repos/pop4959/PopCraft/stargazers","contributors_url":"https://api.github.com/repos/pop4959/PopCraft/contributors","subscribers_url":"https://api.github.com/repos/pop4959/PopCraft/subscribers","subscription_url":"https://api.github.com/repos/pop4959/PopCraft/subscription","commits_url":"https://api.github.com/repos/pop4959/PopCraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/pop4959/PopCraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/pop4959/PopCraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/pop4959/PopCraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/pop4959/PopCraft/contents/{+path}","compare_url":"https://api.github.com/repos/pop4959/PopCraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pop4959/PopCraft/merges","archive_url":"https://api.github.com/repos/pop4959/PopCraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pop4959/PopCraft/downloads","issues_url":"https://api.github.com/repos/pop4959/PopCraft/issues{/number}","pulls_url":"https://api.github.com/repos/pop4959/PopCraft/pulls{/number}","milestones_url":"https://api.github.com/repos/pop4959/PopCraft/milestones{/number}","notifications_url":"https://api.github.com/repos/pop4959/PopCraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pop4959/PopCraft/labels{/name}","releases_url":"https://api.github.com/repos/pop4959/PopCraft/releases{/id}","deployments_url":"https://api.github.com/repos/pop4959/PopCraft/deployments","created_at":"2016-12-17T09:15:35Z","updated_at":"2016-12-17T09:16:06Z","pushed_at":"2017-12-11T09:07:10Z","git_url":"git://github.com/pop4959/PopCraft.git","ssh_url":"git@github.com:pop4959/PopCraft.git","clone_url":"https://github.com/pop4959/PopCraft.git","svn_url":"https://github.com/pop4959/PopCraft","homepage":null,"size":308,"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":2,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":2,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"pop4959:jf-refactor","ref":"jf-refactor","sha":"2915adeec40aac4bd1c691e08cba7f4aa4699e7f","user":{"login":"pop4959","id":17698576,"avatar_url":"https://avatars2.githubusercontent.com/u/17698576?v=4","gravatar_id":"","url":"https://api.github.com/users/pop4959","html_url":"https://github.com/pop4959","followers_url":"https://api.github.com/users/pop4959/followers","following_url":"https://api.github.com/users/pop4959/following{/other_user}","gists_url":"https://api.github.com/users/pop4959/gists{/gist_id}","starred_url":"https://api.github.com/users/pop4959/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pop4959/subscriptions","organizations_url":"https://api.github.com/users/pop4959/orgs","repos_url":"https://api.github.com/users/pop4959/repos","events_url":"https://api.github.com/users/pop4959/events{/privacy}","received_events_url":"https://api.github.com/users/pop4959/received_events","type":"User","site_admin":false},"repo":{"id":76714723,"name":"PopCraft","full_name":"pop4959/PopCraft","owner":{"login":"pop4959","id":17698576,"avatar_url":"https://avatars2.githubusercontent.com/u/17698576?v=4","gravatar_id":"","url":"https://api.github.com/users/pop4959","html_url":"https://github.com/pop4959","followers_url":"https://api.github.com/users/pop4959/followers","following_url":"https://api.github.com/users/pop4959/following{/other_user}","gists_url":"https://api.github.com/users/pop4959/gists{/gist_id}","starred_url":"https://api.github.com/users/pop4959/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pop4959/subscriptions","organizations_url":"https://api.github.com/users/pop4959/orgs","repos_url":"https://api.github.com/users/pop4959/repos","events_url":"https://api.github.com/users/pop4959/events{/privacy}","received_events_url":"https://api.github.com/users/pop4959/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pop4959/PopCraft","description":null,"fork":false,"url":"https://api.github.com/repos/pop4959/PopCraft","forks_url":"https://api.github.com/repos/pop4959/PopCraft/forks","keys_url":"https://api.github.com/repos/pop4959/PopCraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pop4959/PopCraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pop4959/PopCraft/teams","hooks_url":"https://api.github.com/repos/pop4959/PopCraft/hooks","issue_events_url":"https://api.github.com/repos/pop4959/PopCraft/issues/events{/number}","events_url":"https://api.github.com/repos/pop4959/PopCraft/events","assignees_url":"https://api.github.com/repos/pop4959/PopCraft/assignees{/user}","branches_url":"https://api.github.com/repos/pop4959/PopCraft/branches{/branch}","tags_url":"https://api.github.com/repos/pop4959/PopCraft/tags","blobs_url":"https://api.github.com/repos/pop4959/PopCraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pop4959/PopCraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pop4959/PopCraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/pop4959/PopCraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pop4959/PopCraft/statuses/{sha}","languages_url":"https://api.github.com/repos/pop4959/PopCraft/languages","stargazers_url":"https://api.github.com/repos/pop4959/PopCraft/stargazers","contributors_url":"https://api.github.com/repos/pop4959/PopCraft/contributors","subscribers_url":"https://api.github.com/repos/pop4959/PopCraft/subscribers","subscription_url":"https://api.github.com/repos/pop4959/PopCraft/subscription","commits_url":"https://api.github.com/repos/pop4959/PopCraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/pop4959/PopCraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/pop4959/PopCraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/pop4959/PopCraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/pop4959/PopCraft/contents/{+path}","compare_url":"https://api.github.com/repos/pop4959/PopCraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pop4959/PopCraft/merges","archive_url":"https://api.github.com/repos/pop4959/PopCraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pop4959/PopCraft/downloads","issues_url":"https://api.github.com/repos/pop4959/PopCraft/issues{/number}","pulls_url":"https://api.github.com/repos/pop4959/PopCraft/pulls{/number}","milestones_url":"https://api.github.com/repos/pop4959/PopCraft/milestones{/number}","notifications_url":"https://api.github.com/repos/pop4959/PopCraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pop4959/PopCraft/labels{/name}","releases_url":"https://api.github.com/repos/pop4959/PopCraft/releases{/id}","deployments_url":"https://api.github.com/repos/pop4959/PopCraft/deployments","created_at":"2016-12-17T09:15:35Z","updated_at":"2016-12-17T09:16:06Z","pushed_at":"2017-12-11T09:07:10Z","git_url":"git://github.com/pop4959/PopCraft.git","ssh_url":"git@github.com:pop4959/PopCraft.git","clone_url":"https://github.com/pop4959/PopCraft.git","svn_url":"https://github.com/pop4959/PopCraft","homepage":null,"size":308,"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":2,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":2,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/pop4959/PopCraft/pulls/4"},"html":{"href":"https://github.com/pop4959/PopCraft/pull/4"},"issue":{"href":"https://api.github.com/repos/pop4959/PopCraft/issues/4"},"comments":{"href":"https://api.github.com/repos/pop4959/PopCraft/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/pop4959/PopCraft/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/pop4959/PopCraft/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pop4959/PopCraft/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/pop4959/PopCraft/statuses/d79bfe7a3239b123715f6b5997e563ed3d1b25b6"}},"author_association":"OWNER"}}
{"actor":{"display_login":"JonnyFrey"}}