Merge remote-tracking branch 'upstream/master' into master

This commit is contained in:
ThatGamerBlue
2021-05-26 16:48:16 +01:00
29 changed files with 312 additions and 213 deletions

View File

@@ -31,7 +31,6 @@ import net.runelite.api.events.PlayerDespawned;
import net.runelite.api.kit.KitType;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.game.FriendChatManager;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.ItemMapping;
import net.runelite.client.util.PvPUtil;
@@ -50,7 +49,6 @@ public class PlayerManager
private final Client client;
private final ItemManager itemManager;
private final EventBus eventBus;
private final FriendChatManager friendChatManager;
private final Map<String, PlayerContainer> playerMap = new ConcurrentHashMap<>();
private final Map<String, HiscoreResult> resultCache = new ConcurrentHashMap<>();
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
@@ -60,14 +58,12 @@ public class PlayerManager
final Client client,
final EventBus eventBus,
final ItemManager itemManager,
final FriendChatManager friendChatManager,
final OkHttpClient okHttpClient
)
{
this.client = client;
this.itemManager = itemManager;
this.eventBus = eventBus;
this.friendChatManager = friendChatManager;
this.hiscoreClient = new HiscoreClient(okHttpClient);
eventBus.register(this);
@@ -219,7 +215,7 @@ public class PlayerManager
PlayerContainer player = playerMap.computeIfAbsent(event.getPlayer().getName(), s -> new PlayerContainer(event.getPlayer()));
update(player);
player.setFriend(client.isFriended(player.getName(), false));
player.setClan(friendChatManager.isMember(player.getName()));
player.setClan(event.getPlayer().isFriendsChatMember());
}
@Subscribe

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* Copyright (c) 2021, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,94 +24,45 @@
*/
package net.runelite.client.game;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.FriendsChatMember;
import net.runelite.api.FriendsChatManager;
import net.runelite.api.FriendsChatRank;
import net.runelite.api.Client;
import net.runelite.api.EnumComposition;
import net.runelite.api.EnumID;
import net.runelite.api.FriendsChatRank;
import net.runelite.api.GameState;
import net.runelite.api.IndexedSprite;
import net.runelite.api.SpriteID;
import net.runelite.api.events.FriendsChatChanged;
import net.runelite.api.events.GameStateChanged;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.Text;
@Singleton
public class FriendChatManager
public class ChatIconManager
{
private static final int[] RANK_IMAGES =
{
SpriteID.FRIENDS_CHAT_RANK_SMILEY_FRIEND,
SpriteID.FRIENDS_CHAT_RANK_SINGLE_CHEVRON_RECRUIT,
SpriteID.FRIENDS_CHAT_RANK_DOUBLE_CHEVRON_CORPORAL,
SpriteID.FRIENDS_CHAT_RANK_TRIPLE_CHEVRON_SERGEANT,
SpriteID.FRIENDS_CHAT_RANK_BRONZE_STAR_LIEUTENANT,
SpriteID.FRIENDS_CHAT_RANK_SILVER_STAR_CAPTAIN,
SpriteID.FRIENDS_CHAT_RANK_GOLD_STAR_GENERAL,
SpriteID.FRIENDS_CHAT_RANK_KEY_CHANNEL_OWNER,
SpriteID.FRIENDS_CHAT_RANK_CROWN_JAGEX_MODERATOR,
};
private static final Dimension IMAGE_DIMENSION = new Dimension(11, 11);
private static final Color IMAGE_OUTLINE_COLOR = new Color(33, 33, 33);
private final Client client;
private final SpriteManager spriteManager;
private final BufferedImage[] rankImages = new BufferedImage[RANK_IMAGES.length];
private final LoadingCache<String, FriendsChatRank> ranksCache = CacheBuilder.newBuilder()
.maximumSize(100)
.expireAfterWrite(1, TimeUnit.MINUTES)
.build(new CacheLoader<String, FriendsChatRank>()
{
@Override
public FriendsChatRank load(@Nonnull String key)
{
final FriendsChatManager friendsChatManager = client.getFriendsChatManager();
if (friendsChatManager == null)
{
return FriendsChatRank.UNRANKED;
}
private BufferedImage[] friendsChatRankImages;
FriendsChatMember friendsChatMember = friendsChatManager.findByName(sanitize(key));
return friendsChatMember != null ? friendsChatMember.getRank() : FriendsChatRank.UNRANKED;
}
});
private int offset;
private int friendsChatOffset;
@Inject
private FriendChatManager(Client client, SpriteManager spriteManager, EventBus eventBus)
private ChatIconManager(Client client, SpriteManager spriteManager, EventBus eventBus)
{
this.client = client;
this.spriteManager = spriteManager;
eventBus.register(this);
}
public boolean isMember(String name)
{
FriendsChatManager friendsChatManager = client.getFriendsChatManager();
return friendsChatManager != null && friendsChatManager.findByName(name) != null;
}
public FriendsChatRank getRank(String playerName)
{
return ranksCache.getUnchecked(playerName);
}
@Nullable
public BufferedImage getRankImage(final FriendsChatRank friendsChatRank)
{
@@ -120,64 +71,57 @@ public class FriendChatManager
return null;
}
return rankImages[friendsChatRank.ordinal() - 1];
return friendsChatRankImages[friendsChatRank.ordinal() - 1];
}
public int getIconNumber(final FriendsChatRank friendsChatRank)
{
return offset + friendsChatRank.ordinal() - 1;
return friendsChatOffset + friendsChatRank.ordinal() - 1;
}
@Subscribe
public void onGameStateChanged(GameStateChanged gameStateChanged)
{
if (gameStateChanged.getGameState() == GameState.LOGIN_SCREEN && offset == 0)
if (gameStateChanged.getGameState() == GameState.LOGIN_SCREEN && friendsChatOffset == 0)
{
loadRankIcons();
}
}
@Subscribe
public void onFriendsChatChanged(FriendsChatChanged friendsChatChanged)
{
ranksCache.invalidateAll();
}
private void loadRankIcons()
{
final EnumComposition friendsChatIcons = client.getEnum(EnumID.FRIENDS_CHAT_RANK_ICONS);
{
IndexedSprite[] modIcons = client.getModIcons();
offset = modIcons.length;
friendsChatOffset = modIcons.length;
IndexedSprite blank = ImageUtil.getImageIndexedSprite(
new BufferedImage(modIcons[0].getWidth(), modIcons[0].getHeight(), BufferedImage.TYPE_INT_ARGB),
client);
modIcons = Arrays.copyOf(modIcons, offset + RANK_IMAGES.length);
Arrays.fill(modIcons, offset, modIcons.length, blank);
modIcons = Arrays.copyOf(modIcons, friendsChatOffset + friendsChatIcons.size());
Arrays.fill(modIcons, friendsChatOffset, modIcons.length, blank);
client.setModIcons(modIcons);
}
for (int i = 0; i < RANK_IMAGES.length; i++)
friendsChatRankImages = new BufferedImage[friendsChatIcons.size()];
final IndexedSprite[] modIcons = client.getModIcons();
for (int i = 0; i < friendsChatIcons.size(); i++)
{
final int fi = i;
spriteManager.getSpriteAsync(RANK_IMAGES[i], 0, sprite ->
spriteManager.getSpriteAsync(friendsChatIcons.getIntValue(friendsChatIcons.getKeys()[i]), 0, sprite ->
{
IndexedSprite[] modIcons = client.getModIcons();
rankImages[fi] = friendsChatImageFromSprite(sprite);
modIcons[offset + fi] = ImageUtil.getImageIndexedSprite(rankImages[fi], client);
friendsChatRankImages[fi] = friendsChatImageFromSprite(sprite);
modIcons[friendsChatOffset + fi] = ImageUtil.getImageIndexedSprite(friendsChatRankImages[fi], client);
});
}
}
private static String sanitize(String lookup)
{
final String cleaned = Text.removeTags(lookup);
return cleaned.replace('\u00A0', ' ');
}
private static BufferedImage friendsChatImageFromSprite(final BufferedImage sprite)
{
final BufferedImage canvas = ImageUtil.resizeCanvas(sprite, IMAGE_DIMENSION.width, IMAGE_DIMENSION.height);

View File

@@ -37,6 +37,11 @@ public @interface PluginDescriptor
{
String name();
/**
* Internal name used in the config.
*/
String configName() default "";
/**
* A short, one-line summary of the plugin.
*/

View File

@@ -25,6 +25,7 @@
package net.runelite.client.plugins;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.graph.Graph;
import com.google.common.graph.GraphBuilder;
@@ -337,7 +338,8 @@ public class PluginManager
{
log.debug("Disabling {} due to safe mode", clazz);
// also disable the plugin from autostarting later
configManager.unsetConfiguration(RuneLiteConfig.GROUP_NAME, clazz.getSimpleName().toLowerCase());
configManager.unsetConfiguration(RuneLiteConfig.GROUP_NAME,
(Strings.isNullOrEmpty(pluginDescriptor.configName()) ? clazz.getSimpleName() : pluginDescriptor.configName()).toLowerCase());
continue;
}
@@ -465,22 +467,17 @@ public class PluginManager
public void setPluginEnabled(Plugin plugin, boolean enabled)
{
final String keyName = plugin.getClass().getSimpleName().toLowerCase();
configManager.setConfiguration(RuneLiteConfig.GROUP_NAME, keyName, String.valueOf(enabled));
final PluginDescriptor pluginDescriptor = plugin.getClass().getAnnotation(PluginDescriptor.class);
final String keyName = Strings.isNullOrEmpty(pluginDescriptor.configName()) ? plugin.getClass().getSimpleName() : pluginDescriptor.configName();
configManager.setConfiguration(RuneLiteConfig.GROUP_NAME, keyName.toLowerCase(), String.valueOf(enabled));
}
public boolean isPluginEnabled(Plugin plugin)
{
final String keyName = plugin.getClass().getSimpleName().toLowerCase();
final String value = configManager.getConfiguration(RuneLiteConfig.GROUP_NAME, keyName);
if (value != null)
{
return Boolean.valueOf(value);
}
final PluginDescriptor pluginDescriptor = plugin.getClass().getAnnotation(PluginDescriptor.class);
return pluginDescriptor == null || pluginDescriptor.enabledByDefault();
final String keyName = Strings.isNullOrEmpty(pluginDescriptor.configName()) ? plugin.getClass().getSimpleName() : pluginDescriptor.configName();
final String value = configManager.getConfiguration(RuneLiteConfig.GROUP_NAME, keyName.toLowerCase());
return value != null ? Boolean.parseBoolean(value) : pluginDescriptor.enabledByDefault();
}
private Plugin instantiate(List<Plugin> scannedPlugins, Class<Plugin> clazz) throws PluginInstantiationException

View File

@@ -50,6 +50,7 @@ import static net.runelite.api.ChatMessageType.OBJECT_EXAMINE;
import static net.runelite.api.ChatMessageType.PUBLICCHAT;
import static net.runelite.api.ChatMessageType.SPAM;
import net.runelite.api.Client;
import net.runelite.api.FriendsChatManager;
import net.runelite.api.MessageNode;
import net.runelite.api.Player;
import net.runelite.api.events.ChatMessage;
@@ -58,7 +59,6 @@ import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.game.FriendChatManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.util.Text;
@@ -117,9 +117,6 @@ public class ChatFilterPlugin extends Plugin
@Inject
private ChatFilterConfig config;
@Inject
private FriendChatManager friendChatManager;
@Provides
ChatFilterConfig provideConfig(ConfigManager configManager)
{
@@ -274,7 +271,13 @@ public class ChatFilterPlugin extends Plugin
boolean isMessageFromSelf = playerName.equals(client.getLocalPlayer().getName());
return !isMessageFromSelf &&
(config.filterFriends() || !client.isFriended(playerName, false)) &&
(config.filterFriendsChat() || !friendChatManager.isMember(playerName));
(config.filterFriendsChat() || !isFriendsChatMember(playerName));
}
private boolean isFriendsChatMember(String name)
{
FriendsChatManager friendsChatManager = client.getFriendsChatManager();
return friendsChatManager != null && friendsChatManager.findByName(name) != null;
}
String censorMessage(final String username, final String message)

View File

@@ -37,6 +37,7 @@ import java.util.Deque;
import java.util.Iterator;
import java.util.Queue;
import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.ChatLineBuffer;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
@@ -72,6 +73,7 @@ import org.apache.commons.lang3.StringUtils;
description = "Retain your chat history when logging in/out or world hopping",
tags = {"chat", "history", "retain", "cycle", "pm"}
)
@Slf4j
public class ChatHistoryPlugin extends Plugin implements KeyListener
{
private static final String WELCOME_MESSAGE = "Welcome to Old School RuneScape";
@@ -173,6 +175,8 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
case PUBLICCHAT:
case MODCHAT:
case FRIENDSCHAT:
case CLAN_GUEST_CHAT:
case CLAN_CHAT:
case CONSOLE:
messageQueue.offer(chatMessage.getMessageNode());
}
@@ -262,7 +266,7 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
{
final ChatboxTab tab = ChatboxTab.of(entry.getActionParam1());
if (tab == null || !config.clearHistory() || !Text.removeTags(entry.getOption()).equals(tab.getAfter()))
if (tab == null || tab.getAfter() == null || !config.clearHistory() || !Text.removeTags(entry.getOption()).equals(tab.getAfter()))
{
return;
}
@@ -311,6 +315,16 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
return;
}
log.debug("Clearing chatbox history for tab {}", tab);
clearMessageQueue(tab);
if (tab.getAfter() == null)
{
// if the tab has a vanilla Clear option, it isn't necessary to delete the messages ourselves.
return;
}
boolean removed = false;
for (ChatMessageType msgType : tab.getMessageTypes())
{
@@ -333,10 +347,9 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
if (removed)
{
clientThread.invoke(() -> client.runScript(ScriptID.BUILD_CHATBOX));
// this rebuilds both the chatbox and the pmbox
clientThread.invoke(() -> client.runScript(ScriptID.SPLITPM_CHANGED));
}
clearMessageQueue(tab);
}
@Override

View File

@@ -54,10 +54,13 @@ enum ChatboxTab
ChatMessageType.CONSOLE, ChatMessageType.SPAM, ChatMessageType.PLAYERRELATED, ChatMessageType.TENSECTIMEOUT,
ChatMessageType.WELCOME, ChatMessageType.UNKNOWN),
CLAN("Clan", "Clan: Off", WidgetInfo.CHATBOX_TAB_CLAN,
CHANNEL("Channel", null, WidgetInfo.CHATBOX_TAB_CHANNEL,
ChatMessageType.FRIENDSCHATNOTIFICATION, ChatMessageType.FRIENDSCHAT, ChatMessageType.CHALREQ_FRIENDSCHAT),
TRADE("Trade", "Trade: Off", WidgetInfo.CHATBOX_TAB_TRADE,
CLAN("Clan", null, WidgetInfo.CHATBOX_TAB_CLAN,
ChatMessageType.CLAN_CHAT, ChatMessageType.CLAN_MESSAGE, ChatMessageType.CLAN_GUEST_CHAT, ChatMessageType.CLAN_GUEST_MESSAGE),
TRADE("Trade", "Trade: Show none", WidgetInfo.CHATBOX_TAB_TRADE,
ChatMessageType.TRADE_SENT, ChatMessageType.TRADEREQ, ChatMessageType.TRADE, ChatMessageType.CHALREQ_TRADE),
;

View File

@@ -38,6 +38,7 @@ import lombok.Getter;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.Experience;
import net.runelite.api.IndexedSprite;
import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry;
import net.runelite.api.NPC;
@@ -430,6 +431,25 @@ public class DevToolsPlugin extends Plugin
.build());
break;
}
case "modicons":
{
final ChatMessageBuilder builder = new ChatMessageBuilder();
final IndexedSprite[] modIcons = client.getModIcons();
for (int i = 0; i < modIcons.length; i++)
{
builder.append(i + "=").img(i);
if (i != modIcons.length - 1)
{
builder.append(", ");
}
}
chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.GAMEMESSAGE)
.runeLiteFormattedMessage(builder.build())
.build());
break;
}
}
}

View File

@@ -76,7 +76,7 @@ import net.runelite.client.config.ChatColorConfig;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.game.FriendChatManager;
import net.runelite.client.game.ChatIconManager;
import net.runelite.client.game.SpriteManager;
import net.runelite.client.game.chatbox.ChatboxPanelManager;
import net.runelite.client.plugins.Plugin;
@@ -96,13 +96,14 @@ import net.runelite.client.util.Text;
public class FriendsChatPlugin extends Plugin
{
private static final int MAX_CHATS = 10;
private static final String RECENT_TITLE = "Recent FCs";
private static final int MESSAGE_DELAY = 10;
@Inject
private Client client;
@Inject
private FriendChatManager friendChatManager;
private ChatIconManager chatIconManager;
@Inject
private FriendsChatConfig config;
@@ -157,7 +158,7 @@ public class FriendsChatPlugin extends Plugin
clientThread.invoke(() -> colorIgnoredPlayers(Color.WHITE));
members.clear();
resetCounter();
resetChats();
rebuildFriendsChat();
}
@Subscribe
@@ -167,7 +168,7 @@ public class FriendsChatPlugin extends Plugin
{
if (!config.recentChats())
{
resetChats();
rebuildFriendsChat();
}
if (config.showCounter())
@@ -397,7 +398,7 @@ public class FriendsChatPlugin extends Plugin
if (config.chatIcons() && rank != null && rank != FriendsChatRank.UNRANKED)
{
rankIcon = friendChatManager.getIconNumber(rank);
rankIcon = chatIconManager.getIconNumber(rank);
}
ChatMessageBuilder message = new ChatMessageBuilder()
@@ -556,9 +557,19 @@ public class FriendsChatPlugin extends Plugin
@Subscribe
public void onScriptPostFired(ScriptPostFired event)
{
if (event.getScriptId() == ScriptID.FRIENDS_CHAT_CHANNEL_REBUILD && config.showIgnores())
if (event.getScriptId() == ScriptID.FRIENDS_CHAT_CHANNEL_REBUILD)
{
colorIgnoredPlayers(config.showIgnoresColor());
if (config.showIgnores())
{
colorIgnoredPlayers(config.showIgnoresColor());
}
FriendsChatManager friendsChatManager = client.getFriendsChatManager();
Widget chatTitle = client.getWidget(WidgetInfo.FRIENDS_CHAT_TITLE);
if (friendsChatManager != null && friendsChatManager.getCount() > 0 && chatTitle != null)
{
chatTitle.setText(chatTitle.getText() + " (" + friendsChatManager.getCount() + "/100)");
}
}
}
@@ -569,11 +580,11 @@ public class FriendsChatPlugin extends Plugin
private void insertRankIcon(final ChatMessage message)
{
final FriendsChatRank rank = friendChatManager.getRank(message.getName());
final FriendsChatRank rank = getRank(message.getName());
if (rank != null && rank != FriendsChatRank.UNRANKED)
{
int iconNumber = friendChatManager.getIconNumber(rank);
int iconNumber = chatIconManager.getIconNumber(rank);
final String img = "<img=" + iconNumber + ">";
if (message.getType() == ChatMessageType.FRIENDSCHAT)
{
@@ -589,30 +600,41 @@ public class FriendsChatPlugin extends Plugin
}
}
private void resetChats()
private FriendsChatRank getRank(String playerName)
{
Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST);
final FriendsChatManager friendsChatManager = client.getFriendsChatManager();
if (friendsChatManager == null)
{
return FriendsChatRank.UNRANKED;
}
if (chatList == null)
FriendsChatMember friendsChatMember = friendsChatManager.findByName(playerName);
return friendsChatMember != null ? friendsChatMember.getRank() : FriendsChatRank.UNRANKED;
}
private void rebuildFriendsChat()
{
Widget chat = client.getWidget(WidgetInfo.FRIENDS_CHAT_ROOT);
if (chat == null)
{
return;
}
FriendsChatManager friendsChatManager = client.getFriendsChatManager();
if (friendsChatManager == null || friendsChatManager.getCount() == 0)
{
chatList.setChildren(null);
}
Object[] args = chat.getOnVarTransmitListener();
clientThread.invokeLater(() -> client.runScript(args));
}
private void loadFriendsChats()
{
Widget chatOwner = client.getWidget(WidgetInfo.FRIENDS_CHAT_OWNER);
Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST);
if (chatList == null)
if (chatList == null || chatOwner == null)
{
return;
}
chatOwner.setText(RECENT_TITLE);
int y = 2;
chatList.setChildren(null);
for (String chat : Lists.reverse(chats))

View File

@@ -96,6 +96,7 @@ import net.runelite.http.api.ws.messages.party.UserSync;
@PluginDescriptor(
name = "Party",
configName = "PartyPlugin2",
description = "Party management and basic info",
enabledByDefault = false
)

View File

@@ -34,7 +34,7 @@ import javax.inject.Singleton;
import net.runelite.api.FriendsChatRank;
import net.runelite.api.Player;
import net.runelite.api.Point;
import net.runelite.client.game.FriendChatManager;
import net.runelite.client.game.ChatIconManager;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority;
@@ -49,15 +49,15 @@ public class PlayerIndicatorsOverlay extends Overlay
private final PlayerIndicatorsService playerIndicatorsService;
private final PlayerIndicatorsConfig config;
private final FriendChatManager friendChatManager;
private final ChatIconManager chatIconManager;
@Inject
private PlayerIndicatorsOverlay(PlayerIndicatorsConfig config, PlayerIndicatorsService playerIndicatorsService,
FriendChatManager friendChatManager)
ChatIconManager chatIconManager)
{
this.config = config;
this.playerIndicatorsService = playerIndicatorsService;
this.friendChatManager = friendChatManager;
this.chatIconManager = chatIconManager;
setPosition(OverlayPosition.DYNAMIC);
setPriority(OverlayPriority.MED);
}
@@ -108,13 +108,13 @@ public class PlayerIndicatorsOverlay extends Overlay
return;
}
if (config.showFriendsChatRanks() && actor.isFriendsChatMember())
if (actor.isFriendsChatMember() && config.showFriendsChatRanks())
{
final FriendsChatRank rank = friendChatManager.getRank(name);
final FriendsChatRank rank = playerIndicatorsService.getFriendsChatRank(actor);
if (rank != FriendsChatRank.UNRANKED)
{
final BufferedImage rankImage = friendChatManager.getRankImage(rank);
final BufferedImage rankImage = chatIconManager.getRankImage(rank);
if (rankImage != null)
{
@@ -145,4 +145,4 @@ public class PlayerIndicatorsOverlay extends Overlay
OverlayUtil.renderTextLocation(graphics, textLocation, name, color);
}
}
}

View File

@@ -28,16 +28,28 @@ import com.google.inject.Provides;
import java.awt.Color;
import javax.inject.Inject;
import lombok.Value;
import net.runelite.api.Client;
import net.runelite.api.FriendsChatRank;
import static net.runelite.api.FriendsChatRank.UNRANKED;
import net.runelite.api.Client;
import static net.runelite.api.MenuAction.*;
import static net.runelite.api.MenuAction.ITEM_USE_ON_PLAYER;
import static net.runelite.api.MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET;
import static net.runelite.api.MenuAction.PLAYER_EIGTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_FIFTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_FIRST_OPTION;
import static net.runelite.api.MenuAction.PLAYER_FOURTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_SECOND_OPTION;
import static net.runelite.api.MenuAction.PLAYER_SEVENTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_SIXTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_THIRD_OPTION;
import static net.runelite.api.MenuAction.RUNELITE_PLAYER;
import static net.runelite.api.MenuAction.SPELL_CAST_ON_PLAYER;
import static net.runelite.api.MenuAction.WALK;
import net.runelite.api.MenuEntry;
import net.runelite.api.Player;
import net.runelite.api.events.ClientTick;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.game.FriendChatManager;
import net.runelite.client.game.ChatIconManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager;
@@ -65,11 +77,14 @@ public class PlayerIndicatorsPlugin extends Plugin
@Inject
private PlayerIndicatorsMinimapOverlay playerIndicatorsMinimapOverlay;
@Inject
private PlayerIndicatorsService playerIndicatorsService;
@Inject
private Client client;
@Inject
private FriendChatManager friendChatManager;
private ChatIconManager chatIconManager;
@Provides
PlayerIndicatorsConfig provideConfig(ConfigManager configManager)
@@ -182,10 +197,13 @@ public class PlayerIndicatorsPlugin extends Plugin
{
color = config.getFriendsChatMemberColor();
FriendsChatRank rank = friendChatManager.getRank(player.getName());
if (rank != UNRANKED)
if (config.showFriendsChatRanks())
{
image = friendChatManager.getIconNumber(rank);
FriendsChatRank rank = playerIndicatorsService.getFriendsChatRank(player);
if (rank != UNRANKED)
{
image = chatIconManager.getIconNumber(rank);
}
}
}
else if (config.highlightTeamMembers()
@@ -222,7 +240,7 @@ public class PlayerIndicatorsPlugin extends Plugin
newTarget = ColorUtil.prependColorTag(newTarget, decorations.getColor());
}
if (decorations.getImage() != -1 && config.showFriendsChatRanks())
if (decorations.getImage() != -1)
{
newTarget = "<img=" + decorations.getImage() + ">" + newTarget;
}

View File

@@ -29,6 +29,9 @@ import java.util.function.BiConsumer;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.FriendsChatManager;
import net.runelite.api.FriendsChatMember;
import net.runelite.api.FriendsChatRank;
import net.runelite.api.Player;
@Singleton
@@ -88,4 +91,16 @@ public class PlayerIndicatorsService
}
}
}
FriendsChatRank getFriendsChatRank(Player player)
{
final FriendsChatManager friendsChatManager = client.getFriendsChatManager();
if (friendsChatManager == null)
{
return FriendsChatRank.UNRANKED;
}
FriendsChatMember friendsChatMember = friendsChatManager.findByName(player.getName());
return friendsChatMember != null ? friendsChatMember.getRank() : FriendsChatRank.UNRANKED;
}
}

View File

@@ -211,9 +211,9 @@ public class TwitchPlugin extends Plugin implements TwitchListener, ChatboxInput
public boolean onChatboxInput(ChatboxInput chatboxInput)
{
String message = chatboxInput.getValue();
if (message.startsWith("//"))
if (message.startsWith("/t "))
{
message = message.substring(2);
message = message.substring(3);
if (message.isEmpty() || twitchIRCClient == null)
{
return true;