From 6a209b860ca6422e144afd2c0bb06828cadd2000 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 21 Nov 2019 20:00:55 -0500 Subject: [PATCH] api: refactor to use NameableContainer This uses a nameable container for the friends and ignore lists, and provides the clan manager which inherits from it --- .../java/net/runelite/api/ClanMember.java | 7 --- ...endManager.java => ClanMemberManager.java} | 18 ++++-- .../main/java/net/runelite/api/Client.java | 56 +++---------------- .../main/java/net/runelite/api/Friend.java | 13 ----- .../main/java/net/runelite/api/Ignore.java | 13 ----- .../main/java/net/runelite/api/Nameable.java | 13 +++++ .../net/runelite/api/NameableContainer.java | 50 +++++++++++++++++ 7 files changed, 84 insertions(+), 86 deletions(-) rename runelite-api/src/main/java/net/runelite/api/{FriendManager.java => ClanMemberManager.java} (82%) create mode 100644 runelite-api/src/main/java/net/runelite/api/NameableContainer.java diff --git a/runelite-api/src/main/java/net/runelite/api/ClanMember.java b/runelite-api/src/main/java/net/runelite/api/ClanMember.java index b8082af3d9..3afb7d85d9 100644 --- a/runelite-api/src/main/java/net/runelite/api/ClanMember.java +++ b/runelite-api/src/main/java/net/runelite/api/ClanMember.java @@ -29,13 +29,6 @@ package net.runelite.api; */ public interface ClanMember extends ChatPlayer { - /** - * Gets the username of the member. - * - * @return the username - */ - String getUsername(); - /** * Gets the world the member is in. * diff --git a/runelite-api/src/main/java/net/runelite/api/FriendManager.java b/runelite-api/src/main/java/net/runelite/api/ClanMemberManager.java similarity index 82% rename from runelite-api/src/main/java/net/runelite/api/FriendManager.java rename to runelite-api/src/main/java/net/runelite/api/ClanMemberManager.java index 4bdd5a496f..e618525084 100644 --- a/runelite-api/src/main/java/net/runelite/api/FriendManager.java +++ b/runelite-api/src/main/java/net/runelite/api/ClanMemberManager.java @@ -24,9 +24,19 @@ */ package net.runelite.api; -/** - * Represents the friend and ignore list manager. - */ -public interface FriendManager +public interface ClanMemberManager extends NameableContainer { + /** + * Gets the clan owner of the currently joined clan chat + * + * @return + */ + String getClanOwner(); + + /** + * Gets the clan chat name of the currently joined clan chat + * + * @return + */ + String getClanChatName(); } diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index 8ab313e0f1..ea20abdccf 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -1111,68 +1111,26 @@ public interface Client extends GameEngine boolean isFriended(String name, boolean mustBeLoggedIn); /** - * Gets the number of players in the clan chat. - * - * @return the number of clan chat members - */ - int getClanChatCount(); - - /** - * Gets an array of players in the clan chat. - * - * @return the clan chat members, null if not in a clan - */ - ClanMember[] getClanMembers(); - - /** - * Gets the clan owner of the currently joined clan chat + * Retrieve the clan member manager * * @return */ - String getClanOwner(); + @Nullable + ClanMemberManager getClanMemberManager(); /** - * Gets the clan chat name of the currently joined clan chat + * Retrieve the nameable container containing friends * * @return */ - String getClanChatName(); + NameableContainer getFriendContainer(); /** - * Gets an array of players in the friends list. - * - * @return the friends list - */ - Friend[] getFriends(); - - /** - * Gets the number of friends on the friends list. + * Retrieve the nameable container containing ignores * * @return */ - int getFriendsCount(); - - /** - * Gets an array of players on the ignore list. - * - * @return - */ - Ignore[] getIgnores(); - - /** - * Gets the number of ignored players on the ignore list. - * - * @return - */ - int getIgnoreCount(); - - /** - * Checks whether a player is in the same clan chat. - * - * @param name the name of the player - * @return true if the player is in clan chat - */ - boolean isClanMember(String name); + NameableContainer getIgnoreContainer(); /** * Gets the clients saved preferences. diff --git a/runelite-api/src/main/java/net/runelite/api/Friend.java b/runelite-api/src/main/java/net/runelite/api/Friend.java index 7b28e18a67..d585767e2f 100644 --- a/runelite-api/src/main/java/net/runelite/api/Friend.java +++ b/runelite-api/src/main/java/net/runelite/api/Friend.java @@ -29,17 +29,4 @@ package net.runelite.api; */ public interface Friend extends ChatPlayer { - /** - * The name of the player. - * - * @return the name - */ - String getName(); - - /** - * The previous name the player had. - * - * @return the previous name - */ - String getPrevName(); } diff --git a/runelite-api/src/main/java/net/runelite/api/Ignore.java b/runelite-api/src/main/java/net/runelite/api/Ignore.java index 52f42e0aaa..e2506ca183 100644 --- a/runelite-api/src/main/java/net/runelite/api/Ignore.java +++ b/runelite-api/src/main/java/net/runelite/api/Ignore.java @@ -29,17 +29,4 @@ package net.runelite.api; */ public interface Ignore extends Nameable { - /** - * The name of the player. - * - * @return the name - */ - String getName(); - - /** - * The previous name the player had. - * - * @return the previous name - */ - String getPrevName(); } diff --git a/runelite-api/src/main/java/net/runelite/api/Nameable.java b/runelite-api/src/main/java/net/runelite/api/Nameable.java index 081074594e..f627d98901 100644 --- a/runelite-api/src/main/java/net/runelite/api/Nameable.java +++ b/runelite-api/src/main/java/net/runelite/api/Nameable.java @@ -29,4 +29,17 @@ package net.runelite.api; */ public interface Nameable extends Comparable { + /** + * The name of the player. + * + * @return the name + */ + String getName(); + + /** + * The previous name the player had. + * + * @return the previous name + */ + String getPrevName(); } diff --git a/runelite-api/src/main/java/net/runelite/api/NameableContainer.java b/runelite-api/src/main/java/net/runelite/api/NameableContainer.java new file mode 100644 index 0000000000..a76bb78891 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/NameableContainer.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2019, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api; + +public interface NameableContainer +{ + /** + * Get the number of members in this container + * + * @return + */ + int getCount(); + + /** + * Get the members in this container + * + * @return + */ + T[] getMembers(); + + /** + * Find a nameable by name + * + * @param name the name + * @return + */ + T findByName(String name); +}