From c2c644d9b0f8a66e757b67145935b0e3c447db97 Mon Sep 17 00:00:00 2001 From: Cow Date: Tue, 16 Jun 2020 02:32:15 +0200 Subject: Added `/moo search` to search through mc log files --- src/main/java/eu/olli/cowmoonication/handler/FriendsHandler.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/java/eu/olli/cowmoonication/handler/FriendsHandler.java') diff --git a/src/main/java/eu/olli/cowmoonication/handler/FriendsHandler.java b/src/main/java/eu/olli/cowmoonication/handler/FriendsHandler.java index 9ec469e..8d714a1 100644 --- a/src/main/java/eu/olli/cowmoonication/handler/FriendsHandler.java +++ b/src/main/java/eu/olli/cowmoonication/handler/FriendsHandler.java @@ -148,9 +148,13 @@ public class FriendsHandler { private void loadBestFriends() { try { + boolean createdNewFile = this.bestFriendsFile.createNewFile(); + this.bestFriends.clear(); - String bestFriendsData = FileUtils.readFileToString(this.bestFriendsFile, StandardCharsets.UTF_8); - this.bestFriends.addAll(parseJson(bestFriendsData)); + if (!createdNewFile) { + String bestFriendsData = FileUtils.readFileToString(this.bestFriendsFile, StandardCharsets.UTF_8); + this.bestFriends.addAll(parseJson(bestFriendsData)); + } } catch (IOException e) { main.getLogger().error("Couldn't read best friends file " + this.bestFriendsFile, e); } catch (JsonParseException e) { -- cgit