npcunaggroarea: add notification for timer expiration

This commit is contained in:
Rob Mckennie
2019-10-07 10:42:56 +13:00
committed by Adam
parent 30171938e9
commit 99e26aa174
2 changed files with 30 additions and 0 deletions

View File

@@ -103,4 +103,15 @@ public interface NpcAggroAreaConfig extends Config
{
return false;
}
@ConfigItem(
keyName = "notifyExpire",
name = "Notify Expiration",
description = "Send a notifcation when the unaggressive timer expires",
position = 7
)
default boolean notifyExpire()
{
return false;
}
}

View File

@@ -52,6 +52,7 @@ import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.NpcSpawned;
import net.runelite.api.geometry.Geometry;
import net.runelite.client.Notifier;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.game.ItemManager;
@@ -110,6 +111,9 @@ public class NpcAggroAreaPlugin extends Plugin
@Inject
private ConfigManager configManager;
@Inject
private Notifier notifier;
@Getter
private final WorldPoint[] safeCenters = new WorldPoint[2];
@@ -125,6 +129,8 @@ public class NpcAggroAreaPlugin extends Plugin
private WorldPoint lastPlayerLocation;
private WorldPoint previousUnknownCenter;
private boolean loggingIn;
private boolean notifyOnce;
private List<String> npcNamePatterns;
@Provides
@@ -223,6 +229,7 @@ public class NpcAggroAreaPlugin extends Plugin
{
infoBoxManager.removeInfoBox(currentTimer);
currentTimer = null;
notifyOnce = false;
}
private void createTimer(Duration duration)
@@ -231,6 +238,7 @@ public class NpcAggroAreaPlugin extends Plugin
BufferedImage image = itemManager.getImage(ItemID.ENSOULED_DEMON_HEAD);
currentTimer = new AggressionTimer(duration, image, this, active && config.showTimer());
infoBoxManager.addInfoBox(currentTimer);
notifyOnce = true;
}
private void resetTimer()
@@ -317,6 +325,17 @@ public class NpcAggroAreaPlugin extends Plugin
public void onGameTick(GameTick event)
{
WorldPoint newLocation = client.getLocalPlayer().getWorldLocation();
if (active && currentTimer != null && currentTimer.cull() && notifyOnce)
{
if (config.notifyExpire())
{
notifier.notify("NPC agression has expired!");
}
notifyOnce = false;
}
if (lastPlayerLocation != null)
{
if (safeCenters[1] == null && newLocation.distanceTo2D(lastPlayerLocation) > SAFE_AREA_RADIUS * 4)