public static boolean removeFriend(ProxiedPlayer p, String who) { if (who == null || who == "") { Messages.FRIEND_FAIL_REMOVED.msg(p, "%player%", who); return false; } // Parameter fehlt bzw. ungültig ProxiedPlayer whoPlayer = Util.getPlayer(who); PlayerData pd = PlayerData.get(p.getUniqueId()); if (whoPlayer == null) { for (UUID uuid : pd.getFriends().keySet()) { Friend friend = pd.getFriends().get(uuid); if (friend.getFriendName().equalsIgnoreCase(who)) { friend.remove(true); pd.getFriends().remove(uuid); Messages.FRIEND_REMOVED.msg(p, "%player%", who); PluginMessenger.sendMessage(p, "Friend", "Update"); return true; } } Messages.FRIEND_NOT_IN_FRIENDLIST.msg(p, "%player%", who); return false; } else { if (pd.getFriends().containsKey(whoPlayer.getUniqueId())) { pd.getFriends().remove(whoPlayer.getUniqueId()); Messages.FRIEND_REMOVED.msg(p, "%player%", whoPlayer.getName()); PluginMessenger.sendMessage(p, "Friend", "Update"); return true; } Messages.FRIEND_NOT_IN_FRIENDLIST.msg(p, "%player%", who); return false; } }
public static boolean acceptFriend(ProxiedPlayer p, String toAcceptFriendName) { if (toAcceptFriendName == null || toAcceptFriendName == "") return false; PlayerData pd = PlayerData.get(p.getUniqueId()); ProxiedPlayer toAcceptFriend = Util.getPlayer(toAcceptFriendName); if (toAcceptFriend == null) { Messages.FRIEND_NOT_ONLINE.msg(p, "%player%", toAcceptFriendName); return false; } if (!pd.getFriendRequests().isEmpty()) { for (FriendRequest fr : pd.getFriendRequests()) { ProxiedPlayer friend = fr.getReceiver(); if (friend == null) continue; if (friend.getUniqueId().toString() == toAcceptFriend.getUniqueId().toString()) { fr.setAccepted(true); fr.setAnswered(true); Messages.FRIENDREQUEST_ACCEPTED.msg(p, "%player%", toAcceptFriend.getName()); Messages.FRIENDREQUEST_ACCEPTED_FORSENDER.msg(toAcceptFriend, "%player%", p.getName()); PluginMessenger.sendMessage(p, "Friend", "Update"); PluginMessenger.sendMessage(toAcceptFriend, "Friend", "Update"); return true; } } } if (!pd.getFriends().containsKey(toAcceptFriend.getUniqueId())) { Messages.FRIEND_NOT_IN_FRIENDLIST.msg(p, "%player%", toAcceptFriendName); return false; } Friend friend = pd.getFriends().get(toAcceptFriend.getUniqueId()); friend.setRequestAccepted(true); friend.updateSQL(); Messages.FRIENDREQUEST_ACCEPTED.msg(p, "%player%", toAcceptFriend.getName()); Messages.FRIENDREQUEST_ACCEPTED_FORSENDER.msg(toAcceptFriend, "%player%", p.getName()); PluginMessenger.sendMessage(p, "Friend", "Update"); PluginMessenger.sendMessage(toAcceptFriend, "Friend", "Update"); return true; }