diff --git a/runelite-api/src/main/java/net/runelite/api/GraphicID.java b/runelite-api/src/main/java/net/runelite/api/GraphicID.java new file mode 100644 index 0000000000..4d4622c9c1 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/GraphicID.java @@ -0,0 +1,38 @@ +/* + * 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.api; + +public class GraphicID +{ + public static final int ENTANGLE = 179; + public static final int SNARE = 180; + public static final int BIND = 181; + public static final int ICE_RUSH = 361; + public static final int ICE_BURST = 363; + public static final int ICE_BLITZ = 367; + public static final int ICE_BARRAGE = 369; + public static final int VENGEANCE = 726; + public static final int IMBUED_HEART = 1316; +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java index c961e68e24..854bb51944 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java @@ -31,7 +31,9 @@ import java.io.InputStream; import java.time.Duration; import java.time.temporal.ChronoUnit; import javax.imageio.ImageIO; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; +import net.runelite.api.GraphicID; @Slf4j public enum GameTimer @@ -46,27 +48,39 @@ public enum GameTimer HALFTB("teleblock", 150, ChronoUnit.SECONDS), SUPERANTIVENOM("antivenom", 3, ChronoUnit.MINUTES), SUPERANTIFIRE("superantifire", 2, ChronoUnit.MINUTES), - ANTIDOTEPLUSPLUS("antidoteplusplus", 12, ChronoUnit.MINUTES); + ANTIDOTEPLUSPLUS("antidoteplusplus", 12, ChronoUnit.MINUTES), + BIND("bind", GraphicID.BIND, 5, ChronoUnit.SECONDS), + HALFBIND("bind", GraphicID.BIND, 2500, ChronoUnit.MILLIS), + SNARE("snare", GraphicID.SNARE, 10, ChronoUnit.SECONDS), + HALFSNARE("snare", GraphicID.SNARE, 5, ChronoUnit.SECONDS), + ENTANGLE("entangle", GraphicID.ENTANGLE, 15, ChronoUnit.SECONDS), + HALFENTANGLE("entangle", GraphicID.ENTANGLE, 7500, ChronoUnit.MILLIS), + ICERUSH("icerush", GraphicID.ICE_RUSH, 5, ChronoUnit.SECONDS), + ICEBURST("iceburst", GraphicID.ICE_BURST, 10, ChronoUnit.SECONDS), + ICEBLITZ("iceblitz", GraphicID.ICE_BLITZ, 15, ChronoUnit.SECONDS), + ICEBARRAGE("icebarrage", GraphicID.ICE_BARRAGE, 20, ChronoUnit.SECONDS), + IMBUEDHEART("imbuedheart", GraphicID.IMBUED_HEART, 420, ChronoUnit.SECONDS), + VENGEANCE("vengeance", GraphicID.VENGEANCE, 30, ChronoUnit.SECONDS); + @Getter private final String imageResource; + @Getter private final Duration duration; + @Getter + private final Integer graphicId; private BufferedImage image; - GameTimer(String imageResource, long time, ChronoUnit unit) + GameTimer(String imageResource, Integer graphicId, long time, ChronoUnit unit) { this.imageResource = imageResource; + this.graphicId = graphicId; this.duration = Duration.of(time, unit); } - public String getImageResource() + GameTimer(String imageResource, long time, ChronoUnit unit) { - return imageResource; - } - - public Duration getDuration() - { - return duration; + this(imageResource, null, time, unit); } public BufferedImage getImage() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersConfig.java index 12f77b56df..3146d4803b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersConfig.java @@ -144,4 +144,34 @@ public interface TimersConfig extends Config { return true; } + + @ConfigItem( + keyName = "showImbuedHeart", + name = "Imbued Heart timer", + description = "Configures whether imbued heart timer is displayed" + ) + default boolean showImbuedHeart() + { + return true; + } + + @ConfigItem( + keyName = "showVengeance", + name = "Vengeance timer", + description = "Configures whether vengeance timer is displayed" + ) + default boolean showVengeance() + { + return true; + } + + @ConfigItem( + keyName = "showFreezes", + name = "Freeze timer", + description = "Configures whether freeze timer is displayed" + ) + default boolean showFreezes() + { + return true; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java index e9ec2cfe5f..d417ddb4d1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java @@ -35,11 +35,27 @@ import static net.runelite.client.plugins.timers.GameTimer.OVERLOAD; import static net.runelite.client.plugins.timers.GameTimer.STAMINA; import static net.runelite.client.plugins.timers.GameTimer.SUPERANTIFIRE; import static net.runelite.client.plugins.timers.GameTimer.SUPERANTIVENOM; +import static net.runelite.client.plugins.timers.GameTimer.BIND; +import static net.runelite.client.plugins.timers.GameTimer.ENTANGLE; +import static net.runelite.client.plugins.timers.GameTimer.HALFBIND; +import static net.runelite.client.plugins.timers.GameTimer.HALFENTANGLE; +import static net.runelite.client.plugins.timers.GameTimer.HALFSNARE; +import static net.runelite.client.plugins.timers.GameTimer.ICEBARRAGE; +import static net.runelite.client.plugins.timers.GameTimer.ICEBLITZ; +import static net.runelite.client.plugins.timers.GameTimer.ICEBURST; +import static net.runelite.client.plugins.timers.GameTimer.ICERUSH; +import static net.runelite.client.plugins.timers.GameTimer.IMBUEDHEART; +import static net.runelite.client.plugins.timers.GameTimer.SNARE; +import static net.runelite.client.plugins.timers.GameTimer.VENGEANCE; import com.google.common.eventbus.Subscribe; import com.google.inject.Provides; import javax.inject.Inject; +import net.runelite.api.Actor; import net.runelite.api.ChatMessageType; +import net.runelite.api.Client; import net.runelite.api.ItemID; +import net.runelite.api.Prayer; +import net.runelite.api.events.GraphicChanged; import net.runelite.client.config.ConfigManager; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ConfigChanged; @@ -53,6 +69,9 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager; ) public class TimersPlugin extends Plugin { + @Inject + Client client; + @Inject TimersConfig config; @@ -225,6 +244,91 @@ public class TimersPlugin extends Plugin { removeGameTimer(SUPERANTIFIRE); } + + if (event.getMessage().equals("Your imbued heart has regained its magical power.")) + { + removeGameTimer(IMBUEDHEART); + } + } + + @Subscribe + public void onGraphicChanged(GraphicChanged event) + { + Actor actor = event.getActor(); + + if (actor != client.getLocalPlayer()) + { + return; + } + + if (actor.getGraphic() == IMBUEDHEART.getGraphicId() && config.showImbuedHeart()) + { + createGameTimer(IMBUEDHEART); + } + + if (actor.getGraphic() == VENGEANCE.getGraphicId() && config.showVengeance()) + { + createGameTimer(VENGEANCE); + } + + if (config.showFreezes()) + { + if (actor.getGraphic() == BIND.getGraphicId()) + { + if (client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC)) + { + createGameTimer(HALFBIND); + } + else + { + createGameTimer(BIND); + } + } + + if (actor.getGraphic() == SNARE.getGraphicId()) + { + if (client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC)) + { + createGameTimer(HALFSNARE); + } + else + { + createGameTimer(SNARE); + } + } + + if (actor.getGraphic() == ENTANGLE.getGraphicId()) + { + if (client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC)) + { + createGameTimer(HALFENTANGLE); + } + else + { + createGameTimer(ENTANGLE); + } + } + + if (actor.getGraphic() == ICERUSH.getGraphicId()) + { + createGameTimer(ICERUSH); + } + + if (actor.getGraphic() == ICEBURST.getGraphicId()) + { + createGameTimer(ICEBURST); + } + + if (actor.getGraphic() == ICEBLITZ.getGraphicId()) + { + createGameTimer(ICEBLITZ); + } + + if (actor.getGraphic() == ICEBARRAGE.getGraphicId()) + { + createGameTimer(ICEBARRAGE); + } + } } public void createGameTimer(GameTimer timer) diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/timers/bind.png b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/bind.png new file mode 100644 index 0000000000..cfaa07029c Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/bind.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/timers/entangle.png b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/entangle.png new file mode 100644 index 0000000000..abe631c595 Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/entangle.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/timers/icebarrage.png b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/icebarrage.png new file mode 100644 index 0000000000..0b1fd9a050 Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/icebarrage.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/timers/iceblitz.png b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/iceblitz.png new file mode 100644 index 0000000000..49e0cf4ce9 Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/iceblitz.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/timers/iceburst.png b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/iceburst.png new file mode 100644 index 0000000000..141df53986 Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/iceburst.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/timers/icerush.png b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/icerush.png new file mode 100644 index 0000000000..31fa6d49c7 Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/icerush.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/timers/imbuedheart.png b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/imbuedheart.png new file mode 100644 index 0000000000..89e85e4458 Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/imbuedheart.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/timers/snare.png b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/snare.png new file mode 100644 index 0000000000..13f89814c6 Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/snare.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/timers/vengeance.png b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/vengeance.png new file mode 100644 index 0000000000..fd8f60557f Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/timers/vengeance.png differ