From d1342f821be7d01f8c6534d643393f54eaa5a6f1 Mon Sep 17 00:00:00 2001 From: Kamiel Date: Wed, 28 Feb 2018 04:11:47 +0100 Subject: [PATCH 1/5] 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() From 259d3c0eecdb2ae40c1eba55a6570890dbcc6800 Mon Sep 17 00:00:00 2001 From: Kamiel Date: Wed, 28 Feb 2018 04:17:37 +0100 Subject: [PATCH 2/5] Add ability to highlight rooms --- .../client/plugins/raids/RaidsConfig.java | 15 +++++++++++++-- .../client/plugins/raids/RaidsOverlay.java | 12 ++++++++++-- .../client/plugins/raids/RaidsPlugin.java | 15 ++++++++++++--- 3 files changed, 35 insertions(+), 7 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 5e5946b609..da23b389b8 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 @@ -81,6 +81,17 @@ public interface RaidsConfig extends Config @ConfigItem( position = 4, + keyName = "whitelistedRooms", + name = "Whitelisted rooms", + description = "Display whitelisted rooms in green on the overlay. Separate with comma (full name)" + ) + default String whitelistedRooms() + { + return ""; + } + + @ConfigItem( + position = 5, keyName = "blacklistedRooms", name = "Blacklisted rooms", description = "Display blacklisted rooms in red on the overlay. Separate with comma (full name)" @@ -91,7 +102,7 @@ public interface RaidsConfig extends Config } @ConfigItem( - position = 5, + position = 6, keyName = "enableLayoutWhitelist", name = "Enable layout whitelist", description = "Enable the layout whitelist" @@ -102,7 +113,7 @@ public interface RaidsConfig extends Config } @ConfigItem( - position = 6, + position = 7, keyName = "whitelistedLayouts", name = "Whitelisted layouts", description = "Warn when layout doesn't match a whitelisted one. Add layouts like CFSCPPCSCF separated with comma" 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 8200c594d3..ae75c95c4f 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 @@ -101,7 +101,11 @@ public class RaidsOverlay extends Overlay switch (room.getType()) { case COMBAT: - if (plugin.getBlacklist().contains(room.getBoss().getName().toLowerCase())) + if (plugin.getRoomWhitelist().contains(room.getBoss().getName().toLowerCase())) + { + color = Color.GREEN; + } + else if (plugin.getRoomBlacklist().contains(room.getBoss().getName().toLowerCase())) { color = Color.RED; } @@ -112,7 +116,11 @@ public class RaidsOverlay extends Overlay break; case PUZZLE: - if (plugin.getBlacklist().contains(room.getPuzzle().getName().toLowerCase())) + if (plugin.getRoomWhitelist().contains(room.getPuzzle().getName().toLowerCase())) + { + color = Color.GREEN; + } + else if (plugin.getRoomBlacklist().contains(room.getPuzzle().getName().toLowerCase())) { color = Color.RED; } 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 73bbd9bdad..7cf1c30339 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 @@ -99,7 +99,10 @@ public class RaidsPlugin extends Plugin private Raid raid; @Getter - private ArrayList blacklist = new ArrayList<>(); + private ArrayList roomWhitelist = new ArrayList<>(); + + @Getter + private ArrayList roomBlacklist = new ArrayList<>(); @Getter private ArrayList layoutWhitelist = new ArrayList<>(); @@ -161,9 +164,14 @@ public class RaidsPlugin extends Plugin updateInfoBoxState(); } + if (event.getKey().equals("whitelistedRooms")) + { + updateList(roomWhitelist, config.whitelistedRooms()); + } + if (event.getKey().equals("blacklistedRooms")) { - updateList(blacklist, config.blacklistedRooms()); + updateList(roomBlacklist, config.blacklistedRooms()); } if (event.getKey().equals("whitelistedLayouts")) @@ -295,7 +303,8 @@ public class RaidsPlugin extends Plugin private void updateLists() { - updateList(blacklist, config.blacklistedRooms()); + updateList(roomWhitelist, config.blacklistedRooms()); + updateList(roomBlacklist, config.blacklistedRooms()); updateList(layoutWhitelist, config.whitelistedLayouts()); } From a84f8fbaa4f53906981a61d722822b2845612954 Mon Sep 17 00:00:00 2001 From: Kamiel Date: Wed, 28 Feb 2018 04:43:45 +0100 Subject: [PATCH 3/5] Add ability to whitelist boss rotations --- .../runelite/client/plugins/raids/Raid.java | 7 ++ .../client/plugins/raids/RaidsConfig.java | 24 +++++- .../client/plugins/raids/RaidsOverlay.java | 12 ++- .../client/plugins/raids/RaidsPlugin.java | 78 ++++++++++++++++++- 4 files changed, 117 insertions(+), 4 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/Raid.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/Raid.java index caf2207f14..a7b151f409 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/Raid.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/Raid.java @@ -24,7 +24,9 @@ */ package net.runelite.client.plugins.raids; +import com.google.common.base.Joiner; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import lombok.Getter; import net.runelite.client.plugins.raids.solver.Layout; @@ -109,6 +111,11 @@ public class Raid return combatRooms.toArray(new RaidRoom[combatRooms.size()]); } + public String getRotationString() + { + return Joiner.on(",").join(Arrays.stream(getCombatRooms()).map(r -> r.getBoss().getName()).toArray()); + } + public String toCode() { StringBuilder builder = new StringBuilder(); 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 da23b389b8..4beeb15957 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 @@ -103,6 +103,28 @@ public interface RaidsConfig extends Config @ConfigItem( position = 6, + keyName = "enableRotationWhitelist", + name = "Enable rotation whitelist", + description = "Enable the rotation whitelist" + ) + default boolean enableRotationWhitelist() + { + return false; + } + + @ConfigItem( + position = 7, + keyName = "whitelistedRotations", + name = "Whitelisted rotations", + description = "Warn when boss rotation doesn't match a whitelisted one. Add rotations like [tekton, muttadile, guardians]" + ) + default String whitelistedRotations() + { + return ""; + } + + @ConfigItem( + position = 8, keyName = "enableLayoutWhitelist", name = "Enable layout whitelist", description = "Enable the layout whitelist" @@ -113,7 +135,7 @@ public interface RaidsConfig extends Config } @ConfigItem( - position = 7, + position = 9, keyName = "whitelistedLayouts", name = "Whitelisted layouts", description = "Warn when layout doesn't match a whitelisted one. Add layouts like CFSCPPCSCF separated with comma" 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 ae75c95c4f..802b4dd19e 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 @@ -86,6 +86,14 @@ public class RaidsOverlay extends Overlay "Layout", Color.WHITE, layout, color )); + int bossMatches = 0; + int bossCount = 0; + + if (config.enableRotationWhitelist()) + { + bossMatches = plugin.getRotationMatches(); + } + for (Room layoutRoom : plugin.getRaid().getLayout().getRooms()) { int position = layoutRoom.getPosition(); @@ -101,11 +109,13 @@ public class RaidsOverlay extends Overlay switch (room.getType()) { case COMBAT: + bossCount++; if (plugin.getRoomWhitelist().contains(room.getBoss().getName().toLowerCase())) { color = Color.GREEN; } - else if (plugin.getRoomBlacklist().contains(room.getBoss().getName().toLowerCase())) + else if (plugin.getRoomBlacklist().contains(room.getBoss().getName().toLowerCase()) + || config.enableRotationWhitelist() && bossCount > bossMatches) { color = Color.RED; } 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 7cf1c30339..e0b1a5d29e 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 @@ -35,11 +35,21 @@ import java.text.DecimalFormat; import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.imageio.ImageIO; import javax.inject.Inject; import lombok.Getter; import lombok.extern.slf4j.Slf4j; -import net.runelite.api.*; +import net.runelite.api.ChatMessageType; +import net.runelite.api.Client; +import net.runelite.api.GameState; +import net.runelite.api.InstanceTemplates; +import net.runelite.api.ObjectID; +import net.runelite.api.Point; +import net.runelite.api.Setting; +import net.runelite.api.Tile; +import net.runelite.api.Varbits; import static net.runelite.api.Perspective.SCENE_SIZE; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ConfigChanged; @@ -72,6 +82,7 @@ public class RaidsPlugin extends Plugin 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 static final Pattern ROTATION_REGEX = Pattern.compile("\\[(.*?)\\]"); private BufferedImage raidsIcon; private RaidsTimer timer; @@ -104,6 +115,9 @@ public class RaidsPlugin extends Plugin @Getter private ArrayList roomBlacklist = new ArrayList<>(); + @Getter + private ArrayList rotationWhitelist = new ArrayList<>(); + @Getter private ArrayList layoutWhitelist = new ArrayList<>(); @@ -174,6 +188,11 @@ public class RaidsPlugin extends Plugin updateList(roomBlacklist, config.blacklistedRooms()); } + if (event.getKey().equals("whitelistedRotations")) + { + updateList(rotationWhitelist, config.whitelistedRotations()); + } + if (event.getKey().equals("whitelistedLayouts")) { updateList(layoutWhitelist, config.whitelistedLayouts()); @@ -305,13 +324,31 @@ public class RaidsPlugin extends Plugin { updateList(roomWhitelist, config.blacklistedRooms()); updateList(roomBlacklist, config.blacklistedRooms()); + updateList(rotationWhitelist, config.whitelistedRotations()); updateList(layoutWhitelist, config.whitelistedLayouts()); } private void updateList(ArrayList list, String input) { list.clear(); - list.addAll(Arrays.asList(input.toLowerCase().split(SPLIT_REGEX))); + + if (list == rotationWhitelist) + { + Matcher m = ROTATION_REGEX.matcher(input); + while (m.find()) + { + String rotation = m.group(1); + + if (!list.contains(rotation)) + { + list.add(rotation); + } + } + } + else + { + list.addAll(Arrays.asList(input.toLowerCase().split(SPLIT_REGEX))); + } } private void cacheColors() @@ -323,6 +360,43 @@ public class RaidsPlugin extends Plugin .refreshAll(); } + public int getRotationMatches() + { + String rotation = raid.getRotationString().toLowerCase(); + String[] bosses = rotation.split(SPLIT_REGEX); + + if (rotationWhitelist.contains(rotation)) + { + return bosses.length; + } + + for (String whitelisted : rotationWhitelist) + { + int matches = 0; + String[] whitelistedBosses = whitelisted.split(SPLIT_REGEX); + + for (int i = 0; i < whitelistedBosses.length; i++) + { + if (i < bosses.length && whitelistedBosses[i].equals(bosses[i])) + { + matches++; + } + else + { + matches = 0; + break; + } + } + + if (matches >= 2) + { + return matches; + } + } + + return 0; + } + private Point findLobbyBase() { Tile[][] tiles = client.getRegion().getTiles()[LOBBY_PLANE]; From c004747a88f39f3800f07524153907bba60bdb1a Mon Sep 17 00:00:00 2001 From: Kamiel Date: Thu, 1 Mar 2018 11:07:51 +0100 Subject: [PATCH 4/5] Add floor duration(s) to infobox tooltip --- .../client/plugins/raids/RaidsPlugin.java | 7 +++ .../client/plugins/raids/RaidsTimer.java | 49 ++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) 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 e0b1a5d29e..c0ffabb0e9 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 @@ -78,6 +78,7 @@ public class RaidsPlugin extends Plugin { private static final int LOBBY_PLANE = 3; private static final String RAID_START_MESSAGE = "The raid has begun!"; + private static final String LEVEL_COMPLETE_MESSAGE = "level complete!"; 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("###.##"); @@ -258,10 +259,16 @@ public class RaidsPlugin extends Plugin infoBoxManager.addInfoBox(timer); } + if (timer != null && message.contains(LEVEL_COMPLETE_MESSAGE)) + { + timer.timeFloor(); + } + if (message.startsWith(RAID_COMPLETE_MESSAGE)) { if (timer != null) { + timer.timeFloor(); timer.setStopped(true); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java index 562105924a..8331789b64 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java @@ -36,7 +36,11 @@ import net.runelite.client.ui.overlay.infobox.InfoBox; public class RaidsTimer extends InfoBox { private final Instant startTime; + private Instant floorTime; private LocalTime time; + private LocalTime firstFloorTime; + private LocalTime secondFloorTime; + private LocalTime olmTime; @Setter private boolean stopped; @@ -45,9 +49,30 @@ public class RaidsTimer extends InfoBox { super(image); this.startTime = startTime; + floorTime = startTime; stopped = false; } + public void timeFloor() + { + Duration elapsed = Duration.between(floorTime, Instant.now()); + + if (firstFloorTime == null) + { + firstFloorTime = LocalTime.ofSecondOfDay(elapsed.getSeconds()); + } + else if (secondFloorTime == null) + { + secondFloorTime = LocalTime.ofSecondOfDay(elapsed.getSeconds()); + } + else if (olmTime == null) + { + olmTime = LocalTime.ofSecondOfDay(elapsed.getSeconds()); + } + + floorTime = Instant.now(); + } + @Override public String getText() { @@ -84,6 +109,28 @@ public class RaidsTimer extends InfoBox @Override public String getTooltip() { - return "Elapsed raid time: " + time.format(DateTimeFormatter.ofPattern("HH:mm:ss")); + StringBuilder builder = new StringBuilder(); + builder.append("Elapsed raid time: "); + builder.append(time.format(DateTimeFormatter.ofPattern("HH:mm:ss"))); + + if (firstFloorTime != null) + { + builder.append("
First floor: "); + builder.append(firstFloorTime.format(DateTimeFormatter.ofPattern("mm:ss"))); + } + + if (secondFloorTime != null) + { + builder.append("
Second floor: "); + builder.append(secondFloorTime.format(DateTimeFormatter.ofPattern("mm:ss"))); + } + + if (olmTime != null) + { + builder.append("
Olm: "); + builder.append(olmTime.format(DateTimeFormatter.ofPattern("mm:ss"))); + } + + return builder.toString(); } } From 8bc8bfa6a4552ecb8865fa3b743bbf0365539070 Mon Sep 17 00:00:00 2001 From: Kamiel Date: Thu, 1 Mar 2018 23:42:13 +0100 Subject: [PATCH 5/5] Get points from varbits instead of widget --- .../src/main/java/net/runelite/api/Varbits.java | 2 ++ .../runelite/client/plugins/raids/RaidsPlugin.java | 14 +++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/Varbits.java b/runelite-api/src/main/java/net/runelite/api/Varbits.java index c9a83c6851..b952776710 100644 --- a/runelite-api/src/main/java/net/runelite/api/Varbits.java +++ b/runelite-api/src/main/java/net/runelite/api/Varbits.java @@ -179,6 +179,8 @@ public enum Varbits * Raids */ IN_RAID(5432), + TOTAL_POINTS(5431), + PERSONAL_POINTS(5422), /** * Nightmare Zone 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 c0ffabb0e9..51c1e62f8f 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 @@ -54,8 +54,6 @@ import static net.runelite.api.Perspective.SCENE_SIZE; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.VarbitChanged; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.chat.ChatColor; import net.runelite.client.chat.ChatColorType; import net.runelite.client.chat.ChatMessageBuilder; @@ -80,8 +78,8 @@ public class RaidsPlugin extends Plugin private static final String RAID_START_MESSAGE = "The raid has begun!"; private static final String LEVEL_COMPLETE_MESSAGE = "level complete!"; 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 DecimalFormat POINTS_FORMAT = new DecimalFormat("#,###"); private static final String SPLIT_REGEX = "\\s*,\\s*"; private static final Pattern ROTATION_REGEX = Pattern.compile("\\[(.*?)\\]"); @@ -274,10 +272,8 @@ public class RaidsPlugin extends Plugin if (config.pointsMessage()) { - Widget raidsWidget = client.getWidget(WidgetInfo.RAIDS_POINTS_INFOBOX).getChild(TEXT_CHILD); - String[] raidPoints = raidsWidget.getText().split("
"); - int totalPoints = Integer.parseInt(raidPoints[TOTAL_POINTS].replace(",", "")); - int personalPoints = Integer.parseInt(raidPoints[PERSONAL_POINTS].replace(",", "")); + int totalPoints = client.getSetting(Varbits.TOTAL_POINTS); + int personalPoints = client.getSetting(Varbits.PERSONAL_POINTS); double percentage = personalPoints / (totalPoints / 100.0); @@ -285,11 +281,11 @@ public class RaidsPlugin extends Plugin .append(ChatColorType.NORMAL) .append("Total points: ") .append(ChatColorType.HIGHLIGHT) - .append(raidPoints[TOTAL_POINTS]) + .append(POINTS_FORMAT.format(totalPoints)) .append(ChatColorType.NORMAL) .append(", Personal points: ") .append(ChatColorType.HIGHLIGHT) - .append(raidPoints[PERSONAL_POINTS]) + .append(POINTS_FORMAT.format(personalPoints)) .append(ChatColorType.NORMAL) .append(" (") .append(ChatColorType.HIGHLIGHT)