diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java index 42a4b49d55..18a836a6a1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java @@ -85,11 +85,6 @@ public class RaidsPlugin extends Plugin private static final String SPLIT_REGEX = "\\s*,\\s*"; private static final Pattern ROTATION_REGEX = Pattern.compile("\\[(.*?)]"); - private RaidsTimer timer; - - @Getter - private boolean inRaidChambers; - @Inject private ChatMessageManager chatMessageManager; @@ -117,20 +112,25 @@ public class RaidsPlugin extends Plugin @Inject private SpriteManager spriteManager; + @Getter + private final ArrayList roomWhitelist = new ArrayList<>(); + + @Getter + private final ArrayList roomBlacklist = new ArrayList<>(); + + @Getter + private final ArrayList rotationWhitelist = new ArrayList<>(); + + @Getter + private final ArrayList layoutWhitelist = new ArrayList<>(); + @Getter private Raid raid; @Getter - private ArrayList roomWhitelist = new ArrayList<>(); + private boolean inRaidChambers; - @Getter - private ArrayList roomBlacklist = new ArrayList<>(); - - @Getter - private ArrayList rotationWhitelist = new ArrayList<>(); - - @Getter - private ArrayList layoutWhitelist = new ArrayList<>(); + private RaidsTimer timer; @Provides RaidsConfig provideConfig(ConfigManager configManager) @@ -149,14 +149,8 @@ public class RaidsPlugin extends Plugin { overlayManager.add(overlay); overlayManager.add(pointsOverlay); - - if (client.getGameState() == GameState.LOGGED_IN) - { - inRaidChambers = client.getVar(Varbits.IN_RAID) == 1; - updateInfoBoxState(); - } - updateLists(); + checkRaidPresence(true); } @Override @@ -164,40 +158,28 @@ public class RaidsPlugin extends Plugin { overlayManager.remove(overlay); overlayManager.remove(pointsOverlay); - - if (timer != null) - { - infoBoxManager.removeInfoBox(timer); - } + infoBoxManager.removeInfoBox(timer); + inRaidChambers = false; + raid = null; + timer = null; } @Subscribe public void onConfigChanged(ConfigChanged event) { + if (!event.getGroup().equals("raids")) + { + return; + } + if (event.getKey().equals("raidsTimer")) { updateInfoBoxState(); + return; } - if (event.getKey().equals("whitelistedRooms")) - { - updateList(roomWhitelist, config.whitelistedRooms()); - } - - if (event.getKey().equals("blacklistedRooms")) - { - updateList(roomBlacklist, config.blacklistedRooms()); - } - - if (event.getKey().equals("whitelistedRotations")) - { - updateList(rotationWhitelist, config.whitelistedRotations()); - } - - if (event.getKey().equals("whitelistedLayouts")) - { - updateList(layoutWhitelist, config.whitelistedLayouts()); - } + updateLists(); + checkRaidPresence(true); } @Subscribe @@ -219,47 +201,7 @@ public class RaidsPlugin extends Plugin @Subscribe public void onVarbitChange(VarbitChanged event) { - boolean setting = client.getVar(Varbits.IN_RAID) == 1; - - if (inRaidChambers != setting) - { - inRaidChambers = setting; - updateInfoBoxState(); - - if (inRaidChambers) - { - raid = buildRaid(); - - if (raid == null) - { - log.debug("Failed to build raid"); - return; - } - - Layout layout = layoutSolver.findLayout(raid.toCode()); - - if (layout == null) - { - log.debug("Could not find layout match"); - return; - } - - raid.updateLayout(layout); - RotationSolver.solve(raid.getCombatRooms()); - overlay.setScoutOverlayShown(true); - } - else if (!config.scoutOverlayAtBank()) - { - overlay.setScoutOverlayShown(false); - raid = null; - } - } - - if (client.getVar(VarPlayer.IN_RAID_PARTY) == -1) - { - overlay.setScoutOverlayShown(false); - raid = null; - } + checkRaidPresence(false); } @Subscribe @@ -321,23 +263,73 @@ public class RaidsPlugin extends Plugin } } + private void checkRaidPresence(boolean force) + { + if (client.getGameState() != GameState.LOGGED_IN) + { + return; + } + + boolean setting = client.getVar(Varbits.IN_RAID) == 1; + + if (force || inRaidChambers != setting) + { + inRaidChambers = setting; + updateInfoBoxState(); + + if (inRaidChambers) + { + raid = buildRaid(); + + if (raid == null) + { + log.debug("Failed to build raid"); + return; + } + + Layout layout = layoutSolver.findLayout(raid.toCode()); + + if (layout == null) + { + log.debug("Could not find layout match"); + return; + } + + raid.updateLayout(layout); + RotationSolver.solve(raid.getCombatRooms()); + overlay.setScoutOverlayShown(true); + } + else if (!config.scoutOverlayAtBank()) + { + overlay.setScoutOverlayShown(false); + } + } + + if (client.getVar(VarPlayer.IN_RAID_PARTY) == -1) + { + overlay.setScoutOverlayShown(false); + } + } + private void updateInfoBoxState() { - if (timer != null) + if (timer == null) { - if (inRaidChambers && config.raidsTimer()) - { - infoBoxManager.addInfoBox(timer); - } - else - { - infoBoxManager.removeInfoBox(timer); - } + return; + } - if (!inRaidChambers) - { - timer = null; - } + if (inRaidChambers && config.raidsTimer()) + { + infoBoxManager.addInfoBox(timer); + } + else + { + infoBoxManager.removeInfoBox(timer); + } + + if (!inRaidChambers) + { + timer = null; } } @@ -372,7 +364,7 @@ public class RaidsPlugin extends Plugin } } - public int getRotationMatches() + int getRotationMatches() { String rotation = raid.getRotationString().toLowerCase(); String[] bosses = rotation.split(SPLIT_REGEX);