diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxOverlay.java index 00d60e94ee..25df342865 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxOverlay.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.coxhelper; +import com.google.common.collect.ImmutableSet; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; @@ -32,6 +33,7 @@ import java.awt.Font; import java.awt.Graphics2D; import java.awt.Polygon; import java.util.List; +import java.util.Set; import javax.inject.Inject; import javax.inject.Singleton; import net.runelite.api.Actor; @@ -53,6 +55,9 @@ import net.runelite.client.ui.overlay.OverlayUtil; @Singleton public class CoxOverlay extends Overlay { + private static final Set GAP = ImmutableSet.of( + 34, 33, 26, 25, 18, 17, 10, 9, 2, 1 + ); private final Client client; private final CoxPlugin plugin; @@ -105,7 +110,6 @@ public class CoxOverlay extends Overlay if (plugin.isTektonTickCounter()) { ticksLeft = npcs.getTicksUntilAttack(); - int attackTicksleft = plugin.getTektonAttackTicks(); if (ticksLeft > 0) { if (ticksLeft == 1) @@ -214,67 +218,67 @@ public class CoxOverlay extends Overlay if (plugin.isTimers()) { - if (plugin.getBurnTarget().size() > 0) + if (plugin.getVictims().size() > 0) { - for (Actor actor : plugin.getBurnTarget()) + plugin.getVictims().forEach(victim -> { - final int ticksLeft = plugin.getBurnTicks(); + final int ticksLeft = victim.getTicks(); String ticksLeftStr = String.valueOf(ticksLeft); Color tickcolor; - if (ticksLeft >= 0) + switch (victim.getType()) { - if (ticksLeft == 34 || - ticksLeft == 33 || - ticksLeft == 26 || - ticksLeft == 25 || - ticksLeft == 18 || - ticksLeft == 17 || - ticksLeft == 10 || - ticksLeft == 9 || - ticksLeft == 2 || - ticksLeft == 1) - { - tickcolor = new Color(255, 0, 0, 255); - ticksLeftStr = "GAP"; - } - else - { - tickcolor = new Color(255, 255, 255, 255); - } - Point canvasPoint = actor.getCanvasTextLocation(graphics, ticksLeftStr, 0); - renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), tickcolor, canvasPoint); + case ACID: + if (ticksLeft > 0) + { + if (ticksLeft > 1) + { + tickcolor = new Color(69, 241, 44, 255); + } + else + { + tickcolor = new Color(255, 255, 255, 255); + } + Point canvasPoint = victim.getPlayer().getCanvasTextLocation(graphics, ticksLeftStr, 0); + renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), tickcolor, canvasPoint); + } + break; + case BURN: + if (ticksLeft > 0) + { + if (GAP.contains(ticksLeft)) + { + tickcolor = new Color(255, 0, 0, 255); + ticksLeftStr = "GAP"; + } + else + { + tickcolor = new Color(255, 255, 255, 255); + } + Point canvasPoint = victim.getPlayer().getCanvasTextLocation(graphics, ticksLeftStr, 0); + renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), tickcolor, canvasPoint); + } + break; + case TELEPORT: + if (plugin.isTpOverlay()) + { + if (ticksLeft > 0) + { + if (ticksLeft > 1) + { + tickcolor = new Color(193, 255, 245, 255); + } + else + { + tickcolor = new Color(255, 255, 255, 255); + } + Point canvasPoint = victim.getPlayer().getCanvasTextLocation(graphics, ticksLeftStr, 0); + renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), tickcolor, canvasPoint); + } + renderActorOverlay(graphics, victim.getPlayer(), new Color(193, 255, 245, 255), 2, 100, 10); + } + break; } - } - } - - if (plugin.getAcidTarget() != null) - { - Actor actor = plugin.getAcidTarget(); - renderActorOverlay(graphics, actor, plugin.getAcidColor(), 2, 100, 10); - final int ticksLeft = plugin.getAcidTicks(); - Color tickcolor; - if (ticksLeft > 0) - { - if (ticksLeft > 1) - { - tickcolor = new Color(69, 241, 44, 255); - } - else - { - tickcolor = new Color(255, 255, 255, 255); - } - final String ticksLeftStr = String.valueOf(ticksLeft); - Point canvasPoint = actor.getCanvasTextLocation(graphics, ticksLeftStr, 0); - renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), tickcolor, canvasPoint); - } - } - } - - if (plugin.isTpOverlay()) - { - if (plugin.getTeleportTarget() != null) - { - renderActorOverlay(graphics, plugin.getTeleportTarget(), new Color(193, 255, 245, 255), 2, 100, 10); + }); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxPlugin.java index bde7448e3a..bb7b69bcf1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxPlugin.java @@ -31,8 +31,10 @@ import com.google.inject.Provides; import java.awt.Color; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; @@ -59,7 +61,7 @@ import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcSpawned; -import net.runelite.api.events.ProjectileMoved; +import net.runelite.api.events.ProjectileSpawned; import net.runelite.api.events.SpotAnimationChanged; import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.config.ConfigManager; @@ -80,123 +82,77 @@ import net.runelite.client.util.Text; @Slf4j @Singleton +@Getter(AccessLevel.PACKAGE) public class CoxPlugin extends Plugin { private static final int ANIMATION_ID_G1 = 430; private static final String OLM_HAND_CRIPPLE = "The Great Olm\'s left claw clenches to protect itself temporarily."; private static final Pattern TP_REGEX = Pattern.compile("You have been paired with (.*)! The magical power will enact soon..."); - @Setter - @Getter(AccessLevel.PACKAGE) - protected PrayAgainst prayAgainstOlm; - @Getter(AccessLevel.PACKAGE) - protected long lastPrayTime; - private int sleepcount = 0; - private boolean needOlm = false; - private GraphicsObject teleportObject; @Inject + @Getter(AccessLevel.NONE) private Client client; @Inject + @Getter(AccessLevel.NONE) private ChatMessageManager chatMessageManager; @Inject + @Getter(AccessLevel.NONE) private CoxOverlay coxOverlay; @Inject + @Getter(AccessLevel.NONE) private CoxInfoBox coxInfoBox; @Inject + @Getter(AccessLevel.NONE) private CoxConfig config; @Inject + @Getter(AccessLevel.NONE) private OverlayManager overlayManager; @Inject + @Getter(AccessLevel.NONE) private EventBus eventBus; - @Getter(AccessLevel.PACKAGE) - private boolean HandCripple; - @Getter(AccessLevel.PACKAGE) + private boolean handCripple; private boolean runOlm; - @Getter(AccessLevel.PACKAGE) private int vanguards; - @Getter(AccessLevel.PACKAGE) private boolean tektonActive; - @Getter(AccessLevel.PACKAGE) private NPC hand; - @Getter(AccessLevel.PACKAGE) private NPC Olm_NPC; - @Getter(AccessLevel.PACKAGE) - private NPC OlmMelee_NPC; - @Getter(AccessLevel.PACKAGE) private List Olm_Crystals = new ArrayList<>(); - @Getter(AccessLevel.PACKAGE) private List Olm_Heal = new ArrayList<>(); - @Getter(AccessLevel.PACKAGE) private List Olm_TP = new ArrayList<>(); - @Getter(AccessLevel.PACKAGE) private List Olm_PSN = new ArrayList<>(); - @Getter(AccessLevel.PACKAGE) - private List burnTarget = new ArrayList<>(); - @Getter(AccessLevel.PACKAGE) - private Actor teleportTarget; - @Getter(AccessLevel.PACKAGE) + private Set victims = new HashSet<>(); private Actor acidTarget; - @Getter(AccessLevel.PACKAGE) private int crippleTimer = 45; - @Getter(AccessLevel.PACKAGE) - private int burnTicks = 41; - @Getter(AccessLevel.PACKAGE) - private int acidTicks = 25; - @Getter(AccessLevel.PACKAGE) private int teleportTicks = 10; - @Getter(AccessLevel.PACKAGE) private int tektonAttackTicks; - @Getter(AccessLevel.PACKAGE) private int OlmPhase = 0; - @Getter(AccessLevel.PACKAGE) private int Olm_TicksUntilAction = -1; - @Getter(AccessLevel.PACKAGE) private int Olm_ActionCycle = -1; //4:0 = auto 3:0 = null 2:0 = auto 1:0 = spec + actioncycle =4 - @Getter(AccessLevel.PACKAGE) private int Olm_NextSpec = -1; // 1= crystals 2=lightnig 3=portals 4= heal hand if p4 - @Getter(AccessLevel.PACKAGE) - private float percent; - @Getter(AccessLevel.PACKAGE) private Map npcContainer = new HashMap<>(); - - @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) + private PrayAgainst prayAgainstOlm; + private long lastPrayTime; + private int sleepcount = 0; + private boolean needOlm = false; private boolean muttadile; - @Getter(AccessLevel.PACKAGE) private boolean tekton; - @Getter(AccessLevel.PACKAGE) private boolean tektonTickCounter; - @Getter(AccessLevel.PACKAGE) private boolean guardians; - @Getter(AccessLevel.PACKAGE) private boolean guardinTickCounter; - @Getter(AccessLevel.PACKAGE) private boolean vangHighlight; - @Getter(AccessLevel.PACKAGE) private boolean vangHealth; - @Getter(AccessLevel.PACKAGE) private boolean configPrayAgainstOlm; - @Getter(AccessLevel.PACKAGE) private boolean timers; - @Getter(AccessLevel.PACKAGE) private boolean tpOverlay; - @Getter(AccessLevel.PACKAGE) private boolean olmTick; - @Getter(AccessLevel.PACKAGE) private Color muttaColor; - @Getter(AccessLevel.PACKAGE) private Color guardColor; - @Getter(AccessLevel.PACKAGE) private Color tektonColor; - @Getter(AccessLevel.PACKAGE) private Color burnColor; - @Getter(AccessLevel.PACKAGE) private Color acidColor; - @Getter(AccessLevel.PACKAGE) private Color tpColor; - @Getter(AccessLevel.PACKAGE) private CoxConfig.FontStyle fontStyle; - @Getter(AccessLevel.PACKAGE) private int textSize; - @Getter(AccessLevel.PACKAGE) private boolean shadows; @Provides @@ -213,16 +169,12 @@ public class CoxPlugin extends Plugin overlayManager.add(coxOverlay); overlayManager.add(coxInfoBox); - HandCripple = false; + handCripple = false; hand = null; - acidTarget = null; - teleportTarget = null; Olm_TP.clear(); prayAgainstOlm = null; - burnTarget.clear(); + victims.clear(); crippleTimer = 45; - burnTicks = 40; - acidTicks = 25; teleportTicks = 10; vanguards = 0; } @@ -231,7 +183,6 @@ public class CoxPlugin extends Plugin protected void shutDown() { eventBus.unregister(this); - overlayManager.remove(coxOverlay); overlayManager.remove(coxInfoBox); } @@ -240,203 +191,231 @@ public class CoxPlugin extends Plugin { eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged); eventBus.subscribe(ChatMessage.class, this, this::onChatMessage); - eventBus.subscribe(ProjectileMoved.class, this, this::onProjectileMoved); + eventBus.subscribe(ProjectileSpawned.class, this, this::onProjectileSpawned); eventBus.subscribe(SpotAnimationChanged.class, this, this::onSpotAnimationChanged); eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned); eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned); eventBus.subscribe(GameTick.class, this, this::onGameTick); } - private void onChatMessage(ChatMessage chatMessage) + private void onConfigChanged(ConfigChanged event) { - if (inRaid()) + if (event.getGroup().equals("Cox")) { - if (chatMessage.getType() == ChatMessageType.GAMEMESSAGE) + updateConfig(); + } + } + + private void onChatMessage(ChatMessage event) + { + if (!inRaid()) + { + return; + } + + if (event.getType() == ChatMessageType.GAMEMESSAGE) + { + final Matcher tpMatcher = TP_REGEX.matcher(event.getMessage()); + + if (tpMatcher.matches()) { - Matcher tpMatcher = TP_REGEX.matcher(chatMessage.getMessage()); - if (tpMatcher.matches()) + for (Player player : client.getPlayers()) { - log.info("TP Matcher has found a match"); - for (Actor actor : client.getPlayers()) + if (player.getName().equals(tpMatcher.group(1))) { - if (actor.getName().equals(tpMatcher.group(1))) - { - log.info("Teleport Target Assigned"); - teleportTarget = actor; - } + victims.add(new Victim(player, Victim.Type.TELEPORT)); } } - switch (Text.standardize(chatMessage.getMessageNode().getValue())) - { - case "the great olm rises with the power of acid.": - case "the great olm rises with the power of crystal.": - case "the great olm rises with the power of flame.": - case "the great olm is giving its all. this is its final stand.": - if (!runOlm) - { - Olm_ActionCycle = -1; - Olm_TicksUntilAction = 4; - } - else - { - Olm_ActionCycle = -1; - Olm_TicksUntilAction = 3; - } - OlmPhase = 0; - runOlm = true; - needOlm = true; - crippleTimer = 45; - Olm_NextSpec = -1; - break; - case "the great olm fires a sphere of aggression your way. your prayers have been sapped.": - prayAgainstOlm = PrayAgainst.MELEE; - lastPrayTime = System.currentTimeMillis(); - break; - case "the great olm fires a sphere of aggression your way.": - prayAgainstOlm = PrayAgainst.MELEE; - lastPrayTime = System.currentTimeMillis(); - break; - case "the great olm fires a sphere of magical power your way. your prayers have been sapped.": - prayAgainstOlm = PrayAgainst.MAGIC; - lastPrayTime = System.currentTimeMillis(); - break; - case "the great olm fires a sphere of magical power your way.": - prayAgainstOlm = PrayAgainst.MAGIC; - lastPrayTime = System.currentTimeMillis(); - break; - case "the great olm fires a sphere of accuracy and dexterity your way. your prayers have been sapped.": - prayAgainstOlm = PrayAgainst.RANGED; - lastPrayTime = System.currentTimeMillis(); - break; - case "the great olm fires a sphere of accuracy and dexterity your way.": - prayAgainstOlm = PrayAgainst.RANGED; - lastPrayTime = System.currentTimeMillis(); - break; - case "the great olm's left claw clenches to protect itself temporarily.": - HandCripple = true; + } + + switch (Text.standardize(event.getMessageNode().getValue())) + { + case "the great olm rises with the power of acid.": + case "the great olm rises with the power of crystal.": + case "the great olm rises with the power of flame.": + case "the great olm is giving its all. this is its final stand.": + if (!runOlm) + { + Olm_ActionCycle = -1; + Olm_TicksUntilAction = 4; + } + else + { + Olm_ActionCycle = -1; + Olm_TicksUntilAction = 3; + } + OlmPhase = 0; + runOlm = true; + needOlm = true; + crippleTimer = 45; + Olm_NextSpec = -1; + break; + case "the great olm fires a sphere of aggression your way. your prayers have been sapped.": + case "the great olm fires a sphere of aggression your way.": + prayAgainstOlm = PrayAgainst.MELEE; + lastPrayTime = System.currentTimeMillis(); + break; + case "the great olm fires a sphere of magical power your way. your prayers have been sapped.": + case "the great olm fires a sphere of magical power your way.": + prayAgainstOlm = PrayAgainst.MAGIC; + lastPrayTime = System.currentTimeMillis(); + break; + case "the great olm fires a sphere of accuracy and dexterity your way. your prayers have been sapped.": + case "the great olm fires a sphere of accuracy and dexterity your way.": + prayAgainstOlm = PrayAgainst.RANGED; + lastPrayTime = System.currentTimeMillis(); + break; + case "the great olm's left claw clenches to protect itself temporarily.": + handCripple = true; - } } } } - private void onProjectileMoved(ProjectileMoved event) + private void onProjectileSpawned(ProjectileSpawned event) { - if (inRaid()) + if (!inRaid()) { - Projectile projectile = event.getProjectile(); - if (projectile.getId() == ProjectileID.OLM_MAGE_ATTACK) - { + return; + } + + final Projectile projectile = event.getProjectile(); + + switch (projectile.getId()) + { + case ProjectileID.OLM_MAGE_ATTACK: prayAgainstOlm = PrayAgainst.MAGIC; lastPrayTime = System.currentTimeMillis(); - } - if (projectile.getId() == ProjectileID.OLM_RANGE_ATTACK) - { + break; + case ProjectileID.OLM_RANGE_ATTACK: prayAgainstOlm = PrayAgainst.RANGED; lastPrayTime = System.currentTimeMillis(); - } - if (projectile.getId() == ProjectileID.OLM_ACID_TRAIL) - { + break; + case ProjectileID.OLM_ACID_TRAIL: acidTarget = projectile.getInteracting(); - } + break; } } - private void onSpotAnimationChanged(SpotAnimationChanged graphicChanged) + private void onSpotAnimationChanged(SpotAnimationChanged event) { - if (inRaid()) + if (!inRaid()) { - Actor actor = graphicChanged.getActor(); - if (actor.getSpotAnimation() == GraphicID.OLM_BURN) + return; + } + + if (!(event.getActor() instanceof Player)) + { + return; + } + + final Player player = (Player) event.getActor(); + + if (player.getSpotAnimation() == GraphicID.OLM_BURN) + { + int add = 0; + + for (Victim victim : victims) { - if (!burnTarget.contains(actor)) + if (victim.getPlayer().getName().equals(player.getName())) { - burnTarget.add(actor); + add++; } } + + if (add == 0) + { + victims.add(new Victim(player, Victim.Type.BURN)); + } } } - private void onNpcSpawned(NpcSpawned npcSpawned) + private void onNpcSpawned(NpcSpawned event) { if (inRaid()) { - NPC npc = npcSpawned.getNpc(); - switch (npc.getId()) - { - case NpcID.TEKTON: - case NpcID.TEKTON_7541: - case NpcID.TEKTON_7542: - case NpcID.TEKTON_7545: - case NpcID.TEKTON_ENRAGED: - case NpcID.TEKTON_ENRAGED_7544: - npcContainer.put(npc, new NPCContainer(npc)); - tektonAttackTicks = 27; - break; - case NpcID.MUTTADILE: - case NpcID.MUTTADILE_7562: - case NpcID.MUTTADILE_7563: - case NpcID.GUARDIAN: - case NpcID.GUARDIAN_7570: - npcContainer.put(npc, new NPCContainer(npc)); - break; - case NpcID.VANGUARD: - case NpcID.VANGUARD_7526: - case NpcID.VANGUARD_7527: - case NpcID.VANGUARD_7528: - case NpcID.VANGUARD_7529: - vanguards++; - npcContainer.put(npc, new NPCContainer(npc)); - break; - case NpcID.GREAT_OLM_LEFT_CLAW: - case NpcID.GREAT_OLM_LEFT_CLAW_7555: - hand = npc; - break; - } + return; + } + + final NPC npc = event.getNpc(); + + switch (npc.getId()) + { + case NpcID.TEKTON: + case NpcID.TEKTON_7541: + case NpcID.TEKTON_7542: + case NpcID.TEKTON_7545: + case NpcID.TEKTON_ENRAGED: + case NpcID.TEKTON_ENRAGED_7544: + npcContainer.put(npc, new NPCContainer(npc)); + tektonAttackTicks = 27; + break; + case NpcID.MUTTADILE: + case NpcID.MUTTADILE_7562: + case NpcID.MUTTADILE_7563: + case NpcID.GUARDIAN: + case NpcID.GUARDIAN_7570: + npcContainer.put(npc, new NPCContainer(npc)); + break; + case NpcID.VANGUARD: + case NpcID.VANGUARD_7526: + case NpcID.VANGUARD_7527: + case NpcID.VANGUARD_7528: + case NpcID.VANGUARD_7529: + vanguards++; + npcContainer.put(npc, new NPCContainer(npc)); + break; + case NpcID.GREAT_OLM_LEFT_CLAW: + case NpcID.GREAT_OLM_LEFT_CLAW_7555: + hand = npc; + break; } } private void onNpcDespawned(NpcDespawned event) { - if (inRaid()) + if (!inRaid()) { - NPC npc = event.getNpc(); - switch (npc.getId()) - { - case NpcID.TEKTON: - case NpcID.TEKTON_7541: - case NpcID.TEKTON_7542: - case NpcID.TEKTON_7545: - case NpcID.TEKTON_ENRAGED: - case NpcID.TEKTON_ENRAGED_7544: - case NpcID.MUTTADILE: - case NpcID.MUTTADILE_7562: - case NpcID.MUTTADILE_7563: - case NpcID.GUARDIAN: - case NpcID.GUARDIAN_7570: - case NpcID.GUARDIAN_7571: - case NpcID.GUARDIAN_7572: - if (npcContainer.remove(event.getNpc()) != null && !npcContainer.isEmpty()) - { - npcContainer.remove(event.getNpc()); - } - break; - case NpcID.VANGUARD: - case NpcID.VANGUARD_7526: - case NpcID.VANGUARD_7527: - case NpcID.VANGUARD_7528: - case NpcID.VANGUARD_7529: - if (npcContainer.remove(event.getNpc()) != null && !npcContainer.isEmpty()) - { - npcContainer.remove(event.getNpc()); - } - vanguards--; - break; - case NpcID.GREAT_OLM_RIGHT_CLAW_7553: - case NpcID.GREAT_OLM_RIGHT_CLAW: - HandCripple = false; - break; - } + return; + } + + final NPC npc = event.getNpc(); + + switch (npc.getId()) + { + case NpcID.TEKTON: + case NpcID.TEKTON_7541: + case NpcID.TEKTON_7542: + case NpcID.TEKTON_7545: + case NpcID.TEKTON_ENRAGED: + case NpcID.TEKTON_ENRAGED_7544: + case NpcID.MUTTADILE: + case NpcID.MUTTADILE_7562: + case NpcID.MUTTADILE_7563: + case NpcID.GUARDIAN: + case NpcID.GUARDIAN_7570: + case NpcID.GUARDIAN_7571: + case NpcID.GUARDIAN_7572: + if (npcContainer.remove(event.getNpc()) != null && !npcContainer.isEmpty()) + { + npcContainer.remove(event.getNpc()); + } + break; + case NpcID.VANGUARD: + case NpcID.VANGUARD_7526: + case NpcID.VANGUARD_7527: + case NpcID.VANGUARD_7528: + case NpcID.VANGUARD_7529: + if (npcContainer.remove(event.getNpc()) != null && !npcContainer.isEmpty()) + { + npcContainer.remove(event.getNpc()); + } + vanguards--; + break; + case NpcID.GREAT_OLM_RIGHT_CLAW_7553: + case NpcID.GREAT_OLM_RIGHT_CLAW: + handCripple = false; + break; } } @@ -449,7 +428,7 @@ public class CoxPlugin extends Plugin sleepcount = 0; Olm_Heal.clear(); npcContainer.clear(); - burnTarget.clear(); + victims.clear(); Olm_NPC = null; hand = null; prayAgainstOlm = null; @@ -457,7 +436,8 @@ public class CoxPlugin extends Plugin return; } - npcHandler(); + handleNpcs(); + handleVictims(); if (needOlm = true) { @@ -472,57 +452,32 @@ public class CoxPlugin extends Plugin } } - if (teleportTarget != null) - { - log.info(teleportTarget.getName()); - Player target = (Player) teleportTarget; - client.setHintArrow(target); - teleportTicks--; - if (teleportTicks <= 0) - { - client.clearHintArrow(); - teleportTarget = null; - teleportTicks = 10; - } - } - - if (acidTarget != null) - { - acidTicks--; - if (acidTicks <= 0) - { - acidTarget = null; - acidTicks = 25; - } - } - - if (burnTarget.size() > 0) - { - burnTicks--; - if (burnTicks <= 0) - { - burnTarget.clear(); - burnTicks = 41; - } - } - - if (HandCripple) + if (handCripple) { crippleTimer--; if (crippleTimer <= 0) { - HandCripple = false; + handCripple = false; crippleTimer = 45; } } if (runOlm) { - olmHandler(); + handleOlm(); } } - private void npcHandler() + private void handleVictims() + { + if (victims.size() > 0) + { + victims.forEach(Victim::updateTicks); + victims.removeIf(victim -> victim.getTicks() <= 0); + } + } + + private void handleNpcs() { for (NPCContainer npcs : getNpcContainer().values()) { @@ -605,7 +560,7 @@ public class CoxPlugin extends Plugin } } - private void olmHandler() + private void handleOlm() { Olm_Crystals.clear(); Olm_Heal.clear(); @@ -706,14 +661,6 @@ public class CoxPlugin extends Plugin return client.getVar(Varbits.IN_RAID) == 1; } - private void onConfigChanged(ConfigChanged configChanged) - { - if (configChanged.getGroup().equals("Cox")) - { - updateConfig(); - } - } - private void updateConfig() { this.muttadile = config.muttadile(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/Victim.java b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/Victim.java new file mode 100644 index 0000000000..b5b3684b3e --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/Victim.java @@ -0,0 +1,40 @@ +package net.runelite.client.plugins.coxhelper; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import net.runelite.api.Player; + +@Getter(AccessLevel.PACKAGE) +class Victim +{ + private Player player; + private Type type; + private int ticks; + + Victim(Player player, Type type) + { + this.player = player; + this.type = type; + this.ticks = type.getTicks(); + } + + void updateTicks() + { + if (ticks > 0) + { + ticks--; + } + } + + @AllArgsConstructor + @Getter(AccessLevel.PACKAGE) + enum Type + { + BURN(41), + ACID(23), + TELEPORT(10); + + private int ticks; + } +}