Merge pull request #397 from UniquePassive/notify-on-15k-tick-idle
Notify before 5 minute idle and 6h logout
This commit is contained in:
@@ -178,4 +178,8 @@ public interface Client extends GameEngine
|
|||||||
|
|
||||||
|
|
||||||
BufferProvider getBufferProvider();
|
BufferProvider getBufferProvider();
|
||||||
|
|
||||||
|
int getMouseIdleTicks();
|
||||||
|
|
||||||
|
int getKeyboardIdleTicks();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,6 +115,9 @@ import net.runelite.client.ui.ClientUI;
|
|||||||
)
|
)
|
||||||
public class IdleNotifierPlugin extends Plugin
|
public class IdleNotifierPlugin extends Plugin
|
||||||
{
|
{
|
||||||
|
private static final int LOGOUT_WARNING_AFTER_TICKS = 14000; // 4 minutes and 40 seconds
|
||||||
|
private static final Duration SIX_HOUR_LOGOUT_WARNING_AFTER_DURATION = Duration.ofMinutes(340);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Notifier notifier;
|
Notifier notifier;
|
||||||
|
|
||||||
@@ -135,6 +138,11 @@ public class IdleNotifierPlugin extends Plugin
|
|||||||
private boolean notifyIdle = false;
|
private boolean notifyIdle = false;
|
||||||
private boolean notifyHitpoints = true;
|
private boolean notifyHitpoints = true;
|
||||||
private boolean notifyPrayer = true;
|
private boolean notifyPrayer = true;
|
||||||
|
private boolean notifyIdleLogout = true;
|
||||||
|
private boolean notify6HourLogout = true;
|
||||||
|
|
||||||
|
private Instant sixHourWarningTime;
|
||||||
|
private boolean ready;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
IdleNotifierConfig provideConfig(ConfigManager configManager)
|
IdleNotifierConfig provideConfig(ConfigManager configManager)
|
||||||
@@ -243,6 +251,24 @@ public class IdleNotifierPlugin extends Plugin
|
|||||||
public void onGameStateChanged(GameStateChanged gameStateChanged)
|
public void onGameStateChanged(GameStateChanged gameStateChanged)
|
||||||
{
|
{
|
||||||
lastInteracting = null;
|
lastInteracting = null;
|
||||||
|
|
||||||
|
GameState state = gameStateChanged.getGameState();
|
||||||
|
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case LOGGING_IN:
|
||||||
|
case HOPPING:
|
||||||
|
case CONNECTION_LOST:
|
||||||
|
ready = true;
|
||||||
|
break;
|
||||||
|
case LOGGED_IN:
|
||||||
|
if (ready)
|
||||||
|
{
|
||||||
|
sixHourWarningTime = Instant.now().plus(SIX_HOUR_LOGOUT_WARNING_AFTER_DURATION);
|
||||||
|
ready = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Schedule(
|
@Schedule(
|
||||||
@@ -258,6 +284,33 @@ public class IdleNotifierPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (client.getMouseIdleTicks() > LOGOUT_WARNING_AFTER_TICKS
|
||||||
|
&& client.getKeyboardIdleTicks() > LOGOUT_WARNING_AFTER_TICKS)
|
||||||
|
{
|
||||||
|
if (notifyIdleLogout)
|
||||||
|
{
|
||||||
|
sendNotification("[" + local.getName() + "] is about to log out from idling too long!");
|
||||||
|
notifyIdleLogout = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
notifyIdleLogout = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Instant.now().compareTo(sixHourWarningTime) >= 0)
|
||||||
|
{
|
||||||
|
if (notify6HourLogout)
|
||||||
|
{
|
||||||
|
sendNotification("[" + local.getName() + "] is about to log out from being online for 6 hours!");
|
||||||
|
notify6HourLogout = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
notify6HourLogout = true;
|
||||||
|
}
|
||||||
|
|
||||||
Duration waitDuration = Duration.ofMillis(config.getTimeout());
|
Duration waitDuration = Duration.ofMillis(config.getTimeout());
|
||||||
if (notifyIdle && local.getAnimation() == IDLE
|
if (notifyIdle && local.getAnimation() == IDLE
|
||||||
&& Instant.now().compareTo(lastAnimating.plus(waitDuration)) >= 0)
|
&& Instant.now().compareTo(lastAnimating.plus(waitDuration)) >= 0)
|
||||||
|
|||||||
@@ -355,4 +355,12 @@ public interface RSClient extends RSGameEngine, Client
|
|||||||
@Import("rasterProvider")
|
@Import("rasterProvider")
|
||||||
@Override
|
@Override
|
||||||
BufferProvider getBufferProvider();
|
BufferProvider getBufferProvider();
|
||||||
|
|
||||||
|
@Import("mouseIdleTicks")
|
||||||
|
@Override
|
||||||
|
int getMouseIdleTicks();
|
||||||
|
|
||||||
|
@Import("keyboardIdleTicks")
|
||||||
|
@Override
|
||||||
|
int getKeyboardIdleTicks();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user