Merge branch 'master' of https://www.github.com/runelite/runelite into 24112021

This commit is contained in:
Justin
2021-11-24 22:47:50 +11:00
25 changed files with 1557 additions and 1035 deletions

View File

@@ -127,7 +127,8 @@ public class CommandManager
int intStackCount = client.getIntStackSize();
final String typedText = stringStack[stringStackCount - 1];
final int chatType = intStack[intStackCount - 1];
final int chatType = intStack[intStackCount - 2];
final int clanTarget = intStack[intStackCount - 1];
ChatboxInput chatboxInput = new ChatboxInput(typedText, chatType)
{
@@ -142,7 +143,7 @@ public class CommandManager
}
resumed = true;
clientThread.invoke(() -> sendChatboxInput(chatType, typedText));
clientThread.invoke(() -> sendChatboxInput(typedText, chatType, clanTarget));
}
};
boolean stop = false;
@@ -198,12 +199,12 @@ public class CommandManager
}
}
private void sendChatboxInput(int chatType, String input)
private void sendChatboxInput(String input, int chatType, int clanTarget)
{
sending = true;
try
{
client.runScript(ScriptID.CHATBOX_INPUT, chatType, input);
client.runScript(ScriptID.CHAT_SEND, input, chatType, clanTarget, 0, -1);
}
finally
{

View File

@@ -68,17 +68,6 @@ public interface ChatChannelConfig extends Config
return 20;
}
@ConfigItem(
keyName = "targetMode",
name = "Target mode",
description = "Enables target changing mode via /f, /c, and /g which controls which channel messages are sent to.",
position = 1
)
default boolean targetMode()
{
return true;
}
@ConfigItem(
keyName = "clanChatIcons",
name = "Chat Icons",

View File

@@ -41,7 +41,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import javax.inject.Inject;
import lombok.AllArgsConstructor;
import net.runelite.api.ChatLineBuffer;
import net.runelite.api.ChatMessageType;
import net.runelite.api.ChatPlayer;
@@ -77,8 +76,6 @@ import net.runelite.api.widgets.WidgetInfo;
import net.runelite.api.widgets.WidgetType;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.chat.QueuedMessage;
import net.runelite.client.config.ChatColorConfig;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
@@ -123,9 +120,6 @@ public class ChatChannelPlugin extends Plugin
@Inject
private ChatColorConfig chatColorConfig;
@Inject
private ChatMessageManager chatMessageManager;
private List<String> chats;
/**
* queue of temporary messages added to the client
@@ -136,21 +130,6 @@ public class ChatChannelPlugin extends Plugin
private boolean kickConfirmed = false;
private boolean inputWarning;
@AllArgsConstructor
private enum InputMode
{
FRIEND("Friends Chat", ChatMessageType.FRIENDSCHAT),
CLAN("Clan Chat", ChatMessageType.CLAN_CHAT),
GUEST("Guest Clan Chat", ChatMessageType.CLAN_GUEST_CHAT);
private final String prompt;
private final ChatMessageType chatMessageType;
}
private InputMode inputMode;
@Provides
ChatChannelConfig getConfig(ConfigManager configManager)
{
@@ -174,15 +153,6 @@ public class ChatChannelPlugin extends Plugin
chats = null;
clientThread.invoke(() -> colorIgnoredPlayers(Color.WHITE));
rebuildFriendsChat();
if (inputMode != null)
{
clientThread.invoke(() ->
{
switchTypingMode(null);
client.runScript(ScriptID.CHAT_PROMPT_INIT);
});
}
}
@Subscribe
@@ -197,15 +167,6 @@ public class ChatChannelPlugin extends Plugin
Color ignoreColor = config.showIgnores() ? config.showIgnoresColor() : Color.WHITE;
clientThread.invoke(() -> colorIgnoredPlayers(ignoreColor));
if (inputMode != null && !config.targetMode())
{
clientThread.invoke(() ->
{
switchTypingMode(null);
client.runScript(ScriptID.CHAT_PROMPT_INIT);
});
}
}
}
@@ -625,72 +586,6 @@ public class ChatChannelPlugin extends Plugin
clientThread.invokeLater(() -> confirmKickPlayer(kickPlayerName));
break;
}
case "preChatSendpublic":
{
if (!config.targetMode())
{
return;
}
final String chatboxInput = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
switch (chatboxInput)
{
case "/p":
switchTypingMode(null);
break;
case "/f":
switchTypingMode(InputMode.FRIEND);
break;
case "/c":
switchTypingMode(InputMode.CLAN);
break;
case "/g":
switchTypingMode(InputMode.GUEST);
break;
default:
if (inputMode != null)
{
final int[] intStack = client.getIntStack();
final int intStackSize = client.getIntStackSize();
intStack[intStackSize - 1] = inputMode.chatMessageType.getType(); // chat message type
intStack[intStackSize - 2] = 0; // prefix length
}
break;
}
break;
}
case "setChatboxInput":
{
Widget chatboxInput = client.getWidget(WidgetInfo.CHATBOX_INPUT);
if (chatboxInput != null && inputMode != null)
{
String text = chatboxInput.getText();
int idx = text.indexOf(": ");
if (idx != -1)
{
String newText = inputMode.prompt + ": " + text.substring(idx + 2);
chatboxInput.setText(newText);
}
}
break;
}
}
}
private void switchTypingMode(InputMode mode)
{
inputMode = mode;
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
if (mode != null && !inputWarning)
{
inputWarning = true;
chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage("You've entered " + inputMode.prompt + " typing mode. All typed messages will be sent to your " +
inputMode.prompt.toLowerCase() + ". Use /p to reset to public chat.")
.build());
}
}

View File

@@ -57,8 +57,6 @@ import net.runelite.client.util.ColorUtil;
public class KeyRemappingPlugin extends Plugin
{
private static final String PRESS_ENTER_TO_CHAT = "Press Enter to Chat...";
private static final String SCRIPT_EVENT_SET_CHATBOX_INPUT = "setChatboxInput";
private static final String SCRIPT_EVENT_BLOCK_CHAT_INPUT = "blockChatInput";
@Inject
private Client client;
@@ -160,14 +158,14 @@ public class KeyRemappingPlugin extends Plugin
{
switch (scriptCallbackEvent.getEventName())
{
case SCRIPT_EVENT_SET_CHATBOX_INPUT:
case "setChatboxInput":
Widget chatboxInput = client.getWidget(WidgetInfo.CHATBOX_INPUT);
if (chatboxInput != null && !typing)
{
setChatboxWidgetInput(chatboxInput, PRESS_ENTER_TO_CHAT);
}
break;
case SCRIPT_EVENT_BLOCK_CHAT_INPUT:
case "blockChatInput":
if (!typing)
{
int[] intStack = client.getIntStack();