From 40b1e53b3147af6c95a411bb9e25ecbd150417f7 Mon Sep 17 00:00:00 2001 From: James Munson Date: Wed, 12 Jun 2019 04:49:28 -0700 Subject: [PATCH] Added sound config settings to idle plugin Added Over Special Energy Notification --- runelite-client/pom.xml | 1 + .../runelite/client/game/SoundManager.java | 1 + .../idlenotifier/IdleNotifierConfig.java | 162 +++++++++++++----- .../idlenotifier/IdleNotifierPlugin.java | 32 +++- .../client/plugins/zulrah/ZulrahPlugin.java | 32 +++- .../runelite/client/game/sounds/15seconds.wav | Bin .../runelite/client/game/sounds/5seconds.wav | Bin .../client/game/sounds/attackmagic.wav | Bin .../client/game/sounds/attackmelee.wav | Bin .../client/game/sounds/attackranged.wav | Bin .../net/runelite/client/game/sounds/idle.wav | Bin .../runelite/client/game/sounds/incoming.wav | Bin .../runelite/client/game/sounds/lowhealth.wav | Bin .../runelite/client/game/sounds/lowprayer.wav | Bin .../net/runelite/client/game/sounds/move.wav | Bin .../client/game/sounds/outofcombat.wav | Bin .../runelite/client/game/sounds/praymagic.wav | Bin .../runelite/client/game/sounds/praymelee.wav | Bin .../client/game/sounds/prayranged.wav | Bin .../client/game/sounds/reenableprayer.wav | Bin .../client/game/sounds/restorespec.wav | Bin .../runelite/client/game/sounds/runaway.wav | Bin 22 files changed, 173 insertions(+), 55 deletions(-) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/15seconds.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/5seconds.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/attackmagic.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/attackmelee.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/attackranged.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/idle.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/incoming.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/lowhealth.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/lowprayer.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/move.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/outofcombat.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/praymagic.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/praymelee.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/prayranged.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/reenableprayer.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/restorespec.wav (100%) rename runelite-client/src/main/{java => resources}/net/runelite/client/game/sounds/runaway.wav (100%) diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index b05967307e..407a3b17f3 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -317,6 +317,7 @@ ttf png gif + wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/SoundManager.java b/runelite-client/src/main/java/net/runelite/client/game/SoundManager.java index 2ea639918c..ad5a7e73ec 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/SoundManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/SoundManager.java @@ -29,6 +29,7 @@ public class SoundManager } public void playSound(final Sound sound) + throws UnsupportedAudioFileException, IOException, LineUnavailableException { new Thread(new Runnable() { 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 c39bf1ef97..1f7cd12196 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 @@ -32,10 +32,10 @@ import net.runelite.client.config.ConfigItem; public interface IdleNotifierConfig extends Config { @ConfigItem( - keyName = "animationidle", - name = "Idle Animation Notifications", - description = "Configures if idle animation notifications are enabled", - position = 1 + keyName = "animationidle", + name = "Idle Animation Notifications", + description = "Configures if idle animation notifications are enabled", + position = 1 ) default boolean animationIdle() { @@ -43,10 +43,20 @@ public interface IdleNotifierConfig extends Config } @ConfigItem( - keyName = "interactionidle", - name = "Idle Interaction Notifications", - description = "Configures if idle interaction notifications are enabled e.g. combat, fishing", - position = 2 + keyName = "animationidlesound", + name = "Idle Animation Sound", + description = "Plays a custom sound accompanying Idle Animation notifications", + position = 2 + ) + default boolean animationIdleSound() { + return false; + } + + @ConfigItem( + keyName = "interactionidle", + name = "Idle Interaction Notifications", + description = "Configures if idle interaction notifications are enabled e.g. combat, fishing", + position = 3 ) default boolean interactionIdle() { @@ -54,10 +64,20 @@ public interface IdleNotifierConfig extends Config } @ConfigItem( - keyName = "logoutidle", - name = "Idle Logout Notifications", - description = "Configures if the idle logout notifications are enabled", - position = 3 + keyName = "interactionidlesound", + name = "Idle Interaction Sound", + description = "Plays a custom sound accompanying Idle Interaction notifications", + position = 4 + ) + default boolean interactionIdleSound() { + return false; + } + + @ConfigItem( + keyName = "logoutidle", + name = "Idle Logout Notifications", + description = "Configures if the idle logout notifications are enabled", + position = 5 ) default boolean logoutIdle() { @@ -65,10 +85,20 @@ public interface IdleNotifierConfig extends Config } @ConfigItem( - position = 4, - keyName = "skullNotification", - name = "Skull Notification", - description = "Receive a notification when you skull." + keyName = "outofcombatsound", + name = "Out of Combat Sound", + description = "Plays a custom sound whenever you leave combat", + position = 6 + ) + default boolean outOfCombatSound() { + return false; + } + + @ConfigItem( + position = 7, + keyName = "skullNotification", + name = "Skull Notification", + description = "Receive a notification when you skull." ) default boolean showSkullNotification() { @@ -76,10 +106,10 @@ public interface IdleNotifierConfig extends Config } @ConfigItem( - position = 5, - keyName = "unskullNotification", - name = "Unskull Notification", - description = "Receive a notification when you unskull." + position = 8, + keyName = "unskullNotification", + name = "Unskull Notification", + description = "Receive a notification when you unskull." ) default boolean showUnskullNotification() { @@ -87,10 +117,10 @@ public interface IdleNotifierConfig extends Config } @ConfigItem( - keyName = "timeout", - name = "Idle Notification Delay (ms)", - description = "The notification delay after the player is idle", - position = 6 + keyName = "timeout", + name = "Idle Notification Delay (ms)", + description = "The notification delay after the player is idle", + position = 9 ) default int getIdleNotificationDelay() { @@ -98,10 +128,10 @@ public interface IdleNotifierConfig extends Config } @ConfigItem( - keyName = "hitpoints", - name = "Hitpoints Notification Threshold", - description = "The amount of hitpoints to send a notification at. A value of 0 will disable notification.", - position = 7 + keyName = "hitpoints", + name = "Hitpoints Notification Threshold", + description = "The amount of hitpoints to send a notification at. A value of 0 will disable notification.", + position = 10 ) default int getHitpointsThreshold() { @@ -109,10 +139,20 @@ public interface IdleNotifierConfig extends Config } @ConfigItem( - keyName = "prayer", - name = "Prayer Notification Threshold", - description = "The amount of prayer points to send a notification at. A value of 0 will disable notification.", - position = 8 + keyName = "playHealthSound", + name = "Play sound for Low Health", + description = "Will play a sound for every Low Health notification sent", + position = 12 + ) + default boolean getPlayHealthSound() { + return false; + } + + @ConfigItem( + keyName = "prayer", + name = "Prayer Notification Threshold", + description = "The amount of prayer points to send a notification at. A value of 0 will disable notification.", + position = 12 ) default int getPrayerThreshold() { @@ -120,10 +160,20 @@ public interface IdleNotifierConfig extends Config } @ConfigItem( - keyName = "oxygen", - name = "Oxygen Notification Threshold", - position = 9, - description = "The amount of remaining oxygen to send a notification at. A value of 0 will disable notification." + keyName = "playPrayerSound", + name = "Play sound for Low Prayer", + description = "Will play a sound for every Low Prayer notification sent", + position = 13 + ) + default boolean getPlayPrayerSound() { + return false; + } + + @ConfigItem( + keyName = "oxygen", + name = "Oxygen Notification Threshold", + position = 14, + description = "The amount of remaining oxygen to send a notification at. A value of 0 will disable notification." ) default int getOxygenThreshold() { @@ -131,10 +181,10 @@ public interface IdleNotifierConfig extends Config } @ConfigItem( - keyName = "spec", - name = "Special Attack Energy Notification Threshold", - position = 10, - description = "The amount of spec energy reached to send a notification at. A value of 0 will disable notification." + keyName = "spec", + name = "Special Attack Energy Notification Threshold", + position = 15, + description = "The amount of spec energy reached to send a notification at. A value of 0 will disable notification." ) default int getSpecEnergyThreshold() { @@ -142,12 +192,32 @@ public interface IdleNotifierConfig extends Config } @ConfigItem( - keyName = "pkers", - name = "PKer Notifier", - position = 9, - description = "Notifies if an attackable player based on your level range appears on screen.", - group = "PvP", - warning = "This will not notify you if the player is in your cc or is online on your friends list." + keyName = "specSound", + name = "Special Attack Energy Sound", + description = "Plays a custom sound accompanying Special Attack energy notifications", + position = 16 + ) + default boolean getSpecSound() { + return false; + } + + @ConfigItem( + keyName = "overspec", + name = "Over Special Energy Notification", + description = "Will repeat notifications for any value over the special energy threshold", + position = 17 + ) + default boolean getOverSpecEnergy() { + return false; + } + + @ConfigItem( + keyName = "pkers", + name = "PKer Notifier", + position = 18, + description = "Notifies if an attackable player based on your level range appears on screen.", + group = "PvP", + warning = "This will not notify you if the player is in your cc or is online on your friends list." ) default boolean notifyPkers() { 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 d43ef4bdc2..d108cd89e9 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 @@ -27,12 +27,18 @@ package net.runelite.client.plugins.idlenotifier; import com.google.inject.Provides; import java.awt.TrayIcon; +import java.io.IOException; import java.time.Duration; import java.time.Instant; import java.util.Arrays; import java.util.EnumSet; import java.util.List; import javax.inject.Inject; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import net.runelite.api.Actor; import net.runelite.api.AnimationID; import static net.runelite.api.AnimationID.COOKING_FIRE; @@ -145,6 +151,8 @@ import net.runelite.api.events.PlayerSpawned; import net.runelite.client.Notifier; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.game.Sound; +import net.runelite.client.game.SoundManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.util.PvPUtil; @@ -156,6 +164,8 @@ import net.runelite.client.util.PvPUtil; ) public class IdleNotifierPlugin extends Plugin { + private static final Logger logger = LoggerFactory.getLogger(IdleNotifierPlugin.class); + // This must be more than 500 client ticks (10 seconds) before you get AFK kicked private static final int LOGOUT_WARNING_MILLIS = (4 * 60 + 40) * 1000; // 4 minutes and 40 seconds private static final int COMBAT_WARNING_MILLIS = 19 * 60 * 1000; // 19 minutes @@ -173,6 +183,9 @@ public class IdleNotifierPlugin extends Plugin @Inject private Client client; + @Inject + private SoundManager soundManager; + @Inject private IdleNotifierConfig config; @@ -509,8 +522,19 @@ public class IdleNotifierPlugin extends Plugin if (config.animationIdle() && checkAnimationIdle(waitDuration, local)) { notifier.notify("[" + local.getName() + "] is now idle!"); + if (this.config.animationIdleSound()) + { + try + { + this.soundManager.playSound(Sound.IDLE); + } + catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) + { + logger.info("Failed to play Idle sound: {}", e); + e.printStackTrace(); + } + } } - if (config.interactionIdle() && checkInteractionIdle(waitDuration, local)) { if (lastInteractWasCombat) @@ -557,8 +581,10 @@ public class IdleNotifierPlugin extends Plugin // Check if we have regenerated over the threshold, and that the // regen was small enough. - boolean notify = lastSpecEnergy < threshold && currentSpecEnergy >= threshold - && currentSpecEnergy - lastSpecEnergy <= 100; + boolean notify = lastSpecEnergy < threshold && currentSpecEnergy >= threshold && currentSpecEnergy - lastSpecEnergy <= 100; + + notify = (notify) || ((config.getOverSpecEnergy()) && (currentSpecEnergy >= threshold) && (currentSpecEnergy != lastSpecEnergy) && (currentSpecEnergy - lastSpecEnergy <= 100)); + lastSpecEnergy = currentSpecEnergy; return notify; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahPlugin.java index 387f99c32b..3ed5179ca5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahPlugin.java @@ -28,6 +28,9 @@ package net.runelite.client.plugins.zulrah; import com.google.inject.Provides; import javax.inject.Inject; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; + import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -56,6 +59,8 @@ import net.runelite.client.plugins.zulrah.phase.ZulrahPhase; import net.runelite.client.plugins.zulrah.phase.ZulrahType; import net.runelite.client.ui.overlay.OverlayManager; +import java.io.IOException; + @PluginDescriptor( name = "Zulrah Helper", description = "Shows tiles on where to stand during the phases and what prayer to use.", @@ -167,14 +172,29 @@ public class ZulrahPlugin extends Plugin if (config.sounds()) { - if (type == ZulrahType.RANGE) - { - soundManager.playSound(Sound.PRAY_RANGED); + if (type == ZulrahType.RANGE) { + try + { + soundManager.playSound(Sound.PRAY_RANGED); + } + catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) + { + log.info("Failed to play Idle sound: {}", e); + e.printStackTrace(); + } } - if (type == ZulrahType.MAGIC) - { - soundManager.playSound(Sound.PRAY_MAGIC); + if (type == ZulrahType.MAGIC) { + try + { + soundManager.playSound(Sound.PRAY_MAGIC); + } + catch (UnsupportedAudioFileException|IOException|LineUnavailableException e) + { + log.info("Failed to play Idle sound: {}", e); + e.printStackTrace(); + } } + } diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/15seconds.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/15seconds.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/15seconds.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/15seconds.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/5seconds.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/5seconds.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/5seconds.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/5seconds.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/attackmagic.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/attackmagic.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/attackmagic.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/attackmagic.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/attackmelee.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/attackmelee.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/attackmelee.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/attackmelee.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/attackranged.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/attackranged.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/attackranged.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/attackranged.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/idle.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/idle.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/idle.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/idle.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/incoming.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/incoming.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/incoming.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/incoming.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/lowhealth.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/lowhealth.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/lowhealth.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/lowhealth.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/lowprayer.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/lowprayer.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/lowprayer.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/lowprayer.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/move.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/move.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/move.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/move.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/outofcombat.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/outofcombat.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/outofcombat.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/outofcombat.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/praymagic.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/praymagic.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/praymagic.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/praymagic.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/praymelee.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/praymelee.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/praymelee.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/praymelee.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/prayranged.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/prayranged.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/prayranged.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/prayranged.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/reenableprayer.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/reenableprayer.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/reenableprayer.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/reenableprayer.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/restorespec.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/restorespec.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/restorespec.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/restorespec.wav diff --git a/runelite-client/src/main/java/net/runelite/client/game/sounds/runaway.wav b/runelite-client/src/main/resources/net/runelite/client/game/sounds/runaway.wav similarity index 100% rename from runelite-client/src/main/java/net/runelite/client/game/sounds/runaway.wav rename to runelite-client/src/main/resources/net/runelite/client/game/sounds/runaway.wav