Cleanup Map Usage
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.ticktimers;
|
||||
|
||||
import java.awt.Color;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.Actor;
|
||||
@@ -33,31 +35,26 @@ import net.runelite.api.NPCDefinition;
|
||||
|
||||
class NPCContainer
|
||||
{
|
||||
|
||||
@Getter
|
||||
private NPC npc;
|
||||
|
||||
@Getter
|
||||
private int npcIndex;
|
||||
|
||||
@Getter
|
||||
private String npcName;
|
||||
|
||||
@Getter
|
||||
private int npcSize;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private int TicksUntilAttack;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private int npcSpeed;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private Actor npcInteracting;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private Attackstyle attackStyle;
|
||||
|
||||
NPCContainer(NPC npc)
|
||||
{
|
||||
@@ -66,6 +63,7 @@ class NPCContainer
|
||||
this.npcIndex = npc.getIndex();
|
||||
this.npcInteracting = npc.getInteracting();
|
||||
this.npcSpeed = 0;
|
||||
this.attackStyle = Attackstyle.UNKNOWN;
|
||||
this.TicksUntilAttack = 0;
|
||||
final NPCDefinition composition = npc.getTransformedDefinition();
|
||||
|
||||
@@ -74,4 +72,18 @@ class NPCContainer
|
||||
this.npcSize = composition.getSize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum Attackstyle
|
||||
{
|
||||
MAGE("Mage", Color.CYAN),
|
||||
RANGE("Range", Color.GREEN),
|
||||
MELEE("Melee", Color.RED),
|
||||
UNKNOWN("Unknown", Color.WHITE);
|
||||
|
||||
private String name = "";
|
||||
private Color color;
|
||||
}
|
||||
}
|
||||
@@ -73,16 +73,7 @@ public class TickTimersPlugin extends Plugin
|
||||
private TickTimersConfig config;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private Map<NPC, NPCContainer> Strongstack = new HashMap<>();
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private Map<NPC, NPCContainer> Steelwill = new HashMap<>();
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private Map<NPC, NPCContainer> Grimspike = new HashMap<>();
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private Map<NPC, NPCContainer> General = new HashMap<>();
|
||||
private Map<NPC, NPCContainer> npcContainer = new HashMap<>();
|
||||
|
||||
@Provides
|
||||
TickTimersConfig getConfig(ConfigManager configManager)
|
||||
@@ -93,19 +84,13 @@ public class TickTimersPlugin extends Plugin
|
||||
@Override
|
||||
public void startUp()
|
||||
{
|
||||
Strongstack.clear();
|
||||
Steelwill.clear();
|
||||
Grimspike.clear();
|
||||
General.clear();
|
||||
npcContainer.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutDown()
|
||||
{
|
||||
Strongstack.clear();
|
||||
Steelwill.clear();
|
||||
Grimspike.clear();
|
||||
General.clear();
|
||||
npcContainer.clear();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -126,11 +111,7 @@ public class TickTimersPlugin extends Plugin
|
||||
{
|
||||
return;
|
||||
}
|
||||
Strongstack.clear();
|
||||
Steelwill.clear();
|
||||
Grimspike.clear();
|
||||
General.clear();
|
||||
|
||||
npcContainer.clear();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -140,17 +121,11 @@ public class TickTimersPlugin extends Plugin
|
||||
switch (npc.getId())
|
||||
{
|
||||
case NpcID.SERGEANT_STRONGSTACK:
|
||||
Strongstack.put(npc, new NPCContainer(npc));
|
||||
break;
|
||||
case NpcID.SERGEANT_STEELWILL:
|
||||
Steelwill.put(npc, new NPCContainer(npc));
|
||||
break;
|
||||
case NpcID.SERGEANT_GRIMSPIKE:
|
||||
Grimspike.put(npc, new NPCContainer(npc));
|
||||
break;
|
||||
case NpcID.GENERAL_GRAARDOR:
|
||||
case NpcID.GENERAL_GRAARDOR_6494:
|
||||
General.put(npc, new NPCContainer(npc));
|
||||
npcContainer.put(npc, new NPCContainer(npc));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -158,21 +133,9 @@ public class TickTimersPlugin extends Plugin
|
||||
@Subscribe
|
||||
public void onNpcDespawned(NpcDespawned event)
|
||||
{
|
||||
if (Grimspike.remove(event.getNpc()) != null && !Grimspike.isEmpty())
|
||||
if (npcContainer.remove(event.getNpc()) != null && !npcContainer.isEmpty())
|
||||
{
|
||||
Grimspike.clear();
|
||||
}
|
||||
if (Steelwill.remove(event.getNpc()) != null && !Steelwill.isEmpty())
|
||||
{
|
||||
Steelwill.clear();
|
||||
}
|
||||
if (Strongstack.remove(event.getNpc()) != null && !Strongstack.isEmpty())
|
||||
{
|
||||
Strongstack.clear();
|
||||
}
|
||||
if (General.remove(event.getNpc()) != null && !General.isEmpty())
|
||||
{
|
||||
General.clear();
|
||||
npcContainer.remove(event.getNpc());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,64 +150,67 @@ public class TickTimersPlugin extends Plugin
|
||||
|
||||
private void graardorHandler()
|
||||
{
|
||||
for (NPCContainer grimspike : getGrimspike().values())
|
||||
for (NPCContainer npcs : getNpcContainer().values())
|
||||
{
|
||||
grimspike.setTicksUntilAttack(grimspike.getTicksUntilAttack() - 1);
|
||||
switch (grimspike.getNpc().getAnimation())
|
||||
switch (npcs.getNpc().getId())
|
||||
{
|
||||
case AnimationID.MINION_AUTO1:
|
||||
case AnimationID.MINION_AUTO2:
|
||||
case AnimationID.MINION_AUTO4:
|
||||
if (grimspike.getTicksUntilAttack() < 1)
|
||||
case NpcID.SERGEANT_STRONGSTACK:
|
||||
npcs.setTicksUntilAttack(npcs.getTicksUntilAttack() - 1);
|
||||
npcs.setAttackStyle(NPCContainer.Attackstyle.MELEE);
|
||||
switch (npcs.getNpc().getAnimation())
|
||||
{
|
||||
grimspike.setTicksUntilAttack(5);
|
||||
case AnimationID.MINION_AUTO1:
|
||||
case AnimationID.MINION_AUTO2:
|
||||
if (npcs.getTicksUntilAttack() < 1)
|
||||
{
|
||||
npcs.setTicksUntilAttack(5);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (NPCContainer strongstack : getStrongstack().values())
|
||||
{
|
||||
strongstack.setTicksUntilAttack(strongstack.getTicksUntilAttack() - 1);
|
||||
switch (strongstack.getNpc().getAnimation())
|
||||
{
|
||||
case AnimationID.MINION_AUTO1:
|
||||
case AnimationID.MINION_AUTO2:
|
||||
if (strongstack.getTicksUntilAttack() < 1)
|
||||
case NpcID.SERGEANT_STEELWILL:
|
||||
npcs.setTicksUntilAttack(npcs.getTicksUntilAttack() - 1);
|
||||
npcs.setAttackStyle(NPCContainer.Attackstyle.MAGE);
|
||||
switch (npcs.getNpc().getAnimation())
|
||||
{
|
||||
strongstack.setTicksUntilAttack(5);
|
||||
case AnimationID.MINION_AUTO1:
|
||||
case AnimationID.MINION_AUTO2:
|
||||
case AnimationID.MINION_AUTO3:
|
||||
if (npcs.getTicksUntilAttack() < 1)
|
||||
{
|
||||
npcs.setTicksUntilAttack(5);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NpcID.SERGEANT_GRIMSPIKE:
|
||||
npcs.setTicksUntilAttack(npcs.getTicksUntilAttack() - 1);
|
||||
npcs.setAttackStyle(NPCContainer.Attackstyle.RANGE);
|
||||
switch (npcs.getNpc().getAnimation())
|
||||
{
|
||||
case AnimationID.MINION_AUTO1:
|
||||
case AnimationID.MINION_AUTO2:
|
||||
case AnimationID.MINION_AUTO4:
|
||||
if (npcs.getTicksUntilAttack() < 1)
|
||||
{
|
||||
npcs.setTicksUntilAttack(5);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (NPCContainer steelwill : getSteelwill().values())
|
||||
{
|
||||
steelwill.setTicksUntilAttack(steelwill.getTicksUntilAttack() - 1);
|
||||
switch (steelwill.getNpc().getAnimation())
|
||||
{
|
||||
case AnimationID.MINION_AUTO1:
|
||||
case AnimationID.MINION_AUTO2:
|
||||
case AnimationID.MINION_AUTO3:
|
||||
if (steelwill.getTicksUntilAttack() < 1)
|
||||
case NpcID.GENERAL_GRAARDOR:
|
||||
case NpcID.GENERAL_GRAARDOR_6494:
|
||||
npcs.setTicksUntilAttack(npcs.getTicksUntilAttack() - 1);
|
||||
npcs.setAttackStyle(NPCContainer.Attackstyle.MELEE);
|
||||
switch (npcs.getNpc().getAnimation())
|
||||
{
|
||||
steelwill.setTicksUntilAttack(5);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (NPCContainer boss : getGeneral().values())
|
||||
{
|
||||
boss.setTicksUntilAttack(boss.getTicksUntilAttack() - 1);
|
||||
switch (boss.getNpc().getAnimation())
|
||||
{
|
||||
case AnimationID.GENERAL_AUTO1:
|
||||
case AnimationID.GENERAL_AUTO2:
|
||||
case AnimationID.GENERAL_AUTO3:
|
||||
if (boss.getTicksUntilAttack() < 1)
|
||||
{
|
||||
boss.setTicksUntilAttack(6);
|
||||
case AnimationID.GENERAL_AUTO1:
|
||||
case AnimationID.GENERAL_AUTO2:
|
||||
case AnimationID.GENERAL_AUTO3:
|
||||
if (npcs.getTicksUntilAttack() < 1)
|
||||
{
|
||||
npcs.setTicksUntilAttack(6);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -65,89 +65,25 @@ public class TimersOverlay extends Overlay
|
||||
{
|
||||
Color tickcolor;
|
||||
|
||||
for (NPCContainer npc : plugin.getStrongstack().values())
|
||||
for (NPCContainer npcs : plugin.getNpcContainer().values())
|
||||
{
|
||||
renderNpcOverlay(graphics, npc.getNpc(), Color.RED, 100, 10);
|
||||
final int ticksLeft = npc.getTicksUntilAttack();
|
||||
renderNpcOverlay(graphics, npcs.getNpc(), npcs.getAttackStyle().getColor(), 100, 10);
|
||||
final int ticksLeft = npcs.getTicksUntilAttack();
|
||||
if (ticksLeft > 0)
|
||||
{
|
||||
if (ticksLeft == 1)
|
||||
{
|
||||
tickcolor = Color.RED;
|
||||
tickcolor = npcs.getAttackStyle().getColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
tickcolor = Color.WHITE;
|
||||
}
|
||||
final String ticksLeftStr = String.valueOf(ticksLeft);
|
||||
Point canvasPoint = npc.getNpc().getCanvasTextLocation(graphics, ticksLeftStr, 0);
|
||||
Point canvasPoint = npcs.getNpc().getCanvasTextLocation(graphics, ticksLeftStr, 0);
|
||||
renderTextLocation(graphics, ticksLeftStr, config.textSize(), config.fontStyle().getFont(), tickcolor, canvasPoint);
|
||||
}
|
||||
}
|
||||
|
||||
for (NPCContainer npc : plugin.getSteelwill().values())
|
||||
{
|
||||
renderNpcOverlay(graphics, npc.getNpc(), Color.CYAN, 100, 10);
|
||||
final int ticksLeft = npc.getTicksUntilAttack();
|
||||
if (ticksLeft > 0)
|
||||
{
|
||||
if (ticksLeft == 1)
|
||||
{
|
||||
tickcolor = Color.CYAN;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
tickcolor = Color.WHITE;
|
||||
}
|
||||
final String ticksLeftStr = String.valueOf(ticksLeft);
|
||||
Point canvasPoint = npc.getNpc().getCanvasTextLocation(graphics, ticksLeftStr, 0);
|
||||
renderTextLocation(graphics, ticksLeftStr, config.textSize(), config.fontStyle().getFont(), tickcolor, canvasPoint);
|
||||
}
|
||||
}
|
||||
|
||||
for (NPCContainer npc : plugin.getGrimspike().values())
|
||||
{
|
||||
renderNpcOverlay(graphics, npc.getNpc(), Color.GREEN, 100, 10);
|
||||
final int ticksLeft = npc.getTicksUntilAttack();
|
||||
if (ticksLeft > 0)
|
||||
{
|
||||
if (ticksLeft == 1)
|
||||
{
|
||||
tickcolor = Color.GREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
tickcolor = Color.WHITE;
|
||||
}
|
||||
final String ticksLeftStr = String.valueOf(ticksLeft);
|
||||
Point canvasPoint = npc.getNpc().getCanvasTextLocation(graphics, ticksLeftStr, 0);
|
||||
renderTextLocation(graphics, ticksLeftStr, config.textSize(), config.fontStyle().getFont(), tickcolor, canvasPoint);
|
||||
}
|
||||
}
|
||||
|
||||
for (NPCContainer npc : plugin.getGeneral().values())
|
||||
{
|
||||
renderNpcOverlay(graphics, npc.getNpc(), Color.RED, 100, 10);
|
||||
final int ticksLeft = npc.getTicksUntilAttack();
|
||||
if (ticksLeft > 0)
|
||||
{
|
||||
if (ticksLeft == 1)
|
||||
{
|
||||
tickcolor = Color.RED;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
tickcolor = Color.WHITE;
|
||||
}
|
||||
final String ticksLeftStr = String.valueOf(ticksLeft);
|
||||
Point canvasPoint = npc.getNpc().getCanvasTextLocation(graphics, ticksLeftStr, 0);
|
||||
renderTextLocation(graphics, ticksLeftStr, config.textSize(), config.fontStyle().getFont(), tickcolor, canvasPoint);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user