diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsConfig.java index 663e03fbb3..fe6a657e5e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsConfig.java @@ -32,17 +32,6 @@ import net.runelite.client.config.ConfigItem; @ConfigGroup("barrows") public interface BarrowsConfig extends Config { - @ConfigItem( - keyName = "showMinimap", - name = "Show Minimap in tunnels", - description = "Configures whether or not the minimap is displayed", - position = 0 - ) - default boolean showMinimap() - { - return true; - } - @ConfigItem( keyName = "showBrotherLoc", name = "Show Brothers location", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsOverlay.java index 4ecdebccf3..d430ef0c01 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsOverlay.java @@ -28,16 +28,9 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Rectangle; -import java.util.List; import javax.inject.Inject; import net.runelite.api.Client; -import net.runelite.api.GameObject; -import net.runelite.api.NPC; -import net.runelite.api.NPCComposition; -import net.runelite.api.ObjectComposition; import net.runelite.api.Perspective; -import net.runelite.api.Player; -import net.runelite.api.WallObject; import net.runelite.api.coords.LocalPoint; import net.runelite.api.widgets.Widget; import net.runelite.client.ui.overlay.Overlay; @@ -65,59 +58,9 @@ class BarrowsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - Player local = client.getLocalPlayer(); - final Color npcColor = getMinimapDotColor(1); - final Color playerColor = getMinimapDotColor(2); Widget puzzleAnswer = plugin.getPuzzleAnswer(); - // tunnels are only on z=0 - if (!plugin.getWalls().isEmpty() && client.getPlane() == 0 && config.showMinimap()) - { - // NPC dots - graphics.setColor(npcColor); - final List npcs = client.getNpcs(); - for (NPC npc : npcs) - { - final NPCComposition composition = npc.getComposition(); - - if (composition != null && !composition.isMinimapVisible()) - { - continue; - } - - net.runelite.api.Point minimapLocation = npc.getMinimapLocation(); - if (minimapLocation != null) - { - graphics.fillOval(minimapLocation.getX(), minimapLocation.getY(), 4, 4); - } - } - - // Player dots - graphics.setColor(playerColor); - final List players = client.getPlayers(); - for (Player player : players) - { - if (player == local) - { - // Skip local player as we draw square for it later - continue; - } - - net.runelite.api.Point minimapLocation = player.getMinimapLocation(); - if (minimapLocation != null) - { - graphics.fillOval(minimapLocation.getX(), minimapLocation.getY(), 4, 4); - } - } - - // Render barrows walls/doors - renderObjects(graphics, local); - - // Local player square - graphics.setColor(playerColor); - graphics.fillRect(local.getMinimapLocation().getX(), local.getMinimapLocation().getY(), 3, 3); - } - else if (config.showBrotherLoc()) + if (config.showBrotherLoc()) { renderBarrowsBrothers(graphics); } @@ -132,81 +75,6 @@ class BarrowsOverlay extends Overlay return null; } - private void renderObjects(Graphics2D graphics, Player localPlayer) - { - LocalPoint localLocation = localPlayer.getLocalLocation(); - for (WallObject wall : plugin.getWalls()) - { - LocalPoint location = wall.getLocalLocation(); - if (localLocation.distanceTo(location) <= MAX_DISTANCE) - { - renderWalls(graphics, wall); - } - } - - for (GameObject ladder : plugin.getLadders()) - { - LocalPoint location = ladder.getLocalLocation(); - if (localLocation.distanceTo(location) <= MAX_DISTANCE) - { - renderLadders(graphics, ladder); - } - } - } - - private void renderWalls(Graphics2D graphics, WallObject wall) - { - net.runelite.api.Point minimapLocation = wall.getMinimapLocation(); - - if (minimapLocation == null) - { - return; - } - - ObjectComposition objectComp = client.getObjectDefinition(wall.getId()); - ObjectComposition impostor = objectComp.getImpostorIds() != null ? objectComp.getImpostor() : null; - - if (impostor != null && impostor.getActions()[0] != null) - { - graphics.setColor(Color.green); - } - else - { - graphics.setColor(Color.gray); - } - - graphics.fillRect(minimapLocation.getX(), minimapLocation.getY(), 3, 3); - } - - /** - * Get minimap dot color from client - * @param typeIndex index of minimap dot type (1 npcs, 2 players) - * @return color - */ - private Color getMinimapDotColor(int typeIndex) - { - final int pixel = client.getMapDots()[typeIndex].getPixels()[1]; - return new Color(pixel); - } - - private void renderLadders(Graphics2D graphics, GameObject ladder) - { - net.runelite.api.Point minimapLocation = ladder.getMinimapLocation(); - - if (minimapLocation == null) - { - return; - } - - ObjectComposition objectComp = client.getObjectDefinition(ladder.getId()); - - if (objectComp.getImpostorIds() != null && objectComp.getImpostor() != null) - { - graphics.setColor(Color.orange); - graphics.fillRect(minimapLocation.getX(), minimapLocation.getY(), 6, 6); - } - } - private void renderBarrowsBrothers(Graphics2D graphics) { for (BarrowsBrothers brother : BarrowsBrothers.values()) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsPlugin.java index 2d4db73d12..77619ba55a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsPlugin.java @@ -25,33 +25,19 @@ package net.runelite.client.plugins.barrows; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Sets; import com.google.inject.Provides; import java.time.temporal.ChronoUnit; -import java.util.HashSet; -import java.util.Set; import javax.inject.Inject; -import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; -import net.runelite.api.GameObject; import net.runelite.api.GameState; import net.runelite.api.InventoryID; import net.runelite.api.Item; import net.runelite.api.ItemContainer; -import net.runelite.api.NullObjectID; -import net.runelite.api.ObjectID; import net.runelite.api.SpriteID; -import net.runelite.api.WallObject; import net.runelite.api.events.ConfigChanged; -import net.runelite.api.events.GameObjectChanged; -import net.runelite.api.events.GameObjectDespawned; -import net.runelite.api.events.GameObjectSpawned; import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.WallObjectChanged; -import net.runelite.api.events.WallObjectDespawned; -import net.runelite.api.events.WallObjectSpawned; import net.runelite.api.events.WidgetLoaded; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetID; @@ -75,21 +61,10 @@ import net.runelite.client.util.QuantityFormatter; @PluginDescriptor( name = "Barrows Brothers", description = "Show helpful information for the Barrows minigame", - tags = {"combat", "minigame", "minimap", "bosses", "pve", "pvm"} + tags = {"combat", "minigame", "bosses", "pve", "pvm"} ) public class BarrowsPlugin extends Plugin { - @Getter(AccessLevel.PACKAGE) - private static final Set BARROWS_WALLS = Sets.newHashSet - ( - ObjectID.DOOR_20678, NullObjectID.NULL_20681, NullObjectID.NULL_20682, NullObjectID.NULL_20683, NullObjectID.NULL_20684, NullObjectID.NULL_20685, NullObjectID.NULL_20686, NullObjectID.NULL_20687, - NullObjectID.NULL_20688, NullObjectID.NULL_20689, NullObjectID.NULL_20690, NullObjectID.NULL_20691, NullObjectID.NULL_20692, NullObjectID.NULL_20693, NullObjectID.NULL_20694, NullObjectID.NULL_20695, - NullObjectID.NULL_20696, ObjectID.DOOR_20697, NullObjectID.NULL_20700, NullObjectID.NULL_20701, NullObjectID.NULL_20702, NullObjectID.NULL_20703, NullObjectID.NULL_20704, NullObjectID.NULL_20705, - NullObjectID.NULL_20706, NullObjectID.NULL_20707, NullObjectID.NULL_20708, NullObjectID.NULL_20709, NullObjectID.NULL_20710, NullObjectID.NULL_20711, NullObjectID.NULL_20712, NullObjectID.NULL_20713, - NullObjectID.NULL_20714, NullObjectID.NULL_20715, NullObjectID.NULL_20728, NullObjectID.NULL_20730 - ); - - private static final Set BARROWS_LADDERS = Sets.newHashSet(NullObjectID.NULL_20675, NullObjectID.NULL_20676, NullObjectID.NULL_20677); private static final ImmutableList POSSIBLE_SOLUTIONS = ImmutableList.of( WidgetInfo.BARROWS_PUZZLE_ANSWER1, WidgetInfo.BARROWS_PUZZLE_ANSWER2, @@ -99,12 +74,6 @@ public class BarrowsPlugin extends Plugin private static final long PRAYER_DRAIN_INTERVAL_MS = 18200; private static final int CRYPT_REGION_ID = 14231; - @Getter(AccessLevel.PACKAGE) - private final Set walls = new HashSet<>(); - - @Getter(AccessLevel.PACKAGE) - private final Set ladders = new HashSet<>(); - private LoopTimer barrowsPrayerDrainTimer; private boolean wasInCrypt = false; @@ -156,8 +125,6 @@ public class BarrowsPlugin extends Plugin { overlayManager.remove(barrowsOverlay); overlayManager.remove(brotherOverlay); - walls.clear(); - ladders.clear(); puzzleAnswer = null; wasInCrypt = false; stopPrayerDrainTimer(); @@ -185,66 +152,6 @@ public class BarrowsPlugin extends Plugin } } - @Subscribe - public void onWallObjectSpawned(WallObjectSpawned event) - { - WallObject wallObject = event.getWallObject(); - if (BARROWS_WALLS.contains(wallObject.getId())) - { - walls.add(wallObject); - } - } - - @Subscribe - public void onWallObjectChanged(WallObjectChanged event) - { - WallObject previous = event.getPrevious(); - WallObject wallObject = event.getWallObject(); - - walls.remove(previous); - if (BARROWS_WALLS.contains(wallObject.getId())) - { - walls.add(wallObject); - } - } - - @Subscribe - public void onWallObjectDespawned(WallObjectDespawned event) - { - WallObject wallObject = event.getWallObject(); - walls.remove(wallObject); - } - - @Subscribe - public void onGameObjectSpawned(GameObjectSpawned event) - { - GameObject gameObject = event.getGameObject(); - if (BARROWS_LADDERS.contains(gameObject.getId())) - { - ladders.add(gameObject); - } - } - - @Subscribe - public void onGameObjectChanged(GameObjectChanged event) - { - GameObject previous = event.getPrevious(); - GameObject gameObject = event.getGameObject(); - - ladders.remove(previous); - if (BARROWS_LADDERS.contains(gameObject.getId())) - { - ladders.add(gameObject); - } - } - - @Subscribe - public void onGameObjectDespawned(GameObjectDespawned event) - { - GameObject gameObject = event.getGameObject(); - ladders.remove(gameObject); - } - @Subscribe public void onGameStateChanged(GameStateChanged event) { @@ -252,8 +159,6 @@ public class BarrowsPlugin extends Plugin { wasInCrypt = isInCrypt(); // on region changes the tiles get set to null - walls.clear(); - ladders.clear(); puzzleAnswer = null; } else if (event.getGameState() == GameState.LOGGED_IN) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cerberus/CerberusGhost.java b/runelite-client/src/main/java/net/runelite/client/plugins/cerberus/CerberusGhost.java deleted file mode 100644 index 744085c9a4..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cerberus/CerberusGhost.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2018, Tomas Slusny - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.cerberus; - -import com.google.common.collect.ImmutableMap; -import java.util.Map; -import java.util.Optional; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import net.runelite.api.NPC; -import net.runelite.api.NpcID; -import net.runelite.api.Skill; - -@Getter -@RequiredArgsConstructor -public enum CerberusGhost -{ - RANGE(NpcID.SUMMONED_SOUL, Skill.RANGED), - MAGE(NpcID.SUMMONED_SOUL_5868, Skill.MAGIC), - MELEE(NpcID.SUMMONED_SOUL_5869, Skill.ATTACK); - - private final int npcId; - private final Skill type; - - private static final Map MAP; - - static - { - ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); - - for (final CerberusGhost ghost : values()) - { - builder.put(ghost.getNpcId(), ghost); - } - - MAP = builder.build(); - } - - /** - * Try to identify if NPC is ghost - * @param npc npc - * @return optional ghost - */ - public static Optional fromNPC(final NPC npc) - { - return npc == null ? Optional.empty() : Optional.ofNullable(MAP.get(npc.getId())); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cerberus/CerberusOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/cerberus/CerberusOverlay.java deleted file mode 100644 index 2f384fcd80..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cerberus/CerberusOverlay.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2018, Tomas Slusny - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.cerberus; - -import java.awt.Dimension; -import java.awt.Graphics2D; -import javax.inject.Inject; -import javax.inject.Singleton; -import net.runelite.client.game.SkillIconManager; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.components.ComponentOrientation; -import net.runelite.client.ui.overlay.components.ImageComponent; -import net.runelite.client.ui.overlay.components.PanelComponent; - -@Singleton -public class CerberusOverlay extends Overlay -{ - private final CerberusPlugin plugin; - private final SkillIconManager iconManager; - private final PanelComponent panelComponent = new PanelComponent(); - - @Inject - CerberusOverlay(final CerberusPlugin plugin, final SkillIconManager iconManager) - { - this.plugin = plugin; - this.iconManager = iconManager; - setPosition(OverlayPosition.BOTTOM_RIGHT); - panelComponent.setOrientation(ComponentOrientation.HORIZONTAL); - } - - @Override - public Dimension render(Graphics2D graphics) - { - if (plugin.getGhosts().isEmpty()) - { - return null; - } - - panelComponent.getChildren().clear(); - - // Ghosts are already sorted - plugin.getGhosts().stream() - // Iterate only through the correct amount of ghosts - .limit(CerberusGhost.values().length) - .forEach(npc -> CerberusGhost - .fromNPC(npc) - .ifPresent(ghost -> panelComponent - .getChildren() - .add(new ImageComponent(iconManager.getSkillImage(ghost.getType()))))); - - - return panelComponent.render(graphics); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cerberus/CerberusPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cerberus/CerberusPlugin.java deleted file mode 100644 index 47f1adbec4..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cerberus/CerberusPlugin.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2018, Tomas Slusny - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.runelite.client.plugins.cerberus; - -import com.google.common.collect.ComparisonChain; -import java.util.ArrayList; -import java.util.List; -import javax.inject.Inject; -import javax.inject.Singleton; -import lombok.Getter; -import net.runelite.api.GameState; -import net.runelite.api.NPC; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.GameTick; -import net.runelite.api.events.NpcDespawned; -import net.runelite.api.events.NpcSpawned; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.ui.overlay.OverlayManager; - -@PluginDescriptor( - name = "Cerberus", - description = "Show what to pray against the summoned souls", - tags = {"bosses", "combat", "ghosts", "prayer", "pve", "overlay", "souls"} -) -@Singleton -public class CerberusPlugin extends Plugin -{ - @Getter - private final List ghosts = new ArrayList<>(); - - @Inject - private OverlayManager overlayManager; - - @Inject - private CerberusOverlay overlay; - - @Override - protected void startUp() throws Exception - { - overlayManager.add(overlay); - } - - @Override - protected void shutDown() throws Exception - { - overlayManager.remove(overlay); - ghosts.clear(); - } - - @Subscribe - public void onGameStateChanged(GameStateChanged event) - { - GameState gameState = event.getGameState(); - if (gameState == GameState.LOGIN_SCREEN || gameState == GameState.HOPPING || gameState == GameState.CONNECTION_LOST) - { - ghosts.clear(); - } - } - - @Subscribe - public void onNpcSpawned(final NpcSpawned event) - { - final NPC npc = event.getNpc(); - CerberusGhost.fromNPC(npc).ifPresent(ghost -> ghosts.add(npc)); - } - - @Subscribe - public void onNpcDespawned(final NpcDespawned event) - { - ghosts.remove(event.getNpc()); - } - - @Subscribe - public void onGameTick(GameTick gameTick) - { - if (ghosts.isEmpty()) - { - return; - } - - ghosts.sort((a, b) -> ComparisonChain.start() - // First, sort by the southernmost ghost (e.g with lowest y) - .compare(a.getLocalLocation().getY(), b.getLocalLocation().getY()) - // Then, sort by the westernmost ghost (e.g with lowest x) - .compare(a.getLocalLocation().getX(), b.getLocalLocation().getX()) - // This will give use the current wave and order of the ghosts based on - // what ghost will attack first - .result()); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpConfig.java index 4b2fe5bb9c..13475f7c44 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpConfig.java @@ -31,17 +31,6 @@ import net.runelite.client.config.ConfigItem; @ConfigGroup("corp") public interface CorpConfig extends Config { - @ConfigItem( - keyName = "leftClickCore", - name = "Left click walk on core", - description = "Prioritizes Walk here over Attack on the Dark energy core", - position = 1 - ) - default boolean leftClickCore() - { - return true; - } - @ConfigItem( keyName = "showDamage", name = "Show damage overlay", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpPlugin.java index 627c9091e8..9ad661094c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpPlugin.java @@ -35,16 +35,12 @@ import net.runelite.api.Actor; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.GameState; -import net.runelite.api.MenuAction; -import static net.runelite.api.MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET; -import net.runelite.api.MenuEntry; import net.runelite.api.NPC; import net.runelite.api.NpcID; import net.runelite.api.Varbits; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.HitsplatApplied; import net.runelite.api.events.InteractingChanged; -import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcSpawned; import net.runelite.client.chat.ChatColorType; @@ -65,10 +61,6 @@ import net.runelite.client.ui.overlay.OverlayManager; @Slf4j public class CorpPlugin extends Plugin { - private static final int NPC_SECTION_ACTION = MenuAction.NPC_SECOND_OPTION.getId(); - private static final String ATTACK = "Attack"; - private static final String DARK_ENERGY_CORE = "Dark energy core"; - @Getter(AccessLevel.PACKAGE) private NPC corp; @@ -224,28 +216,4 @@ public class CorpPlugin extends Plugin players.add(source); } - - @Subscribe - public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) - { - if (menuEntryAdded.getType() != NPC_SECTION_ACTION - || !config.leftClickCore() || !menuEntryAdded.getOption().equals(ATTACK)) - { - return; - } - - final int npcIndex = menuEntryAdded.getIdentifier(); - final NPC npc = client.getCachedNPCs()[npcIndex]; - if (npc == null || !npc.getName().equals(DARK_ENERGY_CORE)) - { - return; - } - - // since this is the menu entry add event, this is the last menu entry - MenuEntry[] menuEntries = client.getMenuEntries(); - MenuEntry menuEntry = menuEntries[menuEntries.length - 1]; - - menuEntry.setType(NPC_SECTION_ACTION + MENU_ACTION_DEPRIORITIZE_OFFSET); - client.setMenuEntries(menuEntries); - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java index ddd3a1513c..5e1fc06a39 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java @@ -202,16 +202,6 @@ public interface MenuEntrySwapperConfig extends Config return HouseAdvertisementMode.VIEW; } - @ConfigItem( - keyName = "swapPickpocket", - name = "Pickpocket", - description = "Swap Talk-to with Pickpocket" - ) - default boolean swapPickpocket() - { - return true; - } - @ConfigItem( keyName = "swapPay", name = "Pay", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index 7d37fae388..6cd6055faf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -371,11 +371,6 @@ public class MenuEntrySwapperPlugin extends Plugin if (option.equals("talk-to")) { - if (config.swapPickpocket() && shouldSwapPickpocket(target)) - { - swap("pickpocket", option, target, index); - } - if (config.swapAbyssTeleport() && target.contains("mage of zamorak")) { swap("teleport", option, target, index); @@ -647,11 +642,6 @@ public class MenuEntrySwapperPlugin extends Plugin } } - private static boolean shouldSwapPickpocket(String target) - { - return !target.startsWith("villager") && !target.startsWith("bandit") && !target.startsWith("menaphite thug"); - } - @Subscribe public void onClientTick(ClientTick clientTick) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoConfig.java index 9f08e128af..6adb3af1f2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoConfig.java @@ -53,17 +53,6 @@ public interface OpponentInfoConfig extends Config return HitpointsDisplayStyle.HITPOINTS; } - @ConfigItem( - keyName = "showOpponentsOpponent", - name = "Show opponent's opponent", - description = "Toggle showing opponent's opponent if within a multi-combat area", - position = 2 - ) - default boolean showOpponentsOpponent() - { - return true; - } - @ConfigItem( keyName = "showOpponentsInMenu", name = "Show opponents in menu", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoOverlay.java index f7945a5646..45c40cf939 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoOverlay.java @@ -37,7 +37,6 @@ import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.NPC; import net.runelite.api.Player; -import net.runelite.api.Varbits; import net.runelite.client.game.HiscoreManager; import net.runelite.client.game.NPCManager; import net.runelite.client.ui.overlay.Overlay; @@ -69,7 +68,6 @@ class OpponentInfoOverlay extends Overlay private int lastRatio = 0; private int lastHealthScale = 0; private String opponentName; - private String opponentsOpponentName; @Inject private OpponentInfoOverlay( @@ -128,17 +126,6 @@ class OpponentInfoOverlay extends Overlay } } } - - final Actor opponentsOpponent = opponent.getInteracting(); - if (opponentsOpponent != null - && (opponentsOpponent != client.getLocalPlayer() || client.getVar(Varbits.MULTICOMBAT_AREA) == 1)) - { - opponentsOpponentName = Text.removeTags(opponentsOpponent.getName()); - } - else - { - opponentsOpponentName = null; - } } if (opponentName == null) @@ -218,16 +205,6 @@ class OpponentInfoOverlay extends Overlay panelComponent.getChildren().add(progressBarComponent); } - // Opponents opponent - if (opponentsOpponentName != null && opponentInfoConfig.showOpponentsOpponent()) - { - textWidth = Math.max(textWidth, fontMetrics.stringWidth(opponentsOpponentName)); - panelComponent.setPreferredSize(new Dimension(textWidth, 0)); - panelComponent.getChildren().add(TitleComponent.builder() - .text(opponentsOpponentName) - .build()); - } - return panelComponent.render(graphics); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/reorderprayers/PrayerTabState.java b/runelite-client/src/main/java/net/runelite/client/plugins/reorderprayers/PrayerTabState.java deleted file mode 100644 index 993a74f917..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/reorderprayers/PrayerTabState.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2018, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.reorderprayers; - -public enum PrayerTabState -{ - NONE, - PRAYERS, - QUICK_PRAYERS -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersConfig.java deleted file mode 100644 index 7a73dae268..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersConfig.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2018, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.reorderprayers; - -import net.runelite.api.Prayer; -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -@ConfigGroup(ReorderPrayersPlugin.CONFIG_GROUP_KEY) -public interface ReorderPrayersConfig extends Config -{ - - @ConfigItem( - keyName = ReorderPrayersPlugin.CONFIG_UNLOCK_REORDERING_KEY, - name = "Unlock Prayer Reordering", - description = "Configures whether or not you can reorder the prayers", - position = 1 - ) - default boolean unlockPrayerReordering() - { - return false; - } - - @ConfigItem( - keyName = ReorderPrayersPlugin.CONFIG_UNLOCK_REORDERING_KEY, - name = "", - description = "" - ) - void unlockPrayerReordering(boolean unlock); - - @ConfigItem( - keyName = ReorderPrayersPlugin.CONFIG_PRAYER_ORDER_KEY, - name = "Prayer Order", - description = "Configures the order of the prayers", - hidden = true, - position = 2 - ) - default String prayerOrder() - { - return ReorderPrayersPlugin.prayerOrderToString(Prayer.values()); - } - - @ConfigItem( - keyName = ReorderPrayersPlugin.CONFIG_PRAYER_ORDER_KEY, - name = "", - description = "" - ) - void prayerOrder(String prayerOrder); - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersPlugin.java deleted file mode 100644 index 0c85f32c8e..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersPlugin.java +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Copyright (c) 2018, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.reorderprayers; - -import com.google.common.collect.ImmutableList; -import com.google.inject.Provides; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import javax.inject.Inject; -import net.runelite.api.Client; -import net.runelite.api.GameState; -import net.runelite.api.HashTable; -import net.runelite.api.Prayer; -import net.runelite.api.WidgetNode; -import net.runelite.api.events.ConfigChanged; -import net.runelite.api.events.DraggingWidgetChanged; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.WidgetLoaded; -import net.runelite.api.events.WidgetMenuOptionClicked; -import net.runelite.api.widgets.Widget; -import static net.runelite.api.widgets.WidgetConfig.DRAG; -import static net.runelite.api.widgets.WidgetConfig.DRAG_ON; -import net.runelite.api.widgets.WidgetID; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.menus.MenuManager; -import net.runelite.client.menus.WidgetMenuOption; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; - -@PluginDescriptor( - name = "Reorder Prayers", - description = "Reorder the prayers displayed on the Prayer panel" -) -public class ReorderPrayersPlugin extends Plugin -{ - - static final String CONFIG_GROUP_KEY = "reorderprayers"; - - static final String CONFIG_UNLOCK_REORDERING_KEY = "unlockPrayerReordering"; - - static final String CONFIG_PRAYER_ORDER_KEY = "prayerOrder"; - - private static final int PRAYER_WIDTH = 34; - - private static final int PRAYER_HEIGHT = 34; - - private static final int PRAYER_X_OFFSET = 37; - - private static final int PRAYER_Y_OFFSET = 37; - - private static final int QUICK_PRAYER_SPRITE_X_OFFSET = 2; - - private static final int QUICK_PRAYER_SPRITE_Y_OFFSET = 2; - - private static final int PRAYER_COLUMN_COUNT = 5; - - private static final int PRAYER_COUNT = Prayer.values().length; - - private static final List PRAYER_WIDGET_INFO_LIST = ImmutableList.of( - WidgetInfo.PRAYER_THICK_SKIN, - WidgetInfo.PRAYER_BURST_OF_STRENGTH, - WidgetInfo.PRAYER_CLARITY_OF_THOUGHT, - WidgetInfo.PRAYER_SHARP_EYE, - WidgetInfo.PRAYER_MYSTIC_WILL, - WidgetInfo.PRAYER_ROCK_SKIN, - WidgetInfo.PRAYER_SUPERHUMAN_STRENGTH, - WidgetInfo.PRAYER_IMPROVED_REFLEXES, - WidgetInfo.PRAYER_RAPID_RESTORE, - WidgetInfo.PRAYER_RAPID_HEAL, - WidgetInfo.PRAYER_PROTECT_ITEM, - WidgetInfo.PRAYER_HAWK_EYE, - WidgetInfo.PRAYER_MYSTIC_LORE, - WidgetInfo.PRAYER_STEEL_SKIN, - WidgetInfo.PRAYER_ULTIMATE_STRENGTH, - WidgetInfo.PRAYER_INCREDIBLE_REFLEXES, - WidgetInfo.PRAYER_PROTECT_FROM_MAGIC, - WidgetInfo.PRAYER_PROTECT_FROM_MISSILES, - WidgetInfo.PRAYER_PROTECT_FROM_MELEE, - WidgetInfo.PRAYER_EAGLE_EYE, - WidgetInfo.PRAYER_MYSTIC_MIGHT, - WidgetInfo.PRAYER_RETRIBUTION, - WidgetInfo.PRAYER_REDEMPTION, - WidgetInfo.PRAYER_SMITE, - WidgetInfo.PRAYER_PRESERVE, - WidgetInfo.PRAYER_CHIVALRY, - WidgetInfo.PRAYER_PIETY, - WidgetInfo.PRAYER_RIGOUR, - WidgetInfo.PRAYER_AUGURY - ); - - private static final List QUICK_PRAYER_CHILD_IDS = ImmutableList.of( - WidgetID.QuickPrayer.THICK_SKIN_CHILD_ID, - WidgetID.QuickPrayer.BURST_OF_STRENGTH_CHILD_ID, - WidgetID.QuickPrayer.CLARITY_OF_THOUGHT_CHILD_ID, - WidgetID.QuickPrayer.SHARP_EYE_CHILD_ID, - WidgetID.QuickPrayer.MYSTIC_WILL_CHILD_ID, - WidgetID.QuickPrayer.ROCK_SKIN_CHILD_ID, - WidgetID.QuickPrayer.SUPERHUMAN_STRENGTH_CHILD_ID, - WidgetID.QuickPrayer.IMPROVED_REFLEXES_CHILD_ID, - WidgetID.QuickPrayer.RAPID_RESTORE_CHILD_ID, - WidgetID.QuickPrayer.RAPID_HEAL_CHILD_ID, - WidgetID.QuickPrayer.PROTECT_ITEM_CHILD_ID, - WidgetID.QuickPrayer.HAWK_EYE_CHILD_ID, - WidgetID.QuickPrayer.MYSTIC_LORE_CHILD_ID, - WidgetID.QuickPrayer.STEEL_SKIN_CHILD_ID, - WidgetID.QuickPrayer.ULTIMATE_STRENGTH_CHILD_ID, - WidgetID.QuickPrayer.INCREDIBLE_REFLEXES_CHILD_ID, - WidgetID.QuickPrayer.PROTECT_FROM_MAGIC_CHILD_ID, - WidgetID.QuickPrayer.PROTECT_FROM_MISSILES_CHILD_ID, - WidgetID.QuickPrayer.PROTECT_FROM_MELEE_CHILD_ID, - WidgetID.QuickPrayer.EAGLE_EYE_CHILD_ID, - WidgetID.QuickPrayer.MYSTIC_MIGHT_CHILD_ID, - WidgetID.QuickPrayer.RETRIBUTION_CHILD_ID, - WidgetID.QuickPrayer.REDEMPTION_CHILD_ID, - WidgetID.QuickPrayer.SMITE_CHILD_ID, - WidgetID.QuickPrayer.PRESERVE_CHILD_ID, - WidgetID.QuickPrayer.CHIVALRY_CHILD_ID, - WidgetID.QuickPrayer.PIETY_CHILD_ID, - WidgetID.QuickPrayer.RIGOUR_CHILD_ID, - WidgetID.QuickPrayer.AUGURY_CHILD_ID - ); - - private static final String LOCK = "Lock"; - - private static final String UNLOCK = "Unlock"; - - private static final String MENU_TARGET = "Reordering"; - - private static final WidgetMenuOption FIXED_PRAYER_TAB_LOCK = new WidgetMenuOption(LOCK, - MENU_TARGET, WidgetInfo.FIXED_VIEWPORT_PRAYER_TAB); - - private static final WidgetMenuOption FIXED_PRAYER_TAB_UNLOCK = new WidgetMenuOption(UNLOCK, - MENU_TARGET, WidgetInfo.FIXED_VIEWPORT_PRAYER_TAB); - - private static final WidgetMenuOption RESIZABLE_PRAYER_TAB_LOCK = new WidgetMenuOption(LOCK, - MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_PRAYER_TAB); - - private static final WidgetMenuOption RESIZABLE_PRAYER_TAB_UNLOCK = new WidgetMenuOption(UNLOCK, - MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_PRAYER_TAB); - - private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_PRAYER_TAB_LOCK = new WidgetMenuOption(LOCK, - MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_PRAYER_TAB); - - private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_PRAYER_TAB_UNLOCK = new WidgetMenuOption(UNLOCK, - MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_PRAYER_TAB); - - @Inject - private Client client; - - @Inject - private ReorderPrayersConfig config; - - @Inject - private MenuManager menuManager; - - private Prayer[] prayerOrder; - - static String prayerOrderToString(Prayer[] prayerOrder) - { - return Arrays.stream(prayerOrder) - .map(Prayer::name) - .collect(Collectors.joining(",")); - } - - private static Prayer[] stringToPrayerOrder(String string) - { - return Arrays.stream(string.split(",")) - .map(Prayer::valueOf) - .toArray(Prayer[]::new); - } - - private static int getPrayerIndex(Widget widget) - { - int x = widget.getOriginalX() / PRAYER_X_OFFSET; - int y = widget.getOriginalY() / PRAYER_Y_OFFSET; - return x + y * PRAYER_COLUMN_COUNT; - } - - private static void setWidgetPosition(Widget widget, int x, int y) - { - widget.setRelativeX(x); - widget.setRelativeY(y); - widget.setOriginalX(x); - widget.setOriginalY(y); - } - - @Provides - ReorderPrayersConfig provideConfig(ConfigManager configManager) - { - return configManager.getConfig(ReorderPrayersConfig.class); - } - - @Override - protected void startUp() throws Exception - { - refreshPrayerTabOption(); - prayerOrder = stringToPrayerOrder(config.prayerOrder()); - reorderPrayers(); - } - - @Override - protected void shutDown() throws Exception - { - clearPrayerTabMenus(); - prayerOrder = Prayer.values(); - reorderPrayers(false); - } - - @Subscribe - public void onGameStateChanged(GameStateChanged event) - { - if (event.getGameState() == GameState.LOGGED_IN) - { - reorderPrayers(); - } - } - - @Subscribe - public void onConfigChanged(ConfigChanged event) - { - if (event.getGroup().equals(CONFIG_GROUP_KEY)) - { - if (event.getKey().equals(CONFIG_PRAYER_ORDER_KEY)) - { - prayerOrder = stringToPrayerOrder(config.prayerOrder()); - } - else if (event.getKey().equals(CONFIG_UNLOCK_REORDERING_KEY)) - { - refreshPrayerTabOption(); - } - reorderPrayers(); - } - } - - @Subscribe - public void onWidgetLoaded(WidgetLoaded event) - { - if (event.getGroupId() == WidgetID.PRAYER_GROUP_ID || event.getGroupId() == WidgetID.QUICK_PRAYERS_GROUP_ID) - { - reorderPrayers(); - } - } - - @Subscribe - public void onDraggingWidgetChanged(DraggingWidgetChanged event) - { - // is dragging widget and mouse button released - if (event.isDraggingWidget() && client.getMouseCurrentButton() == 0) - { - Widget draggedWidget = client.getDraggedWidget(); - Widget draggedOnWidget = client.getDraggedOnWidget(); - if (draggedWidget != null && draggedOnWidget != null) - { - int draggedGroupId = WidgetInfo.TO_GROUP(draggedWidget.getId()); - int draggedOnGroupId = WidgetInfo.TO_GROUP(draggedOnWidget.getId()); - if (draggedGroupId != WidgetID.PRAYER_GROUP_ID || draggedOnGroupId != WidgetID.PRAYER_GROUP_ID - || draggedOnWidget.getWidth() != PRAYER_WIDTH || draggedOnWidget.getHeight() != PRAYER_HEIGHT) - { - return; - } - // reset dragged on widget to prevent sending a drag widget packet to the server - client.setDraggedOnWidget(null); - - int fromPrayerIndex = getPrayerIndex(draggedWidget); - int toPrayerIndex = getPrayerIndex(draggedOnWidget); - - Prayer tmp = prayerOrder[toPrayerIndex]; - prayerOrder[toPrayerIndex] = prayerOrder[fromPrayerIndex]; - prayerOrder[fromPrayerIndex] = tmp; - - save(); - } - } - } - - @Subscribe - public void onWidgetMenuOptionClicked(WidgetMenuOptionClicked event) - { - if (event.getWidget() == WidgetInfo.FIXED_VIEWPORT_PRAYER_TAB - || event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_PRAYER_TAB - || event.getWidget() == WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_PRAYER_TAB) - { - config.unlockPrayerReordering(event.getMenuOption().equals(UNLOCK)); - } - } - - private void clearPrayerTabMenus() - { - menuManager.removeManagedCustomMenu(FIXED_PRAYER_TAB_LOCK); - menuManager.removeManagedCustomMenu(RESIZABLE_PRAYER_TAB_LOCK); - menuManager.removeManagedCustomMenu(RESIZABLE_BOTTOM_LINE_PRAYER_TAB_LOCK); - menuManager.removeManagedCustomMenu(FIXED_PRAYER_TAB_UNLOCK); - menuManager.removeManagedCustomMenu(RESIZABLE_PRAYER_TAB_UNLOCK); - menuManager.removeManagedCustomMenu(RESIZABLE_BOTTOM_LINE_PRAYER_TAB_UNLOCK); - } - - private void refreshPrayerTabOption() - { - clearPrayerTabMenus(); - if (config.unlockPrayerReordering()) - { - menuManager.addManagedCustomMenu(FIXED_PRAYER_TAB_LOCK); - menuManager.addManagedCustomMenu(RESIZABLE_PRAYER_TAB_LOCK); - menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_PRAYER_TAB_LOCK); - } - else - { - menuManager.addManagedCustomMenu(FIXED_PRAYER_TAB_UNLOCK); - menuManager.addManagedCustomMenu(RESIZABLE_PRAYER_TAB_UNLOCK); - menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_PRAYER_TAB_UNLOCK); - } - } - - private PrayerTabState getPrayerTabState() - { - HashTable componentTable = client.getComponentTable(); - for (WidgetNode widgetNode : componentTable.getNodes()) - { - if (widgetNode.getId() == WidgetID.PRAYER_GROUP_ID) - { - return PrayerTabState.PRAYERS; - } - else if (widgetNode.getId() == WidgetID.QUICK_PRAYERS_GROUP_ID) - { - return PrayerTabState.QUICK_PRAYERS; - } - } - return PrayerTabState.NONE; - } - - private void save() - { - config.prayerOrder(prayerOrderToString(prayerOrder)); - } - - private void reorderPrayers() - { - reorderPrayers(config.unlockPrayerReordering()); - } - - private void reorderPrayers(boolean unlocked) - { - if (client.getGameState() != GameState.LOGGED_IN) - { - return; - } - - PrayerTabState prayerTabState = getPrayerTabState(); - - if (prayerTabState == PrayerTabState.PRAYERS) - { - List prayerWidgets = PRAYER_WIDGET_INFO_LIST.stream() - .map(client::getWidget) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - - if (prayerWidgets.size() != PRAYER_WIDGET_INFO_LIST.size()) - { - return; - } - - for (int index = 0; index < prayerOrder.length; index++) - { - Prayer prayer = prayerOrder[index]; - Widget prayerWidget = prayerWidgets.get(prayer.ordinal()); - - int widgetConfig = prayerWidget.getClickMask(); - if (unlocked) - { - // allow dragging of this widget - widgetConfig |= DRAG; - // allow this widget to be dragged on - widgetConfig |= DRAG_ON; - } - else - { - // remove drag flag - widgetConfig &= ~DRAG; - // remove drag on flag - widgetConfig &= ~DRAG_ON; - } - prayerWidget.setClickMask(widgetConfig); - - int x = index % PRAYER_COLUMN_COUNT; - int y = index / PRAYER_COLUMN_COUNT; - int widgetX = x * PRAYER_X_OFFSET; - int widgetY = y * PRAYER_Y_OFFSET; - setWidgetPosition(prayerWidget, widgetX, widgetY); - } - } - else if (prayerTabState == PrayerTabState.QUICK_PRAYERS) - { - Widget prayersContainer = client.getWidget(WidgetInfo.QUICK_PRAYER_PRAYERS); - if (prayersContainer == null) - { - return; - } - Widget[] prayerWidgets = prayersContainer.getDynamicChildren(); - if (prayerWidgets == null || prayerWidgets.length != PRAYER_COUNT * 3) - { - return; - } - - for (int index = 0; index < prayerOrder.length; index++) - { - Prayer prayer = prayerOrder[index]; - - int x = index % PRAYER_COLUMN_COUNT; - int y = index / PRAYER_COLUMN_COUNT; - - Widget prayerWidget = prayerWidgets[QUICK_PRAYER_CHILD_IDS.get(prayer.ordinal())]; - setWidgetPosition(prayerWidget, x * PRAYER_X_OFFSET, y * PRAYER_Y_OFFSET); - - int childId = PRAYER_COUNT + 2 * prayer.ordinal(); - - Widget prayerSpriteWidget = prayerWidgets[childId]; - setWidgetPosition(prayerSpriteWidget, - QUICK_PRAYER_SPRITE_X_OFFSET + x * PRAYER_X_OFFSET, - QUICK_PRAYER_SPRITE_Y_OFFSET + y * PRAYER_Y_OFFSET); - - Widget prayerToggleWidget = prayerWidgets[childId + 1]; - setWidgetPosition(prayerToggleWidget, x * PRAYER_X_OFFSET, y * PRAYER_Y_OFFSET); - } - } - } - -} diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/cerberus/CerberusPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/cerberus/CerberusPluginTest.java deleted file mode 100644 index e4289fa2f2..0000000000 --- a/runelite-client/src/test/java/net/runelite/client/plugins/cerberus/CerberusPluginTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2018, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.cerberus; - -import com.google.inject.Guice; -import com.google.inject.testing.fieldbinder.Bind; -import com.google.inject.testing.fieldbinder.BoundFieldModule; -import java.util.Arrays; -import java.util.List; -import javax.inject.Inject; -import net.runelite.api.NPC; -import net.runelite.api.coords.LocalPoint; -import net.runelite.api.events.GameTick; -import net.runelite.client.ui.overlay.OverlayManager; -import static org.junit.Assert.assertEquals; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import org.mockito.junit.MockitoJUnitRunner; - -@RunWith(MockitoJUnitRunner.class) -public class CerberusPluginTest -{ - @Mock - @Bind - OverlayManager overlayManager; - - @Inject - CerberusPlugin cerberusPlugin; - - @Before - public void before() - { - Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this); - } - - @Test - public void testOnGameTick() - { - List ghosts = cerberusPlugin.getGhosts(); - ghosts.addAll(Arrays.asList( - mockNpc(new LocalPoint(0, 0)), - mockNpc(new LocalPoint(1, 0)), - mockNpc(new LocalPoint(0, 5)), - mockNpc(new LocalPoint(2, 0)), - mockNpc(new LocalPoint(2, 5)), - mockNpc(new LocalPoint(1, 5)) - )); - cerberusPlugin.onGameTick(new GameTick()); - - // Expected sort is by lowest y first, then by lowest x - assertEquals(ghosts.get(0).getLocalLocation(), new LocalPoint(0, 0)); - assertEquals(ghosts.get(1).getLocalLocation(), new LocalPoint(1, 0)); - assertEquals(ghosts.get(2).getLocalLocation(), new LocalPoint(2, 0)); - - assertEquals(ghosts.get(3).getLocalLocation(), new LocalPoint(0, 5)); - assertEquals(ghosts.get(4).getLocalLocation(), new LocalPoint(1, 5)); - assertEquals(ghosts.get(5).getLocalLocation(), new LocalPoint(2, 5)); - } - - private static NPC mockNpc(LocalPoint localPoint) - { - NPC npc = mock(NPC.class); - when(npc.getLocalLocation()).thenReturn(localPoint); - return npc; - } -} \ No newline at end of file