Merge pull request #4626 from Kamielvf/fix-clear-public
chat history: clear public chat when menu option is clicked
This commit is contained in:
@@ -45,8 +45,11 @@ import net.runelite.client.plugins.PluginDescriptor;
|
|||||||
public class ChatHistoryPlugin extends Plugin
|
public class ChatHistoryPlugin extends Plugin
|
||||||
{
|
{
|
||||||
private static final String WELCOME_MESSAGE = "Welcome to RuneScape.";
|
private static final String WELCOME_MESSAGE = "Welcome to RuneScape.";
|
||||||
|
private static final String CLEAR_HISTORY = "Clear history";
|
||||||
|
private static final String CLEAR_PRIVATE = "<col=ffff00>Private:";
|
||||||
private static final Set<ChatMessageType> ALLOWED_HISTORY = Sets.newHashSet(
|
private static final Set<ChatMessageType> ALLOWED_HISTORY = Sets.newHashSet(
|
||||||
ChatMessageType.PUBLIC,
|
ChatMessageType.PUBLIC,
|
||||||
|
ChatMessageType.PUBLIC_MOD,
|
||||||
ChatMessageType.CLANCHAT,
|
ChatMessageType.CLANCHAT,
|
||||||
ChatMessageType.PRIVATE_MESSAGE_RECEIVED,
|
ChatMessageType.PRIVATE_MESSAGE_RECEIVED,
|
||||||
ChatMessageType.PRIVATE_MESSAGE_SENT,
|
ChatMessageType.PRIVATE_MESSAGE_SENT,
|
||||||
@@ -109,10 +112,19 @@ public class ChatHistoryPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
public void onMenuOptionClicked(MenuOptionClicked event)
|
||||||
{
|
{
|
||||||
if (event.getMenuOption().contains("Clear history"))
|
String menuOption = event.getMenuOption();
|
||||||
|
|
||||||
|
if (menuOption.contains(CLEAR_HISTORY))
|
||||||
{
|
{
|
||||||
messageQueue.removeIf(e -> e.getType() == ChatMessageType.PRIVATE_MESSAGE_RECEIVED ||
|
if (menuOption.startsWith(CLEAR_PRIVATE))
|
||||||
|
{
|
||||||
|
messageQueue.removeIf(e -> e.getType() == ChatMessageType.PRIVATE_MESSAGE_RECEIVED ||
|
||||||
e.getType() == ChatMessageType.PRIVATE_MESSAGE_SENT || e.getType() == ChatMessageType.PRIVATE_MESSAGE_RECEIVED_MOD);
|
e.getType() == ChatMessageType.PRIVATE_MESSAGE_SENT || e.getType() == ChatMessageType.PRIVATE_MESSAGE_RECEIVED_MOD);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
messageQueue.removeIf(e -> e.getType() == ChatMessageType.PUBLIC || e.getType() == ChatMessageType.PUBLIC_MOD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user