Rename and cleanup baby hydra plugin (#331)
This commit is contained in:
@@ -29,7 +29,7 @@ import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("hydra")
|
||||
public interface HydraConfig extends Config
|
||||
public interface BabyHydraConfig extends Config
|
||||
{
|
||||
|
||||
@ConfigItem(
|
||||
@@ -33,17 +33,15 @@ import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.ui.overlay.components.LineComponent;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
|
||||
public class HydraIndicatorOverlay extends Overlay
|
||||
public class BabyHydraIndicatorOverlay extends Overlay
|
||||
{
|
||||
private final HydraConfig config;
|
||||
private final HydraPlugin plugin;
|
||||
private final BabyHydraPlugin plugin;
|
||||
|
||||
private final PanelComponent panelComponent = new PanelComponent();
|
||||
|
||||
@Inject
|
||||
private HydraIndicatorOverlay(HydraConfig config, HydraPlugin plugin)
|
||||
private BabyHydraIndicatorOverlay(BabyHydraPlugin plugin)
|
||||
{
|
||||
this.config = config;
|
||||
this.plugin = plugin;
|
||||
setPosition(OverlayPosition.BOTTOM_RIGHT);
|
||||
setPriority(OverlayPriority.MED);
|
||||
@@ -53,16 +51,11 @@ public class HydraIndicatorOverlay extends Overlay
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!config.PrayerHelper())
|
||||
if (plugin.getHydra() != null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (plugin.Hydra != null)
|
||||
{
|
||||
if (plugin.hydras.containsKey(plugin.Hydra.getIndex()))
|
||||
if (plugin.getHydras().containsKey(plugin.getHydra().getIndex()))
|
||||
{
|
||||
int val = plugin.hydras.get(plugin.Hydra.getIndex());
|
||||
int val = plugin.getHydras().get(plugin.getHydra().getIndex());
|
||||
if (val != 0)
|
||||
{
|
||||
panelComponent.getChildren().clear();
|
||||
@@ -37,37 +37,29 @@ import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
|
||||
public class HydraOverlay extends Overlay
|
||||
public class BabyHydraOverlay extends Overlay
|
||||
{
|
||||
private final HydraConfig config;
|
||||
private final HydraPlugin plugin;
|
||||
private final PanelComponent panelComponent = new PanelComponent();
|
||||
private final BabyHydraConfig config;
|
||||
private final BabyHydraPlugin plugin;
|
||||
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private HydraOverlay(HydraConfig config, HydraPlugin plugin)
|
||||
private BabyHydraOverlay(BabyHydraConfig config, BabyHydraPlugin plugin)
|
||||
{
|
||||
this.config = config;
|
||||
this.plugin = plugin;
|
||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setPriority(OverlayPriority.MED);
|
||||
panelComponent.setPreferredSize(new Dimension(150, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!config.TextIndicator())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for (NPC hydra : client.getNpcs())
|
||||
{
|
||||
if (hydra == null || hydra.getName() == null)
|
||||
@@ -76,38 +68,41 @@ public class HydraOverlay extends Overlay
|
||||
}
|
||||
if (hydra.getName().equalsIgnoreCase("Hydra"))
|
||||
{
|
||||
if (plugin.hydras.containsKey(hydra.getIndex()))
|
||||
if (plugin.getHydras().containsKey(hydra.getIndex()))
|
||||
{
|
||||
int val = plugin.hydras.get(hydra.getIndex());
|
||||
int val = plugin.getHydras().get(hydra.getIndex());
|
||||
if (val != 0)
|
||||
{
|
||||
if (config.BoldText())
|
||||
{
|
||||
graphics.setFont(FontManager.getRunescapeBoldFont());
|
||||
}
|
||||
if (plugin.hydraattacks.containsKey(hydra.getIndex()))
|
||||
if (plugin.getHydraattacks().containsKey(hydra.getIndex()))
|
||||
{
|
||||
int attack = plugin.hydraattacks.get(hydra.getIndex());
|
||||
if (attack == 8261)
|
||||
int attack = plugin.getHydraattacks().get(hydra.getIndex());
|
||||
|
||||
Point textLocation = hydra.getCanvasTextLocation(graphics, "TEMP!!", hydra.getLogicalHeight() + 100);
|
||||
|
||||
if (textLocation != null && attack == 8261)
|
||||
{
|
||||
if (val == 3)
|
||||
{
|
||||
OverlayUtil.renderTextLocation(graphics, hydra.getCanvasTextLocation(graphics, "MAGE", hydra.getLogicalHeight() + 100), "MAGE", Color.BLUE);
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, "MAGE", Color.BLUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayUtil.renderTextLocation(graphics, hydra.getCanvasTextLocation(graphics, "RANGE", hydra.getLogicalHeight() + 100), "RANGE", Color.GREEN);
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, "RANGE", Color.GREEN);
|
||||
}
|
||||
}
|
||||
else if (attack == 8262)
|
||||
else if (textLocation != null && attack == 8262)
|
||||
{
|
||||
if (val == 3)
|
||||
{
|
||||
OverlayUtil.renderTextLocation(graphics, hydra.getCanvasTextLocation(graphics, "RANGE", hydra.getLogicalHeight() + 100), "RANGE", Color.GREEN);
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, "RANGE", Color.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayUtil.renderTextLocation(graphics, hydra.getCanvasTextLocation(graphics, "MAGE", hydra.getLogicalHeight() + 100), "MAGE", Color.BLUE);
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, "MAGE", Color.BLUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,10 +28,12 @@ import com.google.inject.Provides;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.events.AnimationChanged;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.NpcDespawned;
|
||||
import net.runelite.api.events.NpcSpawned;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
@@ -43,58 +45,103 @@ import net.runelite.client.ui.overlay.OverlayManager;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Hydra Helper",
|
||||
description = "Hydra Helper",
|
||||
tags = {"Hydra", "Helper"},
|
||||
description = "Overlays for small hydras",
|
||||
tags = {"Hydra", "Helper", "you", "probably", "want", "the", "other", "one"},
|
||||
type = PluginType.PVM
|
||||
)
|
||||
public class HydraPlugin extends Plugin
|
||||
public class BabyHydraPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@Inject
|
||||
private HydraConfig config;
|
||||
private BabyHydraConfig config;
|
||||
|
||||
@Inject
|
||||
private HydraOverlay HydraOverlay;
|
||||
private BabyHydraOverlay hydraOverlay;
|
||||
|
||||
@Inject
|
||||
private HydraPrayOverlay HydraPrayOverlay;
|
||||
private BabyHydraPrayOverlay hydraPrayOverlay;
|
||||
|
||||
@Inject
|
||||
private HydraIndicatorOverlay HydraIndicatorOverlay;
|
||||
private BabyHydraIndicatorOverlay hydraIndicatorOverlay;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Provides
|
||||
HydraConfig provideConfig(ConfigManager configManager)
|
||||
BabyHydraConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
return configManager.getConfig(HydraConfig.class);
|
||||
return configManager.getConfig(BabyHydraConfig.class);
|
||||
}
|
||||
|
||||
Map<Integer, Integer> hydras = new HashMap<>();
|
||||
Map<Integer, Integer> hydraattacks = new HashMap<>();
|
||||
NPC Hydra;
|
||||
@Getter
|
||||
private Map<Integer, Integer> hydras = new HashMap<>();
|
||||
|
||||
@Getter
|
||||
private Map<Integer, Integer> hydraattacks = new HashMap<>();
|
||||
|
||||
@Getter
|
||||
private NPC hydra;
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
overlayManager.add(HydraOverlay);
|
||||
overlayManager.add(HydraPrayOverlay);
|
||||
overlayManager.add(HydraIndicatorOverlay);
|
||||
if (config.TextIndicator())
|
||||
{
|
||||
overlayManager.add(hydraOverlay);
|
||||
}
|
||||
if (config.PrayerHelper())
|
||||
{
|
||||
overlayManager.add(hydraPrayOverlay);
|
||||
overlayManager.add(hydraIndicatorOverlay);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
overlayManager.remove(HydraOverlay);
|
||||
overlayManager.remove(HydraPrayOverlay);
|
||||
overlayManager.remove(HydraIndicatorOverlay);
|
||||
overlayManager.remove(hydraOverlay);
|
||||
overlayManager.remove(hydraPrayOverlay);
|
||||
overlayManager.remove(hydraIndicatorOverlay);
|
||||
hydras.clear();
|
||||
hydraattacks.clear();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onConfigChanged(ConfigChanged event)
|
||||
{
|
||||
if (!event.getGroup().equals("hydra"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getKey().equals("textindicators"))
|
||||
{
|
||||
if (Boolean.parseBoolean(event.getNewValue()))
|
||||
{
|
||||
overlayManager.add(hydraOverlay);
|
||||
}
|
||||
else
|
||||
{
|
||||
overlayManager.remove(hydraOverlay);
|
||||
}
|
||||
}
|
||||
else if (event.getKey().equals("prayerhelper"))
|
||||
{
|
||||
if (Boolean.parseBoolean(event.getNewValue()))
|
||||
{
|
||||
overlayManager.add(hydraPrayOverlay);
|
||||
overlayManager.add(hydraIndicatorOverlay);
|
||||
}
|
||||
else
|
||||
{
|
||||
overlayManager.remove(hydraPrayOverlay);
|
||||
overlayManager.remove(hydraIndicatorOverlay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onNpcSpawned(NpcSpawned event)
|
||||
{
|
||||
@@ -130,59 +177,65 @@ public class HydraPlugin extends Plugin
|
||||
{
|
||||
Actor monster = event.getActor();
|
||||
Actor local = client.getLocalPlayer();
|
||||
if (monster instanceof NPC)
|
||||
if (!(monster instanceof NPC))
|
||||
{
|
||||
NPC hydra = (NPC) monster;
|
||||
if (hydra.getCombatLevel() != 0 && hydra.getName() != null)
|
||||
{
|
||||
if (hydra.getName().equalsIgnoreCase("Hydra"))
|
||||
{
|
||||
if (hydras.containsKey(hydra.getIndex()))
|
||||
{
|
||||
if (hydra.getAnimation() == 8261 || hydra.getAnimation() == 8262)
|
||||
{
|
||||
if (hydra.getInteracting().equals(local))
|
||||
{
|
||||
Hydra = hydra;
|
||||
}
|
||||
if (hydraattacks.containsKey(hydra.getIndex()))
|
||||
{
|
||||
int lastattack = hydraattacks.get(hydra.getIndex());
|
||||
hydraattacks.replace(hydra.getIndex(), hydra.getAnimation());
|
||||
return;
|
||||
}
|
||||
NPC hydra = (NPC) monster;
|
||||
|
||||
if (lastattack != hydra.getAnimation())
|
||||
{
|
||||
hydras.replace(hydra.getIndex(), 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
int currval = hydras.get(hydra.getIndex());
|
||||
if (currval == 1)
|
||||
{
|
||||
hydras.replace(hydra.getIndex(), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
hydras.replace(hydra.getIndex(), currval - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hydraattacks.put(hydra.getIndex(), hydra.getAnimation());
|
||||
int currval = hydras.get(hydra.getIndex());
|
||||
if (currval == 1)
|
||||
{
|
||||
hydras.replace(hydra.getIndex(), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
hydras.replace(hydra.getIndex(), currval - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hydra.getCombatLevel() == 0 || hydra.getName() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hydra.getName().equalsIgnoreCase("Hydra") || !hydras.containsKey(hydra.getIndex()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (hydra.getAnimation() != 8261 && hydra.getAnimation() != 8262)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (hydra.getInteracting().equals(local))
|
||||
{
|
||||
this.hydra = hydra;
|
||||
}
|
||||
|
||||
if (hydraattacks.containsKey(hydra.getIndex()))
|
||||
{
|
||||
int lastattack = hydraattacks.get(hydra.getIndex());
|
||||
hydraattacks.replace(hydra.getIndex(), hydra.getAnimation());
|
||||
|
||||
if (lastattack != hydra.getAnimation())
|
||||
{
|
||||
hydras.replace(hydra.getIndex(), 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
int currval = hydras.get(hydra.getIndex());
|
||||
if (currval == 1)
|
||||
{
|
||||
hydras.replace(hydra.getIndex(), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
hydras.replace(hydra.getIndex(), currval - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hydraattacks.put(hydra.getIndex(), hydra.getAnimation());
|
||||
int currval = hydras.get(hydra.getIndex());
|
||||
if (currval == 1)
|
||||
{
|
||||
hydras.replace(hydra.getIndex(), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
hydras.replace(hydra.getIndex(), currval - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,56 +40,58 @@ import net.runelite.client.ui.overlay.components.ComponentConstants;
|
||||
import net.runelite.client.ui.overlay.components.ImageComponent;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
|
||||
public class HydraPrayOverlay extends Overlay
|
||||
public class BabyHydraPrayOverlay extends Overlay
|
||||
{
|
||||
private final HydraConfig config;
|
||||
private final HydraPlugin plugin;
|
||||
private final BabyHydraPlugin plugin;
|
||||
|
||||
private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150);
|
||||
|
||||
private final SpriteManager spriteManager;
|
||||
private BufferedImage PRAY_MAGE;
|
||||
private BufferedImage PRAY_RANGED;
|
||||
private final PanelComponent imagePanelComponent = new PanelComponent();
|
||||
|
||||
@Inject
|
||||
private SpriteManager spriteManager;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private HydraPrayOverlay(HydraConfig config, HydraPlugin plugin, SpriteManager spriteManager)
|
||||
private BabyHydraPrayOverlay(BabyHydraPlugin plugin, SpriteManager spriteManager)
|
||||
{
|
||||
this.config = config;
|
||||
this.plugin = plugin;
|
||||
this.spriteManager = spriteManager;
|
||||
setPosition(OverlayPosition.BOTTOM_RIGHT);
|
||||
setPriority(OverlayPriority.HIGH);
|
||||
this.spriteManager = spriteManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!config.PrayerHelper())
|
||||
if (PRAY_MAGE == null)
|
||||
{
|
||||
return null;
|
||||
PRAY_MAGE = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MAGIC, 0);
|
||||
}
|
||||
if (PRAY_RANGED == null)
|
||||
{
|
||||
PRAY_RANGED = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MISSILES, 0);
|
||||
}
|
||||
|
||||
if (plugin.Hydra != null)
|
||||
if (plugin.getHydra() != null)
|
||||
{
|
||||
if (plugin.hydras.containsKey(plugin.Hydra.getIndex()))
|
||||
if (plugin.getHydras().containsKey(plugin.getHydra().getIndex()))
|
||||
{
|
||||
int val = plugin.hydras.get(plugin.Hydra.getIndex());
|
||||
int val = plugin.getHydras().get(plugin.getHydra().getIndex());
|
||||
if (val != 0)
|
||||
{
|
||||
if (plugin.hydraattacks.containsKey(plugin.Hydra.getIndex()))
|
||||
if (plugin.getHydraattacks().containsKey(plugin.getHydra().getIndex()))
|
||||
{
|
||||
int attack = plugin.hydraattacks.get(plugin.Hydra.getIndex());
|
||||
int attack = plugin.getHydraattacks().get(plugin.getHydra().getIndex());
|
||||
if (attack == 8261)
|
||||
{
|
||||
if (val == 3)
|
||||
{
|
||||
final BufferedImage prayerImage = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MAGIC, 0);
|
||||
|
||||
imagePanelComponent.getChildren().clear();
|
||||
imagePanelComponent.getChildren().add(new ImageComponent(prayerImage));
|
||||
imagePanelComponent.getChildren().add(new ImageComponent(PRAY_MAGE));
|
||||
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC)
|
||||
? ComponentConstants.STANDARD_BACKGROUND_COLOR
|
||||
: NOT_ACTIVATED_BACKGROUND_COLOR);
|
||||
@@ -98,10 +100,8 @@ public class HydraPrayOverlay extends Overlay
|
||||
}
|
||||
else
|
||||
{
|
||||
final BufferedImage prayerImage = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MISSILES, 0);
|
||||
|
||||
imagePanelComponent.getChildren().clear();
|
||||
imagePanelComponent.getChildren().add(new ImageComponent(prayerImage));
|
||||
imagePanelComponent.getChildren().add(new ImageComponent(PRAY_RANGED));
|
||||
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MISSILES)
|
||||
? ComponentConstants.STANDARD_BACKGROUND_COLOR
|
||||
: NOT_ACTIVATED_BACKGROUND_COLOR);
|
||||
@@ -113,10 +113,8 @@ public class HydraPrayOverlay extends Overlay
|
||||
{
|
||||
if (val == 3)
|
||||
{
|
||||
final BufferedImage prayerImage = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MISSILES, 0);
|
||||
|
||||
imagePanelComponent.getChildren().clear();
|
||||
imagePanelComponent.getChildren().add(new ImageComponent(prayerImage));
|
||||
imagePanelComponent.getChildren().add(new ImageComponent(PRAY_RANGED));
|
||||
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MISSILES)
|
||||
? ComponentConstants.STANDARD_BACKGROUND_COLOR
|
||||
: NOT_ACTIVATED_BACKGROUND_COLOR);
|
||||
@@ -125,10 +123,8 @@ public class HydraPrayOverlay extends Overlay
|
||||
}
|
||||
else
|
||||
{
|
||||
final BufferedImage prayerImage = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MAGIC, 0);
|
||||
|
||||
imagePanelComponent.getChildren().clear();
|
||||
imagePanelComponent.getChildren().add(new ImageComponent(prayerImage));
|
||||
imagePanelComponent.getChildren().add(new ImageComponent(PRAY_MAGE));
|
||||
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC)
|
||||
? ComponentConstants.STANDARD_BACKGROUND_COLOR
|
||||
: NOT_ACTIVATED_BACKGROUND_COLOR);
|
||||
Reference in New Issue
Block a user