From c3bbd4934817d741c4d9ce8f59c6dc95dd42b7e5 Mon Sep 17 00:00:00 2001 From: TheStonedTurtle <29030969+TheStonedTurtle@users.noreply.github.com> Date: Mon, 18 Feb 2019 07:14:21 -0800 Subject: [PATCH] Add Chat History config options --- .../chathistory/ChatHistoryConfig.java | 55 +++++++++++++++++++ .../chathistory/ChatHistoryPlugin.java | 18 +++++- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryConfig.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryConfig.java new file mode 100644 index 0000000000..e30629c742 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryConfig.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018, TheStonedTurtle + * 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.client.plugins.chathistory; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("chathistory") +public interface ChatHistoryConfig extends Config +{ + @ConfigItem( + keyName = "retainChatHistory", + name = "Retain Chat History", + description = "Retains chat history when logging in/out or world hopping", + position = 0 + ) + default boolean retainChatHistory() + { + return true; + } + + @ConfigItem( + keyName = "pmTargetCycling", + name = "PM Target Cycling", + description = "Pressing Tab while sending a PM will cycle the target username based on PM history", + position = 1 + ) + default boolean pmTargetCycling() + { + return true; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java index 77fcb70df0..43919214ea 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.chathistory; import com.google.common.collect.EvictingQueue; +import com.google.inject.Provides; import java.awt.event.KeyEvent; import java.util.ArrayDeque; import java.util.Deque; @@ -42,6 +43,7 @@ import net.runelite.api.vars.InputType; import net.runelite.client.callback.ClientThread; import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.QueuedMessage; +import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyManager; @@ -70,11 +72,20 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener @Inject private ClientThread clientThread; + @Inject + private ChatHistoryConfig config; + @Inject private KeyManager keyManager; @Inject private ChatMessageManager chatMessageManager; + + @Provides + ChatHistoryConfig getConfig(ConfigManager configManager) + { + return configManager.getConfig(ChatHistoryConfig.class); + } @Override protected void startUp() @@ -101,6 +112,11 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener // of information that chat history was reset if (chatMessage.getMessage().equals(WELCOME_MESSAGE)) { + if (!config.retainChatHistory()) + { + return; + } + QueuedMessage queuedMessage; while ((queuedMessage = messageQueue.poll()) != null) @@ -178,7 +194,7 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener @Override public void keyPressed(KeyEvent e) { - if (e.getKeyCode() != CYCLE_HOTKEY) + if (e.getKeyCode() != CYCLE_HOTKEY || !config.pmTargetCycling()) { return; }