Refactor other BA
This commit is contained in:
@@ -156,20 +156,29 @@ public interface BAToolsConfig extends Config
|
||||
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"
|
||||
)
|
||||
default boolean removeBA() { return true; }
|
||||
default boolean removeBA()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "removeWrongEggs",
|
||||
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"
|
||||
)
|
||||
default boolean removeWrongEggs() { return false; }
|
||||
default boolean removeWrongEggs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "removeWrongHealFood",
|
||||
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"
|
||||
)
|
||||
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.Dimension;
|
||||
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.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.OverlayPosition;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
|
||||
@Slf4j
|
||||
|
||||
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 final BAToolsConfig config;
|
||||
private Client client;
|
||||
private BAToolsPlugin plugin;
|
||||
|
||||
@Inject
|
||||
public BAToolsOverlay(Client client, BAToolsPlugin plugin, BAToolsConfig config)
|
||||
public BAToolsOverlay(BAToolsPlugin plugin, BAToolsConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||
this.config = config;
|
||||
this.client = client;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -76,20 +75,7 @@ public class BAToolsOverlay extends Overlay
|
||||
|
||||
for (Healer healer : plugin.getHealers().values())
|
||||
{
|
||||
NPCComposition composition = healer.getNpc().getComposition();
|
||||
Color color = composition.getCombatLevel() > 1 ? YELLOW : ORANGE;
|
||||
if (composition.getConfigs() != null)
|
||||
{
|
||||
NPCComposition transformedComposition = composition.transform();
|
||||
if (transformedComposition == null)
|
||||
{
|
||||
color = GRAY;
|
||||
}
|
||||
else
|
||||
{
|
||||
composition = transformedComposition;
|
||||
}
|
||||
}
|
||||
Color color;
|
||||
int timeLeft = healer.getLastFoodTime() - (int) Duration.between(plugin.getWave_start(), Instant.now()).getSeconds();
|
||||
timeLeft = timeLeft < 1 ? 0 : timeLeft;
|
||||
|
||||
@@ -118,7 +104,6 @@ public class BAToolsOverlay extends Overlay
|
||||
timeLeft);
|
||||
|
||||
|
||||
|
||||
OverlayUtil.renderActorOverlay(graphics, healer.getNpc(), text, color);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -24,18 +24,16 @@
|
||||
*/
|
||||
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 java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.time.Duration;
|
||||
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 lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -47,6 +45,8 @@ import net.runelite.api.ItemID;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.NpcID;
|
||||
import net.runelite.api.Prayer;
|
||||
import net.runelite.api.SoundEffectID;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
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.client.chat.ChatMessageManager;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.input.KeyListener;
|
||||
import net.runelite.client.input.KeyManager;
|
||||
@@ -85,9 +86,9 @@ import org.apache.commons.lang3.ArrayUtils;
|
||||
)
|
||||
public class BAToolsPlugin extends Plugin implements KeyListener
|
||||
{
|
||||
int inGameBit = 0;
|
||||
int tickNum;
|
||||
int pastCall = 0;
|
||||
private int inGameBit = 0;
|
||||
private int tickNum;
|
||||
private int pastCall = 0;
|
||||
private int currentWave = 1;
|
||||
private static final int BA_WAVE_NUM_INDEX = 2;
|
||||
private final List<MenuEntry> entries = new ArrayList<>();
|
||||
@@ -100,12 +101,6 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private ConfigManager configManager;
|
||||
|
||||
@Inject
|
||||
private ChatMessageManager chatMessageManager;
|
||||
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@@ -165,19 +160,15 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
||||
@Subscribe
|
||||
public void onWidgetLoaded(WidgetLoaded event)
|
||||
{
|
||||
switch (event.getGroupId())
|
||||
{
|
||||
case WidgetID.BA_REWARD_GROUP_ID:
|
||||
if (event.getGroupId() == WidgetID.BA_REWARD_GROUP_ID)
|
||||
{
|
||||
Widget rewardWidget = client.getWidget(WidgetInfo.BA_REWARD_TEXT);
|
||||
|
||||
if (rewardWidget != null && rewardWidget.getText().contains("<br>5"))
|
||||
{
|
||||
tickNum = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick event)
|
||||
@@ -210,7 +201,6 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
||||
counter.setCount(tickNum);
|
||||
if (config.defTimer())
|
||||
{
|
||||
//log.info("" + tickNum++);
|
||||
tickNum++;
|
||||
}
|
||||
}
|
||||
@@ -354,7 +344,6 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
||||
{
|
||||
int spawnNumber = healers.size();
|
||||
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();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isNpcHealer(int npcId)
|
||||
private static boolean isNpcHealer(int npcId)
|
||||
{
|
||||
return npcId == NpcID.PENANCE_HEALER ||
|
||||
npcId == NpcID.PENANCE_HEALER_5766 ||
|
||||
@@ -439,7 +428,7 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
||||
if (correctCall != null) //&& callWidget.getTextColor()==16316664)
|
||||
{
|
||||
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 (client.getWidget(WidgetInfo.BA_DEF_ROLE_TEXT) == null)
|
||||
{
|
||||
remove(new String[]{"take", "light"}, target, true);
|
||||
}
|
||||
else//remove "Light" option (and "Take" option if not defender).
|
||||
{
|
||||
remove("light", target, true);
|
||||
}
|
||||
}
|
||||
else if (option.equals("use"))
|
||||
{
|
||||
if (config.removeHealWrongFood()) {
|
||||
if (config.removeHealWrongFood())
|
||||
{
|
||||
Widget healer = client.getWidget(WidgetInfo.BA_HEAL_LISTEN_TEXT);
|
||||
if (healer != null) {
|
||||
if (healer != null)
|
||||
{
|
||||
String item = target.split("-")[0].trim();
|
||||
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)"
|
||||
if (poison.contains(item)) {//if item is a poison item
|
||||
if (poison.contains(item))
|
||||
{//if item is a poison item
|
||||
int calledPoison = 0;
|
||||
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
|
||||
}
|
||||
} else if (!target.contains("penance healer")) {
|
||||
}
|
||||
else if (!target.contains("penance healer"))
|
||||
{
|
||||
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
|
||||
@@ -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)
|
||||
{
|
||||
String[] currentCall = client.getWidget(WidgetInfo.BA_COLL_LISTEN_TEXT).getText().split(" ");
|
||||
//log.info("1 " + currentCall[0]);
|
||||
|
||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||
MenuEntry correctEgg = null;
|
||||
entries.clear();
|
||||
@@ -606,7 +605,7 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
||||
{
|
||||
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)
|
||||
@@ -711,12 +710,14 @@ public class BAToolsPlugin extends Plugin implements KeyListener
|
||||
private void remove(String[] options, String target, boolean strict)
|
||||
{
|
||||
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)
|
||||
{
|
||||
entries = ArrayUtils.removeElement(entries, entries[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
client.setMenuEntries(entries);
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ import net.runelite.client.ui.overlay.infobox.Counter;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user