runelite-client: add friend list plugin

This adds a count to friend and ignore list titles

Co-authored-by: Forsco <github@forsco.net>
This commit is contained in:
Adam
2018-08-24 21:15:51 -04:00
parent 2b81d30228
commit 692fcfa7d2
4 changed files with 134 additions and 0 deletions

View File

@@ -38,6 +38,8 @@ public enum VarPlayer
BANK_TAB(115),
MEMBERSHIP_DAYS(263),
SPECIAL_ATTACK_PERCENT(300),
SPECIAL_ATTACK_ENABLED(301),

View File

@@ -46,6 +46,7 @@ public class WidgetID
public static final int DEPOSIT_BOX_GROUP_ID = 192;
public static final int INVENTORY_GROUP_ID = 149;
public static final int FRIENDS_LIST_GROUP_ID = 429;
public static final int IGNORE_LIST_GROUP_ID = 432;
public static final int RAIDING_PARTY_GROUP_ID = 500;
public static final int EQUIPMENT_GROUP_ID = 387;
public static final int EQUIPMENT_INVENTORY_GROUP_ID = 85;
@@ -160,6 +161,16 @@ public class WidgetID
static final int RED_HEALTH = 23;
}
static class FriendList
{
static final int TITLE = 3;
}
static class IgnoreList
{
static final int TITLE = 3;
}
static class ClanChat
{
static final int TITLE = 1;

View File

@@ -106,6 +106,10 @@ public enum WidgetInfo
VOLCANIC_MINE_VENT_B_STATUS(WidgetID.VOLCANIC_MINE_GROUP_ID, WidgetID.VolcanicMine.VENT_B_STATUS),
VOLCANIC_MINE_VENT_C_STATUS(WidgetID.VOLCANIC_MINE_GROUP_ID, WidgetID.VolcanicMine.VENT_C_STATUS),
FRIEND_CHAT_TITLE(WidgetID.FRIENDS_LIST_GROUP_ID, WidgetID.FriendList.TITLE),
IGNORE_TITLE(WidgetID.IGNORE_LIST_GROUP_ID, WidgetID.IgnoreList.TITLE),
CLAN_CHAT_TITLE(WidgetID.CLAN_CHAT_GROUP_ID, WidgetID.ClanChat.TITLE),
CLAN_CHAT_NAME(WidgetID.CLAN_CHAT_GROUP_ID, WidgetID.ClanChat.NAME),
CLAN_CHAT_OWNER(WidgetID.CLAN_CHAT_GROUP_ID, WidgetID.ClanChat.OWNER),

View File

@@ -0,0 +1,117 @@
/*
* Copyright (c) 2018, Connor <contact@connor-parks.email>
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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.friendlist;
import com.google.common.eventbus.Subscribe;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.VarPlayer;
import net.runelite.api.events.GameTick;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
@PluginDescriptor(
name = "Friend List",
description = "Add extra information to the friend and ignore lists"
)
public class FriendListPlugin extends Plugin
{
private static final int MAX_FRIENDS_P2P = 400;
private static final int MAX_FRIENDS_F2P = 200;
private static final int MAX_IGNORES_P2P = 400;
private static final int MAX_IGNORES_F2P = 100;
@Inject
private Client client;
@Override
protected void shutDown()
{
final int world = client.getWorld();
setFriendsListTitle("Friends List - World " + world);
setIgnoreListTitle("Ignore List - World " + world);
}
@Subscribe
public void onGameTick(GameTick tick)
{
final int world = client.getWorld();
final boolean isMember = client.getVar(VarPlayer.MEMBERSHIP_DAYS) > 0;
final int friendCount = client.getFriendsCount();
if (friendCount >= 0)
{
final int limit = isMember ? MAX_FRIENDS_P2P : MAX_FRIENDS_F2P;
final String title = "Friends - W" +
world +
" (" +
friendCount +
"/" +
limit +
")";
setFriendsListTitle(title);
}
final int ignoreCount = client.getIgnoreCount();
if (ignoreCount >= 0)
{
final int limit = isMember ? MAX_IGNORES_P2P : MAX_IGNORES_F2P;
final String title = "Ignores - W" +
world +
" (" +
ignoreCount +
"/" +
limit +
")";
setIgnoreListTitle(title);
}
}
private void setFriendsListTitle(final String title)
{
Widget friendListTitleWidget = client.getWidget(WidgetInfo.FRIEND_CHAT_TITLE);
if (friendListTitleWidget != null)
{
friendListTitleWidget.setText(title);
}
}
private void setIgnoreListTitle(final String title)
{
Widget ignoreTitleWidget = client.getWidget(WidgetInfo.IGNORE_TITLE);
if (ignoreTitleWidget != null)
{
ignoreTitleWidget.setText(title);
}
}
}