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