spec counter: combine item variations into one weapon
This is to keep specs from multiple variants of a weapon within one counter, like when in a party with multiple players.
This commit is contained in:
@@ -26,6 +26,7 @@ package net.runelite.client.plugins.specialcounter;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -314,7 +315,7 @@ public class SpecialCounterPlugin extends Plugin
|
|||||||
|
|
||||||
for (SpecialWeapon specialWeapon : SpecialWeapon.values())
|
for (SpecialWeapon specialWeapon : SpecialWeapon.values())
|
||||||
{
|
{
|
||||||
if (specialWeapon.getItemID() == weapon.getId())
|
if (Arrays.stream(specialWeapon.getItemID()).anyMatch(id -> id == weapon.getId()))
|
||||||
{
|
{
|
||||||
return specialWeapon;
|
return specialWeapon;
|
||||||
}
|
}
|
||||||
@@ -328,7 +329,7 @@ public class SpecialCounterPlugin extends Plugin
|
|||||||
|
|
||||||
if (counter == null)
|
if (counter == null)
|
||||||
{
|
{
|
||||||
counter = new SpecialCounter(itemManager.getImage(specialWeapon.getItemID()), this, config,
|
counter = new SpecialCounter(itemManager.getImage(specialWeapon.getItemID()[0]), this, config,
|
||||||
hit, specialWeapon);
|
hit, specialWeapon);
|
||||||
infoBoxManager.addInfoBox(counter);
|
infoBoxManager.addInfoBox(counter);
|
||||||
specialCounter[specialWeapon.ordinal()] = counter;
|
specialCounter[specialWeapon.ordinal()] = counter;
|
||||||
|
|||||||
@@ -33,20 +33,16 @@ import net.runelite.api.ItemID;
|
|||||||
@Getter
|
@Getter
|
||||||
enum SpecialWeapon
|
enum SpecialWeapon
|
||||||
{
|
{
|
||||||
DRAGON_WARHAMMER("Dragon Warhammer", ItemID.DRAGON_WARHAMMER, false, SpecialCounterConfig::dragonWarhammerThreshold),
|
DRAGON_WARHAMMER("Dragon Warhammer", new int[]{ItemID.DRAGON_WARHAMMER}, false, SpecialCounterConfig::dragonWarhammerThreshold),
|
||||||
ARCLIGHT("Arclight", ItemID.ARCLIGHT, false, SpecialCounterConfig::arclightThreshold),
|
ARCLIGHT("Arclight", new int[]{ItemID.ARCLIGHT}, false, SpecialCounterConfig::arclightThreshold),
|
||||||
DARKLIGHT("Darklight", ItemID.DARKLIGHT, false, SpecialCounterConfig::darklightThreshold),
|
DARKLIGHT("Darklight", new int[]{ItemID.DARKLIGHT}, false, SpecialCounterConfig::darklightThreshold),
|
||||||
BANDOS_GODSWORD("Bandos Godsword", ItemID.BANDOS_GODSWORD, true, SpecialCounterConfig::bandosGodswordThreshold),
|
BANDOS_GODSWORD("Bandos Godsword", new int[]{ItemID.BANDOS_GODSWORD, ItemID.BANDOS_GODSWORD_OR}, true, SpecialCounterConfig::bandosGodswordThreshold),
|
||||||
BANDOS_GODSWORD_OR("Bandos Godsword", ItemID.BANDOS_GODSWORD_OR, true, SpecialCounterConfig::bandosGodswordThreshold),
|
BARRELCHEST_ANCHOR("Barrelchest Anchor", new int[]{ItemID.BARRELCHEST_ANCHOR}, true, (c) -> 0),
|
||||||
BARRELCHEST_ANCHOR("Barrelchest Anchor", ItemID.BARRELCHEST_ANCHOR, true, (c) -> 0),
|
BONE_DAGGER("Bone Dagger", new int[]{ItemID.BONE_DAGGER, ItemID.BONE_DAGGER_P, ItemID.BONE_DAGGER_P_8876, ItemID.BONE_DAGGER_P_8878}, true, (c) -> 0),
|
||||||
BONE_DAGGER("Bone Dagger", ItemID.BONE_DAGGER, true, (c) -> 0),
|
DORGESHUUN_CROSSBOW("Dorgeshuun Crossbow", new int[]{ItemID.DORGESHUUN_CROSSBOW}, true, (c) -> 0);
|
||||||
BONE_DAGGER_P("Bone Dagger (p)", ItemID.BONE_DAGGER_P, true, (c) -> 0),
|
|
||||||
BONE_DAGGER_P8876("Bone Dagger (p+)", ItemID.BONE_DAGGER_P_8876, true, (c) -> 0),
|
|
||||||
BONE_DAGGER_P8878("Bone Dagger (p++)", ItemID.BONE_DAGGER_P_8878, true, (c) -> 0),
|
|
||||||
DORGESHUUN_CROSSBOW("Dorgeshuun Crossbow", ItemID.DORGESHUUN_CROSSBOW, true, (c) -> 0);
|
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final int itemID;
|
private final int[] itemID;
|
||||||
private final boolean damage;
|
private final boolean damage;
|
||||||
private final Function<SpecialCounterConfig, Integer> threshold;
|
private final Function<SpecialCounterConfig, Integer> threshold;
|
||||||
}
|
}
|
||||||
@@ -258,6 +258,11 @@ public class SpecialCounterPluginTest
|
|||||||
specialCounterPlugin.onVarbitChanged(new VarbitChanged());
|
specialCounterPlugin.onVarbitChanged(new VarbitChanged());
|
||||||
specialCounterPlugin.onHitsplatApplied(hitsplat(target, Hitsplat.HitsplatType.DAMAGE_ME));
|
specialCounterPlugin.onHitsplatApplied(hitsplat(target, Hitsplat.HitsplatType.DAMAGE_ME));
|
||||||
|
|
||||||
|
// Set up spec weapon as BGS(OR)
|
||||||
|
ItemContainer equipment = mock(ItemContainer.class);
|
||||||
|
when(equipment.getItem(EquipmentInventorySlot.WEAPON.getSlotIdx())).thenReturn(new Item(ItemID.BANDOS_GODSWORD_OR, 1));
|
||||||
|
when(client.getItemContainer(InventoryID.EQUIPMENT)).thenReturn(equipment);
|
||||||
|
|
||||||
// Second special attack
|
// Second special attack
|
||||||
when(client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT)).thenReturn(0);
|
when(client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT)).thenReturn(0);
|
||||||
specialCounterPlugin.onVarbitChanged(new VarbitChanged());
|
specialCounterPlugin.onVarbitChanged(new VarbitChanged());
|
||||||
|
|||||||
Reference in New Issue
Block a user