Item charges update

Add back the removed lsayer related items (deleted in the slayer branch)
Add
    - Xeric talisman
    - Soul bearer
    - Chronicle
This commit is contained in:
Scott Burns
2019-05-01 20:57:59 +02:00
parent c48c85a11e
commit 070b0ed893
9 changed files with 487 additions and 26 deletions

View File

@@ -48,4 +48,5 @@ public class GraphicID
public static final int NPC_CONTACT = 728; public static final int NPC_CONTACT = 728;
public static final int POT_SHARE = 733; public static final int POT_SHARE = 733;
public static final int BAKE_PIE = 746; public static final int BAKE_PIE = 746;
public static final int XERIC_TELEPORT = 1612;
} }

View File

@@ -130,6 +130,7 @@ public class WidgetID
public static final int FULLSCREEN_MAP_GROUP_ID = 165; public static final int FULLSCREEN_MAP_GROUP_ID = 165;
public static final int QUESTLIST_GROUP_ID = 399; public static final int QUESTLIST_GROUP_ID = 399;
public static final int SKILLS_GROUP_ID = 320; public static final int SKILLS_GROUP_ID = 320;
public static final int DIALOG_SPRITE2_ID = 11;
public static final int EQUIPMENT_PAGE_GROUP_ID = 84; public static final int EQUIPMENT_PAGE_GROUP_ID = 84;
public static final int QUESTTAB_GROUP_ID = 629; public static final int QUESTTAB_GROUP_ID = 629;
public static final int MUSIC_GROUP_ID = 239; public static final int MUSIC_GROUP_ID = 239;
@@ -963,6 +964,14 @@ public class WidgetID
static final int MINIQUEST_CONTAINER = 8; static final int MINIQUEST_CONTAINER = 8;
} }
static class DialogSprite2
{
static final int SPRITE1 = 1;
static final int TEXT = 2;
static final int SPRITE2 = 3;
static final int CONTINUE = 4;
}
static class QuestTab static class QuestTab
{ {
static final int QUEST_TAB = 3; static final int QUEST_TAB = 3;

View File

@@ -328,6 +328,11 @@ public enum WidgetInfo
DIALOG_SPRITE(WidgetID.DIALOG_SPRITE_GROUP_ID, 0), DIALOG_SPRITE(WidgetID.DIALOG_SPRITE_GROUP_ID, 0),
DIALOG_SPRITE_SPRITE(WidgetID.DIALOG_SPRITE_GROUP_ID, WidgetID.DialogSprite.SPRITE), DIALOG_SPRITE_SPRITE(WidgetID.DIALOG_SPRITE_GROUP_ID, WidgetID.DialogSprite.SPRITE),
DIALOG_SPRITE_TEXT(WidgetID.DIALOG_SPRITE_GROUP_ID, WidgetID.DialogSprite.TEXT), DIALOG_SPRITE_TEXT(WidgetID.DIALOG_SPRITE_GROUP_ID, WidgetID.DialogSprite.TEXT),
DIALOG2_SPRITE(WidgetID.DIALOG_SPRITE2_ID, 0),
DIALOG2_SPRITE_SPRITE1(WidgetID.DIALOG_SPRITE2_ID, WidgetID.DialogSprite2.SPRITE1),
DIALOG2_SPRITE_SPRITE2(WidgetID.DIALOG_SPRITE2_ID, WidgetID.DialogSprite2.SPRITE2),
DIALOG2_SPRITE_TEXT(WidgetID.DIALOG_SPRITE2_ID, WidgetID.DialogSprite2.TEXT),
DIALOG2_SPRITE_CONTINUE(WidgetID.DIALOG_SPRITE2_ID, WidgetID.DialogSprite2.CONTINUE),
DIALOG_NPC(WidgetID.DIALOG_NPC_GROUP_ID, 0), DIALOG_NPC(WidgetID.DIALOG_NPC_GROUP_ID, 0),
DIALOG_NPC_NAME(WidgetID.DIALOG_NPC_GROUP_ID, WidgetID.DialogNPC.NAME), DIALOG_NPC_NAME(WidgetID.DIALOG_NPC_GROUP_ID, WidgetID.DialogNPC.NAME),

View File

@@ -172,10 +172,10 @@ public interface ItemChargeConfig extends Config
} }
@ConfigItem( @ConfigItem(
keyName = "showBellowCharges", keyName = "showBellowCharges",
name = "Show Bellow Charges", name = "Show Bellow Charges",
description = "Configures if ogre bellow item charge is shown", description = "Configures if ogre bellow item charge is shown",
position = 12 position = 12
) )
default boolean showBellowCharges() default boolean showBellowCharges()
{ {
@@ -183,10 +183,10 @@ public interface ItemChargeConfig extends Config
} }
@ConfigItem( @ConfigItem(
keyName = "showAbyssalBraceletCharges", keyName = "showAbyssalBraceletCharges",
name = "Show Abyssal Bracelet Charges", name = "Show Abyssal Bracelet Charges",
description = "Configures if abyssal bracelet item charge is shown", description = "Configures if abyssal bracelet item charge is shown",
position = 13 position = 13
) )
default boolean showAbyssalBraceletCharges() default boolean showAbyssalBraceletCharges()
{ {
@@ -204,11 +204,58 @@ public interface ItemChargeConfig extends Config
return false; return false;
} }
@ConfigItem(
keyName = "showSlayerBracelets",
name = "Show Slayer Bracelets Charges",
description = "Configures if slayer bracelets' item charges are shown",
position = 15
)
default boolean showSlayerBracelets()
{
return true;
}
@ConfigItem(
keyName = "expeditious",
name = "",
description = "",
hidden = true
)
default int expeditious()
{
return -1;
}
@ConfigItem(
keyName = "expeditious",
name = "",
description = ""
)
void expeditious(int expeditious);
@ConfigItem(
keyName = "slaughter",
name = "",
description = "",
hidden = true
)
default int slaughter()
{
return -1;
}
@ConfigItem(
keyName = "slaughter",
name = "",
description = ""
)
void slaughter(int slaughter);
@ConfigItem( @ConfigItem(
keyName = "showBindingNecklaceCharges", keyName = "showBindingNecklaceCharges",
name = "Show Binding Necklace Charges", name = "Show Binding Necklace Charges",
description = "Configures if binding necklace item charge is shown", description = "Configures if binding necklace item charge is shown",
position = 15 position = 16
) )
default boolean showBindingNecklaceCharges() default boolean showBindingNecklaceCharges()
{ {
@@ -237,21 +284,108 @@ public interface ItemChargeConfig extends Config
keyName = "bindingNotification", keyName = "bindingNotification",
name = "Binding Necklace Notification", name = "Binding Necklace Notification",
description = "Configures if the binding necklace breaking notification is shown", description = "Configures if the binding necklace breaking notification is shown",
position = 16 position = 17
) )
default boolean bindingNotification() default boolean bindingNotification()
{ {
return true; return true;
} }
@ConfigItem(
keyName = "showXericTalismanCharges",
name = "Show Xeric's Talisman Charges",
description = "Configures if Xeric's Talisman item charge is shown",
position = 18
)
default boolean showXericTalismanCharges()
{
return false;
}
@ConfigItem(
keyName = "xericTalisman",
name = "",
description = "",
hidden = true
)
default int xericTalisman()
{
return -1;
}
@ConfigItem(
keyName = "xericTalisman",
name = "",
description = ""
)
void xericTalisman(int xericTalisman);
@ConfigItem(
keyName = "showSoulBearerCharges",
name = "Show Soul Bearer Charges",
description = "Configures if Soul Bearer item charge is shown",
position = 19
)
default boolean showSoulBearerCharges()
{
return false;
}
@ConfigItem(
keyName = "soulBearer",
name = "",
description = "",
hidden = true
)
default int soulBearer()
{
return -1;
}
@ConfigItem(
keyName = "soulBearer",
name = "",
description = ""
)
void soulBearer(int soulBearer);
@ConfigItem(
keyName = "showChronicleCharges",
name = "Show Chronicle Charges",
description = "Configures if Chronicle item charge is shown",
position = 20
)
default boolean showChronicleCharges()
{
return false;
}
@ConfigItem(
keyName = "chronicle",
name = "",
description = "",
hidden = true
)
default int chronicle()
{
return -1;
}
@ConfigItem(
keyName = "chronicle",
name = "",
description = ""
)
void chronicle(int chronicle);
@ConfigItem( @ConfigItem(
keyName = "showInfoboxes", keyName = "showInfoboxes",
name = "Show Infoboxes", name = "Show Infoboxes",
description = "Configures whether to show an infobox equipped charge items", description = "Configures whether to show an infobox equipped charge items",
position = 17 position = 21
) )
default boolean showInfoboxes() default boolean showInfoboxes()
{ {
return false; return false;
} }
} }

View File

@@ -75,6 +75,24 @@ class ItemChargeOverlay extends WidgetItemOverlay
charges = config.dodgyNecklace(); charges = config.dodgyNecklace();
} }
else if (itemId == ItemID.BRACELET_OF_SLAUGHTER)
{
if (!config.showSlayerBracelets())
{
return;
}
charges = config.slaughter();
}
else if (itemId == ItemID.EXPEDITIOUS_BRACELET)
{
if (!config.showSlayerBracelets())
{
return;
}
charges = config.expeditious();
}
else if (itemId == ItemID.BINDING_NECKLACE) else if (itemId == ItemID.BINDING_NECKLACE)
{ {
if (!config.showBindingNecklaceCharges()) if (!config.showBindingNecklaceCharges())
@@ -84,7 +102,32 @@ class ItemChargeOverlay extends WidgetItemOverlay
charges = config.bindingNecklace(); charges = config.bindingNecklace();
} }
else if (itemId == ItemID.XERICS_TALISMAN)
{
if (!config.showXericTalismanCharges())
{
return;
}
charges = config.xericTalisman();
}
else if (itemId == ItemID.SOUL_BEARER)
{
if (!config.showSoulBearerCharges())
{
return;
}
charges = config.soulBearer();
}
else if (itemId == ItemID.CHRONICLE)
{
if (!config.showChronicleCharges())
{
return;
}
charges = config.chronicle();
}
else else
{ {
ItemWithCharge chargeItem = ItemWithCharge.findItem(itemId); ItemWithCharge chargeItem = ItemWithCharge.findItem(itemId);
if (chargeItem == null) if (chargeItem == null)
@@ -109,7 +152,9 @@ class ItemChargeOverlay extends WidgetItemOverlay
final Rectangle bounds = itemWidget.getCanvasBounds(); final Rectangle bounds = itemWidget.getCanvasBounds();
final TextComponent textComponent = new TextComponent(); final TextComponent textComponent = new TextComponent();
textComponent.setPosition(new Point(bounds.x, bounds.y + 16)); textComponent.setPosition(new
Point(bounds.x, bounds.y + 16));
textComponent.setText(charges < 0 ? "?" : String.valueOf(charges)); textComponent.setText(charges < 0 ? "?" : String.valueOf(charges));
textComponent.setColor(itemChargePlugin.getColor(charges)); textComponent.setColor(itemChargePlugin.getColor(charges));
textComponent.render(graphics); textComponent.render(graphics);
@@ -121,4 +166,4 @@ class ItemChargeOverlay extends WidgetItemOverlay
|| config.showImpCharges() || config.showWateringCanCharges() || config.showWaterskinCharges() || config.showImpCharges() || config.showWateringCanCharges() || config.showWaterskinCharges()
|| config.showBellowCharges() || config.showAbyssalBraceletCharges(); || config.showBellowCharges() || config.showAbyssalBraceletCharges();
} }
} }

View File

@@ -34,12 +34,15 @@ import javax.inject.Inject;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.EquipmentInventorySlot; import net.runelite.api.EquipmentInventorySlot;
import net.runelite.api.GraphicID;
import net.runelite.api.InventoryID; import net.runelite.api.InventoryID;
import net.runelite.api.Item; import net.runelite.api.Item;
import net.runelite.api.ItemContainer; import net.runelite.api.ItemContainer;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.GraphicChanged;
import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.ScriptCallbackEvent; import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
@@ -52,6 +55,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager; import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import net.runelite.client.util.Text;
@PluginDescriptor( @PluginDescriptor(
name = "Item Charges", name = "Item Charges",
@@ -62,18 +66,56 @@ public class ItemChargePlugin extends Plugin
{ {
private static final Pattern DODGY_CHECK_PATTERN = Pattern.compile( private static final Pattern DODGY_CHECK_PATTERN = Pattern.compile(
"Your dodgy necklace has (\\d+) charges? left\\."); "Your dodgy necklace has (\\d+) charges? left\\.");
private static final Pattern SLAUGHTER_CHECK_PATTERN = Pattern.compile(
"Your bracelet of slaughter has (\\d{1,2}) charge[s]? left.");
private static final Pattern EXPEDITIOUS_CHECK_PATTERN = Pattern.compile(
"Your expeditious bracelet has (\\d{1,2}) charge[s]? left.");
private static final Pattern DODGY_PROTECT_PATTERN = Pattern.compile( private static final Pattern DODGY_PROTECT_PATTERN = Pattern.compile(
"Your dodgy necklace protects you\\..*It has (\\d+) charges? left\\."); "Your dodgy necklace protects you\\..*It has (\\d+) charges? left\\.");
private static final Pattern SLAUGHTER_ACTIVATE_PATTERN = Pattern.compile(
"Your bracelet of slaughter prevents your slayer count decreasing. It has (\\d{1,2}) charge[s]? left.");
private static final Pattern EXPEDITIOUS_ACTIVATE_PATTERN = Pattern.compile(
"Your expeditious bracelet helps you progress your slayer (?:task )?faster. It has (\\d{1,2}) charge[s]? left.");
private static final Pattern DODGY_BREAK_PATTERN = Pattern.compile( private static final Pattern DODGY_BREAK_PATTERN = Pattern.compile(
"Your dodgy necklace protects you\\..*It then crumbles to dust\\."); "Your dodgy necklace protects you\\..*It then crumbles to dust\\.");
private static final String RING_OF_RECOIL_BREAK_MESSAGE = "<col=7f007f>Your Ring of Recoil has shattered.</col>"; private static final String RING_OF_RECOIL_BREAK_MESSAGE = "<col=7f007f>Your Ring of Recoil has shattered.</col>";
private static final Pattern BINDING_CHECK_PATTERN = Pattern.compile( private static Pattern BINDING_CHECK_PATTERN = Pattern.compile(
"You have ([0-9]+|one) charges? left before your Binding necklace disintegrates\\."); "You have ([0-9]+|one) charges? left before your Binding necklace disintegrates.");
private static final Pattern BINDING_USED_PATTERN = Pattern.compile( private static final Pattern BINDING_USED_PATTERN = Pattern.compile(
"You bind the temple's power into (mud|lava|steam|dust|smoke|mist) runes\\."); "You bind the temple's power into (mud|lava|steam|dust|smoke|mist) runes\\.");
private static final String BINDING_BREAK_TEXT = "Your Binding necklace has disintegrated."; private static final String BINDING_BREAK_TEXT = "Your Binding necklace has disintegrated.";
private static final Pattern XERIC_CHECK_CHARGE_PATTERN = Pattern.compile(
"talisman has (\\d+|one) charges?");
private static final Pattern XERIC_RECHARGEWIDGET_PATTERN = Pattern.compile(
"Your talisman now has (\\d+|one) charges?\\.");
private static final Pattern XERIC_OUT_OF_CHARGES = Pattern.compile(
"Your talisman has run out of charges");
private static final Pattern XERIC_UNCHARGE_PATTERN = Pattern.compile(
"lizard fangs? from your talisman\\.");
private static final Pattern SOULBEARER_RECHARGE_PATTERN = Pattern.compile(
"You add (\\d+|a) charges? to your soul bearer.It now has (\\d+) charges\\.");
private static final Pattern SOULBEARER_RECHARGE_PATTERN2 = Pattern.compile(
"Your soul bearer now has one charge\\.");
private static final Pattern SOULBEARER_CHECK_CHARGE_PATTERN = Pattern.compile(
"soul bearer has (\\d+|one) charges?\\.");
private static final Pattern SOULBEARER_UNCHARGE_PATTERN = Pattern.compile(
"You remove the runes from the soul bearer\\.");
private static final Pattern SOULBEARER_BANKHEADS_PATTERN = Pattern.compile(
"Your soul bearer carries the ensouled heads? to your ?bank\\. It has (\\d+|one) charges? left\\.");
private static final Pattern SOULBEARER_OUT_OF_CHARGES = Pattern.compile(
"Your soul bearer carries the ensouled heads? to (.+)\\. It has run out of charges\\.");
private static final Pattern CHRONICLE_CHECK_CHARGE_PATTERN = Pattern.compile(
"Your book has (\\d+) charges left\\.");
private static final Pattern CHRONICLE_ADD_CHARGE_PATTERN = Pattern.compile(
"You add (\\d+|a single) charges? to your book. It now has (\\d+) charges\\.");
private static final Pattern CHRONICLE_LAST_CHARGE_PATTERN = Pattern.compile(
"You have one charge left in your book\\.");
private static final Pattern CHRONICLE_OUT_OF_CHARGES_PATTERN = Pattern.compile(
"Your book has run out of charges\\.");
private static final int MAX_DODGY_CHARGES = 10; private static final int MAX_DODGY_CHARGES = 10;
private static final int MAX_SLAUGHTER_CHARGES = 30;
private static final int MAX_EXPEDITIOUS_CHARGES = 30;
private static final int MAX_BINDING_CHARGES = 16; private static final int MAX_BINDING_CHARGES = 16;
@Inject @Inject
@@ -149,6 +191,12 @@ public class ItemChargePlugin extends Plugin
removeInfobox(ItemWithSlot.DODGY_NECKLACE); removeInfobox(ItemWithSlot.DODGY_NECKLACE);
} }
if (!config.showSlayerBracelets())
{
removeInfobox(ItemWithSlot.BRACELET_OF_SLAUGHTER);
removeInfobox(ItemWithSlot.EXPEDITIOUS_BRACELET);
}
if (!config.showBindingNecklaceCharges()) if (!config.showBindingNecklaceCharges())
{ {
removeInfobox(ItemWithSlot.BINDING_NECKLACE); removeInfobox(ItemWithSlot.BINDING_NECKLACE);
@@ -160,10 +208,21 @@ public class ItemChargePlugin extends Plugin
{ {
String message = event.getMessage(); String message = event.getMessage();
Matcher dodgyCheckMatcher = DODGY_CHECK_PATTERN.matcher(message); Matcher dodgyCheckMatcher = DODGY_CHECK_PATTERN.matcher(message);
Matcher slaughterCheckMatcher = SLAUGHTER_CHECK_PATTERN.matcher(message);
Matcher expeditiousCheckMatcher = EXPEDITIOUS_CHECK_PATTERN.matcher(message);
Matcher dodgyProtectMatcher = DODGY_PROTECT_PATTERN.matcher(message); Matcher dodgyProtectMatcher = DODGY_PROTECT_PATTERN.matcher(message);
Matcher slaughterActivateMatcher = SLAUGHTER_ACTIVATE_PATTERN.matcher(message);
Matcher expeditiousActivateMatcher = EXPEDITIOUS_ACTIVATE_PATTERN.matcher(message);
Matcher dodgyBreakMatcher = DODGY_BREAK_PATTERN.matcher(message); Matcher dodgyBreakMatcher = DODGY_BREAK_PATTERN.matcher(message);
Matcher bindingNecklaceCheckMatcher = BINDING_CHECK_PATTERN.matcher(event.getMessage()); Matcher bindingNecklaceCheckMatcher = BINDING_CHECK_PATTERN.matcher(event.getMessage());
Matcher bindingNecklaceUsedMatcher = BINDING_USED_PATTERN.matcher(event.getMessage()); Matcher bindingNecklaceUsedMatcher = BINDING_USED_PATTERN.matcher(event.getMessage());
Matcher xericRechargeMatcher = XERIC_CHECK_CHARGE_PATTERN.matcher(message);
Matcher xericOutOfChargesMatcher = XERIC_OUT_OF_CHARGES.matcher(message);
Matcher soulbearerCheckMatcher = SOULBEARER_CHECK_CHARGE_PATTERN.matcher(message);
Matcher chronicleCheckMatcher = CHRONICLE_CHECK_CHARGE_PATTERN.matcher(message);
Matcher chronicleRechargeMatcher = CHRONICLE_ADD_CHARGE_PATTERN.matcher(message);
Matcher chronicleLastChargeMatcher = CHRONICLE_LAST_CHARGE_PATTERN.matcher(message);
Matcher chronicleOutOfChargesMatcher = CHRONICLE_OUT_OF_CHARGES_PATTERN.matcher(message);
if (event.getType() == ChatMessageType.GAMEMESSAGE || event.getType() == ChatMessageType.SPAM) if (event.getType() == ChatMessageType.GAMEMESSAGE || event.getType() == ChatMessageType.SPAM)
{ {
@@ -171,6 +230,30 @@ public class ItemChargePlugin extends Plugin
{ {
notifier.notify("Your Ring of Recoil has shattered"); notifier.notify("Your Ring of Recoil has shattered");
} }
else if (dodgyCheckMatcher.find())
{
updateDodgyNecklaceCharges(Integer.parseInt(dodgyCheckMatcher.group(1)));
}
else if (slaughterCheckMatcher.find())
{
updateBraceletOfSlaughterCharges(Integer.parseInt(slaughterCheckMatcher.group(1)));
}
else if (expeditiousCheckMatcher.find())
{
updateExpeditiousCharges(Integer.parseInt(expeditiousCheckMatcher.group(1)));
}
else if (dodgyProtectMatcher.find())
{
updateDodgyNecklaceCharges(Integer.parseInt(dodgyProtectMatcher.group(1)));
}
else if (slaughterActivateMatcher.find())
{
updateBraceletOfSlaughterCharges(Integer.parseInt(slaughterActivateMatcher.group(1)));
}
else if (expeditiousActivateMatcher.find())
{
updateExpeditiousCharges(Integer.parseInt(expeditiousActivateMatcher.group(1)));
}
else if (dodgyBreakMatcher.find()) else if (dodgyBreakMatcher.find())
{ {
if (config.dodgyNotification()) if (config.dodgyNotification())
@@ -180,14 +263,6 @@ public class ItemChargePlugin extends Plugin
updateDodgyNecklaceCharges(MAX_DODGY_CHARGES); updateDodgyNecklaceCharges(MAX_DODGY_CHARGES);
} }
else if (dodgyCheckMatcher.find())
{
updateDodgyNecklaceCharges(Integer.parseInt(dodgyCheckMatcher.group(1)));
}
else if (dodgyProtectMatcher.find())
{
updateDodgyNecklaceCharges(Integer.parseInt(dodgyProtectMatcher.group(1)));
}
else if (message.contains(BINDING_BREAK_TEXT)) else if (message.contains(BINDING_BREAK_TEXT))
{ {
if (config.bindingNotification()) if (config.bindingNotification())
@@ -214,6 +289,41 @@ public class ItemChargePlugin extends Plugin
updateBindingNecklaceCharges(charges); updateBindingNecklaceCharges(charges);
} }
else if (xericRechargeMatcher.find())
{
final int xericCharges = xericRechargeMatcher.group(1).equals("one") ? 1 : (Integer.parseInt(xericRechargeMatcher.group(1)));
updateXericCharges(xericCharges);
}
else if (xericOutOfChargesMatcher.find())
{
final int xericCharges = 0;
updateXericCharges(xericCharges);
}
else if (soulbearerCheckMatcher.find())
{
final int soulbearerCharges = soulbearerCheckMatcher.group(1).equals("one") ? 1 : (Integer.parseInt(soulbearerCheckMatcher.group(1)));
updateSoulBearerCharges(soulbearerCharges);
}
else if (chronicleCheckMatcher.find())
{
final int chronicleCharges = chronicleCheckMatcher.group(1).equals("one") ? 1 : (Integer.parseInt(chronicleCheckMatcher.group(1)));
updateChronicleCharges(chronicleCharges);
}
else if (chronicleRechargeMatcher.find())
{
final int chronicleCharges = chronicleRechargeMatcher.group(2).equals("one") ? 1 : (Integer.parseInt(chronicleRechargeMatcher.group(2)));
updateChronicleCharges(chronicleCharges);
}
else if (chronicleLastChargeMatcher.find())
{
final int chronicleCharges = 1;
updateChronicleCharges(chronicleCharges);
}
else if (chronicleOutOfChargesMatcher.find())
{
final int chronicleCharges = 0;
updateChronicleCharges(chronicleCharges);
}
} }
} }
@@ -242,12 +352,102 @@ public class ItemChargePlugin extends Plugin
updateJewelleryInfobox(ItemWithSlot.ABYSSAL_BRACELET, items); updateJewelleryInfobox(ItemWithSlot.ABYSSAL_BRACELET, items);
} }
if (config.showSlayerBracelets())
{
updateJewelleryInfobox(ItemWithSlot.BRACELET_OF_SLAUGHTER, items);
updateJewelleryInfobox(ItemWithSlot.EXPEDITIOUS_BRACELET, items);
}
if (config.showBindingNecklaceCharges()) if (config.showBindingNecklaceCharges())
{ {
updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, items); updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, items);
} }
} }
@Subscribe
public void onGameTick(GameTick event)
{
Widget braceletBreakWidget = client.getWidget(WidgetInfo.DIALOG_SPRITE_TEXT);
if (braceletBreakWidget != null)
{
String braceletText = Text.removeTags(braceletBreakWidget.getText()); //remove color and linebreaks
if (braceletText.contains("bracelet of slaughter"))
{
config.slaughter(MAX_SLAUGHTER_CHARGES);
}
else if (braceletText.contains("expeditious bracelet"))
{
config.expeditious(MAX_EXPEDITIOUS_CHARGES);
}
}
Widget dialog1 = client.getWidget(WidgetInfo.DIALOG_SPRITE_TEXT);
Widget dialog2 = client.getWidget(WidgetInfo.DIALOG2_SPRITE_TEXT);
if (dialog1 != null)
{
String widgetText = Text.removeTags(dialog1.getText());
Matcher xericRechargeMatcher = XERIC_RECHARGEWIDGET_PATTERN.matcher(widgetText);
Matcher soulbearerRechargeMatcher = SOULBEARER_RECHARGE_PATTERN.matcher(widgetText);
Matcher soulbearerRecharge2Matcher = SOULBEARER_RECHARGE_PATTERN2.matcher(widgetText);
if (xericRechargeMatcher.find())
{
final int xericCharges = xericRechargeMatcher.group(1).equals("one") ? 1 : (Integer.parseInt(xericRechargeMatcher.group(1)));
updateXericCharges(xericCharges);
}
else if (soulbearerRechargeMatcher.find())
{
final int soulbearerCharges = soulbearerRechargeMatcher.group(2).equals("one") ? 1 : (Integer.parseInt(soulbearerRechargeMatcher.group(2)));
updateSoulBearerCharges(soulbearerCharges);
}
else if (soulbearerRecharge2Matcher.find())
{
final int soulbearerCharges = 1;
updateSoulBearerCharges(soulbearerCharges);
}
}
if (dialog2 != null)
{
String widgetText = Text.removeTags(dialog2.getText());
Matcher xericUnchargeMatcher = XERIC_UNCHARGE_PATTERN.matcher(widgetText);
Matcher soulbearerUnchargeMatcher = SOULBEARER_UNCHARGE_PATTERN.matcher(widgetText);
Matcher soulbearerBankHeadsMatcher = SOULBEARER_BANKHEADS_PATTERN.matcher(widgetText);
Matcher soulbearerOutOfCharges = SOULBEARER_OUT_OF_CHARGES.matcher(widgetText);
if (xericUnchargeMatcher.find())
{
final int xericCharges = 0;
updateXericCharges(xericCharges);
}
else if (soulbearerUnchargeMatcher.find() || soulbearerOutOfCharges.find())
{
final int soulbearerCharges = 0;
updateSoulBearerCharges(soulbearerCharges);
}
else if (soulbearerBankHeadsMatcher.find())
{
final int soulbearerCharges = soulbearerBankHeadsMatcher.group(1).equals("one") ? 1 : (Integer.parseInt(soulbearerBankHeadsMatcher.group(1)));
updateSoulBearerCharges(soulbearerCharges);
}
}
}
@Subscribe
public void onGraphicChanged(GraphicChanged event)
{
if (event.getActor() == client.getLocalPlayer())
{
if (client.getLocalPlayer().getGraphic() == GraphicID.XERIC_TELEPORT)
{
final int xericCharges = Math.max(config.xericTalisman() - 1, 0);
updateXericCharges(xericCharges);
}
}
}
@Subscribe @Subscribe
private void onScriptCallbackEvent(ScriptCallbackEvent event) private void onScriptCallbackEvent(ScriptCallbackEvent event)
{ {
@@ -280,6 +480,40 @@ public class ItemChargePlugin extends Plugin
} }
} }
private void updateBraceletOfSlaughterCharges(final int value)
{
config.slaughter(value);
if (config.showInfoboxes() && config.showSlayerBracelets())
{
final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT);
if (itemContainer == null)
{
return;
}
updateJewelleryInfobox(ItemWithSlot.BRACELET_OF_SLAUGHTER, itemContainer.getItems());
}
}
private void updateExpeditiousCharges(final int value)
{
config.expeditious(value);
if (config.showInfoboxes() && config.showSlayerBracelets())
{
final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT);
if (itemContainer == null)
{
return;
}
updateJewelleryInfobox(ItemWithSlot.EXPEDITIOUS_BRACELET, itemContainer.getItems());
}
}
private void updateBindingNecklaceCharges(final int value) private void updateBindingNecklaceCharges(final int value)
{ {
config.bindingNecklace(value); config.bindingNecklace(value);
@@ -297,6 +531,21 @@ public class ItemChargePlugin extends Plugin
} }
} }
private void updateXericCharges(int xericCharges)
{
config.xericTalisman(xericCharges);
}
private void updateSoulBearerCharges(int soulBearerCharges)
{
config.soulBearer(soulBearerCharges);
}
private void updateChronicleCharges(int chronicleCharges)
{
config.chronicle(chronicleCharges);
}
private void checkDestroyWidget() private void checkDestroyWidget()
{ {
final int currentTick = client.getTickCount(); final int currentTick = client.getTickCount();
@@ -355,6 +604,14 @@ public class ItemChargePlugin extends Plugin
{ {
charges = config.dodgyNecklace(); charges = config.dodgyNecklace();
} }
else if (id == ItemID.BRACELET_OF_SLAUGHTER && type == ItemWithSlot.BRACELET_OF_SLAUGHTER)
{
charges = config.slaughter();
}
else if (id == ItemID.EXPEDITIOUS_BRACELET && type == ItemWithSlot.EXPEDITIOUS_BRACELET)
{
charges = config.expeditious();
}
else if (id == ItemID.BINDING_NECKLACE && type == ItemWithSlot.BINDING_NECKLACE) else if (id == ItemID.BINDING_NECKLACE && type == ItemWithSlot.BINDING_NECKLACE)
{ {
charges = config.bindingNecklace(); charges = config.bindingNecklace();

View File

@@ -34,5 +34,7 @@ enum ItemChargeType
WATERCAN, WATERCAN,
WATERSKIN, WATERSKIN,
DODGY_NECKLACE, DODGY_NECKLACE,
BRACELET_OF_SLAUGHTER,
EXPEDITIOUS_BRACELET,
BINDING_NECKLACE BINDING_NECKLACE
} }

View File

@@ -30,7 +30,13 @@ import javax.annotation.Nullable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import static net.runelite.api.ItemID.*; import static net.runelite.api.ItemID.*;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.*; import static net.runelite.client.plugins.itemcharges.ItemChargeType.ABYSSAL_BRACELET;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.BELLOWS;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.FUNGICIDE_SPRAY;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.IMPBOX;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.TELEPORT;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERCAN;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERSKIN;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter

View File

@@ -33,6 +33,8 @@ import net.runelite.api.EquipmentInventorySlot;
enum ItemWithSlot enum ItemWithSlot
{ {
ABYSSAL_BRACELET(ItemChargeType.ABYSSAL_BRACELET, EquipmentInventorySlot.GLOVES), ABYSSAL_BRACELET(ItemChargeType.ABYSSAL_BRACELET, EquipmentInventorySlot.GLOVES),
BRACELET_OF_SLAUGHTER(ItemChargeType.BRACELET_OF_SLAUGHTER, EquipmentInventorySlot.GLOVES),
EXPEDITIOUS_BRACELET(ItemChargeType.EXPEDITIOUS_BRACELET, EquipmentInventorySlot.GLOVES),
DODGY_NECKLACE(ItemChargeType.DODGY_NECKLACE, EquipmentInventorySlot.AMULET), DODGY_NECKLACE(ItemChargeType.DODGY_NECKLACE, EquipmentInventorySlot.AMULET),
BINDING_NECKLACE(ItemChargeType.BINDING_NECKLACE, EquipmentInventorySlot.AMULET), BINDING_NECKLACE(ItemChargeType.BINDING_NECKLACE, EquipmentInventorySlot.AMULET),
TELEPORT(ItemChargeType.TELEPORT, EquipmentInventorySlot.WEAPON, EquipmentInventorySlot.AMULET, EquipmentInventorySlot.GLOVES, EquipmentInventorySlot.RING); TELEPORT(ItemChargeType.TELEPORT, EquipmentInventorySlot.WEAPON, EquipmentInventorySlot.AMULET, EquipmentInventorySlot.GLOVES, EquipmentInventorySlot.RING);