From 6a23898699d033c71c6c7364c219cf11c1912fb4 Mon Sep 17 00:00:00 2001 From: Scott Burns Date: Thu, 16 May 2019 01:36:04 +0200 Subject: [PATCH] Refactor other BA --- .../client/plugins/batools/BAToolsConfig.java | 105 ++++++----- .../plugins/batools/BAToolsOverlay.java | 43 ++--- .../client/plugins/batools/BAToolsPlugin.java | 173 +++++++++--------- .../client/plugins/batools/CycleCounter.java | 4 +- 4 files changed, 160 insertions(+), 165 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsConfig.java index c8747828f9..961eda4030 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsConfig.java @@ -32,9 +32,9 @@ import net.runelite.client.config.ConfigItem; public interface BAToolsConfig extends Config { @ConfigItem( - keyName = "defTimer", - name = "Defender Tick Timer", - description = "Shows the current cycle tick of runners." + keyName = "defTimer", + name = "Defender Tick Timer", + description = "Shows the current cycle tick of runners." ) default boolean defTimer() { @@ -42,9 +42,9 @@ public interface BAToolsConfig extends Config } @ConfigItem( - keyName = "calls", - name = "Remove Incorrect Calls", - description = "Remove incorrect calls." + keyName = "calls", + name = "Remove Incorrect Calls", + description = "Remove incorrect calls." ) default boolean calls() { @@ -52,9 +52,9 @@ public interface BAToolsConfig extends Config } @ConfigItem( - keyName = "swapLadder", - name = "Swap ladder option", - description = "Swap Climb-down with Quick-start in the wave lobbies" + keyName = "swapLadder", + name = "Swap ladder option", + description = "Swap Climb-down with Quick-start in the wave lobbies" ) default boolean swapLadder() { @@ -62,9 +62,9 @@ public interface BAToolsConfig extends Config } @ConfigItem( - keyName = "healerCodes", - name = "Healer Codes", - description = "Overlay to show healer codes" + keyName = "healerCodes", + name = "Healer Codes", + description = "Overlay to show healer codes" ) default boolean healerCodes() { @@ -72,9 +72,9 @@ public interface BAToolsConfig extends Config } @ConfigItem( - keyName = "healerMenuOption", - name = "Healer menu options", - description = "asd" + keyName = "healerMenuOption", + name = "Healer menu options", + description = "asd" ) default boolean healerMenuOption() { @@ -82,9 +82,9 @@ public interface BAToolsConfig extends Config } @ConfigItem( - keyName = "antiDrag", - name = "Anti Drag", - description = "asd" + keyName = "antiDrag", + name = "Anti Drag", + description = "asd" ) default boolean antiDrag() { @@ -92,9 +92,9 @@ public interface BAToolsConfig extends Config } @ConfigItem( - keyName = "antiDragDelay", - name = "Anti Drag Delay", - description = "asd" + keyName = "antiDragDelay", + name = "Anti Drag Delay", + description = "asd" ) default int antiDragDelay() { @@ -102,9 +102,9 @@ public interface BAToolsConfig extends Config } @ConfigItem( - keyName = "eggBoi", - name = "Collector helper", - description = "asd" + keyName = "eggBoi", + name = "Collector helper", + description = "asd" ) default boolean eggBoi() { @@ -112,9 +112,9 @@ public interface BAToolsConfig extends Config } @ConfigItem( - keyName = "osHelp", - name = "Shift OS", - description = "asd" + keyName = "osHelp", + name = "Shift OS", + description = "asd" ) default boolean osHelp() { @@ -122,9 +122,9 @@ public interface BAToolsConfig extends Config } @ConfigItem( - keyName = "prayerMetronome", - name = "Prayer Metronome", - description = "asd" + keyName = "prayerMetronome", + name = "Prayer Metronome", + description = "asd" ) default boolean prayerMetronome() { @@ -132,9 +132,9 @@ public interface BAToolsConfig extends Config } @ConfigItem( - keyName = "prayerMetronomeVolume", - name = "Prayer Metronome Volume", - description = "asd" + keyName = "prayerMetronomeVolume", + name = "Prayer Metronome Volume", + description = "asd" ) default int prayerMetronomeVolume() { @@ -142,9 +142,9 @@ public interface BAToolsConfig extends Config } @ConfigItem( - keyName = "attackStyles", - name = "Attack Styles", - description = "Hide attack styles depending on weapon." + keyName = "attackStyles", + name = "Attack Styles", + description = "Hide attack styles depending on weapon." ) default boolean attackStyles() { @@ -152,24 +152,33 @@ public interface BAToolsConfig extends Config } @ConfigItem( - keyName = "removeBA", - name = "*Barbarian Assault Helper*", - description = "Remove unnecessary menu options in Barbarian Assault depending on role
Examples: Remove attack options when not attacker
Remove take options when not collector" + keyName = "removeBA", + name = "*Barbarian Assault Helper*", + description = "Remove unnecessary menu options in Barbarian Assault depending on role
Examples: Remove attack options when not attacker
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
Examples: Remove attack options when not attacker
Remove take options when not collector" + keyName = "removeWrongEggs", + name = "Remove wrong eggs - *Barbarian Assault Helper*", + description = "Remove unnecessary menu options in Barbarian Assault depending on role
Examples: Remove attack options when not attacker
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
Examples: Remove attack options when not attacker
Remove take options when not collector" + keyName = "removeWrongHealFood", + name = "Remove wrong Heal Food - *Barbarian Assault Helper*", + description = "Remove unnecessary menu options in Barbarian Assault depending on role
Examples: Remove attack options when not attacker
Remove take options when not collector" ) - default boolean removeHealWrongFood() { return false; } + default boolean removeHealWrongFood() + { + return false; + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsOverlay.java index 083945d9b6..f200ae5272 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsOverlay.java @@ -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; } @@ -69,37 +68,24 @@ public class BAToolsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if(!config.healerCodes()) + if (!config.healerCodes()) { return null; } 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; - } - } - int timeLeft = healer.getLastFoodTime() - (int)Duration.between(plugin.getWave_start(), Instant.now()).getSeconds(); + Color color; + int timeLeft = healer.getLastFoodTime() - (int) Duration.between(plugin.getWave_start(), Instant.now()).getSeconds(); timeLeft = timeLeft < 1 ? 0 : timeLeft; - if(healer.getFoodRemaining() > 1) + if (healer.getFoodRemaining() > 1) { color = GREEN; } - else if(healer.getFoodRemaining() == 1) + else if (healer.getFoodRemaining() == 1) { - if(timeLeft > 0) + if (timeLeft > 0) { color = RED; } @@ -118,7 +104,6 @@ public class BAToolsOverlay extends Overlay timeLeft); - OverlayUtil.renderActorOverlay(graphics, healer.getNpc(), text, color); } return null; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsPlugin.java index ebc17a3421..b44af32f56 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsPlugin.java @@ -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; @@ -78,16 +79,16 @@ import org.apache.commons.lang3.ArrayUtils; @Slf4j @PluginDescriptor( - name = "BA Tools", - description = "Custom tools for Barbarian Assault", - tags = {"minigame", "overlay", "timer"}, - type = PluginType.PVM + name = "BA Tools", + description = "Custom tools for Barbarian Assault", + tags = {"minigame", "overlay", "timer"}, + type = PluginType.PVM ) 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 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,16 +160,12 @@ public class BAToolsPlugin extends Plugin implements KeyListener @Subscribe 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); + if (rewardWidget != null && rewardWidget.getText().contains("
5")) { - Widget rewardWidget = client.getWidget(WidgetInfo.BA_REWARD_TEXT); - - if (rewardWidget != null && rewardWidget.getText().contains("
5")) - { - tickNum = 0; - } + tickNum = 0; } } } @@ -210,38 +201,37 @@ public class BAToolsPlugin extends Plugin implements KeyListener counter.setCount(tickNum); if (config.defTimer()) { - //log.info("" + tickNum++); tickNum++; } } Widget weapon = client.getWidget(593, 1); - if(config.attackStyles() - && weapon!=null - && inGameBit == 1 - && weapon.getText().contains("Crystal halberd") || weapon.getText().contains("Dragon claws") - && client.getWidget(WidgetInfo.BA_ATK_LISTEN_TEXT)!=null) + if (config.attackStyles() + && weapon != null + && inGameBit == 1 + && weapon.getText().contains("Crystal halberd") || weapon.getText().contains("Dragon claws") + && client.getWidget(WidgetInfo.BA_ATK_LISTEN_TEXT) != null) { String style = client.getWidget(WidgetInfo.BA_ATK_LISTEN_TEXT).getText(); - if(style.contains("Defensive")) + if (style.contains("Defensive")) { client.getWidget(WidgetInfo.COMBAT_STYLE_ONE).setHidden(true); client.getWidget(WidgetInfo.COMBAT_STYLE_TWO).setHidden(true); client.getWidget(WidgetInfo.COMBAT_STYLE_THREE).setHidden(true); client.getWidget(WidgetInfo.COMBAT_STYLE_FOUR).setHidden(false); } - else if(style.contains("Aggressive")) + else if (style.contains("Aggressive")) { client.getWidget(WidgetInfo.COMBAT_STYLE_ONE).setHidden(true); client.getWidget(WidgetInfo.COMBAT_STYLE_TWO).setHidden(false); client.getWidget(WidgetInfo.COMBAT_STYLE_THREE).setHidden(true); client.getWidget(WidgetInfo.COMBAT_STYLE_FOUR).setHidden(true); } - else if(style.contains("Controlled")) + else if (style.contains("Controlled")) { - if(weapon.getText().contains("Crystal halberd")) + if (weapon.getText().contains("Crystal halberd")) { client.getWidget(WidgetInfo.COMBAT_STYLE_ONE).setHidden(false); client.getWidget(WidgetInfo.COMBAT_STYLE_THREE).setHidden(true); @@ -254,7 +244,7 @@ public class BAToolsPlugin extends Plugin implements KeyListener client.getWidget(WidgetInfo.COMBAT_STYLE_TWO).setHidden(true); client.getWidget(WidgetInfo.COMBAT_STYLE_FOUR).setHidden(true); } - else if(style.contains("Accurate") && weapon.getText().contains("Dragon claws")) + else if (style.contains("Accurate") && weapon.getText().contains("Dragon claws")) { client.getWidget(WidgetInfo.COMBAT_STYLE_ONE).setHidden(false); client.getWidget(WidgetInfo.COMBAT_STYLE_TWO).setHidden(true); @@ -278,9 +268,9 @@ public class BAToolsPlugin extends Plugin implements KeyListener client.getWidget(WidgetInfo.COMBAT_STYLE_FOUR).setHidden(false); } - if(config.prayerMetronome() && isAnyPrayerActive()) + if (config.prayerMetronome() && isAnyPrayerActive()) { - for(int i = 0; i < config.prayerMetronomeVolume(); i++) + for (int i = 0; i < config.prayerMetronomeVolume(); i++) { client.playSoundEffect(SoundEffectID.GE_INCREMENT_PLOP); } @@ -334,7 +324,7 @@ public class BAToolsPlugin extends Plugin implements KeyListener public void onChatMessage(ChatMessage event) { if (event.getType() == ChatMessageType.GAMEMESSAGE - && event.getMessage().startsWith("---- Wave:")) + && event.getMessage().startsWith("---- Wave:")) { String[] message = event.getMessage().split(" "); currentWave = Integer.parseInt(message[BA_WAVE_NUM_INDEX]); @@ -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,24 +381,24 @@ 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 || - npcId == NpcID.PENANCE_HEALER_5767 || - npcId == NpcID.PENANCE_HEALER_5768 || - npcId == NpcID.PENANCE_HEALER_5769 || - npcId == NpcID.PENANCE_HEALER_5770 || - npcId == NpcID.PENANCE_HEALER_5771 || - npcId == NpcID.PENANCE_HEALER_5772 || - npcId == NpcID.PENANCE_HEALER_5773 || - npcId == NpcID.PENANCE_HEALER_5774; + npcId == NpcID.PENANCE_HEALER_5766 || + npcId == NpcID.PENANCE_HEALER_5767 || + npcId == NpcID.PENANCE_HEALER_5768 || + npcId == NpcID.PENANCE_HEALER_5769 || + npcId == NpcID.PENANCE_HEALER_5770 || + npcId == NpcID.PENANCE_HEALER_5771 || + npcId == NpcID.PENANCE_HEALER_5772 || + npcId == NpcID.PENANCE_HEALER_5773 || + npcId == NpcID.PENANCE_HEALER_5774; } @Subscribe @@ -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])); } } @@ -452,24 +441,31 @@ public class BAToolsPlugin extends Plugin implements KeyListener { swap("quick-start", option, target, true); } - else if(config.removeBA() && client.getVar(Varbits.IN_GAME_BA) == 1 && !option.contains("tell-"))//if in barbarian assault and menu isnt from a horn + else if (config.removeBA() && client.getVar(Varbits.IN_GAME_BA) == 1 && !option.contains("tell-"))//if in barbarian assault and menu isnt from a horn { - 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); + } else//remove "Light" option (and "Take" option if not defender). + { 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); - if (healer != null) { + if (healer != null) + { String item = target.split("-")[0].trim(); List poison = Arrays.asList("poisoned tofu", "poisoned meat", "poisoned worms"); List 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 @@ -508,26 +507,26 @@ public class BAToolsPlugin extends Plugin implements KeyListener } } } - else if(option.equals("attack") && client.getWidget(WidgetInfo.BA_ATK_ROLE_TEXT) == null && !target.equals("queen spawn"))//if not attacker + else if (option.equals("attack") && client.getWidget(WidgetInfo.BA_ATK_ROLE_TEXT) == null && !target.equals("queen spawn"))//if not attacker {//remove attack option from everything but queen spawns remove(option, target, true); } - else if((option.equals("fix") || (option.equals("block") && target.equals("penance cave"))) && client.getWidget(WidgetInfo.BA_DEF_ROLE_TEXT) == null)//if not defender + else if ((option.equals("fix") || (option.equals("block") && target.equals("penance cave"))) && client.getWidget(WidgetInfo.BA_DEF_ROLE_TEXT) == null)//if not defender {//the check for option requires checking target as well because defensive attack style option is also called "block". remove(option, target, true); } - else if((option.equals("load")) && client.getWidget(WidgetInfo.BA_COLL_ROLE_TEXT) == null)//if not collector, remove hopper options + else if ((option.equals("load")) && client.getWidget(WidgetInfo.BA_COLL_ROLE_TEXT) == null)//if not collector, remove hopper options { remove(new String[]{option, "look-in"}, target, true); } - else if(config.removeWrongEggs() && option.equals("take")) + else if (config.removeWrongEggs() && option.equals("take")) { Widget eggToColl = client.getWidget(WidgetInfo.BA_COLL_LISTEN_TEXT); - if(eggToColl != null)//if we're a collector + if (eggToColl != null)//if we're a collector { List eggsToHide = new ArrayList<>(); eggsToHide.add(ItemID.HAMMER); - switch(eggToColl.getText())//choose which eggs to hide take option for + switch (eggToColl.getText())//choose which eggs to hide take option for { case "Red eggs": eggsToHide.add(ItemID.BLUE_EGG); @@ -542,7 +541,7 @@ public class BAToolsPlugin extends Plugin implements KeyListener eggsToHide.add(ItemID.BLUE_EGG); break; } - if(eggsToHide.contains(itemId)) + if (eggsToHide.contains(itemId)) { remove(option, target, true);//hide wrong eggs } @@ -550,7 +549,7 @@ public class BAToolsPlugin extends Plugin implements KeyListener else { List defenderItems = Arrays.asList(ItemID.HAMMER, ItemID.TOFU, ItemID.CRACKERS, ItemID.WORMS);//logs are handled separately due to hiding "light" option too. - if(client.getWidget(WidgetInfo.BA_DEF_ROLE_TEXT) == null || !defenderItems.contains(itemId))//if not defender, or item is not a defenderItem + if (client.getWidget(WidgetInfo.BA_DEF_ROLE_TEXT) == null || !defenderItems.contains(itemId))//if not defender, or item is not a defenderItem { remove(option, target, true);//hide everything except hammer/logs and bait if Defender } @@ -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("Healer item machine") && shiftDown) @@ -650,8 +649,8 @@ public class BAToolsPlugin extends Plugin implements KeyListener String target = event.getMenuTarget(); if ((currentCall.equals("Pois. Worms") && (target.contains("Poisoned worms") && target.contains("->") && target.contains("Penance Healer"))) - || (currentCall.equals("Pois. Meat") && (target.contains("Poisoned meat") && target.contains("->") && target.contains("Penance Healer"))) - || (currentCall.equals("Pois. Tofu") && (target.contains("Poisoned tofu") && target.contains("->") && target.contains("Penance Healer")))) + || (currentCall.equals("Pois. Meat") && (target.contains("Poisoned meat") && target.contains("->") && target.contains("Penance Healer"))) + || (currentCall.equals("Pois. Tofu") && (target.contains("Poisoned tofu") && target.contains("->") && target.contains("Penance Healer")))) { foodPressed.put(event.getId(), Instant.now()); } @@ -701,7 +700,7 @@ public class BAToolsPlugin extends Plugin implements KeyListener { MenuEntry[] entries = client.getMenuEntries(); 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]); client.setMenuEntries(entries); @@ -711,11 +710,13 @@ 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); - if(idx >= 0 && entries[idx] != null) + int idx = searchIndex(entries, option, target, strict); + if (idx >= 0 && entries[idx] != null) + { entries = ArrayUtils.removeElement(entries, entries[idx]); + } } client.setMenuEntries(entries); @@ -792,9 +793,9 @@ public class BAToolsPlugin extends Plugin implements KeyListener // world point of the tile marker WorldPoint worldPoint = new WorldPoint( - ((regionId >>> 8) << 6) + regionX, - ((regionId & 0xff) << 6) + regionY, - z + ((regionId >>> 8) << 6) + regionX, + ((regionId & 0xff) << 6) + regionY, + z ); int[][][] instanceTemplateChunks = client.getInstanceTemplateChunks(); @@ -807,11 +808,11 @@ public class BAToolsPlugin extends Plugin implements KeyListener int templateChunkY = (chunkData >> 3 & 0x7FF) * CHUNK_SIZE; int templateChunkX = (chunkData >> 14 & 0x3FF) * CHUNK_SIZE; if (worldPoint.getX() >= templateChunkX && worldPoint.getX() < templateChunkX + CHUNK_SIZE - && worldPoint.getY() >= templateChunkY && worldPoint.getY() < templateChunkY + CHUNK_SIZE) + && worldPoint.getY() >= templateChunkY && worldPoint.getY() < templateChunkY + CHUNK_SIZE) { WorldPoint p = new WorldPoint(client.getBaseX() + x * CHUNK_SIZE + (worldPoint.getX() & (CHUNK_SIZE - 1)), - client.getBaseY() + y * CHUNK_SIZE + (worldPoint.getY() & (CHUNK_SIZE - 1)), - worldPoint.getPlane()); + client.getBaseY() + y * CHUNK_SIZE + (worldPoint.getY() & (CHUNK_SIZE - 1)), + worldPoint.getPlane()); p = rotate(p, rotation); if (p.distanceTo(npc.getWorldLocation()) < 5) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/batools/CycleCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/batools/CycleCounter.java index 3cf2c6b3ec..af7dd4e57f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/batools/CycleCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/batools/CycleCounter.java @@ -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); }