item charges: add ring of forging
This commit is contained in:
committed by
Adam
parent
2825e29a43
commit
e3266d1fa6
@@ -296,11 +296,51 @@ public interface ItemChargeConfig extends Config
|
||||
)
|
||||
void explorerRing(int explorerRing);
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showRingOfForgingCount",
|
||||
name = "Show Ring of Forging Charges",
|
||||
description = "Configures if the Ring of Forging charge count is shown",
|
||||
position = 20
|
||||
)
|
||||
default boolean showRingOfForgingCount()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "ringOfForging",
|
||||
name = "",
|
||||
description = "",
|
||||
hidden = true
|
||||
)
|
||||
default int ringOfForging()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "ringOfForging",
|
||||
name = "",
|
||||
description = ""
|
||||
)
|
||||
void ringOfForging(int ringOfForging);
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "ringOfForgingNotification",
|
||||
name = "Ring of Forging Notification",
|
||||
description = "Configures if the Ring of Forging breaking notification is enabled",
|
||||
position = 21
|
||||
)
|
||||
default boolean ringOfForgingNotification()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showInfoboxes",
|
||||
name = "Show Infoboxes",
|
||||
description = "Configures whether to show an infobox equipped charge items",
|
||||
position = 20
|
||||
position = 22
|
||||
)
|
||||
default boolean showInfoboxes()
|
||||
{
|
||||
|
||||
@@ -96,6 +96,15 @@ class ItemChargeOverlay extends WidgetItemOverlay
|
||||
|
||||
charges = config.explorerRing();
|
||||
}
|
||||
else if (itemId == ItemID.RING_OF_FORGING)
|
||||
{
|
||||
if (!config.showRingOfForgingCount())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
charges = config.ringOfForging();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemWithCharge chargeItem = ItemWithCharge.findItem(itemId);
|
||||
@@ -134,6 +143,6 @@ class ItemChargeOverlay extends WidgetItemOverlay
|
||||
return config.showTeleportCharges() || config.showDodgyCount() || config.showFungicideCharges()
|
||||
|| config.showImpCharges() || config.showWateringCanCharges() || config.showWaterskinCharges()
|
||||
|| config.showBellowCharges() || config.showBasketCharges() || config.showSackCharges()
|
||||
|| config.showAbyssalBraceletCharges() || config.showExplorerRingCharges();
|
||||
|| config.showAbyssalBraceletCharges() || config.showExplorerRingCharges() || config.showRingOfForgingCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.itemcharges;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -75,10 +76,15 @@ public class ItemChargePlugin extends Plugin
|
||||
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 Pattern RING_OF_FORGING_CHECK_PATTERN = Pattern.compile(
|
||||
"You can smelt ([0-9+]+|one) more pieces? of iron ore before a ring melts\\.");
|
||||
private static final String RING_OF_FORGING_USED_TEXT = "You retrieve a bar of iron.";
|
||||
private static final String RING_OF_FORGING_BREAK_TEXT = "<col=7f007f>Your Ring of Forging has melted.</col>";
|
||||
|
||||
private static final int MAX_DODGY_CHARGES = 10;
|
||||
private static final int MAX_BINDING_CHARGES = 16;
|
||||
private static final int MAX_EXPLORER_RING_CHARGES = 30;
|
||||
private static final int MAX_RING_OF_FORGING_CHARGES = 140;
|
||||
|
||||
private int lastExplorerRingCharge = -1;
|
||||
|
||||
@@ -164,6 +170,11 @@ public class ItemChargePlugin extends Plugin
|
||||
{
|
||||
removeInfobox(ItemWithSlot.EXPLORER_RING);
|
||||
}
|
||||
|
||||
if (!config.showRingOfForgingCount())
|
||||
{
|
||||
removeInfobox(ItemWithSlot.RING_OF_FORGING);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -175,6 +186,7 @@ public class ItemChargePlugin extends Plugin
|
||||
Matcher dodgyBreakMatcher = DODGY_BREAK_PATTERN.matcher(message);
|
||||
Matcher bindingNecklaceCheckMatcher = BINDING_CHECK_PATTERN.matcher(event.getMessage());
|
||||
Matcher bindingNecklaceUsedMatcher = BINDING_USED_PATTERN.matcher(event.getMessage());
|
||||
Matcher ringOfForgingCheckMatcher = RING_OF_FORGING_CHECK_PATTERN.matcher(message);
|
||||
|
||||
if (event.getType() == ChatMessageType.GAMEMESSAGE || event.getType() == ChatMessageType.SPAM)
|
||||
{
|
||||
@@ -225,6 +237,44 @@ public class ItemChargePlugin extends Plugin
|
||||
|
||||
updateBindingNecklaceCharges(charges);
|
||||
}
|
||||
else if (ringOfForgingCheckMatcher.find())
|
||||
{
|
||||
final String match = ringOfForgingCheckMatcher.group(1);
|
||||
|
||||
int charges = 1;
|
||||
if (!match.equals("one"))
|
||||
{
|
||||
charges = Integer.parseInt(match);
|
||||
}
|
||||
updateRingOfForgingCharges(charges);
|
||||
}
|
||||
else if (message.equals(RING_OF_FORGING_USED_TEXT))
|
||||
{
|
||||
final ItemContainer equipment = client.getItemContainer(InventoryID.EQUIPMENT);
|
||||
|
||||
// Determine if the player smelted with a Ring of Forging equipped.
|
||||
if (equipment == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Item[] items = equipment.getItems();
|
||||
if (EquipmentInventorySlot.RING.getSlotIdx() < items.length
|
||||
&& items[EquipmentInventorySlot.RING.getSlotIdx()].getId() == ItemID.RING_OF_FORGING)
|
||||
{
|
||||
int charges = Ints.constrainToRange(config.ringOfForging() - 1, 0, MAX_RING_OF_FORGING_CHARGES);
|
||||
updateRingOfForgingCharges(charges);
|
||||
}
|
||||
}
|
||||
else if (message.equals(RING_OF_FORGING_BREAK_TEXT))
|
||||
{
|
||||
if (config.ringOfForgingNotification())
|
||||
{
|
||||
notifier.notify("Your ring of forging has melted.");
|
||||
}
|
||||
|
||||
updateRingOfForgingCharges(MAX_RING_OF_FORGING_CHARGES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,6 +312,11 @@ public class ItemChargePlugin extends Plugin
|
||||
{
|
||||
updateJewelleryInfobox(ItemWithSlot.EXPLORER_RING, items);
|
||||
}
|
||||
|
||||
if (config.showRingOfForgingCount())
|
||||
{
|
||||
updateJewelleryInfobox(ItemWithSlot.RING_OF_FORGING, items);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -341,6 +396,23 @@ public class ItemChargePlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRingOfForgingCharges(final int value)
|
||||
{
|
||||
config.ringOfForging(value);
|
||||
|
||||
if (config.showInfoboxes() && config.showRingOfForgingCount())
|
||||
{
|
||||
final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT);
|
||||
|
||||
if (itemContainer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
updateJewelleryInfobox(ItemWithSlot.RING_OF_FORGING, itemContainer.getItems());
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDestroyWidget()
|
||||
{
|
||||
final int currentTick = client.getTickCount();
|
||||
@@ -364,6 +436,9 @@ public class ItemChargePlugin extends Plugin
|
||||
case "Dodgy necklace":
|
||||
updateDodgyNecklaceCharges(MAX_DODGY_CHARGES);
|
||||
break;
|
||||
case "Ring of forging":
|
||||
updateRingOfForgingCharges(MAX_RING_OF_FORGING_CHARGES);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,6 +482,10 @@ public class ItemChargePlugin extends Plugin
|
||||
{
|
||||
charges = config.explorerRing();
|
||||
}
|
||||
else if (id == ItemID.RING_OF_FORGING && type == ItemWithSlot.RING_OF_FORGING)
|
||||
{
|
||||
charges = config.ringOfForging();
|
||||
}
|
||||
}
|
||||
else if (itemWithCharge.getType() == type.getType())
|
||||
{
|
||||
@@ -456,4 +535,4 @@ public class ItemChargePlugin extends Plugin
|
||||
}
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,5 +37,6 @@ enum ItemChargeType
|
||||
BINDING_NECKLACE,
|
||||
EXPLORER_RING,
|
||||
FRUIT_BASKET,
|
||||
SACK
|
||||
SACK,
|
||||
RING_OF_FORGING,
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ enum ItemWithSlot
|
||||
DODGY_NECKLACE(ItemChargeType.DODGY_NECKLACE, EquipmentInventorySlot.AMULET),
|
||||
BINDING_NECKLACE(ItemChargeType.BINDING_NECKLACE, EquipmentInventorySlot.AMULET),
|
||||
EXPLORER_RING(ItemChargeType.EXPLORER_RING, EquipmentInventorySlot.RING),
|
||||
RING_OF_FORGING(ItemChargeType.RING_OF_FORGING, EquipmentInventorySlot.RING),
|
||||
TELEPORT(ItemChargeType.TELEPORT, EquipmentInventorySlot.WEAPON, EquipmentInventorySlot.AMULET, EquipmentInventorySlot.GLOVES, EquipmentInventorySlot.RING);
|
||||
|
||||
private final ItemChargeType type;
|
||||
|
||||
@@ -31,6 +31,11 @@ import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.EquipmentInventorySlot;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.config.RuneLiteConfig;
|
||||
@@ -40,8 +45,10 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@@ -52,6 +59,11 @@ public class ItemChargePluginTest
|
||||
private static final String PROTECT_1 = "Your dodgy necklace protects you. <col=ff0000>It has 1 charge left.</col>";
|
||||
private static final String BREAK = "Your dodgy necklace protects you. <col=ff0000>It then crumbles to dust.</col>";
|
||||
|
||||
private static final String CHECK_RING_OF_FORGING_FULL = "You can smelt 140 more pieces of iron ore before a ring melts.";
|
||||
private static final String CHECK_RING_OF_FORGING_ONE = "You can smelt one more piece of iron ore before a ring melts.";
|
||||
private static final String USED_RING_OF_FORGING = "You retrieve a bar of iron.";
|
||||
private static final String BREAK_RING_OF_FORGING = "<col=7f007f>Your Ring of Forging has melted.</col>";
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private Client client;
|
||||
@@ -107,5 +119,35 @@ public class ItemChargePluginTest
|
||||
itemChargePlugin.onChatMessage(chatMessage);
|
||||
verify(config).dodgyNecklace(eq(10));
|
||||
reset(config);
|
||||
|
||||
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_RING_OF_FORGING_ONE, "", 0);
|
||||
itemChargePlugin.onChatMessage(chatMessage);
|
||||
verify(config).ringOfForging(eq(1));
|
||||
reset(config);
|
||||
|
||||
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_RING_OF_FORGING_FULL, "", 0);
|
||||
itemChargePlugin.onChatMessage(chatMessage);
|
||||
verify(config).ringOfForging(eq(140));
|
||||
reset(config);
|
||||
|
||||
when(config.ringOfForging()).thenReturn(90);
|
||||
// Create equipment inventory with ring of forging
|
||||
ItemContainer equipmentItemContainer = mock(ItemContainer.class);
|
||||
when(client.getItemContainer(eq(InventoryID.EQUIPMENT))).thenReturn(equipmentItemContainer);
|
||||
Item[] items = new Item[EquipmentInventorySlot.RING.getSlotIdx() + 1];
|
||||
when(equipmentItemContainer.getItems()).thenReturn(items);
|
||||
Item ring = mock(Item.class);
|
||||
when(ring.getId()).thenReturn(ItemID.RING_OF_FORGING);
|
||||
items[EquipmentInventorySlot.RING.getSlotIdx()] = ring;
|
||||
// Run message
|
||||
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_RING_OF_FORGING, "", 0);
|
||||
itemChargePlugin.onChatMessage(chatMessage);
|
||||
verify(config).ringOfForging(eq(89));
|
||||
reset(config);
|
||||
|
||||
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_RING_OF_FORGING, "", 0);
|
||||
itemChargePlugin.onChatMessage(chatMessage);
|
||||
verify(config).ringOfForging(eq(140));
|
||||
reset(config);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user