itemcharges: Add support for blood essence
Co-authored-by: Adam <Adam@sigterm.info>
This commit is contained in:
@@ -46,6 +46,7 @@ public interface ItemChargeConfig extends Config
|
||||
String KEY_EXPEDITIOUS_BRACELET = "expeditiousBracelet";
|
||||
String KEY_EXPLORERS_RING = "explorerRing";
|
||||
String KEY_RING_OF_FORGING = "ringOfForging";
|
||||
String KEY_BLOOD_ESSENCE = "bloodEssence";
|
||||
|
||||
@ConfigSection(
|
||||
name = "Charge Settings",
|
||||
@@ -415,4 +416,16 @@ public interface ItemChargeConfig extends Config
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showBloodEssenceCharges",
|
||||
name = "Blood Essence Charges",
|
||||
description = "Show Blood Essence charges",
|
||||
position = 30,
|
||||
section = chargesSection
|
||||
)
|
||||
default boolean showBloodEssenceCharges()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,13 @@ public class ItemChargePlugin extends Plugin
|
||||
"Your expeditious bracelet has (\\d{1,2}) charges? left\\."
|
||||
);
|
||||
private static final String EXPEDITIOUS_BRACELET_BREAK_TEXT = "Your Expeditious Bracelet has crumbled to dust.";
|
||||
private static final Pattern BLOOD_ESSENCE_CHECK_PATTERN = Pattern.compile(
|
||||
"Your blood essence has (\\d{1,4}) charges? remaining"
|
||||
);
|
||||
private static final Pattern BLOOD_ESSENCE_EXTRACT_PATTERN = Pattern.compile(
|
||||
"You manage to extract power from the Blood Essence and craft (\\d{1,3}) extra runes?\\."
|
||||
);
|
||||
private static final String BLOOD_ESSENCE_ACTIVATE_TEXT = "You activate the blood essence.";
|
||||
|
||||
private static final int MAX_DODGY_CHARGES = 10;
|
||||
private static final int MAX_BINDING_CHARGES = 16;
|
||||
@@ -138,6 +145,7 @@ public class ItemChargePlugin extends Plugin
|
||||
private static final int MAX_AMULET_OF_CHEMISTRY_CHARGES = 5;
|
||||
private static final int MAX_AMULET_OF_BOUNTY_CHARGES = 10;
|
||||
private static final int MAX_SLAYER_BRACELET_CHARGES = 30;
|
||||
private static final int MAX_BLOOD_ESSENCE_CHARGES = 1000;
|
||||
|
||||
private int lastExplorerRingCharge = -1;
|
||||
|
||||
@@ -227,6 +235,8 @@ public class ItemChargePlugin extends Plugin
|
||||
Matcher slaughterCheckMatcher = BRACELET_OF_SLAUGHTER_CHECK_PATTERN.matcher(message);
|
||||
Matcher expeditiousActivateMatcher = EXPEDITIOUS_BRACELET_ACTIVATE_PATTERN.matcher(message);
|
||||
Matcher expeditiousCheckMatcher = EXPEDITIOUS_BRACELET_CHECK_PATTERN.matcher(message);
|
||||
Matcher bloodEssenceCheckMatcher = BLOOD_ESSENCE_CHECK_PATTERN.matcher(message);
|
||||
Matcher bloodEssenceExtractMatcher = BLOOD_ESSENCE_EXTRACT_PATTERN.matcher(message);
|
||||
|
||||
if (config.recoilNotification() && message.contains(RING_OF_RECOIL_BREAK_MESSAGE))
|
||||
{
|
||||
@@ -413,6 +423,18 @@ public class ItemChargePlugin extends Plugin
|
||||
{
|
||||
updateExpeditiousBraceletCharges(Integer.parseInt(expeditiousCheckMatcher.group(1)));
|
||||
}
|
||||
else if (bloodEssenceCheckMatcher.find())
|
||||
{
|
||||
updateBloodEssenceCharges(Integer.parseInt(bloodEssenceCheckMatcher.group(1)));
|
||||
}
|
||||
else if (bloodEssenceExtractMatcher.find())
|
||||
{
|
||||
updateBloodEssenceCharges(getItemCharges(ItemChargeConfig.KEY_BLOOD_ESSENCE) - Integer.parseInt(bloodEssenceExtractMatcher.group(1)));
|
||||
}
|
||||
else if (message.contains(BLOOD_ESSENCE_ACTIVATE_TEXT))
|
||||
{
|
||||
updateBloodEssenceCharges(MAX_BLOOD_ESSENCE_CHARGES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,6 +562,12 @@ public class ItemChargePlugin extends Plugin
|
||||
updateInfoboxes();
|
||||
}
|
||||
|
||||
private void updateBloodEssenceCharges(final int value)
|
||||
{
|
||||
setItemCharges(ItemChargeConfig.KEY_BLOOD_ESSENCE, value);
|
||||
updateInfoboxes();
|
||||
}
|
||||
|
||||
private void checkDestroyWidget()
|
||||
{
|
||||
final int currentTick = client.getTickCount();
|
||||
|
||||
@@ -51,7 +51,8 @@ enum ItemChargeType
|
||||
SACK(ItemChargeConfig::showSackCharges),
|
||||
RING_OF_FORGING(ItemChargeConfig::showRingOfForgingCount),
|
||||
POTION(ItemChargeConfig::showPotionDoseCount),
|
||||
GUTHIX_REST(ItemChargeConfig::showGuthixRestDoses);
|
||||
GUTHIX_REST(ItemChargeConfig::showGuthixRestDoses),
|
||||
BLOOD_ESSENCE(ItemChargeConfig::showBloodEssenceCharges);
|
||||
|
||||
private final Predicate<ItemChargeConfig> enabled;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ enum ItemWithConfig
|
||||
AMULET_OF_BOUNTY(ItemID.AMULET_OF_BOUNTY, ItemChargeConfig.KEY_AMULET_OF_BOUNTY, ItemChargeType.AMULET_OF_BOUNTY),
|
||||
BRACELET_OF_SLAUGHTER(ItemID.BRACELET_OF_SLAUGHTER, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, ItemChargeType.BRACELET_OF_SLAUGHTER),
|
||||
EXPEDITIOUS_BRACELET(ItemID.EXPEDITIOUS_BRACELET, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, ItemChargeType.EXPEDITIOUS_BRACELET),
|
||||
CHRONICLE(ItemID.CHRONICLE, ItemChargeConfig.KEY_CHRONICLE, ItemChargeType.TELEPORT);
|
||||
CHRONICLE(ItemID.CHRONICLE, ItemChargeConfig.KEY_CHRONICLE, ItemChargeType.TELEPORT),
|
||||
BLOOD_ESSENCE(ItemID.BLOOD_ESSENCE_ACTIVE, ItemChargeConfig.KEY_BLOOD_ESSENCE, ItemChargeType.BLOOD_ESSENCE);
|
||||
|
||||
private final int itemId;
|
||||
private final String configKey;
|
||||
|
||||
@@ -93,6 +93,10 @@ public class ItemChargePluginTest
|
||||
private static final String ACTIVATE_EXPEDITIOUS_BRACELET = "Your expeditious bracelet helps you progress your slayer task faster. It has 11 charges left.";
|
||||
private static final String BREAK_EXPEDITIOUS_BRACELET = "Your expeditious bracelet helps you progress your slayer task faster. <col=ff0000>It then crumbles to dust.</col>";
|
||||
|
||||
private static final String ACTIVATE_BLOOD_ESSENCE = "You activate the blood essence.";
|
||||
private static final String EXTRACT_BLOOD_ESSENCE = "You manage to extract power from the Blood Essence and craft 67 extra runes.";
|
||||
private static final String CHECK_BLOOD_ESSENCE = "Your blood essence has 56 charges remaining";
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private Client client;
|
||||
@@ -421,4 +425,29 @@ public class ItemChargePluginTest
|
||||
itemChargePlugin.onChatMessage(chatMessage);
|
||||
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, 30);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBloodEssenceActivate()
|
||||
{
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", ACTIVATE_BLOOD_ESSENCE, "", 0);
|
||||
itemChargePlugin.onChatMessage(chatMessage);
|
||||
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BLOOD_ESSENCE, 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBloodEssenceExtract()
|
||||
{
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", EXTRACT_BLOOD_ESSENCE, "", 0);
|
||||
when(configManager.getConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BLOOD_ESSENCE, Integer.class)).thenReturn(1000);
|
||||
itemChargePlugin.onChatMessage(chatMessage);
|
||||
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BLOOD_ESSENCE, 933);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBloodEssenceCheck()
|
||||
{
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_BLOOD_ESSENCE, "", 0);
|
||||
itemChargePlugin.onChatMessage(chatMessage);
|
||||
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BLOOD_ESSENCE, 56);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user