theatre: fix nylo handler swaps. (#1640)
* theatre: fix nylo handler swaps. * nylohandler: bug-fix * Update ItemID.java * Update Weapons.java * Update Weapons.java
This commit is contained in:
@@ -60,10 +60,10 @@ import net.runelite.api.events.PlayerMenuOptionClicked;
|
||||
import net.runelite.api.events.PlayerMenuOptionsChanged;
|
||||
import net.runelite.api.events.WidgetMenuOptionClicked;
|
||||
import net.runelite.api.events.WidgetPressed;
|
||||
import net.runelite.api.util.Text;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import static net.runelite.client.menus.ComparableEntries.newBaseComparableEntry;
|
||||
import net.runelite.api.util.Text;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
@@ -83,10 +83,10 @@ public class MenuManager
|
||||
//Used to manage custom non-player menu options
|
||||
private final Multimap<Integer, WidgetMenuOption> managedMenuOptions = HashMultimap.create();
|
||||
private final Set<String> npcMenuOptions = new HashSet<>();
|
||||
private final HashSet<AbstractComparableEntry> priorityEntries = new HashSet<>();
|
||||
private LinkedHashMap<MenuEntry, AbstractComparableEntry> currentPriorityEntries = new LinkedHashMap<>();
|
||||
private final HashSet<AbstractComparableEntry> hiddenEntries = new HashSet<>();
|
||||
private final HashMap<AbstractComparableEntry, AbstractComparableEntry> swaps = new HashMap<>();
|
||||
private final Set<AbstractComparableEntry> priorityEntries = new HashSet<>();
|
||||
private final Map<MenuEntry, AbstractComparableEntry> currentPriorityEntries = new LinkedHashMap<>();
|
||||
private final Set<AbstractComparableEntry> hiddenEntries = new HashSet<>();
|
||||
private final Map<AbstractComparableEntry, AbstractComparableEntry> swaps = new HashMap<>();
|
||||
|
||||
private MenuEntry leftClickEntry = null;
|
||||
private MenuEntry firstEntry = null;
|
||||
@@ -708,11 +708,15 @@ public class MenuManager
|
||||
/**
|
||||
* Removes all swaps with target
|
||||
*/
|
||||
public void removeSwaps(String withTarget)
|
||||
public void removeSwaps(String... fromTarget)
|
||||
{
|
||||
final String target = Text.standardize(withTarget);
|
||||
|
||||
swaps.keySet().removeIf(e -> e.getTarget().equals(target));
|
||||
for (String target : fromTarget)
|
||||
{
|
||||
final String s = Text.standardize(target);
|
||||
swaps.keySet().removeIf(e -> e.getTarget().equals(s));
|
||||
priorityEntries.removeIf(e -> e.getTarget().equals(s));
|
||||
hiddenEntries.removeIf(e -> e.getTarget().equals(s));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -123,7 +123,7 @@ public class TheatrePlugin extends Plugin
|
||||
room = TheatreRoom.UNKNOWN;
|
||||
maidenHandler = new MaidenHandler(client, this, modelOutline);
|
||||
bloatHandler = new BloatHandler(client, this);
|
||||
nyloHandler = new NyloHandler(client, this, menuManager, itemManager, eventBus);
|
||||
nyloHandler = new NyloHandler(client, this, menuManager, eventBus);
|
||||
sotetsegHandler = new SotetsegHandler(client, this);
|
||||
xarpusHandler = new XarpusHandler(client, this);
|
||||
verzikHandler = new VerzikHandler(client, this);
|
||||
|
||||
@@ -19,7 +19,6 @@ import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Perspective;
|
||||
import net.runelite.api.Point;
|
||||
@@ -28,9 +27,8 @@ import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.api.events.NpcDespawned;
|
||||
import net.runelite.api.events.NpcSpawned;
|
||||
import net.runelite.api.kit.KitType;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.menus.AbstractComparableEntry;
|
||||
import net.runelite.client.menus.MenuManager;
|
||||
import net.runelite.client.plugins.theatre.RoomHandler;
|
||||
import net.runelite.client.plugins.theatre.TheatreConstant;
|
||||
@@ -44,7 +42,6 @@ public class NyloHandler extends RoomHandler
|
||||
final List<NPC> waveSpawns = new ArrayList<>();
|
||||
final List<NPC> waveAgros = new ArrayList<>();
|
||||
private final MenuManager menuManager;
|
||||
private final ItemManager itemManager;
|
||||
private final EventBus eventBus;
|
||||
public long startTime = 0L;
|
||||
int startTick = 0;
|
||||
@@ -57,12 +54,10 @@ public class NyloHandler extends RoomHandler
|
||||
private int wave = 0;
|
||||
private NyloOverlay overlay = null;
|
||||
private NyloPredictor predictor = null;
|
||||
private AttackStyle currentAttack = null;
|
||||
|
||||
public NyloHandler(final Client client, final TheatrePlugin plugin, final MenuManager menuManager, final ItemManager itemManager, final EventBus eventBus)
|
||||
public NyloHandler(final Client client, final TheatrePlugin plugin, final MenuManager menuManager, final EventBus eventBus)
|
||||
{
|
||||
super(client, plugin);
|
||||
this.itemManager = itemManager;
|
||||
this.menuManager = menuManager;
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
@@ -125,22 +120,12 @@ public class NyloHandler extends RoomHandler
|
||||
{
|
||||
this.pillars.clear();
|
||||
this.spiders.clear();
|
||||
|
||||
this.wave = 0;
|
||||
|
||||
this.predictor = new NyloPredictor(client, this);
|
||||
this.waveSpawns.clear();
|
||||
this.waveAgros.clear();
|
||||
this.predictor.reset();
|
||||
removeMenuSwaps();
|
||||
|
||||
}
|
||||
|
||||
private void removeMenuSwaps()
|
||||
{
|
||||
menuManager.removeHiddenEntry("Attack", "Nylocas Hagios");
|
||||
menuManager.removeHiddenEntry("Attack", "Nylocas Ischyros");
|
||||
menuManager.removeHiddenEntry("Attack", "Nylocas Toxobolos");
|
||||
menuManager.removeSwaps("Nylocas Hagios", "Nylocas Toxobolos", "Nylocas Ischyros");
|
||||
}
|
||||
|
||||
public void onConfigChanged()
|
||||
@@ -407,121 +392,25 @@ public class NyloHandler extends RoomHandler
|
||||
}
|
||||
}
|
||||
|
||||
private AttackStyle checkAttackStyle(int weaponId)
|
||||
{
|
||||
switch (weaponId)
|
||||
{
|
||||
case ItemID.TOXIC_BLOWPIPE:
|
||||
case ItemID.TWISTED_BOW:
|
||||
case ItemID.CRAWS_BOW:
|
||||
return AttackStyle.RANGE2H;
|
||||
case ItemID.ABYSSAL_WHIP:
|
||||
case ItemID.ABYSSAL_TENTACLE:
|
||||
case ItemID.SCYTHE_OF_VITUR:
|
||||
case ItemID.SCYTHE_OF_VITUR_22664:
|
||||
case ItemID.SCYTHE_OF_VITUR_UNCHARGED:
|
||||
case ItemID.HAM_JOINT:
|
||||
case ItemID.SWIFT_BLADE:
|
||||
case ItemID.BANDOS_GODSWORD:
|
||||
case ItemID.BANDOS_GODSWORD_20782:
|
||||
case ItemID.BANDOS_GODSWORD_21060:
|
||||
case ItemID.BANDOS_GODSWORD_OR:
|
||||
case ItemID.DRAGON_WARHAMMER:
|
||||
case ItemID.DRAGON_CLAWS:
|
||||
case ItemID.EVENT_RPG:
|
||||
case ItemID.GHRAZI_RAPIER:
|
||||
case ItemID.GHRAZI_RAPIER_23628:
|
||||
case ItemID.BLADE_OF_SAELDOR:
|
||||
case ItemID.CRYSTAL_HALBERD:
|
||||
case ItemID.DRAGON_SCIMITAR:
|
||||
case ItemID.RUNE_SCIMITAR:
|
||||
return AttackStyle.MELEE;
|
||||
case ItemID.KODAI_WAND:
|
||||
case ItemID.MASTER_WAND:
|
||||
case ItemID.TRIDENT_OF_THE_SEAS:
|
||||
case ItemID.TRIDENT_OF_THE_SWAMP:
|
||||
case ItemID.SANGUINESTI_STAFF:
|
||||
case ItemID.IBANS_STAFF:
|
||||
case ItemID.IBANS_STAFF_1410:
|
||||
case ItemID.IBANS_STAFF_U:
|
||||
case ItemID.TRIDENT_OF_THE_SWAMP_E:
|
||||
case ItemID.TRIDENT_OF_THE_SEAS_E:
|
||||
return AttackStyle.MAGE;
|
||||
case ItemID.RED_CHINCHOMPA:
|
||||
case ItemID.CHINCHOMPA:
|
||||
case ItemID.BLACK_CHINCHOMPA:
|
||||
case ItemID.ARMADYL_CROSSBOW:
|
||||
case ItemID.DRAGON_CROSSBOW:
|
||||
case ItemID.RUNE_CROSSBOW:
|
||||
case ItemID.DORGESHUUN_CROSSBOW:
|
||||
return AttackStyle.RANGE;
|
||||
case ItemID.AVERNIC_DEFENDER:
|
||||
case ItemID.DRAGON_DEFENDER:
|
||||
case ItemID.DRAGON_DEFENDER_T:
|
||||
if (currentAttack == AttackStyle.RANGE2H)
|
||||
{
|
||||
return AttackStyle.MELEE;
|
||||
}
|
||||
default:
|
||||
return currentAttack;
|
||||
}
|
||||
}
|
||||
|
||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
||||
{
|
||||
if (!event.getOption().equalsIgnoreCase("equip") &&
|
||||
!event.getOption().equalsIgnoreCase("wield") &&
|
||||
!event.getOption().equalsIgnoreCase("hold"))
|
||||
{
|
||||
if (currentAttack != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (currentAttack == null)
|
||||
{
|
||||
if (client.getLocalPlayer() != null
|
||||
&& client.getViewportWidget() != null
|
||||
&& client.getLocalPlayer().getPlayerAppearance() != null
|
||||
&& client.getLocalPlayer().getPlayerAppearance().getEquipmentId(KitType.WEAPON) != 0
|
||||
)
|
||||
{
|
||||
currentAttack = checkAttackStyle(client.getLocalPlayer().getPlayerAppearance().getEquipmentId(KitType.WEAPON));
|
||||
}
|
||||
}
|
||||
if (event.getOption().equalsIgnoreCase("equip") ||
|
||||
event.getOption().equalsIgnoreCase("wield") ||
|
||||
event.getOption().equalsIgnoreCase("hold"))
|
||||
{
|
||||
currentAttack = checkAttackStyle(event.getIdentifier());
|
||||
}
|
||||
if (currentAttack != null)
|
||||
{
|
||||
doSwaps();
|
||||
}
|
||||
}
|
||||
final String option = event.getOption().toLowerCase();
|
||||
|
||||
private void doSwaps()
|
||||
{
|
||||
switch (currentAttack)
|
||||
if (!option.equals("equip") && !option.equals("wield") && !option.equals("hold"))
|
||||
{
|
||||
case RANGE:
|
||||
case RANGE2H:
|
||||
removeMenuSwaps();
|
||||
menuManager.addHiddenEntry("Attack", "Nylocas Hagios");
|
||||
menuManager.addHiddenEntry("Attack", "Nylocas Ischyros");
|
||||
break;
|
||||
case MELEE:
|
||||
removeMenuSwaps();
|
||||
menuManager.addHiddenEntry("Attack", "Nylocas Hagios");
|
||||
menuManager.addHiddenEntry("Attack", "Nylocas Toxobolos");
|
||||
break;
|
||||
case MAGE:
|
||||
removeMenuSwaps();
|
||||
menuManager.addHiddenEntry("Attack", "Nylocas Ischyros");
|
||||
menuManager.addHiddenEntry("Attack", "Nylocas Toxobolos");
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
final int id = event.getIdentifier();
|
||||
final Set<AbstractComparableEntry> entries = Weapons.getEntries(id);
|
||||
menuManager.removeSwaps("Nylocas Hagios", "Nylocas Toxobolos", "Nylocas Ischyros");
|
||||
|
||||
if (entries.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
entries.forEach(menuManager::addHiddenEntry);
|
||||
}
|
||||
|
||||
private void recalculateLocal()
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package net.runelite.client.plugins.theatre.rooms.nylocas;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import jdk.internal.jline.internal.Nullable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.menus.AbstractComparableEntry;
|
||||
import net.runelite.client.menus.ComparableEntries;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum Weapons
|
||||
{
|
||||
MELEE(ImmutableSet.of(ItemID.ABYSSAL_WHIP, ItemID.ABYSSAL_TENTACLE, ItemID.SCYTHE_OF_VITUR,
|
||||
ItemID.SCYTHE_OF_VITUR_22664, ItemID.SCYTHE_OF_VITUR_UNCHARGED, ItemID.HAM_JOINT, ItemID.SWIFT_BLADE,
|
||||
ItemID.BANDOS_GODSWORD, ItemID.BANDOS_GODSWORD_20782, ItemID.BANDOS_GODSWORD_21060, ItemID.BANDOS_GODSWORD_OR,
|
||||
ItemID.DRAGON_WARHAMMER, ItemID.DRAGON_CLAWS, ItemID.EVENT_RPG, ItemID.GHRAZI_RAPIER, ItemID.GHRAZI_RAPIER_23628,
|
||||
ItemID.BLADE_OF_SAELDOR, ItemID.CRYSTAL_HALBERD, ItemID.DRAGON_SCIMITAR, ItemID.RUNE_SCIMITAR, ItemID.BLADE_OF_SAELDOR_23996,
|
||||
ItemID.BLADE_OF_SAELDOR_INACTIVE, ItemID.BLADE_OF_SAELDOR_INACTIVE_23999),
|
||||
ImmutableSet.of(ComparableEntries.newBaseComparableEntry("Attack", "Nylocas Hagios"),
|
||||
ComparableEntries.newBaseComparableEntry("Attack", "Nylocas Toxobolos"))
|
||||
),
|
||||
MAGE(ImmutableSet.of(ItemID.KODAI_WAND, ItemID.MASTER_WAND, ItemID.TRIDENT_OF_THE_SEAS,
|
||||
ItemID.TRIDENT_OF_THE_SWAMP, ItemID.SANGUINESTI_STAFF, ItemID.IBANS_STAFF, ItemID.IBANS_STAFF_1410,
|
||||
ItemID.IBANS_STAFF_U, ItemID.TRIDENT_OF_THE_SWAMP_E, ItemID.TRIDENT_OF_THE_SEAS_E),
|
||||
ImmutableSet.of(ComparableEntries.newBaseComparableEntry("Attack", "Nylocas Ischyros"),
|
||||
ComparableEntries.newBaseComparableEntry("Attack", "Nylocas Toxobolos"))
|
||||
),
|
||||
RANGE(ImmutableSet.of(ItemID.TOXIC_BLOWPIPE, ItemID.TWISTED_BOW, ItemID.CRAWS_BOW,
|
||||
ItemID.RED_CHINCHOMPA, ItemID.CHINCHOMPA, ItemID.BLACK_CHINCHOMPA, ItemID.ARMADYL_CROSSBOW,
|
||||
ItemID.DRAGON_CROSSBOW, ItemID.RUNE_CROSSBOW, ItemID.DORGESHUUN_CROSSBOW),
|
||||
ImmutableSet.of(ComparableEntries.newBaseComparableEntry("Attack", "Nylocas Hagios"),
|
||||
ComparableEntries.newBaseComparableEntry("Attack", "Nylocas Ischyros"))
|
||||
);
|
||||
|
||||
private final Set<Integer> ids;
|
||||
private final Set<AbstractComparableEntry> entries;
|
||||
private static final Map<Set<Integer>, Set<AbstractComparableEntry>> map;
|
||||
|
||||
static
|
||||
{
|
||||
final ImmutableMap.Builder<Set<Integer>, Set<AbstractComparableEntry>> builder = new ImmutableMap.Builder<>();
|
||||
for (Weapons weps : Weapons.values())
|
||||
{
|
||||
builder.put(weps.getIds(), weps.getEntries());
|
||||
}
|
||||
map = builder.build();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static Set<AbstractComparableEntry> getEntries(int id)
|
||||
{
|
||||
final Set<AbstractComparableEntry> entries = new HashSet<>();
|
||||
|
||||
for (Map.Entry<Set<Integer>, Set<AbstractComparableEntry>> entry : map.entrySet())
|
||||
{
|
||||
if (entry.getKey().contains(id))
|
||||
{
|
||||
entries.addAll(entry.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user