team: add clan member counter
This commit is contained in:
@@ -1579,6 +1579,7 @@ public final class SpriteID
|
|||||||
public static final int HEALTHBAR_DEFAULT_BACK_140PX = 2189;
|
public static final int HEALTHBAR_DEFAULT_BACK_140PX = 2189;
|
||||||
public static final int HEALTHBAR_DEFAULT_FRONT_160PX = 2190;
|
public static final int HEALTHBAR_DEFAULT_FRONT_160PX = 2190;
|
||||||
public static final int HEALTHBAR_DEFAULT_BACK_160PX = 2191;
|
public static final int HEALTHBAR_DEFAULT_BACK_160PX = 2191;
|
||||||
|
public static final int TAB_CLAN_CHAT = 2307;
|
||||||
public static final int WIKI_DESELECTED = 2420;
|
public static final int WIKI_DESELECTED = 2420;
|
||||||
public static final int WIKI_SELECTED = 2421;
|
public static final int WIKI_SELECTED = 2421;
|
||||||
public static final int FRIENDS_CHAT_RANK_SMILEY_FRIEND = 2825;
|
public static final int FRIENDS_CHAT_RANK_SMILEY_FRIEND = 2825;
|
||||||
|
|||||||
@@ -48,6 +48,13 @@ public interface TeamConfig extends Config
|
|||||||
)
|
)
|
||||||
String friendsChatSection = "friendsChatSection";
|
String friendsChatSection = "friendsChatSection";
|
||||||
|
|
||||||
|
@ConfigSection(
|
||||||
|
name = "Clan Chat",
|
||||||
|
description = "Configuration for clan chat",
|
||||||
|
position = 30
|
||||||
|
)
|
||||||
|
String clanChatSection = "clanChatSection";
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "teamCapesOverlay",
|
keyName = "teamCapesOverlay",
|
||||||
name = "Team cape overlay",
|
name = "Team cape overlay",
|
||||||
@@ -83,4 +90,16 @@ public interface TeamConfig extends Config
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "clanChatMemberCounter",
|
||||||
|
name = "Clan Chat Members Counter",
|
||||||
|
description = "Show the amount of clan chat members near you.",
|
||||||
|
position = 0,
|
||||||
|
section = clanChatSection
|
||||||
|
)
|
||||||
|
default boolean clanChatMemberCounter()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,9 @@ public class TeamPlugin extends Plugin
|
|||||||
|
|
||||||
private final BiMap<String, Player> players = HashBiMap.create();
|
private final BiMap<String, Player> players = HashBiMap.create();
|
||||||
private int friendsChatCount;
|
private int friendsChatCount;
|
||||||
|
private int clanChatCount;
|
||||||
private MembersIndicator friendsChatIndicator;
|
private MembersIndicator friendsChatIndicator;
|
||||||
|
private MembersIndicator clanChatIndicator;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
TeamConfig provideConfig(ConfigManager configManager)
|
TeamConfig provideConfig(ConfigManager configManager)
|
||||||
@@ -129,7 +131,9 @@ public class TeamPlugin extends Plugin
|
|||||||
playerTeam.clear();
|
playerTeam.clear();
|
||||||
players.clear();
|
players.clear();
|
||||||
removeFriendsChatCounter();
|
removeFriendsChatCounter();
|
||||||
|
removeClanChatCounter();
|
||||||
friendsChatCount = 0;
|
friendsChatCount = 0;
|
||||||
|
clanChatCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -145,6 +149,15 @@ public class TeamPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
removeFriendsChatCounter();
|
removeFriendsChatCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.clanChatMemberCounter())
|
||||||
|
{
|
||||||
|
clientThread.invoke(this::addClanChatCounter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
removeClanChatCounter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,6 +170,7 @@ public class TeamPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
players.clear();
|
players.clear();
|
||||||
removeFriendsChatCounter();
|
removeFriendsChatCounter();
|
||||||
|
removeClanChatCounter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,6 +189,12 @@ public class TeamPlugin extends Plugin
|
|||||||
++friendsChatCount;
|
++friendsChatCount;
|
||||||
addFriendsChatCounter();
|
addFriendsChatCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player.isClanMember())
|
||||||
|
{
|
||||||
|
++clanChatCount;
|
||||||
|
addClanChatCounter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,6 +221,17 @@ public class TeamPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player.isClanMember())
|
||||||
|
{
|
||||||
|
if (clanChatCount > 0)
|
||||||
|
{
|
||||||
|
if (--clanChatCount == 0)
|
||||||
|
{
|
||||||
|
removeClanChatCounter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -256,6 +287,33 @@ public class TeamPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onClanChannelChanged(ClanChannelChanged event)
|
||||||
|
{
|
||||||
|
if (!event.isGuest())
|
||||||
|
{
|
||||||
|
removeClanChatCounter();
|
||||||
|
clanChatCount = 0;
|
||||||
|
|
||||||
|
ClanChannel clanChannel = event.getClanChannel();
|
||||||
|
if (clanChannel != null)
|
||||||
|
{
|
||||||
|
for (ClanChannelMember member : clanChannel.getMembers())
|
||||||
|
{
|
||||||
|
final String memberName = Text.toJagexName(member.getName());
|
||||||
|
|
||||||
|
final Player player = players.get(memberName);
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
++clanChatCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addClanChatCounter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onFriendsChatMemberJoined(FriendsChatMemberJoined event)
|
public void onFriendsChatMemberJoined(FriendsChatMemberJoined event)
|
||||||
{
|
{
|
||||||
@@ -296,6 +354,46 @@ public class TeamPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onClanMemberJoined(ClanMemberJoined clanMemberJoined)
|
||||||
|
{
|
||||||
|
final ClanChannelMember member = clanMemberJoined.getClanMember();
|
||||||
|
|
||||||
|
if (member.getWorld() == client.getWorld())
|
||||||
|
{
|
||||||
|
final String memberName = Text.toJagexName(member.getName());
|
||||||
|
|
||||||
|
final Player player = players.get(memberName);
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
++clanChatCount;
|
||||||
|
addClanChatCounter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onClanMemberLeft(ClanMemberLeft clanMemberLeft)
|
||||||
|
{
|
||||||
|
final ClanChannelMember member = clanMemberLeft.getClanMember();
|
||||||
|
|
||||||
|
if (member.getWorld() == client.getWorld())
|
||||||
|
{
|
||||||
|
final String memberName = Text.toJagexName(member.getName());
|
||||||
|
final Player player = players.get(memberName);
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
if (clanChatCount > 0)
|
||||||
|
{
|
||||||
|
if (--clanChatCount == 0)
|
||||||
|
{
|
||||||
|
removeClanChatCounter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addFriendsChatCounter()
|
private void addFriendsChatCounter()
|
||||||
{
|
{
|
||||||
if (!config.friendsChatMemberCounter() || friendsChatIndicator != null || friendsChatCount == 0)
|
if (!config.friendsChatMemberCounter() || friendsChatIndicator != null || friendsChatCount == 0)
|
||||||
@@ -326,4 +424,35 @@ public class TeamPlugin extends Plugin
|
|||||||
infoBoxManager.removeInfoBox(friendsChatIndicator);
|
infoBoxManager.removeInfoBox(friendsChatIndicator);
|
||||||
friendsChatIndicator = null;
|
friendsChatIndicator = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addClanChatCounter()
|
||||||
|
{
|
||||||
|
if (!config.clanChatMemberCounter() || clanChatIndicator != null || clanChatCount == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final BufferedImage image = spriteManager.getSprite(SpriteID.TAB_CLAN_CHAT, 0);
|
||||||
|
clanChatIndicator = new MembersIndicator(image, this)
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public String getText()
|
||||||
|
{
|
||||||
|
return Integer.toString(clanChatCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTooltip()
|
||||||
|
{
|
||||||
|
return clanChatCount + " clan chat member(s) near you";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
infoBoxManager.addInfoBox(clanChatIndicator);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeClanChatCounter()
|
||||||
|
{
|
||||||
|
infoBoxManager.removeInfoBox(clanChatIndicator);
|
||||||
|
clanChatIndicator = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user