From d1342f821be7d01f8c6534d643393f54eaa5a6f1 Mon Sep 17 00:00:00 2001 From: Kamiel Date: Wed, 28 Feb 2018 04:11:47 +0100 Subject: [PATCH] Add ability to whitelist layouts --- .../client/plugins/raids/RaidsConfig.java | 27 +++++++++++++++++++ .../client/plugins/raids/RaidsOverlay.java | 14 +++++++++- .../client/plugins/raids/RaidsPlugin.java | 25 +++++++++++++---- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java index 8879806273..5e5946b609 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java @@ -36,6 +36,7 @@ import net.runelite.client.config.ConfigItem; public interface RaidsConfig extends Config { @ConfigItem( + position = 0, keyName = "raidsTimer", name = "Display elapsed raid time", description = "Display elapsed raid time" @@ -46,6 +47,7 @@ public interface RaidsConfig extends Config } @ConfigItem( + position = 1, keyName = "pointsMessage", name = "Display points in chatbox after raid", description = "Display a message with total points, individual points and percentage at the end of a raid" @@ -56,6 +58,7 @@ public interface RaidsConfig extends Config } @ConfigItem( + position = 2, keyName = "scoutOverlay", name = "Show scout overlay", description = "Display an overlay that shows the current raid layout (when entering lobby)" @@ -66,6 +69,7 @@ public interface RaidsConfig extends Config } @ConfigItem( + position = 3, keyName = "scoutOverlayAtBank", name = "Show scout overlay outside lobby", description = "Keep the overlay active while at the raids area" @@ -76,6 +80,7 @@ public interface RaidsConfig extends Config } @ConfigItem( + position = 4, keyName = "blacklistedRooms", name = "Blacklisted rooms", description = "Display blacklisted rooms in red on the overlay. Separate with comma (full name)" @@ -84,4 +89,26 @@ public interface RaidsConfig extends Config { return ""; } + + @ConfigItem( + position = 5, + keyName = "enableLayoutWhitelist", + name = "Enable layout whitelist", + description = "Enable the layout whitelist" + ) + default boolean enableLayoutWhitelist() + { + return false; + } + + @ConfigItem( + position = 6, + keyName = "whitelistedLayouts", + name = "Whitelisted layouts", + description = "Warn when layout doesn't match a whitelisted one. Add layouts like CFSCPPCSCF separated with comma" + ) + default String whitelistedLayouts() + { + return ""; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java index 48388e89be..8200c594d3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java @@ -74,6 +74,18 @@ public class RaidsOverlay extends Overlay panelComponent.setTitleColor(Color.WHITE); panelComponent.setTitle("Raid scouter"); + Color color = Color.WHITE; + String layout = plugin.getRaid().getLayout().toCode().replaceAll("#", "").replaceAll("ยค", ""); + + if (config.enableLayoutWhitelist() && !plugin.getLayoutWhitelist().contains(layout.toLowerCase())) + { + color = Color.RED; + } + + panelComponent.getLines().add(new PanelComponent.Line( + "Layout", Color.WHITE, layout, color + )); + for (Room layoutRoom : plugin.getRaid().getLayout().getRooms()) { int position = layoutRoom.getPosition(); @@ -84,7 +96,7 @@ public class RaidsOverlay extends Overlay continue; } - Color color = Color.WHITE; + color = Color.WHITE; switch (room.getType()) { 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 e9fa977526..73bbd9bdad 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 @@ -71,6 +71,7 @@ public class RaidsPlugin extends Plugin private static final String RAID_COMPLETE_MESSAGE = "Congratulations - your raid is complete!"; private static final int TOTAL_POINTS = 0, PERSONAL_POINTS = 1, TEXT_CHILD = 4; private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("###.##"); + private static final String SPLIT_REGEX = "\\s*,\\s*"; private BufferedImage raidsIcon; private RaidsTimer timer; @@ -100,6 +101,9 @@ public class RaidsPlugin extends Plugin @Getter private ArrayList blacklist = new ArrayList<>(); + @Getter + private ArrayList layoutWhitelist = new ArrayList<>(); + @Provides RaidsConfig provideConfig(ConfigManager configManager) { @@ -132,7 +136,7 @@ public class RaidsPlugin extends Plugin cacheColors(); } - updateBlacklist(); + updateLists(); } @Override @@ -159,7 +163,12 @@ public class RaidsPlugin extends Plugin if (event.getKey().equals("blacklistedRooms")) { - updateBlacklist(); + updateList(blacklist, config.blacklistedRooms()); + } + + if (event.getKey().equals("whitelistedLayouts")) + { + updateList(layoutWhitelist, config.whitelistedLayouts()); } } @@ -284,10 +293,16 @@ public class RaidsPlugin extends Plugin } } - private void updateBlacklist() + private void updateLists() { - blacklist.clear(); - blacklist.addAll(Arrays.asList(config.blacklistedRooms().toLowerCase().split("\\s*,\\s*"))); + updateList(blacklist, config.blacklistedRooms()); + updateList(layoutWhitelist, config.whitelistedLayouts()); + } + + private void updateList(ArrayList list, String input) + { + list.clear(); + list.addAll(Arrays.asList(input.toLowerCase().split(SPLIT_REGEX))); } private void cacheColors()