This commit is contained in:
James Munson
2019-04-22 12:22:16 -07:00
5 changed files with 79 additions and 6 deletions

View File

@@ -103,4 +103,15 @@ public interface BoostsConfig extends Config
{
return 0;
}
@ConfigItem(
keyName = "groupNotifications",
name = "Group Notifications",
description = "Configures whether or not to group notifications for multiple skills into a single notification",
position = 7
)
default boolean groupNotifications()
{
return false;
}
}

View File

@@ -26,8 +26,10 @@ package net.runelite.client.plugins.boosts;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Provides;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -100,6 +102,7 @@ public class BoostsPlugin extends Plugin
private int lastChangeUp = -1;
private boolean preserveBeenActive = false;
private long lastTickMillis;
private List<String> boostedSkillsChanged = new ArrayList<>();
@Provides
BoostsConfig provideConfig(ConfigManager configManager)
@@ -213,7 +216,14 @@ public class BoostsPlugin extends Plugin
int boost = cur - real;
if (boost <= boostThreshold && boostThreshold < lastBoost)
{
notifier.notify(skill.getName() + " level is getting low!");
if (config.groupNotifications())
{
boostedSkillsChanged.add(skill.getName());
}
else
{
notifier.notify(skill.getName() + " level is getting low!");
}
}
}
}
@@ -223,6 +233,35 @@ public class BoostsPlugin extends Plugin
{
lastTickMillis = System.currentTimeMillis();
if (config.groupNotifications() && !boostedSkillsChanged.isEmpty())
{
if (boostedSkillsChanged.size() == 1)
{
notifier.notify(boostedSkillsChanged.get(0) + " level is getting low!");
}
else
{
String notification = "";
for (int i = 0; i < boostedSkillsChanged.size(); i++)
{
if (i == 0)
{
notification = boostedSkillsChanged.get(i);
}
else if (i < boostedSkillsChanged.size() - 1)
{
notification = notification + ", " + boostedSkillsChanged.get(i);
}
else
{
notification = notification + " and " + boostedSkillsChanged.get(i) + " levels are getting low!";
notifier.notify(notification);
}
}
}
boostedSkillsChanged.clear();
}
if (getChangeUpTicks() <= 0)
{
switch (config.displayNextDebuffChange())

View File

@@ -129,9 +129,9 @@ public class FreezeTimersPlugin extends Plugin
final Pattern ppattern = Pattern.compile("> <col=ffffff>(.+?)<col=");
final Matcher smatch = spattern.matcher(event.getMenuTarget());
final Matcher pmatch = ppattern.matcher(event.getMenuTarget());
smatch.find();
pmatch.find();
if (smatch.group(1) != null && pmatch.group(1) != null)
if (smatch.find() && smatch.group(1) != null &&
pmatch.find() && pmatch.group(1) != null)
{
currticks = ticks;
spell = smatch.group(1);

View File

@@ -37,6 +37,7 @@ public interface NpcAggroAreaConfig extends Config
String CONFIG_CENTER2 = "center2";
String CONFIG_LOCATION = "location";
String CONFIG_DURATION = "duration";
String CONFIG_NOT_WORKING_OVERLAY = "overlay";
@ConfigItem(
keyName = "npcUnaggroAlwaysActive",
@@ -92,4 +93,15 @@ public interface NpcAggroAreaConfig extends Config
{
return Color.YELLOW;
}
@ConfigItem(
keyName = "npcUnaggroShowNotWorkingOverlay",
name = "Show not working hint",
description = "Show hint if plugin is enabled in unsupported area",
position = 6
)
default boolean showNotWorkingOverlay()
{
return true;
}
}

View File

@@ -128,6 +128,7 @@ public class NpcAggroAreaPlugin extends Plugin
private WorldPoint previousUnknownCenter;
private boolean loggingIn;
private List<String> npcNamePatterns;
private boolean notWorkingOverlayShown = false;
@Provides
NpcAggroAreaConfig provideConfig(ConfigManager configManager)
@@ -139,7 +140,12 @@ public class NpcAggroAreaPlugin extends Plugin
protected void startUp() throws Exception
{
overlayManager.add(overlay);
overlayManager.add(notWorkingOverlay);
if (config.showNotWorkingOverlay())
{
overlayManager.add(notWorkingOverlay);
notWorkingOverlayShown = true;
}
npcNamePatterns = NAME_SPLITTER.splitToList(config.npcNamePatterns());
recheckActive();
}
@@ -149,7 +155,11 @@ public class NpcAggroAreaPlugin extends Plugin
{
removeTimer();
overlayManager.remove(overlay);
overlayManager.remove(notWorkingOverlay);
if (notWorkingOverlayShown)
{
overlayManager.remove(notWorkingOverlay);
}
Arrays.fill(safeCenters, null);
lastPlayerLocation = null;
currentTimer = null;
@@ -406,6 +416,7 @@ public class NpcAggroAreaPlugin extends Plugin
configManager.unsetConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_CENTER2);
configManager.unsetConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_LOCATION);
configManager.unsetConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_DURATION);
configManager.unsetConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_NOT_WORKING_OVERLAY);
}
private void saveConfig()