runecraft plugin: add a notification when a runepouch degrades
This commit is contained in:
@@ -211,4 +211,14 @@ public interface RunecraftConfig extends Config
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "degradingNotification",
|
||||||
|
name = "Notify when pouch degrades",
|
||||||
|
description = "Send a notification when a pouch degrades"
|
||||||
|
)
|
||||||
|
default boolean degradingNotification()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import net.runelite.api.queries.InventoryItemQuery;
|
|||||||
import net.runelite.api.queries.NPCQuery;
|
import net.runelite.api.queries.NPCQuery;
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
@@ -68,6 +69,8 @@ import net.runelite.client.util.QueryRunner;
|
|||||||
public class RunecraftPlugin extends Plugin
|
public class RunecraftPlugin extends Plugin
|
||||||
{
|
{
|
||||||
private static Pattern bindNeckString = Pattern.compile("You have ([0-9]+) charges left before your Binding necklace disintegrates.");
|
private static Pattern bindNeckString = Pattern.compile("You have ([0-9]+) charges left before your Binding necklace disintegrates.");
|
||||||
|
private static final String POUCH_DECAYED_NOTIFICATION_MESSAGE = "Your rune pouch has decayed.";
|
||||||
|
private static final String POUCH_DECAYED_MESSAGE = "Your pouch has decayed through use.";
|
||||||
private static final int DESTROY_ITEM_WIDGET_ID = WidgetInfo.DESTROY_ITEM_YES.getId();
|
private static final int DESTROY_ITEM_WIDGET_ID = WidgetInfo.DESTROY_ITEM_YES.getId();
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
@@ -100,6 +103,9 @@ public class RunecraftPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private RunecraftConfig config;
|
private RunecraftConfig config;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Notifier notifier;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
RunecraftConfig getConfig(ConfigManager configManager)
|
RunecraftConfig getConfig(ConfigManager configManager)
|
||||||
{
|
{
|
||||||
@@ -135,36 +141,48 @@ public class RunecraftPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onChatMessage(ChatMessage event)
|
public void onChatMessage(ChatMessage event)
|
||||||
{
|
{
|
||||||
if (event.getType() != ChatMessageType.SERVER || !config.showBindNeck())
|
if (event.getType() != ChatMessageType.SERVER)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matcher match = bindNeckString.matcher(event.getMessage());
|
if (config.showBindNeck())
|
||||||
if (match.find())
|
|
||||||
{
|
{
|
||||||
bindNeckOverlay.bindingCharges = Integer.parseInt(match.group(1));
|
Matcher match = bindNeckString.matcher(event.getMessage());
|
||||||
return;
|
if (match.find())
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getMessage().contains("You bind the temple's power"))
|
|
||||||
{
|
|
||||||
if (event.getMessage().contains("mud")
|
|
||||||
|| event.getMessage().contains("lava")
|
|
||||||
|| event.getMessage().contains("steam")
|
|
||||||
|| event.getMessage().contains("dust")
|
|
||||||
|| event.getMessage().contains("smoke")
|
|
||||||
|| event.getMessage().contains("mist"))
|
|
||||||
{
|
{
|
||||||
bindNeckOverlay.bindingCharges -= 1;
|
bindNeckOverlay.bindingCharges = Integer.parseInt(match.group(1));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getMessage().contains("You bind the temple's power"))
|
||||||
|
{
|
||||||
|
if (event.getMessage().contains("mud")
|
||||||
|
|| event.getMessage().contains("lava")
|
||||||
|
|| event.getMessage().contains("steam")
|
||||||
|
|| event.getMessage().contains("dust")
|
||||||
|
|| event.getMessage().contains("smoke")
|
||||||
|
|| event.getMessage().contains("mist"))
|
||||||
|
{
|
||||||
|
bindNeckOverlay.bindingCharges -= 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getMessage().contains("Your Binding necklace has disintegrated."))
|
||||||
|
{
|
||||||
|
//set it to 17 because this message is triggered first before the above chat event
|
||||||
|
bindNeckOverlay.bindingCharges = 17;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (config.degradingNotification())
|
||||||
if (event.getMessage().contains("Your Binding necklace has disintegrated."))
|
|
||||||
{
|
{
|
||||||
//set it to 17 because this message is triggered first before the above chat event
|
if (event.getMessage().contains(POUCH_DECAYED_MESSAGE))
|
||||||
bindNeckOverlay.bindingCharges = 17;
|
{
|
||||||
|
notifier.notify(POUCH_DECAYED_NOTIFICATION_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user