Add additional config options
This commit is contained in:
@@ -41,6 +41,7 @@ import net.runelite.client.events.GameStateChanged;
|
|||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.task.Schedule;
|
import net.runelite.client.task.Schedule;
|
||||||
|
import net.runelite.client.ui.ClientUI;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Idle notifier"
|
name = "Idle notifier"
|
||||||
@@ -50,6 +51,7 @@ public class IdleNotifier extends Plugin
|
|||||||
private final Client client = RuneLite.getClient();
|
private final Client client = RuneLite.getClient();
|
||||||
private final RuneLite runelite = RuneLite.getRunelite();
|
private final RuneLite runelite = RuneLite.getRunelite();
|
||||||
private final IdleNotifierConfig config = runelite.getConfigManager().getConfig(IdleNotifierConfig.class);
|
private final IdleNotifierConfig config = runelite.getConfigManager().getConfig(IdleNotifierConfig.class);
|
||||||
|
private final ClientUI gui = runelite.getGui();
|
||||||
|
|
||||||
private Instant lastAnimating;
|
private Instant lastAnimating;
|
||||||
private Instant lastInteracting;
|
private Instant lastInteracting;
|
||||||
@@ -170,7 +172,7 @@ public class IdleNotifier extends Plugin
|
|||||||
if (notifyIdle && local.getAnimation() == IDLE
|
if (notifyIdle && local.getAnimation() == IDLE
|
||||||
&& Instant.now().compareTo(lastAnimating.plus(waitDuration)) >= 0)
|
&& Instant.now().compareTo(lastAnimating.plus(waitDuration)) >= 0)
|
||||||
{
|
{
|
||||||
runelite.notify("[" + local.getName() + "] is now idle!");
|
sendNotification("[" + local.getName() + "] is now idle!");
|
||||||
notifyIdle = false;
|
notifyIdle = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,9 +184,25 @@ public class IdleNotifier extends Plugin
|
|||||||
|
|
||||||
if (lastInteracting != null && Instant.now().compareTo(lastInteracting.plus(waitDuration)) >= 0)
|
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;
|
lastInteracting = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendNotification(String message)
|
||||||
|
{
|
||||||
|
if (!config.alertWhenFocused() && gui.isFocused())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (config.requestFocus())
|
||||||
|
{
|
||||||
|
gui.requestFocus();
|
||||||
|
}
|
||||||
|
if (config.sendTrayNotification())
|
||||||
|
{
|
||||||
|
runelite.notify(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,17 +37,52 @@ public interface IdleNotifierConfig
|
|||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "enabled",
|
keyName = "enabled",
|
||||||
name = "Enabled",
|
name = "Enabled",
|
||||||
description = "Toggles idle notifications"
|
description = "Toggles idle notifications",
|
||||||
|
position = 1
|
||||||
)
|
)
|
||||||
default boolean isEnabled()
|
default boolean isEnabled()
|
||||||
{
|
{
|
||||||
return false;
|
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(
|
@ConfigItem(
|
||||||
keyName = "timeout",
|
keyName = "timeout",
|
||||||
name = "Idle Timeout (ms)",
|
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()
|
default int getTimeout()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user