clanchat: add ability to recolor ignored players

Adds the ability to configure whether or not to mark ignored players inside clanchat with a chosen color

Co-Authored-By: Adam <adam@sigterm.info>
This commit is contained in:
melkypie
2020-01-04 20:46:47 +02:00
committed by Adam
parent ed86df8539
commit 1549e38fa7
4 changed files with 866 additions and 0 deletions

View File

@@ -24,6 +24,7 @@
*/
package net.runelite.client.plugins.clanchat;
import java.awt.Color;
import net.runelite.api.ClanMemberRank;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
@@ -148,4 +149,26 @@ public interface ClanChatConfig extends Config
{
return false;
}
@ConfigItem(
keyName = "showIgnores",
name = "Recolor ignored players",
description = "Recolors players that are on your ignore list",
position = 10
)
default boolean showIgnores()
{
return true;
}
@ConfigItem(
keyName = "showIgnoresColor",
name = "Ignored color",
description = "Allows you to change the color of the ignored players in your clan chat",
position = 11
)
default Color showIgnoresColor()
{
return Color.RED;
}
}

View File

@@ -47,7 +47,9 @@ import net.runelite.api.ClanMemberManager;
import net.runelite.api.ClanMemberRank;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.Ignore;
import net.runelite.api.MessageNode;
import net.runelite.api.NameableContainer;
import net.runelite.api.Player;
import net.runelite.api.ScriptID;
import net.runelite.api.SpriteID;
@@ -139,11 +141,17 @@ public class ClanChatPlugin extends Plugin
public void startUp()
{
chats = new ArrayList<>(Text.fromCSV(config.chatsData()));
if (config.showIgnores())
{
clientThread.invoke(() -> colorIgnoredPlayers(config.showIgnoresColor()));
}
}
@Override
public void shutDown()
{
clientThread.invoke(() -> colorIgnoredPlayers(Color.WHITE));
clanMembers.clear();
removeClanCounter();
resetClanChats();
@@ -167,6 +175,9 @@ public class ClanChatPlugin extends Plugin
{
removeClanCounter();
}
Color ignoreColor = config.showIgnores() ? config.showIgnoresColor() : Color.WHITE;
clientThread.invoke(() -> colorIgnoredPlayers(ignoreColor));
}
}
@@ -541,6 +552,12 @@ public class ClanChatPlugin extends Plugin
clientThread.invokeLater(() -> confirmKickPlayer(kickPlayerName));
break;
}
case "clanChatChannelRebuild":
if (config.showIgnores())
{
clientThread.invoke(() -> colorIgnoredPlayers(config.showIgnoresColor()));
}
break;
}
}
@@ -668,4 +685,27 @@ public class ClanChatPlugin extends Plugin
.option("2. Cancel", Runnables::doNothing)
.build();
}
private void colorIgnoredPlayers(Color ignoreColor)
{
Widget clanChatList = client.getWidget(WidgetInfo.CLAN_CHAT_LIST);
if (clanChatList == null || clanChatList.getChildren() == null)
{
return;
}
NameableContainer<Ignore> ignoreContainer = client.getIgnoreContainer();
// Iterate every 3 widgets, since the order of widgets is name, world, icon
for (int i = 0; i < clanChatList.getChildren().length; i += 3)
{
Widget listWidget = clanChatList.getChild(i);
String clanMemberName = listWidget.getText();
if (clanMemberName.isEmpty() || ignoreContainer.findByName(clanMemberName) == null)
{
continue;
}
listWidget.setTextColor(ignoreColor.getRGB());
}
}
}