From c879a38f637ef55344977a72767541befc514704 Mon Sep 17 00:00:00 2001 From: Crystalknoct Date: Wed, 11 Sep 2019 20:53:29 -0600 Subject: [PATCH 01/13] tzhaartimersplugin fixes no longer requires eventbus --- .../plugins/tzhaartimers/TzhaarTimersPlugin | 291 ++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimersPlugin diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimersPlugin b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimersPlugin new file mode 100644 index 0000000000..51e9c462e5 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimersPlugin @@ -0,0 +1,291 @@ +/* + * Copyright (c) 2019, winterdaze + * 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.tzhaartimers; + +import lombok.Getter; +import net.runelite.api.ChatMessageType; +import net.runelite.api.Client; +import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.GameStateChanged; +import net.runelite.api.util.Text; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.game.ItemManager; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.ui.overlay.infobox.InfoBoxManager; +import net.runelite.client.eventbus.EventBus; + +import javax.inject.Inject; +import java.time.Duration; +import java.time.Instant; +import java.util.Arrays; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static net.runelite.api.ItemID.FIRE_CAPE; +import static net.runelite.api.ItemID.INFERNAL_CAPE; + +@PluginDescriptor( + name = "Tzhaar Timers", + description = "Display elapsed time in the Fight Caves and Inferno", + tags = {"inferno", "fight", "caves", "cape", "timer", "tzhaar"} +) +public class TzhaarTimersPlugin extends Plugin +{ + private static final Pattern WAVE_MESSAGE = Pattern.compile("Wave: (\\d+)"); + private static final String DEFEATED_MESSAGE = "You have been defeated!"; + private static final Pattern COMPLETE_MESSAGE = Pattern.compile("Your (TzTok-Jad|TzKal-Zuk) kill count is:"); + private static final Pattern PAUSED_MESSAGE = Pattern.compile("The (Inferno|Fight Cave) has been paused. You may now log out."); + private static final String CONFIG_GROUP = "tzhaartimers"; + private static final String CONFIG_TIME = "time"; + private static final String CONFIG_STARTED = "started"; + private static final String CONFIG_LASTTIME = "lasttime"; + + @Inject + private InfoBoxManager infoBoxManager; + + @Inject + private Client client; + + @Inject + private ItemManager itemManager; + + @Inject + private ConfigManager configManager; + + @Inject + private EventBus eventBus; + + @Getter + private TzhaarTimers timer; + + private Instant startTime; + private Instant lastTime; + private Boolean started = false; + private boolean loggingIn; + + @Override + public void startUp() + { + addSubscriptions(); + } + + public void onGameStateChanged(GameStateChanged event) + { + switch (event.getGameState()) + { + case LOGGED_IN: + if (loggingIn) + { + loggingIn = false; + loadConfig(); + resetConfig(); + } + break; + case LOGGING_IN: + loggingIn = true; + break; + case LOADING: + if (!loggingIn) + { + updateInfoBoxState(); + } + break; + case HOPPING: + loggingIn = true; + case LOGIN_SCREEN: + removeTimer(); + saveConfig(); + break; + default: + break; + } + } + + public void onChatMessage(ChatMessage event) + { + if (event.getType() != ChatMessageType.GAMEMESSAGE && event.getType() != ChatMessageType.SPAM) + { + return; + } + + String message = Text.removeTags(event.getMessage()); + Matcher matcher = COMPLETE_MESSAGE.matcher(message); + + if (message.contains(DEFEATED_MESSAGE) || matcher.matches()) + { + removeTimer(); + resetConfig(); + resetVars(); + return; + } + + Instant now = Instant.now(); + matcher = PAUSED_MESSAGE.matcher(message); + if (matcher.matches()) + { + lastTime = now; + createTimer(startTime, now); + return; + } + + matcher = WAVE_MESSAGE.matcher(message); + if (!matcher.matches()) + { + return; + } + + if (!started) + { + int wave = Integer.parseInt(matcher.group(1)); + if (wave != 1) + { + return; + } + + started = true; + startTime = now; + } + else if (lastTime != null) + { + startTime = startTime.plus(Duration.between(startTime, now)).minus(Duration.between(startTime, lastTime)); + lastTime = null; + } + + createTimer(startTime, lastTime); + } + + private void updateInfoBoxState() + { + if (timer == null) + { + return; + } + + if (!checkInFightCaves() && !checkInInferno()) + { + removeTimer(); + resetConfig(); + resetVars(); + } + } + + private boolean checkInFightCaves() + { + return client.getMapRegions() != null && Arrays.stream(client.getMapRegions()) + .filter(x -> x == 9551) + .toArray().length > 0; + } + + private boolean checkInInferno() + { + return client.getMapRegions() != null && Arrays.stream(client.getMapRegions()) + .filter(x -> x == 9043) + .toArray().length > 0; + } + + private void resetVars() + { + startTime = null; + lastTime = null; + started = false; + } + + private void removeTimer() + { + infoBoxManager.removeInfoBox(timer); + timer = null; + } + + private void createTimer(Instant startTime, Instant lastTime) + { + if (timer != null) + { + infoBoxManager.removeInfoBox(timer); + } + + if (checkInFightCaves()) + { + timer = new TzhaarTimers(itemManager.getImage(FIRE_CAPE), this, startTime, lastTime); + infoBoxManager.addInfoBox(timer); + } + else if (checkInInferno()) + { + timer = new TzhaarTimers(itemManager.getImage(INFERNAL_CAPE), this, startTime, lastTime); + infoBoxManager.addInfoBox(timer); + } + } + + @Override + protected void shutDown() throws Exception + { + eventBus.unregister(this); + removeTimer(); + resetConfig(); + resetVars(); + } + + private void addSubscriptions() + { + eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged); + eventBus.subscribe(ChatMessage.class, this, this::onChatMessage); + } + + private void loadConfig() + { + startTime = configManager.getConfiguration(CONFIG_GROUP, CONFIG_TIME, Instant.class); + started = configManager.getConfiguration(CONFIG_GROUP, CONFIG_STARTED, Boolean.class); + lastTime = configManager.getConfiguration(CONFIG_GROUP, CONFIG_LASTTIME, Instant.class); + if (started == null) + { + started = false; + } + } + + private void resetConfig() + { + configManager.unsetConfiguration(CONFIG_GROUP, CONFIG_TIME); + configManager.unsetConfiguration(CONFIG_GROUP, CONFIG_STARTED); + configManager.unsetConfiguration(CONFIG_GROUP, CONFIG_LASTTIME); + } + + private void saveConfig() + { + if (startTime == null) + { + return; + } + + if (lastTime == null) + { + lastTime = Instant.now(); + } + + configManager.setConfiguration(CONFIG_GROUP, CONFIG_TIME, startTime); + configManager.setConfiguration(CONFIG_GROUP, CONFIG_STARTED, started); + configManager.setConfiguration(CONFIG_GROUP, CONFIG_LASTTIME, lastTime); + resetVars(); + } +} From 41320564fc039d7049b1473a7edbdfc872dd7a1a Mon Sep 17 00:00:00 2001 From: Crystalknoct Date: Wed, 11 Sep 2019 20:54:08 -0600 Subject: [PATCH 02/13] tzhaartimers fixes the requirement of modified eventbus --- .../client/plugins/tzhaartimers/TzhaarTimers | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimers diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimers b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimers new file mode 100644 index 0000000000..d0d187b56a --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimers @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2019, winterdaze + * 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.tzhaartimers; + +import net.runelite.client.ui.overlay.infobox.InfoBox; + +import java.awt.image.BufferedImage; +import java.awt.Color; +import java.time.Duration; +import java.time.Instant; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; + +public class TzhaarTimers extends InfoBox +{ + private final Instant startTime; + private LocalTime time; + private Instant lastTime; + + public TzhaarTimers(BufferedImage image, TzhaarTimersPlugin plugin, Instant startTime, Instant lastTime) + { + super(image, plugin); + this.startTime = startTime; + this.lastTime = lastTime; + } + + @Override + public String getText() + { + if (startTime == null) + { + return ""; + } + + if (lastTime == null) + { + Duration elapsed = Duration.between(startTime, Instant.now()); + time = LocalTime.ofSecondOfDay(elapsed.getSeconds()); + } + else + { + Duration elapsed = Duration.between(startTime, lastTime); + time = LocalTime.ofSecondOfDay(elapsed.getSeconds()); + } + + if (time.getHour() > 0) + { + return time.format(DateTimeFormatter.ofPattern("HH:mm")); + } + return time.format(DateTimeFormatter.ofPattern("mm:ss")); + } + + @Override + public Color getTextColor() + { + return Color.WHITE; + } + + @Override + public String getTooltip() + { + StringBuilder builder = new StringBuilder(); + builder.append("Elapsed time: "); + builder.append(time.format(DateTimeFormatter.ofPattern("HH:mm:ss"))); + + return builder.toString(); + } +} From d03576463c676999ad2c1f5c2e025efc3903ea49 Mon Sep 17 00:00:00 2001 From: Crystalknoct Date: Wed, 11 Sep 2019 20:57:06 -0600 Subject: [PATCH 03/13] tzhaartimers added.java .java --- .../plugins/tzhaartimers/{TzhaarTimers => TzhaarTimers.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/{TzhaarTimers => TzhaarTimers.java} (100%) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimers b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimers.java similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimers rename to runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimers.java From e5134ab6371b5cad2d9563bb4f55af4743176f3a Mon Sep 17 00:00:00 2001 From: Crystalknoct Date: Wed, 11 Sep 2019 20:57:37 -0600 Subject: [PATCH 04/13] tzhaartimersplugin.java adds.java --- .../tzhaartimers/{TzhaarTimersPlugin => TzhaarTimersPlugin.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/{TzhaarTimersPlugin => TzhaarTimersPlugin.java} (100%) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimersPlugin b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimersPlugin.java similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimersPlugin rename to runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimersPlugin.java From a6df8993268aec5e0c89962ed16b75903c7dfc2a Mon Sep 17 00:00:00 2001 From: Crystalknoct Date: Thu, 12 Sep 2019 21:39:12 -0600 Subject: [PATCH 05/13] Bosstimetracker:renamed renamed --- .../{TzhaarTimers.java => BossTimeTracker.java} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/{TzhaarTimers.java => BossTimeTracker.java} (92%) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimers.java b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTracker.java similarity index 92% rename from runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimers.java rename to runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTracker.java index d0d187b56a..882f415c9f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimers.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTracker.java @@ -22,7 +22,7 @@ * (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.tzhaartimers; +package net.runelite.client.plugins.bosstimetracker; import net.runelite.client.ui.overlay.infobox.InfoBox; @@ -33,13 +33,13 @@ import java.time.Instant; import java.time.LocalTime; import java.time.format.DateTimeFormatter; -public class TzhaarTimers extends InfoBox +public class BossTimeTracker extends InfoBox { private final Instant startTime; private LocalTime time; private Instant lastTime; - public TzhaarTimers(BufferedImage image, TzhaarTimersPlugin plugin, Instant startTime, Instant lastTime) + public BossTimeTracker(BufferedImage image, BossTimeTrackerPlugin plugin, Instant startTime, Instant lastTime) { super(image, plugin); this.startTime = startTime; From 42c6a4341b1581d9b34f2dc3f49449b1f36dc61c Mon Sep 17 00:00:00 2001 From: Crystalknoct Date: Thu, 12 Sep 2019 21:40:10 -0600 Subject: [PATCH 06/13] bosstimetrackerplugin:rename renamed --- ...imersPlugin.java => BossTimeTrackerPlugin.java} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/{TzhaarTimersPlugin.java => BossTimeTrackerPlugin.java} (94%) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTrackerPlugin.java similarity index 94% rename from runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimersPlugin.java rename to runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTrackerPlugin.java index 51e9c462e5..1d49a841e7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/TzhaarTimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTrackerPlugin.java @@ -22,7 +22,7 @@ * (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.tzhaartimers; +package net.runelite.client.plugins.bosstimetracker; import lombok.Getter; import net.runelite.api.ChatMessageType; @@ -48,17 +48,17 @@ import static net.runelite.api.ItemID.FIRE_CAPE; import static net.runelite.api.ItemID.INFERNAL_CAPE; @PluginDescriptor( - name = "Tzhaar Timers", + name = "Boss Time Tracker", description = "Display elapsed time in the Fight Caves and Inferno", tags = {"inferno", "fight", "caves", "cape", "timer", "tzhaar"} ) -public class TzhaarTimersPlugin extends Plugin +public class BossTimeTrackerPlugin extends Plugin { private static final Pattern WAVE_MESSAGE = Pattern.compile("Wave: (\\d+)"); private static final String DEFEATED_MESSAGE = "You have been defeated!"; private static final Pattern COMPLETE_MESSAGE = Pattern.compile("Your (TzTok-Jad|TzKal-Zuk) kill count is:"); private static final Pattern PAUSED_MESSAGE = Pattern.compile("The (Inferno|Fight Cave) has been paused. You may now log out."); - private static final String CONFIG_GROUP = "tzhaartimers"; + private static final String CONFIG_GROUP = "Boss Time Tracker"; private static final String CONFIG_TIME = "time"; private static final String CONFIG_STARTED = "started"; private static final String CONFIG_LASTTIME = "lasttime"; @@ -79,7 +79,7 @@ public class TzhaarTimersPlugin extends Plugin private EventBus eventBus; @Getter - private TzhaarTimers timer; + private BossTimeTracker timer; private Instant startTime; private Instant lastTime; @@ -228,12 +228,12 @@ public class TzhaarTimersPlugin extends Plugin if (checkInFightCaves()) { - timer = new TzhaarTimers(itemManager.getImage(FIRE_CAPE), this, startTime, lastTime); + timer = new BossTimeTracker(itemManager.getImage(FIRE_CAPE), this, startTime, lastTime); infoBoxManager.addInfoBox(timer); } else if (checkInInferno()) { - timer = new TzhaarTimers(itemManager.getImage(INFERNAL_CAPE), this, startTime, lastTime); + timer = new BossTimeTracker(itemManager.getImage(INFERNAL_CAPE), this, startTime, lastTime); infoBoxManager.addInfoBox(timer); } } From 6cb3fb01e29a9237acb63005a13f42e86bec8db0 Mon Sep 17 00:00:00 2001 From: Crystalknoct Date: Thu, 12 Sep 2019 22:59:24 -0600 Subject: [PATCH 07/13] bosstimetrackerplugin: rl+ified it Added type = PluginType.PVM, enabledByDefault = false --- .../client/plugins/tzhaartimers/BossTimeTrackerPlugin.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTrackerPlugin.java index 1d49a841e7..964fc70406 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTrackerPlugin.java @@ -50,7 +50,9 @@ import static net.runelite.api.ItemID.INFERNAL_CAPE; @PluginDescriptor( name = "Boss Time Tracker", description = "Display elapsed time in the Fight Caves and Inferno", - tags = {"inferno", "fight", "caves", "cape", "timer", "tzhaar"} + tags = {"inferno", "fight", "caves", "cape", "timer", "tzhaar"}, + type = PluginType.PVM, + enabledByDefault = false ) public class BossTimeTrackerPlugin extends Plugin { From 6822f2aa2ddce18403502a57edd294df3e845dde Mon Sep 17 00:00:00 2001 From: Crystalknoct Date: Thu, 12 Sep 2019 23:24:03 -0600 Subject: [PATCH 08/13] bosstimetrackerplugin:checkstyle ima derp --- .../client/plugins/tzhaartimers/BossTimeTrackerPlugin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTrackerPlugin.java index 964fc70406..02979340d1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tzhaartimers/BossTimeTrackerPlugin.java @@ -34,6 +34,7 @@ import net.runelite.client.config.ConfigManager; import net.runelite.client.game.ItemManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.PluginType; import net.runelite.client.ui.overlay.infobox.InfoBoxManager; import net.runelite.client.eventbus.EventBus; @@ -50,7 +51,7 @@ import static net.runelite.api.ItemID.INFERNAL_CAPE; @PluginDescriptor( name = "Boss Time Tracker", description = "Display elapsed time in the Fight Caves and Inferno", - tags = {"inferno", "fight", "caves", "cape", "timer", "tzhaar"}, + tags = {"inferno", "fight", "caves", "cape", "timer", "tzhaar", "pvm"}, type = PluginType.PVM, enabledByDefault = false ) From 3ca832e677d28cca20575a20e4e1b04907ffa804 Mon Sep 17 00:00:00 2001 From: f0rmatme Date: Tue, 5 Nov 2019 17:36:47 -0800 Subject: [PATCH 09/13] suppliestracker: crash bug fix for house pool --- .../SuppliesTrackerPlugin.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPlugin.java index 3f3003ed2a..aa7a192327 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPlugin.java @@ -513,6 +513,25 @@ public class SuppliesTrackerPlugin extends Plugin private void onMenuOptionClicked(final MenuOptionClicked event) { + // Fix for house pool + switch (event.getMenuOpcode()) + { + case ITEM_FIRST_OPTION: + case ITEM_SECOND_OPTION: + case ITEM_THIRD_OPTION: + case ITEM_FOURTH_OPTION: + case ITEM_FIFTH_OPTION: + case EXAMINE_ITEM_BANK_EQ: + case WIDGET_FIRST_OPTION: + case WIDGET_SECOND_OPTION: + case WIDGET_THIRD_OPTION: + case WIDGET_FOURTH_OPTION: + case WIDGET_FIFTH_OPTION: + case WIDGET_DEFAULT: + break; + default: + return; + } // Uses stacks to push/pop for tick eating // Create pattern to find eat/drink at beginning Pattern eatPattern = Pattern.compile(EAT_PATTERN); From 2aa13f30728655545557dd725762ce762b73f231 Mon Sep 17 00:00:00 2001 From: Lucwousin Date: Wed, 6 Nov 2019 19:06:50 +0100 Subject: [PATCH 10/13] deathindicators: Fix saving bones to config (#1896) * Don't use a permanently-empty map when adding bones * Save bones when adding them, rather than on shutdown/region change --- .../client/plugins/deathindicator/Bones.java | 46 ++++++++----------- .../deathindicator/DeathIndicatorPlugin.java | 27 ++++++----- 2 files changed, 33 insertions(+), 40 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/deathindicator/Bones.java b/runelite-client/src/main/java/net/runelite/client/plugins/deathindicator/Bones.java index 7b561dd63b..0b5e234fc9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/deathindicator/Bones.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/deathindicator/Bones.java @@ -3,7 +3,6 @@ package net.runelite.client.plugins.deathindicator; import com.google.common.collect.ImmutableMap; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -22,7 +21,6 @@ public class Bones private static final String BONES_PREFIX = "bones_"; private ImmutableMap>> map; - private boolean changed = false; void init(Client client, ConfigManager configManager) { @@ -31,14 +29,14 @@ public class Bones Bone[][] bones = getBones(configManager, regions); if (log.isDebugEnabled()) { - log.debug("Regions are now {}", Arrays.toString(regions)); + log.trace("Regions are now {}", Arrays.toString(regions)); int n = 0; for (Bone[] ar : bones) { n += ar.length; } - log.debug("Loaded {} Bones", n); + log.debug("Loaded {} Bones", n); } initMap(regions, bones); @@ -81,7 +79,7 @@ public class Bones Bone[] boneA = bones[i]; if (boneA.length == 0) { - builder.put(region, Collections.EMPTY_MAP); + builder.put(region, new HashMap<>()); continue; } @@ -103,35 +101,29 @@ public class Bones this.forEach(bone -> bone.addToScene(scene)); } - void save(ConfigManager configManager) + void save(ConfigManager configManager, int region) { - if (this.map == null || !changed) + final Map> regionBones = this.map.get(region); + if (regionBones == null) { - this.changed = false; return; } - for (Map.Entry>> entry : this.map.entrySet()) + final String key = BONES_PREFIX + region; + + if (regionBones.size() == 0) { - final String key = BONES_PREFIX + entry.getKey(); - final Map> map = entry.getValue(); - if (map.size() == 0) - { - configManager.unsetConfiguration(CONFIG_GROUP, key); - continue; - } - - List list = new ArrayList<>(map.values().size()); - for (List lb : map.values()) - { - list.addAll(lb); - } - - String val = GSON.toJson(list.toArray(new Bone[0])); - configManager.setConfiguration(CONFIG_GROUP, key, val); + configManager.unsetConfiguration(CONFIG_GROUP, key); } - this.changed = false; + List list = new ArrayList<>(regionBones.values().size()); + for (List lb : regionBones.values()) + { + list.addAll(lb); + } + + String val = GSON.toJson(list.toArray(new Bone[0])); + configManager.setConfiguration(CONFIG_GROUP, key, val); } public boolean add(Bone bone) @@ -141,7 +133,6 @@ public class Bones return false; } - this.changed = true; final int region = bone.getLoc().getRegionID(); final Map> map = this.map.get(region); final List list = map.computeIfAbsent(bone.getLoc(), wp -> new ArrayList<>()); @@ -151,7 +142,6 @@ public class Bones public void remove(Bone bone) { - this.changed = true; final int region = bone.getLoc().getRegionID(); final Map> map = this.map.get(region); final List list = map.get(bone.getLoc()); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/deathindicator/DeathIndicatorPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/deathindicator/DeathIndicatorPlugin.java index 33ec854e8f..7dd7a6241e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/deathindicator/DeathIndicatorPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/deathindicator/DeathIndicatorPlugin.java @@ -182,7 +182,6 @@ public class DeathIndicatorPlugin extends Plugin worldMapPointManager.removeIf(DeathWorldMapPoint.class::isInstance); clientThread.invokeLater(this::clearBones); - saveBones(); } private void initBones() @@ -190,11 +189,6 @@ public class DeathIndicatorPlugin extends Plugin bones.init(client, configManager); } - private void saveBones() - { - bones.save(configManager); - } - private void clearBones() { bones.clear(client.getScene()); @@ -236,12 +230,16 @@ public class DeathIndicatorPlugin extends Plugin private void onPlayerDeath(PlayerDeath death) { - Player p = death.getPlayer(); + newBoneFor(death.getPlayer()); + } + + private void newBoneFor(Player player) + { Bone b = new Bone(); - b.setName(Text.sanitize(p.getName())); + b.setName(Text.sanitize(player.getName())); b.setTime(Instant.now()); - b.setLoc(p.getWorldLocation()); + b.setLoc(player.getWorldLocation()); while (!bones.add(b)) { @@ -249,6 +247,7 @@ public class DeathIndicatorPlugin extends Plugin } b.addToScene(client.getScene()); + bones.save(configManager, b.getLoc().getRegionID()); } private void onMenuEntryAdded(MenuEntryAdded event) @@ -309,7 +308,13 @@ public class DeathIndicatorPlugin extends Plugin return; } - lastDeath = client.getLocalPlayer().getWorldLocation(); + Player lp = client.getLocalPlayer(); + if (config.permaBones()) + { + newBoneFor(lp); + } + + lastDeath = lp.getWorldLocation(); lastDeathWorld = client.getWorld(); lastDeathTime = Instant.now(); } @@ -400,7 +405,6 @@ public class DeathIndicatorPlugin extends Plugin if (client.getGameState() == GameState.LOGGED_IN) { clientThread.invokeLater(this::clearBones); - saveBones(); } } return; @@ -438,7 +442,6 @@ public class DeathIndicatorPlugin extends Plugin { case LOADING: clearBones(); - saveBones(); break; case LOGGED_IN: if (config.permaBones()) From aa9dda6958c654d5c3912a6b0e3b0b9de72595c6 Mon Sep 17 00:00:00 2001 From: Lucwousin Date: Wed, 6 Nov 2019 19:28:36 +0100 Subject: [PATCH 11/13] Injector plugin version bump (#1897) --- buildSrc/src/main/kotlin/Dependencies.kt | 2 +- .../net/runelite/mapping/ObfuscatedName.java | 40 ------------------- 2 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 runelite-api/src/main/java/net/runelite/mapping/ObfuscatedName.java diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index df4d662ca2..876ca9f328 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -38,7 +38,7 @@ object ProjectVersions { object Plugins { val grgitPlugin = "org.ajoberstar:grgit:2.3.0" val versionsPlugin = "com.github.ben-manes:gradle-versions-plugin:0.27.0" - val injectorPlugin = "com.openosrs:injector-plugin:1.0.0" + val injectorPlugin = "com.openosrs:injector-plugin:1.0.1" val testLogger = Pair("com.adarshr.test-logger", "2.0.0") val versions = Pair("com.github.ben-manes.versions", "0.27.0") val buildScan = Pair("com.gradle.build-scan", "3.0") diff --git a/runelite-api/src/main/java/net/runelite/mapping/ObfuscatedName.java b/runelite-api/src/main/java/net/runelite/mapping/ObfuscatedName.java deleted file mode 100644 index 10ccf9ecd4..0000000000 --- a/runelite-api/src/main/java/net/runelite/mapping/ObfuscatedName.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2016-2017, 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.mapping; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target( - { - ElementType.FIELD, ElementType.METHOD, ElementType.TYPE - }) -public @interface ObfuscatedName -{ - String value(); -} From b2e44e881b96d71dfd0c698ce52919f57f119d79 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Sat, 21 Sep 2019 01:45:17 -0400 Subject: [PATCH 12/13] Fix agility overhead icons --- .../plugins/playerindicators/PlayerIndicatorsOverlay.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index 86dae6756b..dffc76d65d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -180,14 +180,14 @@ public class PlayerIndicatorsOverlay extends Overlay textLocation.getY() - height), ImageUtil.resizeImage(agilityIcon, height, height)); } - else if (level >= plugin.getAgilitySecondThreshold()) + if (level >= plugin.getAgilitySecondThreshold()) { OverlayUtil.renderImageLocation(graphics, new Point(textLocation.getX() + agilityIcon.getWidth() + width, textLocation.getY() - height), ImageUtil.resizeImage(agilityIcon, height, height)); } - else if (level < plugin.getAgilityFirstThreshold()) + if (level < plugin.getAgilityFirstThreshold()) { OverlayUtil.renderImageLocation(graphics, new Point(textLocation.getX() + 5 + width, From ed250e58f1a318d5fbb4ae11a37a710a648f7406 Mon Sep 17 00:00:00 2001 From: Lucwousin Date: Thu, 7 Nov 2019 00:01:21 +0100 Subject: [PATCH 13/13] dependencies: injector plugin 1.0.2 --- buildSrc/src/main/kotlin/Dependencies.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 876ca9f328..9dc9cc341a 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -38,7 +38,7 @@ object ProjectVersions { object Plugins { val grgitPlugin = "org.ajoberstar:grgit:2.3.0" val versionsPlugin = "com.github.ben-manes:gradle-versions-plugin:0.27.0" - val injectorPlugin = "com.openosrs:injector-plugin:1.0.1" + val injectorPlugin = "com.openosrs:injector-plugin:1.0.2" val testLogger = Pair("com.adarshr.test-logger", "2.0.0") val versions = Pair("com.github.ben-manes.versions", "0.27.0") val buildScan = Pair("com.gradle.build-scan", "3.0")