From 46e7a243bf779b765084d4e164bb925cb1a4752d Mon Sep 17 00:00:00 2001 From: Devin Date: Tue, 7 Nov 2017 17:05:59 -0800 Subject: [PATCH 1/4] Add cannonball smithing animation --- .../net/runelite/client/plugins/idlenotifier/IdleNotifier.java | 1 + 1 file changed, 1 insertion(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java index a2365dd91f..54b6c6f393 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java @@ -110,6 +110,7 @@ public class IdleNotifier extends Plugin /* Smithing(Anvil, Furnace, Cannonballs */ case SMITHING_ANVIL: case SMITHING_SMELTING: + case SMITHING_CANNONBALL: /* Fishing */ case FISHING_NET: case FISHING_HARPOON: From dfb467f6336646e9f53e0582061b19bf51bb8fbb Mon Sep 17 00:00:00 2001 From: Devin Date: Tue, 7 Nov 2017 17:29:22 -0800 Subject: [PATCH 2/4] Combine CombatNotifier and IdleNotifier plugins --- .../combatnotifier/CombatNotifier.java | 95 ------------------- .../plugins/idlenotifier/IdleNotifier.java | 36 ++++++- .../IdleNotifierConfig.java} | 25 +++-- 3 files changed, 44 insertions(+), 112 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/combatnotifier/CombatNotifier.java rename runelite-client/src/main/java/net/runelite/client/plugins/{combatnotifier/CombatNotifierConfig.java => idlenotifier/IdleNotifierConfig.java} (70%) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/combatnotifier/CombatNotifier.java b/runelite-client/src/main/java/net/runelite/client/plugins/combatnotifier/CombatNotifier.java deleted file mode 100644 index f7e6bcb866..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/combatnotifier/CombatNotifier.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2017, Kronos - * 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.combatnotifier; - -import com.google.common.eventbus.Subscribe; -import java.time.Duration; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import net.runelite.api.Actor; -import net.runelite.api.Client; -import net.runelite.api.GameState; -import net.runelite.api.Player; -import net.runelite.client.RuneLite; -import net.runelite.client.events.GameStateChanged; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.task.Schedule; - -@PluginDescriptor( - name = "Combat notifier" -) -public class CombatNotifier extends Plugin -{ - private final Client client = RuneLite.getClient(); - private final RuneLite runelite = RuneLite.getRunelite(); - private final CombatNotifierConfig config = runelite.getConfigManager() - .getConfig(CombatNotifierConfig.class); - - private Instant lastInteracting; - - @Override - protected void startUp() throws Exception - { - } - - @Override - protected void shutDown() throws Exception - { - } - - @Subscribe - public void onGameStateChanged(GameStateChanged gameStateChanged) - { - lastInteracting = null; - } - - @Schedule( - period = 1, - unit = ChronoUnit.SECONDS - ) - public void checkIdle() - { - if (client.getGameState() != GameState.LOGGED_IN || !config.isEnabled()) - { - return; - } - - Player local = client.getLocalPlayer(); - Actor opponent = local.getInteracting(); - if (opponent != null && opponent.getCombatLevel() > 0) - { - lastInteracting = Instant.now(); - } - - Duration waitDuration = Duration.ofMillis(config.getTimeout()); - if (lastInteracting != null && Instant.now().compareTo(lastInteracting.plus(waitDuration)) >= 0) - { - runelite.notify("[" + local.getName() + "] is now out of combat!"); - lastInteracting = null; - } - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java index 54b6c6f393..745da7255b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2017, Abel Briggs + * Copyright (c) 2017, Kronos * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,11 +30,14 @@ import java.time.Duration; import java.time.Instant; import java.time.temporal.ChronoUnit; import static net.runelite.api.AnimationID.*; + +import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.Player; import net.runelite.client.RuneLite; import net.runelite.client.events.AnimationChanged; +import net.runelite.client.events.GameStateChanged; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.task.Schedule; @@ -43,12 +47,12 @@ import net.runelite.client.task.Schedule; ) public class IdleNotifier extends Plugin { - private static final Duration WAIT_DURATION = Duration.ofMillis(2500L); - private final Client client = RuneLite.getClient(); private final RuneLite runelite = RuneLite.getRunelite(); + private final IdleNotifierConfig config = runelite.getConfigManager().getConfig(IdleNotifierConfig.class); private Instant lastAnimating; + private Instant lastInteracting; private boolean notifyIdle = false; @Override @@ -64,7 +68,7 @@ public class IdleNotifier extends Plugin @Subscribe public void onAnimationChanged(AnimationChanged event) { - if (client.getGameState() != GameState.LOGGED_IN) + if (!config.isEnabled() || client.getGameState() != GameState.LOGGED_IN) { return; } @@ -144,19 +148,43 @@ public class IdleNotifier extends Plugin } } + @Subscribe + public void onGameStateChanged(GameStateChanged gameStateChanged) + { + lastInteracting = null; + } + @Schedule( period = 2, unit = ChronoUnit.SECONDS ) public void checkIdle() { + if (!config.isEnabled() || client.getGameState() != GameState.LOGGED_IN) + { + return; + } + + Duration waitDuration = Duration.ofMillis(config.getTimeout()); Player local = client.getLocalPlayer(); if (notifyIdle && local.getAnimation() == IDLE - && Instant.now().compareTo(lastAnimating.plus(WAIT_DURATION)) >= 0) + && Instant.now().compareTo(lastAnimating.plus(waitDuration)) >= 0) { runelite.notify("[" + local.getName() + "] is now idle!"); notifyIdle = false; } + + Actor opponent = local.getInteracting(); + if (opponent != null && opponent.getCombatLevel() > 0) + { + lastInteracting = Instant.now(); + } + + if (lastInteracting != null && Instant.now().compareTo(lastInteracting.plus(waitDuration)) >= 0) + { + runelite.notify("[" + local.getName() + "] is now out of combat!"); + lastInteracting = null; + } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/combatnotifier/CombatNotifierConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierConfig.java similarity index 70% rename from runelite-client/src/main/java/net/runelite/client/plugins/combatnotifier/CombatNotifierConfig.java rename to runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierConfig.java index 1c9d14429e..167d9a2b4a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/combatnotifier/CombatNotifierConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierConfig.java @@ -1,15 +1,15 @@ /* - * Copyright (c) 2017, Kronos + * Copyright (c) 2017, Devin French * 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. + * 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 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 @@ -22,23 +22,22 @@ * (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.combatnotifier; +package net.runelite.client.plugins.idlenotifier; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; @ConfigGroup( - keyName = "combatnotifier", - name = "Combat Notifier", - description = "Notifies when the player is out of combat" + keyName = "idlenotifier", + name = "Idle Notifier", + description = "Configuration for the idle notifier plugin" ) -public interface CombatNotifierConfig +public interface IdleNotifierConfig { @ConfigItem( keyName = "enabled", name = "Enabled", - description = "Toggles out of combat notifications" + description = "Toggles idle notifications" ) default boolean isEnabled() { @@ -48,10 +47,10 @@ public interface CombatNotifierConfig @ConfigItem( keyName = "timeout", name = "Idle Timeout (ms)", - description = "The notification delay after the player is out of combat" + description = "The notification delay after the player is idle" ) default int getTimeout() { - return 10000; + return 5000; } } From d455844bf75a81e3316116268d0fa8155797cd64 Mon Sep 17 00:00:00 2001 From: Devin Date: Tue, 7 Nov 2017 17:32:18 -0800 Subject: [PATCH 3/4] Add additional config options --- .../plugins/idlenotifier/IdleNotifier.java | 22 ++++++++++- .../idlenotifier/IdleNotifierConfig.java | 39 ++++++++++++++++++- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java index 745da7255b..e20dd89dfc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java @@ -41,6 +41,7 @@ import net.runelite.client.events.GameStateChanged; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.task.Schedule; +import net.runelite.client.ui.ClientUI; @PluginDescriptor( name = "Idle notifier" @@ -50,6 +51,7 @@ public class IdleNotifier extends Plugin private final Client client = RuneLite.getClient(); private final RuneLite runelite = RuneLite.getRunelite(); private final IdleNotifierConfig config = runelite.getConfigManager().getConfig(IdleNotifierConfig.class); + private final ClientUI gui = runelite.getGui(); private Instant lastAnimating; private Instant lastInteracting; @@ -170,7 +172,7 @@ public class IdleNotifier extends Plugin if (notifyIdle && local.getAnimation() == IDLE && Instant.now().compareTo(lastAnimating.plus(waitDuration)) >= 0) { - runelite.notify("[" + local.getName() + "] is now idle!"); + sendNotification("[" + local.getName() + "] is now idle!"); notifyIdle = false; } @@ -182,9 +184,25 @@ public class IdleNotifier extends Plugin if (lastInteracting != null && Instant.now().compareTo(lastInteracting.plus(waitDuration)) >= 0) { - runelite.notify("[" + local.getName() + "] is now out of combat!"); + sendNotification("[" + local.getName() + "] is now out of combat!"); lastInteracting = null; } } + private void sendNotification(String message) + { + if (!config.alertWhenFocused() && gui.isFocused()) + { + return; + } + if (config.requestFocus()) + { + gui.requestFocus(); + } + if (config.sendTrayNotification()) + { + runelite.notify(message); + } + } + } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierConfig.java index 167d9a2b4a..ed29b71e52 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierConfig.java @@ -37,17 +37,52 @@ public interface IdleNotifierConfig @ConfigItem( keyName = "enabled", name = "Enabled", - description = "Toggles idle notifications" + description = "Toggles idle notifications", + position = 1 ) default boolean isEnabled() { return false; } + @ConfigItem( + keyName = "tray", + name = "Send Tray Notification", + description = "Toggles tray notifications", + position = 2 + ) + default boolean sendTrayNotification() + { + return true; + } + + @ConfigItem( + keyName = "focused", + name = "Alert When Focused", + description = "Toggles idle notifications for when the client is focused", + position = 3 + ) + default boolean alertWhenFocused() + { + return true; + } + + @ConfigItem( + keyName = "request", + name = "Request Window Focus", + description = "Toggles window focus request", + position = 4 + ) + default boolean requestFocus() + { + return true; + } + @ConfigItem( keyName = "timeout", name = "Idle Timeout (ms)", - description = "The notification delay after the player is idle" + description = "The notification delay after the player is idle", + position = 5 ) default int getTimeout() { From 4be34c51a395826131c41afab1749da49f68cf37 Mon Sep 17 00:00:00 2001 From: Devin Date: Tue, 7 Nov 2017 17:34:33 -0800 Subject: [PATCH 4/4] Add low hitpoints and prayer notifications --- .../plugins/idlenotifier/IdleNotifier.java | 42 ++++++++++++++++++- .../idlenotifier/IdleNotifierConfig.java | 22 ++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java index e20dd89dfc..9f7b293bcc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifier.java @@ -35,6 +35,7 @@ import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.Player; +import net.runelite.api.Skill; import net.runelite.client.RuneLite; import net.runelite.client.events.AnimationChanged; import net.runelite.client.events.GameStateChanged; @@ -55,7 +56,11 @@ public class IdleNotifier extends Plugin private Instant lastAnimating; private Instant lastInteracting; + private Instant lastHitpoints; + private Instant lastPrayer; private boolean notifyIdle = false; + private boolean notifyHitpoints = true; + private boolean notifyPrayer = true; @Override protected void startUp() throws Exception @@ -157,7 +162,7 @@ public class IdleNotifier extends Plugin } @Schedule( - period = 2, + period = 1, unit = ChronoUnit.SECONDS ) public void checkIdle() @@ -187,6 +192,40 @@ public class IdleNotifier extends Plugin sendNotification("[" + local.getName() + "] is now out of combat!"); lastInteracting = null; } + + if (client.getRealSkillLevel(Skill.HITPOINTS) > config.getHitpointsThreshold()) + { + if (client.getBoostedSkillLevel(Skill.HITPOINTS) <= config.getHitpointsThreshold()) + { + if (!notifyHitpoints && Instant.now().compareTo(lastHitpoints.plus(waitDuration)) >= 0) + { + sendNotification("[" + local.getName() + "] has low hitpoints!"); + notifyHitpoints = true; + } + } + else + { + lastHitpoints = Instant.now(); + notifyHitpoints = false; + } + } + + if (client.getRealSkillLevel(Skill.PRAYER) > config.getPrayerThreshold()) + { + if (client.getBoostedSkillLevel(Skill.PRAYER) <= config.getPrayerThreshold()) + { + if (!notifyPrayer && Instant.now().compareTo(lastPrayer.plus(waitDuration)) >= 0) + { + sendNotification("[" + local.getName() + "] has low prayer!"); + notifyPrayer = true; + } + } + else + { + lastPrayer = Instant.now(); + notifyPrayer = false; + } + } } private void sendNotification(String message) @@ -204,5 +243,4 @@ public class IdleNotifier extends Plugin runelite.notify(message); } } - } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierConfig.java index ed29b71e52..336432cf37 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierConfig.java @@ -88,4 +88,26 @@ public interface IdleNotifierConfig { return 5000; } + + @ConfigItem( + keyName = "hitpoints", + name = "Hitpoints Threshold", + description = "The amount of hitpoints to send a notification at", + position = 6 + ) + default int getHitpointsThreshold() + { + return 15; + } + + @ConfigItem( + keyName = "prayer", + name = "Prayer Threshold", + description = "The amount of prayer points to send a notification at", + position = 7 + ) + default int getPrayerThreshold() + { + return 15; + } }