Add additional config options

This commit is contained in:
Devin
2017-11-07 17:32:18 -08:00
parent dfb467f633
commit d455844bf7
2 changed files with 57 additions and 4 deletions

View File

@@ -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);
}
}
}

View File

@@ -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()
{