chat commands: update boss kc from boss log

This commit is contained in:
Magic fTail
2018-07-13 00:43:04 +02:00
committed by Adam
parent 2ef485dc30
commit 3f8c10d036
3 changed files with 72 additions and 1 deletions

View File

@@ -42,8 +42,13 @@ import net.runelite.api.GameState;
import net.runelite.api.ItemComposition;
import net.runelite.api.MessageNode;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.SetMessage;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.vars.AccountType;
import net.runelite.api.widgets.Widget;
import static net.runelite.api.widgets.WidgetID.KILL_LOGS_GROUP_ID;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.chat.ChatColorType;
import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.chat.ChatMessageManager;
@@ -84,6 +89,8 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener
private final HiscoreClient hiscoreClient = new HiscoreClient();
private final KillCountClient killCountClient = new KillCountClient();
private boolean logKills;
@Inject
private Client client;
@@ -259,6 +266,56 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener
}
}
@Subscribe
public void onGameTick(GameTick event)
{
if (!logKills)
{
return;
}
logKills = false;
Widget title = client.getWidget(WidgetInfo.KILL_LOG_TITLE);
Widget bossMonster = client.getWidget(WidgetInfo.KILL_LOG_MONSTER);
Widget bossKills = client.getWidget(WidgetInfo.KILL_LOG_KILLS);
if (title == null || bossMonster == null || bossKills == null
|| !"Boss Kill Log".equals(title.getText()))
{
return;
}
Widget[] bossChildren = bossMonster.getChildren();
Widget[] killsChildren = bossKills.getChildren();
for (int i = 0; i < bossChildren.length; ++i)
{
Widget boss = bossChildren[i];
Widget kill = killsChildren[i];
String bossName = boss.getText();
int kc = Integer.parseInt(kill.getText().replace(",", ""));
if (kc != getKc(bossName))
{
setKc(bossName, kc);
}
}
}
@Subscribe
public void onWidgetLoaded(WidgetLoaded widget)
{
// don't load kc if in an instance, if the player is in another players poh
// and reading their boss log
if (widget.getGroupId() != KILL_LOGS_GROUP_ID || client.isInInstancedRegion())
{
return;
}
logKills = true;
}
@Override
public boolean onChatboxInput(ChatboxInput chatboxInput)
{