Add oxygen alert to idle notifier (#5630)

Fixes #4890
This commit is contained in:
robinwithes
2018-09-26 09:58:18 +02:00
committed by Tomas Slusny
parent fe3cf40f2d
commit 7a98b4ed55
3 changed files with 44 additions and 0 deletions

View File

@@ -408,6 +408,11 @@ public enum Varbits
*/
ACCOUNT_TYPE(1777),
/**
* The varbit that stores the oxygen percentage for player
*/
OXYGEN_LEVEL(5811),
/**
* Corp beast damage
*/

View File

@@ -96,4 +96,16 @@ public interface IdleNotifierConfig extends Config
{
return 0;
}
@ConfigItem(
keyName = "oxygen",
name = "Oxygen Notification Threshold",
position = 7,
description = "The amount of remaining oxygen to send a notification at. A value of 0 will disable notification."
)
default int getOxygenThreshold()
{
return 0;
}
}

View File

@@ -83,6 +83,7 @@ public class IdleNotifierPlugin extends Plugin
private Actor lastInteract;
private boolean notifyHitpoints = true;
private boolean notifyPrayer = true;
private boolean notifyOxygen = true;
private boolean notifyIdleLogout = true;
private boolean notify6HourLogout = true;
private int lastCombatCountdown = 0;
@@ -345,6 +346,32 @@ public class IdleNotifierPlugin extends Plugin
{
notifier.notify("[" + local.getName() + "] has low prayer!");
}
if (checkLowOxygen())
{
notifier.notify("[" + local.getName() + "] has low oxygen!");
}
}
private boolean checkLowOxygen()
{
if (config.getOxygenThreshold() == 0)
{
return false;
}
if (config.getOxygenThreshold() >= client.getVar(Varbits.OXYGEN_LEVEL) * 0.1)
{
if (!notifyOxygen)
{
notifyOxygen = true;
return true;
}
}
else
{
notifyOxygen = false;
}
return false;
}
private boolean checkLowHitpoints()