Add binding necklace to Item Charge plugin
This commit is contained in:
committed by
TheStonedTurtle
parent
c0563ac3e3
commit
0489d7de9d
@@ -204,11 +204,51 @@ public interface ItemChargeConfig extends Config
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showBindingNecklaceCharges",
|
||||
name = "Show Binding Necklace Charges",
|
||||
description = "Configures if binding necklace item charge is shown",
|
||||
position = 15
|
||||
)
|
||||
default boolean showBindingNecklaceCharges()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "bindingNecklace",
|
||||
name = "",
|
||||
description = "",
|
||||
hidden = true
|
||||
)
|
||||
default int bindingNecklace()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "bindingNecklace",
|
||||
name = "",
|
||||
description = ""
|
||||
)
|
||||
void bindingNecklace(int bindingNecklace);
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "bindingNotification",
|
||||
name = "Binding Necklace Notification",
|
||||
description = "Configures if the binding necklace breaking notification is shown",
|
||||
position = 16
|
||||
)
|
||||
default boolean bindingNotification()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showInfoboxes",
|
||||
name = "Show Infoboxes",
|
||||
description = "Configures whether to show an infobox equipped charge items",
|
||||
position = 15
|
||||
position = 17
|
||||
)
|
||||
default boolean showInfoboxes()
|
||||
{
|
||||
|
||||
@@ -84,6 +84,15 @@ class ItemChargeOverlay extends Overlay
|
||||
|
||||
charges = config.dodgyNecklace();
|
||||
}
|
||||
else if (item.getId() == ItemID.BINDING_NECKLACE)
|
||||
{
|
||||
if (!config.showBindingNecklaceCharges())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
charges = config.bindingNecklace();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemWithCharge chargeItem = ItemWithCharge.findItem(item.getId());
|
||||
|
||||
@@ -64,8 +64,14 @@ public class ItemChargePlugin extends Plugin
|
||||
private static final Pattern DODGY_BREAK_PATTERN = Pattern.compile(
|
||||
"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 Pattern BINDING_CHECK_PATTERN = Pattern.compile(
|
||||
"You have ([0-9]+|one) charges? left before your Binding necklace disintegrates\\.");
|
||||
private static final Pattern BINDING_USED_PATTERN = Pattern.compile(
|
||||
"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 int MAX_DODGY_CHARGES = 10;
|
||||
private static final int MAX_BINDING_CHARGES = 16;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
@@ -135,6 +141,11 @@ public class ItemChargePlugin extends Plugin
|
||||
{
|
||||
removeInfobox(ItemWithSlot.DODGY_NECKLACE);
|
||||
}
|
||||
|
||||
if (!config.showBindingNecklaceCharges())
|
||||
{
|
||||
removeInfobox(ItemWithSlot.BINDING_NECKLACE);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -144,6 +155,9 @@ public class ItemChargePlugin extends Plugin
|
||||
Matcher dodgyCheckMatcher = DODGY_CHECK_PATTERN.matcher(message);
|
||||
Matcher dodgyProtectMatcher = DODGY_PROTECT_PATTERN.matcher(message);
|
||||
Matcher dodgyBreakMatcher = DODGY_BREAK_PATTERN.matcher(message);
|
||||
Matcher bindingNecklaceCheckMatcher = BINDING_CHECK_PATTERN.matcher(event.getMessage());
|
||||
Matcher bindingNecklaceUsedMatcher = BINDING_USED_PATTERN.matcher(event.getMessage());
|
||||
|
||||
if (event.getType() == ChatMessageType.GAMEMESSAGE || event.getType() == ChatMessageType.SPAM)
|
||||
{
|
||||
if (config.recoilNotification() && message.contains(RING_OF_RECOIL_BREAK_MESSAGE))
|
||||
@@ -167,6 +181,32 @@ public class ItemChargePlugin extends Plugin
|
||||
{
|
||||
updateDodgyNecklaceCharges(Integer.parseInt(dodgyProtectMatcher.group(1)));
|
||||
}
|
||||
else if (message.contains(BINDING_BREAK_TEXT))
|
||||
{
|
||||
if (config.bindingNotification())
|
||||
{
|
||||
notifier.notify(BINDING_BREAK_TEXT);
|
||||
}
|
||||
|
||||
// This chat message triggers before the used message so add 1 to the max charges to ensure proper sync
|
||||
updateBindingNecklaceCharges(MAX_BINDING_CHARGES + 1);
|
||||
}
|
||||
else if (bindingNecklaceUsedMatcher.find())
|
||||
{
|
||||
updateBindingNecklaceCharges(config.bindingNecklace() - 1);
|
||||
}
|
||||
else if (bindingNecklaceCheckMatcher.find())
|
||||
{
|
||||
final String match = bindingNecklaceCheckMatcher.group(1);
|
||||
|
||||
int charges = 1;
|
||||
if (!match.equals("one"))
|
||||
{
|
||||
charges = Integer.parseInt(match);
|
||||
}
|
||||
|
||||
updateBindingNecklaceCharges(charges);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,6 +234,11 @@ public class ItemChargePlugin extends Plugin
|
||||
{
|
||||
updateJewelleryInfobox(ItemWithSlot.ABYSSAL_BRACELET, items);
|
||||
}
|
||||
|
||||
if (config.showBindingNecklaceCharges())
|
||||
{
|
||||
updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, items);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDodgyNecklaceCharges(final int value)
|
||||
@@ -213,6 +258,23 @@ public class ItemChargePlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBindingNecklaceCharges(final int value)
|
||||
{
|
||||
config.bindingNecklace(value);
|
||||
|
||||
if (config.showInfoboxes() && config.showBindingNecklaceCharges())
|
||||
{
|
||||
final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT);
|
||||
|
||||
if (itemContainer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, itemContainer.getItems());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateJewelleryInfobox(ItemWithSlot item, Item[] items)
|
||||
{
|
||||
for (final EquipmentInventorySlot equipmentInventorySlot : item.getSlots())
|
||||
@@ -245,6 +307,10 @@ public class ItemChargePlugin extends Plugin
|
||||
{
|
||||
charges = config.dodgyNecklace();
|
||||
}
|
||||
else if (id == ItemID.BINDING_NECKLACE && type == ItemWithSlot.BINDING_NECKLACE)
|
||||
{
|
||||
charges = config.bindingNecklace();
|
||||
}
|
||||
}
|
||||
else if (itemWithCharge.getType() == type.getType())
|
||||
{
|
||||
|
||||
@@ -33,5 +33,6 @@ enum ItemChargeType
|
||||
TELEPORT,
|
||||
WATERCAN,
|
||||
WATERSKIN,
|
||||
DODGY_NECKLACE
|
||||
DODGY_NECKLACE,
|
||||
BINDING_NECKLACE
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ enum ItemWithSlot
|
||||
{
|
||||
ABYSSAL_BRACELET(ItemChargeType.ABYSSAL_BRACELET, EquipmentInventorySlot.GLOVES),
|
||||
DODGY_NECKLACE(ItemChargeType.DODGY_NECKLACE, EquipmentInventorySlot.AMULET),
|
||||
BINDING_NECKLACE(ItemChargeType.BINDING_NECKLACE, EquipmentInventorySlot.AMULET),
|
||||
TELEPORT(ItemChargeType.TELEPORT, EquipmentInventorySlot.WEAPON, EquipmentInventorySlot.AMULET, EquipmentInventorySlot.GLOVES, EquipmentInventorySlot.RING);
|
||||
|
||||
private final ItemChargeType type;
|
||||
|
||||
Reference in New Issue
Block a user