From c4bea0259989624687cecac6f3be04832e86e718 Mon Sep 17 00:00:00 2001 From: Twiglet1022 <29353990+Twiglet1022@users.noreply.github.com> Date: Sun, 25 Nov 2018 13:12:40 +0000 Subject: [PATCH] Improve responsiveness of fishing idle notification (#6457) Move fishing idle notification from animation-based to interaction based to enhance the responsiveness of it. --- .../idlenotifier/IdleNotifierConfig.java | 9 ++-- .../idlenotifier/IdleNotifierPlugin.java | 43 +++++++++++-------- .../idlenotifier/IdleNotifierPluginTest.java | 2 +- 3 files changed, 31 insertions(+), 23 deletions(-) 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 1d688565ae..97d5bab95b 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 @@ -43,12 +43,12 @@ public interface IdleNotifierConfig extends Config } @ConfigItem( - keyName = "combatidle", - name = "Combat Idle Notifications", - description = "Configures if out of combat notifications are enabled", + keyName = "interactionidle", + name = "Idle Interaction Notifications", + description = "Configures if idle interaction notifications are enabled e.g. combat, fishing", position = 2 ) - default boolean combatIdle() + default boolean interactionIdle() { return true; } @@ -107,5 +107,4 @@ public interface IdleNotifierConfig extends Config { return 0; } - } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPlugin.java index 59b5a09565..c543234067 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPlugin.java @@ -69,6 +69,8 @@ public class IdleNotifierPlugin extends Plugin private static final int HIGHEST_MONSTER_ATTACK_SPEED = 8; // Except Scarab Mage, but they are with other monsters private static final Duration SIX_HOUR_LOGOUT_WARNING_AFTER_DURATION = Duration.ofMinutes(340); + private static final String FISHING_SPOT = "Fishing spot"; + @Inject private Notifier notifier; @@ -90,6 +92,7 @@ public class IdleNotifierPlugin extends Plugin private int lastCombatCountdown = 0; private Instant sixHourWarningTime; private boolean ready; + private boolean lastInteractWasCombat; @Provides IdleNotifierConfig provideConfig(ConfigManager configManager) @@ -161,19 +164,8 @@ public class IdleNotifierPlugin extends Plugin case SMITHING_SMELTING: case SMITHING_CANNONBALL: /* Fishing */ - case FISHING_NET: - case FISHING_BIG_NET: - case FISHING_HARPOON: - case FISHING_BARBTAIL_HARPOON: - case FISHING_DRAGON_HARPOON: - case FISHING_CAGE: - case FISHING_POLE_CAST: - case FISHING_INFERNAL_HARPOON: - case FISHING_OILY_ROD: - case FISHING_KARAMBWAN: case FISHING_CRUSHING_INFERNAL_EELS: case FISHING_CUTTING_SACRED_EELS: - case FISHING_BAREHAND: /* Mining(Normal) */ case MINING_BRONZE_PICKAXE: case MINING_IRON_PICKAXE: @@ -273,6 +265,15 @@ public class IdleNotifierPlugin extends Plugin resetTimers(); lastInteract = target; lastInteracting = Instant.now(); + lastInteractWasCombat = true; + } + else if (target.getName() != null && target.getName().contains(FISHING_SPOT)) + { + // Player is fishing + resetTimers(); + lastInteract = target; + lastInteracting = Instant.now(); + lastInteractWasCombat = false; } } @@ -331,7 +332,8 @@ public class IdleNotifierPlugin extends Plugin if (client.getGameState() != GameState.LOGGED_IN || local == null - || System.currentTimeMillis() - client.getMouseLastPressedMillis() < 200 + // If user has clicked in the last second then they're not idle so don't send idle notification + || System.currentTimeMillis() - client.getMouseLastPressedMillis() < 1000 || client.getKeyboardIdleTicks() < 10) { resetTimers(); @@ -353,9 +355,16 @@ public class IdleNotifierPlugin extends Plugin notifier.notify("[" + local.getName() + "] is now idle!"); } - if (config.combatIdle() && checkOutOfCombat(waitDuration, local)) + if (config.interactionIdle() && checkInteractionIdle(waitDuration, local)) { - notifier.notify("[" + local.getName() + "] is now out of combat!"); + if (lastInteractWasCombat) + { + notifier.notify("[" + local.getName() + "] is now out of combat!"); + } + else + { + notifier.notify("[" + local.getName() + "] is now idle!"); + } } if (checkLowHitpoints()) @@ -445,7 +454,7 @@ public class IdleNotifierPlugin extends Plugin return false; } - private boolean checkOutOfCombat(Duration waitDuration, Player local) + private boolean checkInteractionIdle(Duration waitDuration, Player local) { if (lastInteract == null) { @@ -571,11 +580,11 @@ public class IdleNotifierPlugin extends Plugin lastAnimation = IDLE; } - // Reset combat idle timer + // Reset interaction idle timer lastInteracting = null; if (client.getGameState() == GameState.LOGIN_SCREEN || local == null || local.getInteracting() != lastInteract) { lastInteract = null; } } -} +} \ No newline at end of file diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPluginTest.java index 3fed66da12..df76e1676a 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPluginTest.java @@ -106,7 +106,7 @@ public class IdleNotifierPluginTest // Mock config when(config.logoutIdle()).thenReturn(true); when(config.animationIdle()).thenReturn(true); - when(config.combatIdle()).thenReturn(true); + when(config.interactionIdle()).thenReturn(true); when(config.getIdleNotificationDelay()).thenReturn(0); when(config.getHitpointsThreshold()).thenReturn(42); when(config.getPrayerThreshold()).thenReturn(42);