Refactor other BA
This commit is contained in:
@@ -156,20 +156,29 @@ public interface BAToolsConfig extends Config
|
|||||||
name = "*Barbarian Assault Helper*",
|
name = "*Barbarian Assault Helper*",
|
||||||
description = "Remove unnecessary menu options in Barbarian Assault depending on role<br>Examples: Remove attack options when not attacker<br>Remove take options when not collector"
|
description = "Remove unnecessary menu options in Barbarian Assault depending on role<br>Examples: Remove attack options when not attacker<br>Remove take options when not collector"
|
||||||
)
|
)
|
||||||
default boolean removeBA() { return true; }
|
default boolean removeBA()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "removeWrongEggs",
|
keyName = "removeWrongEggs",
|
||||||
name = "Remove wrong eggs - *Barbarian Assault Helper*",
|
name = "Remove wrong eggs - *Barbarian Assault Helper*",
|
||||||
description = "Remove unnecessary menu options in Barbarian Assault depending on role<br>Examples: Remove attack options when not attacker<br>Remove take options when not collector"
|
description = "Remove unnecessary menu options in Barbarian Assault depending on role<br>Examples: Remove attack options when not attacker<br>Remove take options when not collector"
|
||||||
)
|
)
|
||||||
default boolean removeWrongEggs() { return false; }
|
default boolean removeWrongEggs()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "removeWrongHealFood",
|
keyName = "removeWrongHealFood",
|
||||||
name = "Remove wrong Heal Food - *Barbarian Assault Helper*",
|
name = "Remove wrong Heal Food - *Barbarian Assault Helper*",
|
||||||
description = "Remove unnecessary menu options in Barbarian Assault depending on role<br>Examples: Remove attack options when not attacker<br>Remove take options when not collector"
|
description = "Remove unnecessary menu options in Barbarian Assault depending on role<br>Examples: Remove attack options when not attacker<br>Remove take options when not collector"
|
||||||
)
|
)
|
||||||
default boolean removeHealWrongFood() { return false; }
|
default boolean removeHealWrongFood()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,16 +27,17 @@ package net.runelite.client.plugins.batools;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import net.runelite.api.NPCComposition;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.NPCComposition;
|
||||||
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
||||||
public class BAToolsOverlay extends Overlay
|
public class BAToolsOverlay extends Overlay
|
||||||
@@ -52,16 +53,14 @@ public class BAToolsOverlay extends Overlay
|
|||||||
private static final Color GRAY = new Color(158, 158, 158);
|
private static final Color GRAY = new Color(158, 158, 158);
|
||||||
|
|
||||||
private final BAToolsConfig config;
|
private final BAToolsConfig config;
|
||||||
private Client client;
|
|
||||||
private BAToolsPlugin plugin;
|
private BAToolsPlugin plugin;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BAToolsOverlay(Client client, BAToolsPlugin plugin, BAToolsConfig config)
|
public BAToolsOverlay(BAToolsPlugin plugin, BAToolsConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.client = client;
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,20 +75,7 @@ public class BAToolsOverlay extends Overlay
|
|||||||
|
|
||||||
for (Healer healer : plugin.getHealers().values())
|
for (Healer healer : plugin.getHealers().values())
|
||||||
{
|
{
|
||||||
NPCComposition composition = healer.getNpc().getComposition();
|
Color color;
|
||||||
Color color = composition.getCombatLevel() > 1 ? YELLOW : ORANGE;
|
|
||||||
if (composition.getConfigs() != null)
|
|
||||||
{
|
|
||||||
NPCComposition transformedComposition = composition.transform();
|
|
||||||
if (transformedComposition == null)
|
|
||||||
{
|
|
||||||
color = GRAY;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
composition = transformedComposition;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int timeLeft = healer.getLastFoodTime() - (int) Duration.between(plugin.getWave_start(), Instant.now()).getSeconds();
|
int timeLeft = healer.getLastFoodTime() - (int) Duration.between(plugin.getWave_start(), Instant.now()).getSeconds();
|
||||||
timeLeft = timeLeft < 1 ? 0 : timeLeft;
|
timeLeft = timeLeft < 1 ? 0 : timeLeft;
|
||||||
|
|
||||||
@@ -118,7 +104,6 @@ public class BAToolsOverlay extends Overlay
|
|||||||
timeLeft);
|
timeLeft);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
OverlayUtil.renderActorOverlay(graphics, healer.getNpc(), text, color);
|
OverlayUtil.renderActorOverlay(graphics, healer.getNpc(), text, color);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -24,18 +24,16 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.batools;
|
package net.runelite.client.plugins.batools;
|
||||||
|
|
||||||
import net.runelite.api.Item;
|
|
||||||
import net.runelite.api.Prayer;
|
|
||||||
import net.runelite.api.SoundEffectID;
|
|
||||||
import net.runelite.api.Tile;
|
|
||||||
import net.runelite.api.kit.KitType;
|
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -47,6 +45,8 @@ import net.runelite.api.ItemID;
|
|||||||
import net.runelite.api.MenuEntry;
|
import net.runelite.api.MenuEntry;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.NpcID;
|
import net.runelite.api.NpcID;
|
||||||
|
import net.runelite.api.Prayer;
|
||||||
|
import net.runelite.api.SoundEffectID;
|
||||||
import net.runelite.api.Varbits;
|
import net.runelite.api.Varbits;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.ChatMessage;
|
||||||
@@ -65,6 +65,7 @@ import net.runelite.api.widgets.WidgetID;
|
|||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
import net.runelite.client.chat.ChatMessageManager;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.input.KeyListener;
|
import net.runelite.client.input.KeyListener;
|
||||||
import net.runelite.client.input.KeyManager;
|
import net.runelite.client.input.KeyManager;
|
||||||
@@ -85,9 +86,9 @@ import org.apache.commons.lang3.ArrayUtils;
|
|||||||
)
|
)
|
||||||
public class BAToolsPlugin extends Plugin implements KeyListener
|
public class BAToolsPlugin extends Plugin implements KeyListener
|
||||||
{
|
{
|
||||||
int inGameBit = 0;
|
private int inGameBit = 0;
|
||||||
int tickNum;
|
private int tickNum;
|
||||||
int pastCall = 0;
|
private int pastCall = 0;
|
||||||
private int currentWave = 1;
|
private int currentWave = 1;
|
||||||
private static final int BA_WAVE_NUM_INDEX = 2;
|
private static final int BA_WAVE_NUM_INDEX = 2;
|
||||||
private final List<MenuEntry> entries = new ArrayList<>();
|
private final List<MenuEntry> entries = new ArrayList<>();
|
||||||
@@ -100,12 +101,6 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
|||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ConfigManager configManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ChatMessageManager chatMessageManager;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private OverlayManager overlayManager;
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
@@ -165,19 +160,15 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onWidgetLoaded(WidgetLoaded event)
|
public void onWidgetLoaded(WidgetLoaded event)
|
||||||
{
|
{
|
||||||
switch (event.getGroupId())
|
if (event.getGroupId() == WidgetID.BA_REWARD_GROUP_ID)
|
||||||
{
|
|
||||||
case WidgetID.BA_REWARD_GROUP_ID:
|
|
||||||
{
|
{
|
||||||
Widget rewardWidget = client.getWidget(WidgetInfo.BA_REWARD_TEXT);
|
Widget rewardWidget = client.getWidget(WidgetInfo.BA_REWARD_TEXT);
|
||||||
|
|
||||||
if (rewardWidget != null && rewardWidget.getText().contains("<br>5"))
|
if (rewardWidget != null && rewardWidget.getText().contains("<br>5"))
|
||||||
{
|
{
|
||||||
tickNum = 0;
|
tickNum = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameTick(GameTick event)
|
public void onGameTick(GameTick event)
|
||||||
@@ -210,7 +201,6 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
|||||||
counter.setCount(tickNum);
|
counter.setCount(tickNum);
|
||||||
if (config.defTimer())
|
if (config.defTimer())
|
||||||
{
|
{
|
||||||
//log.info("" + tickNum++);
|
|
||||||
tickNum++;
|
tickNum++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -354,7 +344,6 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
|||||||
{
|
{
|
||||||
int spawnNumber = healers.size();
|
int spawnNumber = healers.size();
|
||||||
healers.put(npc, new Healer(npc, spawnNumber, currentWave));
|
healers.put(npc, new Healer(npc, spawnNumber, currentWave));
|
||||||
//log.info("spawn number: " + spawnNumber + " on wave " + currentWave);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -392,13 +381,13 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
|||||||
{
|
{
|
||||||
Actor opponent = event.getTarget();
|
Actor opponent = event.getTarget();
|
||||||
|
|
||||||
if (opponent != null && opponent instanceof NPC && isNpcHealer(((NPC) opponent).getId()) && event.getSource() != client.getLocalPlayer())
|
if (opponent instanceof NPC && isNpcHealer(((NPC) opponent).getId()) && event.getSource() != client.getLocalPlayer())
|
||||||
{
|
{
|
||||||
lastInteracted = opponent;
|
lastInteracted = opponent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNpcHealer(int npcId)
|
private static boolean isNpcHealer(int npcId)
|
||||||
{
|
{
|
||||||
return npcId == NpcID.PENANCE_HEALER ||
|
return npcId == NpcID.PENANCE_HEALER ||
|
||||||
npcId == NpcID.PENANCE_HEALER_5766 ||
|
npcId == NpcID.PENANCE_HEALER_5766 ||
|
||||||
@@ -439,7 +428,7 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
|||||||
if (correctCall != null) //&& callWidget.getTextColor()==16316664)
|
if (correctCall != null) //&& callWidget.getTextColor()==16316664)
|
||||||
{
|
{
|
||||||
entries.add(correctCall);
|
entries.add(correctCall);
|
||||||
client.setMenuEntries(entries.toArray(new MenuEntry[entries.size()]));
|
client.setMenuEntries(entries.toArray(new MenuEntry[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,19 +446,26 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
|||||||
if (itemId == ItemID.LOGS && !target.contains("healing vial"))
|
if (itemId == ItemID.LOGS && !target.contains("healing vial"))
|
||||||
{
|
{
|
||||||
if (client.getWidget(WidgetInfo.BA_DEF_ROLE_TEXT) == null)
|
if (client.getWidget(WidgetInfo.BA_DEF_ROLE_TEXT) == null)
|
||||||
|
{
|
||||||
remove(new String[]{"take", "light"}, target, true);
|
remove(new String[]{"take", "light"}, target, true);
|
||||||
|
}
|
||||||
else//remove "Light" option (and "Take" option if not defender).
|
else//remove "Light" option (and "Take" option if not defender).
|
||||||
|
{
|
||||||
remove("light", target, true);
|
remove("light", target, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (option.equals("use"))
|
else if (option.equals("use"))
|
||||||
{
|
{
|
||||||
if (config.removeHealWrongFood()) {
|
if (config.removeHealWrongFood())
|
||||||
|
{
|
||||||
Widget healer = client.getWidget(WidgetInfo.BA_HEAL_LISTEN_TEXT);
|
Widget healer = client.getWidget(WidgetInfo.BA_HEAL_LISTEN_TEXT);
|
||||||
if (healer != null) {
|
if (healer != null)
|
||||||
|
{
|
||||||
String item = target.split("-")[0].trim();
|
String item = target.split("-")[0].trim();
|
||||||
List<String> poison = Arrays.asList("poisoned tofu", "poisoned meat", "poisoned worms");
|
List<String> poison = Arrays.asList("poisoned tofu", "poisoned meat", "poisoned worms");
|
||||||
List<String> vials = Arrays.asList("healing vial", "healing vial(1)", "healing vial(2)", "healing vial(3)", "healing vial(4)");//"healing vial(4)"
|
List<String> vials = Arrays.asList("healing vial", "healing vial(1)", "healing vial(2)", "healing vial(3)", "healing vial(4)");//"healing vial(4)"
|
||||||
if (poison.contains(item)) {//if item is a poison item
|
if (poison.contains(item))
|
||||||
|
{//if item is a poison item
|
||||||
int calledPoison = 0;
|
int calledPoison = 0;
|
||||||
switch (healer.getText())//choose which poison to hide the use/destroy option for
|
switch (healer.getText())//choose which poison to hide the use/destroy option for
|
||||||
{
|
{
|
||||||
@@ -490,10 +486,13 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
|||||||
{
|
{
|
||||||
remove(new String[]{"use", "destroy", "examine"}, target, true);//remove options
|
remove(new String[]{"use", "destroy", "examine"}, target, true);//remove options
|
||||||
}
|
}
|
||||||
} else if (!target.contains("penance healer")) {
|
}
|
||||||
|
else if (!target.contains("penance healer"))
|
||||||
|
{
|
||||||
remove(option, target, true);
|
remove(option, target, true);
|
||||||
}
|
}
|
||||||
} else if (vials.contains(item))//if item is the healer's healing vial
|
}
|
||||||
|
else if (vials.contains(item))//if item is the healer's healing vial
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!target.equals(item))//if target is not the vial itself
|
if (!target.equals(item))//if target is not the vial itself
|
||||||
@@ -586,7 +585,7 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
|||||||
if (client.getWidget(WidgetInfo.BA_COLL_LISTEN_TEXT) != null && inGameBit == 1 && config.eggBoi() && event.getTarget().endsWith("egg") && shiftDown)
|
if (client.getWidget(WidgetInfo.BA_COLL_LISTEN_TEXT) != null && inGameBit == 1 && config.eggBoi() && event.getTarget().endsWith("egg") && shiftDown)
|
||||||
{
|
{
|
||||||
String[] currentCall = client.getWidget(WidgetInfo.BA_COLL_LISTEN_TEXT).getText().split(" ");
|
String[] currentCall = client.getWidget(WidgetInfo.BA_COLL_LISTEN_TEXT).getText().split(" ");
|
||||||
//log.info("1 " + currentCall[0]);
|
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||||
MenuEntry correctEgg = null;
|
MenuEntry correctEgg = null;
|
||||||
entries.clear();
|
entries.clear();
|
||||||
@@ -606,7 +605,7 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
|||||||
{
|
{
|
||||||
entries.add(correctEgg);
|
entries.add(correctEgg);
|
||||||
}
|
}
|
||||||
client.setMenuEntries(entries.toArray(new MenuEntry[entries.size()]));
|
client.setMenuEntries(entries.toArray(new MenuEntry[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client.getWidget(WidgetInfo.BA_HEAL_LISTEN_TEXT) != null && inGameBit == 1 && config.osHelp() && event.getTarget().equals("<col=ffff>Healer item machine") && shiftDown)
|
if (client.getWidget(WidgetInfo.BA_HEAL_LISTEN_TEXT) != null && inGameBit == 1 && config.osHelp() && event.getTarget().equals("<col=ffff>Healer item machine") && shiftDown)
|
||||||
@@ -711,12 +710,14 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
|||||||
private void remove(String[] options, String target, boolean strict)
|
private void remove(String[] options, String target, boolean strict)
|
||||||
{
|
{
|
||||||
MenuEntry[] entries = client.getMenuEntries();
|
MenuEntry[] entries = client.getMenuEntries();
|
||||||
for(int i = 0; i < options.length; i++)
|
for (String option : options)
|
||||||
{
|
{
|
||||||
int idx = searchIndex(entries, options[i], target, strict);
|
int idx = searchIndex(entries, option, target, strict);
|
||||||
if (idx >= 0 && entries[idx] != null)
|
if (idx >= 0 && entries[idx] != null)
|
||||||
|
{
|
||||||
entries = ArrayUtils.removeElement(entries, entries[idx]);
|
entries = ArrayUtils.removeElement(entries, entries[idx]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
client.setMenuEntries(entries);
|
client.setMenuEntries(entries);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ import net.runelite.client.ui.overlay.infobox.Counter;
|
|||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
public class CycleCounter extends Counter
|
class CycleCounter extends Counter
|
||||||
{
|
{
|
||||||
public CycleCounter(BufferedImage img, Plugin plugin, int tick)
|
CycleCounter(BufferedImage img, Plugin plugin, int tick)
|
||||||
{
|
{
|
||||||
super(img, plugin, tick);
|
super(img, plugin, tick);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user