friendchatmanager: rename to chaticonmanager
FriendsChatManager predates the api having an ability to look up clan members by name, without doing string matching, hence the caching. This is no longer necessary as we can do efficient lookups of players by name now. Also remove the old isMember utility function which is just duplicated from the friends chat manager.
This commit is contained in:
@@ -31,12 +31,13 @@ import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.FriendsChatManager;
|
||||
import net.runelite.api.FriendsChatMember;
|
||||
import net.runelite.api.IterableHashTable;
|
||||
import net.runelite.api.MessageNode;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.ScriptCallbackEvent;
|
||||
import net.runelite.client.game.FriendChatManager;
|
||||
import static net.runelite.client.plugins.chatfilter.ChatFilterPlugin.CENSOR_MESSAGE;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -59,12 +60,11 @@ public class ChatFilterPluginTest
|
||||
private Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private ChatFilterConfig chatFilterConfig;
|
||||
private FriendsChatManager friendsChatManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private FriendChatManager friendChatManager;
|
||||
private ChatFilterConfig chatFilterConfig;
|
||||
|
||||
@Mock
|
||||
private Player localPlayer;
|
||||
@@ -81,7 +81,9 @@ public class ChatFilterPluginTest
|
||||
when(chatFilterConfig.filteredWords()).thenReturn("");
|
||||
when(chatFilterConfig.filteredRegex()).thenReturn("");
|
||||
when(chatFilterConfig.filteredNames()).thenReturn("");
|
||||
|
||||
when(client.getLocalPlayer()).thenReturn(localPlayer);
|
||||
when(client.getFriendsChatManager()).thenReturn(friendsChatManager);
|
||||
}
|
||||
|
||||
private ScriptCallbackEvent createCallbackEvent(final String sender, final String chatMessage, final ChatMessageType messageType)
|
||||
@@ -187,7 +189,6 @@ public class ChatFilterPluginTest
|
||||
@Test
|
||||
public void testMessageFromFriendIsFiltered()
|
||||
{
|
||||
when(friendChatManager.isMember("Iron Mammal")).thenReturn(false);
|
||||
when(chatFilterConfig.filterFriends()).thenReturn(true);
|
||||
assertTrue(chatFilterPlugin.shouldFilterPlayerMessage("Iron Mammal"));
|
||||
}
|
||||
@@ -211,7 +212,7 @@ public class ChatFilterPluginTest
|
||||
@Test
|
||||
public void testMessageFromFriendsChatIsNotFiltered()
|
||||
{
|
||||
when(friendChatManager.isMember("B0aty")).thenReturn(true);
|
||||
when(friendsChatManager.findByName("B0aty")).thenReturn(mock(FriendsChatMember.class));
|
||||
when(chatFilterConfig.filterFriendsChat()).thenReturn(false);
|
||||
assertFalse(chatFilterPlugin.shouldFilterPlayerMessage("B0aty"));
|
||||
}
|
||||
@@ -227,7 +228,6 @@ public class ChatFilterPluginTest
|
||||
public void testMessageFromNonFriendNonFCIsFiltered()
|
||||
{
|
||||
when(client.isFriended("Woox", false)).thenReturn(false);
|
||||
when(friendChatManager.isMember("Woox")).thenReturn(false);
|
||||
assertTrue(chatFilterPlugin.shouldFilterPlayerMessage("Woox"));
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ public class ChatFilterPluginTest
|
||||
when(chatFilterConfig.filteredWords()).thenReturn("test");
|
||||
// if this test is broken, this stubbing is required to trip the assert
|
||||
lenient().when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.REMOVE_MESSAGE);
|
||||
when(friendChatManager.isMember("Lazark")).thenReturn(true);
|
||||
when(friendsChatManager.findByName("Lazark")).thenReturn(mock(FriendsChatMember.class));
|
||||
|
||||
chatFilterPlugin.updateFilteredPatterns();
|
||||
ScriptCallbackEvent event = createCallbackEvent("<img=22>Lazark", "test", ChatMessageType.PUBLICCHAT);
|
||||
|
||||
Reference in New Issue
Block a user