diff options
author | Cow <cow@volloeko.de> | 2020-05-29 12:30:31 +0200 |
---|---|---|
committer | Cow <cow@volloeko.de> | 2020-05-29 12:30:31 +0200 |
commit | b9d6b75423ea24c4947b3a655f199c3b34aa167a (patch) | |
tree | 7df92efa2a2c4533326e9f37e9062db08cc13e51 /src/main/java/eu/olli/cowmoonication/handler/FriendsHandler.java | |
parent | 4d45e0bc9afacc8408295aef50b8fd6530f97104 (diff) | |
download | Cowlection-b9d6b75423ea24c4947b3a655f199c3b34aa167a.tar.gz Cowlection-b9d6b75423ea24c4947b3a655f199c3b34aa167a.tar.bz2 Cowlection-b9d6b75423ea24c4947b3a655f199c3b34aa167a.zip |
Added /moo stalkskyblock <playerName>
- Now using CommandExceptions instead of just red chat color for command error messages
- Simplified creation of chat message
Diffstat (limited to 'src/main/java/eu/olli/cowmoonication/handler/FriendsHandler.java')
-rw-r--r-- | src/main/java/eu/olli/cowmoonication/handler/FriendsHandler.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main/java/eu/olli/cowmoonication/handler/FriendsHandler.java b/src/main/java/eu/olli/cowmoonication/handler/FriendsHandler.java index 119e289..9ec469e 100644 --- a/src/main/java/eu/olli/cowmoonication/handler/FriendsHandler.java +++ b/src/main/java/eu/olli/cowmoonication/handler/FriendsHandler.java @@ -3,11 +3,13 @@ package eu.olli.cowmoonication.handler; import com.google.gson.JsonParseException; import com.google.gson.reflect.TypeToken; import eu.olli.cowmoonication.Cowmoonication; +import eu.olli.cowmoonication.command.exception.ApiContactException; import eu.olli.cowmoonication.data.Friend; import eu.olli.cowmoonication.util.ApiUtils; import eu.olli.cowmoonication.util.GsonUtils; import eu.olli.cowmoonication.util.TickDelay; import io.netty.util.internal.ConcurrentSet; +import net.minecraft.command.PlayerNotFoundException; import net.minecraft.event.ClickEvent; import net.minecraft.event.HoverEvent; import net.minecraft.util.ChatComponentText; @@ -56,9 +58,9 @@ public class FriendsHandler { ApiUtils.fetchFriendData(name, friend -> { if (friend == null) { - main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Sorry, could contact Mojang's API and thus didn't add " + name + " as a best friend."); + throw new ApiContactException("Mojang", "didn't add " + name + " as a best friend."); } else if (friend.equals(Friend.FRIEND_NOT_FOUND)) { - main.getChatHelper().sendMessage(EnumChatFormatting.RED, "There is no player with the name " + EnumChatFormatting.DARK_RED + name + EnumChatFormatting.RED + "."); + throw new PlayerNotFoundException("There is no player with the name " + EnumChatFormatting.DARK_RED + name + EnumChatFormatting.RED + "."); } else { boolean added = bestFriends.add(friend); if (added) { @@ -108,7 +110,7 @@ public class FriendsHandler { if (newName == null) { // skipping friend, something went wrong with API request } else if (newName.equals(ApiUtils.UUID_NOT_FOUND)) { - main.getChatHelper().sendMessage(EnumChatFormatting.RED, "How did you manage to get a unique id on your best friends list that has no name attached to it?"); + throw new PlayerNotFoundException("How did you manage to get a unique id on your best friends list that has no name attached to it?"); } else if (newName.equals(friend.getName())) { // name hasn't changed, only updating lastChecked timestamp Friend bestFriend = getBestFriend(friend.getUuid()); |