dps counter: fix only boss damage to work in parties

When in a party, "Only boss damage" would work only if everyone in the party
had it setup the same. Members who had it enabled would not send their hit to
those who had it disabled. Members who had it enabled would receive and count
hits from those who had it disabled.
This commit is contained in:
JoRouss
2022-04-25 01:59:40 -04:00
committed by Adam
parent 8ac8cd3cdd
commit bed28462a3
2 changed files with 22 additions and 14 deletions

View File

@@ -186,36 +186,36 @@ public class DpsCounterPlugin extends Plugin
Hitsplat hitsplat = hitsplatApplied.getHitsplat();
final int npcId = ((NPC) actor).getId();
final boolean isBoss = BOSSES.contains(npcId);
if (hitsplat.isMine())
{
final int npcId = ((NPC) actor).getId();
boolean isBoss = BOSSES.contains(npcId);
int hit = hitsplat.getAmount();
PartyMember localMember = partyService.getLocalMember();
// broadcast damage
if (localMember != null)
{
final DpsUpdate dpsUpdate = new DpsUpdate(hit, isBoss);
dpsUpdate.setMemberId(localMember.getMemberId());
wsClient.send(dpsUpdate);
}
if (dpsConfig.bossDamage() && !isBoss)
{
return;
}
int hit = hitsplat.getAmount();
// Update local member
PartyMember localMember = partyService.getLocalMember();
// If not in a party, user local player name
final String name = localMember == null ? player.getName() : localMember.getName();
DpsMember dpsMember = members.computeIfAbsent(name, DpsMember::new);
dpsMember.addDamage(hit);
// broadcast damage
if (localMember != null)
{
final DpsUpdate specialCounterUpdate = new DpsUpdate(hit);
specialCounterUpdate.setMemberId(localMember.getMemberId());
wsClient.send(specialCounterUpdate);
}
// apply to total
}
else if (hitsplat.isOthers())
{
final int npcId = ((NPC) actor).getId();
boolean isBoss = BOSSES.contains(npcId);
if ((dpsConfig.bossDamage() || actor != player.getInteracting()) && !isBoss)
{
// only track damage to npcs we are attacking, or is a nearby common boss
@@ -246,6 +246,12 @@ public class DpsCounterPlugin extends Plugin
return;
}
// Received non-boss damage, but we only want boss damage
if (!dpsUpdate.isBoss() && dpsConfig.bossDamage())
{
return;
}
unpause();
DpsMember dpsMember = members.computeIfAbsent(name, DpsMember::new);

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2020 Adam <Adam@sigterm.info>
* Copyright (c) 2021, Jonathan Rousseau <https://github.com/JoRouss>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,4 +34,5 @@ import net.runelite.http.api.ws.messages.party.PartyMemberMessage;
public class DpsUpdate extends PartyMemberMessage
{
private int hit;
private boolean isBoss;
}