Merge remote-tracking branch 'upstream/master' into master

This commit is contained in:
ThatGamerBlue
2021-05-14 21:18:39 +01:00
25 changed files with 590 additions and 654 deletions

View File

@@ -25,9 +25,9 @@
object ProjectVersions {
const val launcherVersion = "2.2.0"
const val rlVersion = "1.7.6"
const val rlVersion = "1.7.7"
const val openosrsVersion = "4.6.0"
const val openosrsVersion = "4.6.1"
const val rsversion = 195
const val cacheversion = 165

View File

@@ -31,6 +31,7 @@ import lombok.RequiredArgsConstructor;
public enum Quest
{
//Free Quests
BELOW_ICE_MOUNTAIN(2874, "Below Ice Mountain"),
BLACK_KNIGHTS_FORTRESS(299, "Black Knights' Fortress"),
COOKS_ASSISTANT(300, "Cook's Assistant"),
THE_CORSAIR_CURSE(301, "The Corsair Curse"),

View File

@@ -130,7 +130,7 @@ public class ChatMessageManager
case PUBLICCHAT:
case MODCHAT:
{
String sanitizedUsername = Text.removeTags(chatMessage.getName());
String sanitizedUsername = Text.removeTags(chatMessage.getName()).replace('\u00A0', ' ');
if (client.getLocalPlayer().getName().equals(sanitizedUsername))
{

View File

@@ -159,11 +159,22 @@ public interface CameraConfig extends Config
return true;
}
@ConfigItem(
keyName = "compassLookPreservePitch",
name = "Preserve pitch on compass look",
description = "Preserves the current pitch value (vertical angle) when using the compass look options.",
position = 11
)
default boolean compassLookPreservePitch()
{
return false;
}
@ConfigItem(
keyName = "invertYaw",
name = "Invert Yaw",
description = "Makes moving the camera horizontally with the mouse backwards",
position = 11
position = 12
)
default boolean invertYaw()
{
@@ -174,7 +185,7 @@ public interface CameraConfig extends Config
keyName = "invertPitch",
name = "Invert Pitch",
description = "Makes moving the camera vertically with the mouse backwards",
position = 12
position = 13
)
default boolean invertPitch()
{

View File

@@ -249,6 +249,12 @@ public class CameraPlugin extends Plugin implements KeyListener, MouseListener
return;
}
if ("lookPreservePitch".equals(event.getEventName()) && config.compassLookPreservePitch())
{
intStack[intStackSize - 1] = client.getCameraPitch();
return;
}
if (config.innerLimit())
{
// This lets the options panel's slider have an exponential rate

View File

@@ -241,6 +241,7 @@ enum DiscordGameEventType
DUNGEON_OURANIA("Ourania Cave", DiscordAreaType.DUNGEONS, 12119),
DUNGEON_QUIDAMORTEM_CAVE("Quidamortem Cave", DiscordAreaType.DUNGEONS, 4763),
DUNGEON_RASHILIYIAS_TOMB("Rashiliyta's Tomb", DiscordAreaType.DUNGEONS, 11668),
DUNGEON_RUINS_OF_CAMDOZAAL("Ruins of Camdozaal", DiscordAreaType.DUNGEONS, 11609, 11610, 11611, 11865, 11866, 11867, 12121, 12122, 12123),
DUNGEON_SALT_MINE("Salt Mine", DiscordAreaType.DUNGEONS, 11425),
DUNGEON_SARADOMINSHRINE("Saradomin Shrine (Paterdomus)", DiscordAreaType.DUNGEONS, 13722),
DUNGEON_SHADE_CATACOMBS("Shade Catacombs", DiscordAreaType.DUNGEONS, 13975),

View File

@@ -40,8 +40,10 @@ public interface ItemChargeConfig extends Config
String KEY_AMULET_OF_BOUNTY = "amuletOfBounty";
String KEY_AMULET_OF_CHEMISTRY = "amuletOfChemistry";
String KEY_BINDING_NECKLACE = "bindingNecklace";
String KEY_BRACELET_OF_SLAUGHTER = "braceletOfSlaughter";
String KEY_CHRONICLE = "chronicle";
String KEY_DODGY_NECKLACE = "dodgyNecklace";
String KEY_EXPEDITIOUS_BRACELET = "expeditiousBracelet";
String KEY_EXPLORERS_RING = "explorerRing";
String KEY_RING_OF_FORGING = "ringOfForging";
@@ -353,4 +355,64 @@ public interface ItemChargeConfig extends Config
{
return false;
}
@ConfigItem(
keyName = "showBraceletOfSlaughterCharges",
name = "Bracelet of Slaughter Charges",
description = "Show Bracelet of Slaughter item charges",
position = 26,
section = chargesSection
)
default boolean showBraceletOfSlaughterCharges()
{
return true;
}
@ConfigItem(
keyName = "slaughterNotification",
name = "Bracelet of Slaughter Notification",
description = "Send a notification when a Bracelet of Slaughter breaks",
position = 27,
section = notificationSection
)
default boolean slaughterNotification()
{
return true;
}
@ConfigItem(
keyName = "showExpeditiousBraceletCharges",
name = "Expeditious Bracelet Charges",
description = "Show Expeditious Bracelet item charges",
position = 28,
section = chargesSection
)
default boolean showExpeditiousBraceletCharges()
{
return true;
}
@ConfigItem(
keyName = "expeditiousNotification",
name = "Expeditious Bracelet Notification",
description = "Send a notification when an Expeditious Bracelet breaks",
position = 29,
section = notificationSection
)
default boolean expeditiousNotification()
{
return true;
}
@ConfigItem(
keyName = "showGuthixRestDoses",
name = "Guthix Rest Doses",
description = "Show Guthix Rest doses",
position = 29,
section = chargesSection
)
default boolean showGuthixRestDoses()
{
return true;
}
}

View File

@@ -27,14 +27,16 @@ package net.runelite.client.plugins.itemcharges;
import java.awt.Color;
import java.awt.image.BufferedImage;
import lombok.Getter;
import lombok.ToString;
import net.runelite.api.EquipmentInventorySlot;
import net.runelite.client.ui.overlay.infobox.Counter;
@Getter
@ToString
class ItemChargeInfobox extends Counter
{
private final ItemChargePlugin plugin;
private final ItemWithSlot item;
private final int item;
private final EquipmentInventorySlot slot;
ItemChargeInfobox(
@@ -42,7 +44,7 @@ class ItemChargeInfobox extends Counter
BufferedImage image,
String name,
int charges,
ItemWithSlot item,
int item,
EquipmentInventorySlot slot)
{
super(image, plugin, charges);

View File

@@ -30,9 +30,7 @@ import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import javax.inject.Inject;
import net.runelite.api.ItemID;
import net.runelite.api.widgets.WidgetItem;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.*;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.overlay.WidgetItemOverlay;
import net.runelite.client.ui.overlay.components.TextComponent;
@@ -54,76 +52,16 @@ class ItemChargeOverlay extends WidgetItemOverlay
@Override
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem widgetItem)
{
if (!displayOverlay())
{
return;
}
graphics.setFont(FontManager.getRunescapeSmallFont());
int charges;
if (itemId == ItemID.DODGY_NECKLACE)
ItemWithConfig itemWithConfig = ItemWithConfig.findItem(itemId);
if (itemWithConfig != null)
{
if (!config.showDodgyCount())
if (!itemWithConfig.getType().getEnabled().test(config))
{
return;
}
charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_DODGY_NECKLACE);
}
else if (itemId == ItemID.BINDING_NECKLACE)
{
if (!config.showBindingNecklaceCharges())
{
return;
}
charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_BINDING_NECKLACE);
}
else if (itemId >= ItemID.EXPLORERS_RING_1 && itemId <= ItemID.EXPLORERS_RING_4)
{
if (!config.showExplorerRingCharges())
{
return;
}
charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_EXPLORERS_RING);
}
else if (itemId == ItemID.RING_OF_FORGING)
{
if (!config.showRingOfForgingCount())
{
return;
}
charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_RING_OF_FORGING);
}
else if (itemId == ItemID.AMULET_OF_CHEMISTRY)
{
if (!config.showAmuletOfChemistryCharges())
{
return;
}
charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY);
}
else if (itemId == ItemID.AMULET_OF_BOUNTY)
{
if (!config.showAmuletOfBountyCharges())
{
return;
}
charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_AMULET_OF_BOUNTY);
}
else if (itemId == ItemID.CHRONICLE)
{
if (!config.showTeleportCharges())
{
return;
}
charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_CHRONICLE);
charges = itemChargePlugin.getItemCharges(itemWithConfig.getConfigKey());
}
else
{
@@ -134,18 +72,7 @@ class ItemChargeOverlay extends WidgetItemOverlay
}
ItemChargeType type = chargeItem.getType();
if ((type == TELEPORT && !config.showTeleportCharges())
|| (type == FUNGICIDE_SPRAY && !config.showFungicideCharges())
|| (type == IMPBOX && !config.showImpCharges())
|| (type == WATERCAN && !config.showWateringCanCharges())
|| (type == WATERSKIN && !config.showWaterskinCharges())
|| (type == BELLOWS && !config.showBellowCharges())
|| (type == FRUIT_BASKET && !config.showBasketCharges())
|| (type == SACK && !config.showSackCharges())
|| (type == ABYSSAL_BRACELET && !config.showAbyssalBraceletCharges())
|| (type == AMULET_OF_CHEMISTRY && !config.showAmuletOfChemistryCharges())
|| (type == AMULET_OF_BOUNTY && !config.showAmuletOfBountyCharges())
|| (type == POTION && !config.showPotionDoseCount()))
if (!type.getEnabled().test(config))
{
return;
}
@@ -153,6 +80,8 @@ class ItemChargeOverlay extends WidgetItemOverlay
charges = chargeItem.getCharges();
}
graphics.setFont(FontManager.getRunescapeSmallFont());
final Rectangle bounds = widgetItem.getCanvasBounds();
final TextComponent textComponent = new TextComponent();
textComponent.setPosition(new Point(bounds.x - 1, bounds.y + 15));
@@ -160,14 +89,4 @@ class ItemChargeOverlay extends WidgetItemOverlay
textComponent.setColor(itemChargePlugin.getColor(charges));
textComponent.render(graphics);
}
private boolean displayOverlay()
{
return config.showTeleportCharges() || config.showDodgyCount() || config.showFungicideCharges()
|| config.showImpCharges() || config.showWateringCanCharges() || config.showWaterskinCharges()
|| config.showBellowCharges() || config.showBasketCharges() || config.showSackCharges()
|| config.showAbyssalBraceletCharges() || config.showExplorerRingCharges() || config.showRingOfForgingCount()
|| config.showAmuletOfChemistryCharges() || config.showAmuletOfBountyCharges() || config.showPotionDoseCount();
}
}

View File

@@ -31,6 +31,8 @@ import com.google.common.primitives.Ints;
import com.google.inject.Provides;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.util.EnumMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.inject.Inject;
@@ -113,6 +115,20 @@ public class ItemChargePlugin extends Plugin
private static final String CHRONICLE_ONE_CHARGE_TEXT = "You have one charge left in your book.";
private static final String CHRONICLE_EMPTY_TEXT = "Your book has run out of charges.";
private static final String CHRONICLE_NO_CHARGES_TEXT = "Your book does not have any charges. Purchase some Teleport Cards from Diango.";
private static final Pattern BRACELET_OF_SLAUGHTER_ACTIVATE_PATTERN = Pattern.compile(
"Your bracelet of slaughter prevents your slayer count from decreasing. (?:(?:It has (\\d{1,2}) charges? left)|(It then crumbles to dust))\\."
);
private static final Pattern BRACELET_OF_SLAUGHTER_CHECK_PATTERN = Pattern.compile(
"Your bracelet of slaughter has (\\d{1,2}) charges? left\\."
);
private static final String BRACELET_OF_SLAUGHTER_BREAK_TEXT = "Your Bracelet of Slaughter has crumbled to dust.";
private static final Pattern EXPEDITIOUS_BRACELET_ACTIVATE_PATTERN = Pattern.compile(
"Your expeditious bracelet helps you progress your slayer (?:task )?faster. (?:(?:It has (\\d{1,2}) charges? left)|(It then crumbles to dust))\\."
);
private static final Pattern EXPEDITIOUS_BRACELET_CHECK_PATTERN = Pattern.compile(
"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 int MAX_DODGY_CHARGES = 10;
private static final int MAX_BINDING_CHARGES = 16;
@@ -120,6 +136,7 @@ public class ItemChargePlugin extends Plugin
private static final int MAX_RING_OF_FORGING_CHARGES = 140;
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 int lastExplorerRingCharge = -1;
@@ -152,6 +169,7 @@ public class ItemChargePlugin extends Plugin
// Limits destroy callback to once per tick
private int lastCheckTick;
private final Map<EquipmentInventorySlot, ItemChargeInfobox> infoboxes = new EnumMap<>(EquipmentInventorySlot.class);
@Provides
ItemChargeConfig getConfig(ConfigManager configManager)
@@ -170,6 +188,7 @@ public class ItemChargePlugin extends Plugin
{
overlayManager.remove(overlay);
infoBoxManager.removeIf(ItemChargeInfobox.class::isInstance);
infoboxes.clear();
lastCheckTick = -1;
}
@@ -181,51 +200,7 @@ public class ItemChargePlugin extends Plugin
return;
}
if (!config.showInfoboxes())
{
infoBoxManager.removeIf(ItemChargeInfobox.class::isInstance);
return;
}
if (!config.showTeleportCharges())
{
removeInfobox(ItemWithSlot.TELEPORT);
}
if (!config.showAmuletOfChemistryCharges())
{
removeInfobox(ItemWithSlot.AMULET_OF_CHEMISTY);
}
if (!config.showAmuletOfBountyCharges())
{
removeInfobox(ItemWithSlot.AMULET_OF_BOUNTY);
}
if (!config.showAbyssalBraceletCharges())
{
removeInfobox(ItemWithSlot.ABYSSAL_BRACELET);
}
if (!config.showDodgyCount())
{
removeInfobox(ItemWithSlot.DODGY_NECKLACE);
}
if (!config.showBindingNecklaceCharges())
{
removeInfobox(ItemWithSlot.BINDING_NECKLACE);
}
if (!config.showExplorerRingCharges())
{
removeInfobox(ItemWithSlot.EXPLORER_RING);
}
if (!config.showRingOfForgingCount())
{
removeInfobox(ItemWithSlot.RING_OF_FORGING);
}
clientThread.invoke(this::updateInfoboxes);
}
@Subscribe
@@ -247,6 +222,10 @@ public class ItemChargePlugin extends Plugin
Matcher amuletOfBountyUsedMatcher = AMULET_OF_BOUNTY_USED_PATTERN.matcher(message);
Matcher chronicleAddMatcher = CHRONICLE_ADD_PATTERN.matcher(message);
Matcher chronicleUseAndCheckMatcher = CHRONICLE_USE_AND_CHECK_PATTERN.matcher(message);
Matcher slaughterActivateMatcher = BRACELET_OF_SLAUGHTER_ACTIVATE_PATTERN.matcher(message);
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);
if (config.recoilNotification() && message.contains(RING_OF_RECOIL_BREAK_MESSAGE))
{
@@ -392,58 +371,58 @@ public class ItemChargePlugin extends Plugin
{
setItemCharges(ItemChargeConfig.KEY_CHRONICLE, 1000);
}
else if (slaughterActivateMatcher.find())
{
final String found = slaughterActivateMatcher.group(1);
if (found == null)
{
updateBraceletOfSlaughterCharges(MAX_SLAYER_BRACELET_CHARGES);
if (config.slaughterNotification())
{
notifier.notify(BRACELET_OF_SLAUGHTER_BREAK_TEXT);
}
}
else
{
updateBraceletOfSlaughterCharges(Integer.parseInt(found));
}
}
else if (slaughterCheckMatcher.find())
{
updateBraceletOfSlaughterCharges(Integer.parseInt(slaughterCheckMatcher.group(1)));
}
else if (expeditiousActivateMatcher.find())
{
final String found = expeditiousActivateMatcher.group(1);
if (found == null)
{
updateExpeditiousBraceletCharges(MAX_SLAYER_BRACELET_CHARGES);
if (config.expeditiousNotification())
{
notifier.notify(EXPEDITIOUS_BRACELET_BREAK_TEXT);
}
}
else
{
updateExpeditiousBraceletCharges(Integer.parseInt(found));
}
}
else if (expeditiousCheckMatcher.find())
{
updateExpeditiousBraceletCharges(Integer.parseInt(expeditiousCheckMatcher.group(1)));
}
}
}
@Subscribe
public void onItemContainerChanged(ItemContainerChanged event)
{
if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT) || !config.showInfoboxes())
if (event.getContainerId() != InventoryID.EQUIPMENT.getId())
{
return;
}
final Item[] items = event.getItemContainer().getItems();
if (config.showTeleportCharges())
{
updateJewelleryInfobox(ItemWithSlot.TELEPORT, items);
}
if (config.showDodgyCount())
{
updateJewelleryInfobox(ItemWithSlot.DODGY_NECKLACE, items);
}
if (config.showAbyssalBraceletCharges())
{
updateJewelleryInfobox(ItemWithSlot.ABYSSAL_BRACELET, items);
}
if (config.showBindingNecklaceCharges())
{
updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, items);
}
if (config.showExplorerRingCharges())
{
updateJewelleryInfobox(ItemWithSlot.EXPLORER_RING, items);
}
if (config.showRingOfForgingCount())
{
updateJewelleryInfobox(ItemWithSlot.RING_OF_FORGING, items);
}
if (config.showAmuletOfChemistryCharges())
{
updateJewelleryInfobox(ItemWithSlot.AMULET_OF_CHEMISTY, items);
}
if (config.showAmuletOfBountyCharges())
{
updateJewelleryInfobox(ItemWithSlot.AMULET_OF_BOUNTY, items);
}
updateInfoboxes();
}
@Subscribe
@@ -496,6 +475,14 @@ public class ItemChargePlugin extends Plugin
log.debug("Reset amulet of chemistry");
updateAmuletOfChemistryCharges(MAX_AMULET_OF_CHEMISTRY_CHARGES);
break;
case ItemID.BRACELET_OF_SLAUGHTER:
log.debug("Reset bracelet of slaughter");
updateBraceletOfSlaughterCharges(MAX_SLAYER_BRACELET_CHARGES);
break;
case ItemID.EXPEDITIOUS_BRACELET:
log.debug("Reset expeditious bracelet");
updateExpeditiousBraceletCharges(MAX_SLAYER_BRACELET_CHARGES);
break;
}
}
});
@@ -505,104 +492,50 @@ public class ItemChargePlugin extends Plugin
private void updateDodgyNecklaceCharges(final int value)
{
setItemCharges(ItemChargeConfig.KEY_DODGY_NECKLACE, value);
if (config.showInfoboxes() && config.showDodgyCount())
{
final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT);
if (itemContainer == null)
{
return;
}
updateJewelleryInfobox(ItemWithSlot.DODGY_NECKLACE, itemContainer.getItems());
}
updateInfoboxes();
}
private void updateAmuletOfChemistryCharges(final int value)
{
setItemCharges(ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, value);
if (config.showInfoboxes() && config.showAmuletOfChemistryCharges())
{
final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT);
if (itemContainer == null)
{
return;
}
updateJewelleryInfobox(ItemWithSlot.AMULET_OF_CHEMISTY, itemContainer.getItems());
}
updateInfoboxes();
}
private void updateAmuletOfBountyCharges(final int value)
{
setItemCharges(ItemChargeConfig.KEY_AMULET_OF_BOUNTY, value);
if (config.showInfoboxes() && config.showAmuletOfBountyCharges())
{
final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT);
if (itemContainer == null)
{
return;
}
updateJewelleryInfobox(ItemWithSlot.AMULET_OF_BOUNTY, itemContainer.getItems());
}
updateInfoboxes();
}
private void updateBindingNecklaceCharges(final int value)
{
setItemCharges(ItemChargeConfig.KEY_BINDING_NECKLACE, value);
if (config.showInfoboxes() && config.showBindingNecklaceCharges())
{
final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT);
if (itemContainer == null)
{
return;
}
updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, itemContainer.getItems());
}
updateInfoboxes();
}
private void updateExplorerRingCharges(final int value)
{
// Note: Varbit counts upwards. We count down from the maximum charges.
setItemCharges(ItemChargeConfig.KEY_EXPLORERS_RING, MAX_EXPLORER_RING_CHARGES - value);
if (config.showInfoboxes() && config.showExplorerRingCharges())
{
final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT);
if (itemContainer == null)
{
return;
}
updateJewelleryInfobox(ItemWithSlot.EXPLORER_RING, itemContainer.getItems());
}
updateInfoboxes();
}
private void updateRingOfForgingCharges(final int value)
{
setItemCharges(ItemChargeConfig.KEY_RING_OF_FORGING, value);
updateInfoboxes();
}
if (config.showInfoboxes() && config.showRingOfForgingCount())
{
final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT);
private void updateBraceletOfSlaughterCharges(final int value)
{
setItemCharges(ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, value);
updateInfoboxes();
}
if (itemContainer == null)
{
return;
}
updateJewelleryInfobox(ItemWithSlot.RING_OF_FORGING, itemContainer.getItems());
}
private void updateExpeditiousBraceletCharges(final int value)
{
setItemCharges(ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, value);
updateInfoboxes();
}
private void checkDestroyWidget()
@@ -627,73 +560,85 @@ public class ItemChargePlugin extends Plugin
}
}
private void updateJewelleryInfobox(ItemWithSlot item, Item[] items)
private void updateInfoboxes()
{
for (final EquipmentInventorySlot equipmentInventorySlot : item.getSlots())
{
updateJewelleryInfobox(item, items, equipmentInventorySlot);
}
}
final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT);
private void updateJewelleryInfobox(ItemWithSlot type, Item[] items, EquipmentInventorySlot slot)
{
removeInfobox(type, slot);
if (slot.getSlotIdx() >= items.length)
if (itemContainer == null)
{
return;
}
final int id = items[slot.getSlotIdx()].getId();
if (id < 0)
final Item[] items = itemContainer.getItems();
boolean showInfoboxes = config.showInfoboxes();
for (EquipmentInventorySlot slot : EquipmentInventorySlot.values())
{
return;
}
if (slot.getSlotIdx() >= items.length)
{
break;
}
final ItemWithCharge itemWithCharge = ItemWithCharge.findItem(id);
int charges = -1;
Item i = items[slot.getSlotIdx()];
int id = i.getId();
ItemChargeType type = null;
int charges = -1;
if (itemWithCharge == null)
{
if (id == ItemID.DODGY_NECKLACE && type == ItemWithSlot.DODGY_NECKLACE)
final ItemWithCharge itemWithCharge = ItemWithCharge.findItem(id);
if (itemWithCharge != null)
{
charges = getItemCharges(ItemChargeConfig.KEY_DODGY_NECKLACE);
type = itemWithCharge.getType();
charges = itemWithCharge.getCharges();
}
else if (id == ItemID.BINDING_NECKLACE && type == ItemWithSlot.BINDING_NECKLACE)
else
{
charges = getItemCharges(ItemChargeConfig.KEY_BINDING_NECKLACE);
final ItemWithConfig itemWithConfig = ItemWithConfig.findItem(id);
if (itemWithConfig != null)
{
type = itemWithConfig.getType();
charges = getItemCharges(itemWithConfig.getConfigKey());
}
}
else if ((id >= ItemID.EXPLORERS_RING_1 && id <= ItemID.EXPLORERS_RING_4) && type == ItemWithSlot.EXPLORER_RING)
boolean enabled = type != null && type.getEnabled().test(config);
if (showInfoboxes && enabled && charges > 0)
{
charges = getItemCharges(ItemChargeConfig.KEY_EXPLORERS_RING);
ItemChargeInfobox infobox = infoboxes.get(slot);
if (infobox != null)
{
if (infobox.getItem() == id)
{
if (infobox.getCount() == charges)
{
continue;
}
log.debug("Updating infobox count for {}", infobox);
infobox.setCount(charges);
continue;
}
log.debug("Rebuilding infobox {}", infobox);
infoBoxManager.removeInfoBox(infobox);
infoboxes.remove(slot);
}
final String name = itemManager.getItemComposition(id).getName();
final BufferedImage image = itemManager.getImage(id);
infobox = new ItemChargeInfobox(this, image, name, charges, id, slot);
infoBoxManager.addInfoBox(infobox);
infoboxes.put(slot, infobox);
}
else if (id == ItemID.RING_OF_FORGING && type == ItemWithSlot.RING_OF_FORGING)
else
{
charges = getItemCharges(ItemChargeConfig.KEY_RING_OF_FORGING);
}
else if (id == ItemID.AMULET_OF_CHEMISTRY && type == ItemWithSlot.AMULET_OF_CHEMISTY)
{
charges = getItemCharges(ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY);
}
else if (id == ItemID.AMULET_OF_BOUNTY && type == ItemWithSlot.AMULET_OF_BOUNTY)
{
charges = getItemCharges(ItemChargeConfig.KEY_AMULET_OF_BOUNTY);
ItemChargeInfobox infobox = infoboxes.remove(slot);
if (infobox != null)
{
log.debug("Removing infobox {}", infobox);
infoBoxManager.removeInfoBox(infobox);
}
}
}
else if (itemWithCharge.getType() == type.getType())
{
charges = itemWithCharge.getCharges();
}
if (charges <= 0)
{
return;
}
final String name = itemManager.getItemComposition(id).getName();
final BufferedImage image = itemManager.getImage(id);
final ItemChargeInfobox infobox = new ItemChargeInfobox(this, image, name, charges, type, slot);
infoBoxManager.addInfoBox(infobox);
}
int getItemCharges(String key)
@@ -716,25 +661,6 @@ public class ItemChargePlugin extends Plugin
configManager.setRSProfileConfiguration(ItemChargeConfig.GROUP, key, value);
}
private void removeInfobox(final ItemWithSlot item)
{
infoBoxManager.removeIf(t -> t instanceof ItemChargeInfobox && ((ItemChargeInfobox) t).getItem() == item);
}
private void removeInfobox(final ItemWithSlot item, final EquipmentInventorySlot slot)
{
infoBoxManager.removeIf(t ->
{
if (!(t instanceof ItemChargeInfobox))
{
return false;
}
final ItemChargeInfobox i = (ItemChargeInfobox) t;
return i.getItem() == item && i.getSlot() == slot;
});
}
Color getColor(int charges)
{
Color color = Color.WHITE;

View File

@@ -25,24 +25,33 @@
*/
package net.runelite.client.plugins.itemcharges;
import java.util.function.Predicate;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
enum ItemChargeType
{
ABYSSAL_BRACELET,
AMULET_OF_CHEMISTRY,
AMULET_OF_BOUNTY,
BELLOWS,
FUNGICIDE_SPRAY,
IMPBOX,
TELEPORT,
WATERCAN,
WATERSKIN,
DODGY_NECKLACE,
BINDING_NECKLACE,
EXPLORER_RING,
FRUIT_BASKET,
SACK,
RING_OF_FORGING,
GUTHIX_REST,
CHRONICLE,
POTION,
ABYSSAL_BRACELET(ItemChargeConfig::showAbyssalBraceletCharges),
AMULET_OF_CHEMISTRY(ItemChargeConfig::showAmuletOfChemistryCharges),
AMULET_OF_BOUNTY(ItemChargeConfig::showAmuletOfBountyCharges),
BELLOWS(ItemChargeConfig::showBellowCharges),
BRACELET_OF_SLAUGHTER(ItemChargeConfig::showBraceletOfSlaughterCharges),
EXPEDITIOUS_BRACELET(ItemChargeConfig::showExpeditiousBraceletCharges),
FUNGICIDE_SPRAY(ItemChargeConfig::showFungicideCharges),
IMPBOX(ItemChargeConfig::showImpCharges),
TELEPORT(ItemChargeConfig::showTeleportCharges),
WATERCAN(ItemChargeConfig::showWateringCanCharges),
WATERSKIN(ItemChargeConfig::showWaterskinCharges),
DODGY_NECKLACE(ItemChargeConfig::showDodgyCount),
BINDING_NECKLACE(ItemChargeConfig::showBindingNecklaceCharges),
EXPLORER_RING(ItemChargeConfig::showExplorerRingCharges),
FRUIT_BASKET(ItemChargeConfig::showBasketCharges),
SACK(ItemChargeConfig::showSackCharges),
RING_OF_FORGING(ItemChargeConfig::showRingOfForgingCount),
POTION(ItemChargeConfig::showPotionDoseCount),
GUTHIX_REST(ItemChargeConfig::showGuthixRestDoses);
private final Predicate<ItemChargeConfig> enabled;
}

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2021, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.itemcharges;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import javax.annotation.Nullable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.runelite.api.ItemID;
@AllArgsConstructor
@Getter
enum ItemWithConfig
{
DODGY_NECKLACE(ItemID.DODGY_NECKLACE, ItemChargeConfig.KEY_DODGY_NECKLACE, ItemChargeType.DODGY_NECKLACE),
BINDING_NECKLACE(ItemID.BINDING_NECKLACE, ItemChargeConfig.KEY_BINDING_NECKLACE, ItemChargeType.BINDING_NECKLACE),
EXPLORERS_RING_1(ItemID.EXPLORERS_RING_1, ItemChargeConfig.KEY_EXPLORERS_RING, ItemChargeType.EXPLORER_RING),
EXPLORERS_RING_2(ItemID.EXPLORERS_RING_2, ItemChargeConfig.KEY_EXPLORERS_RING, ItemChargeType.EXPLORER_RING),
EXPLORERS_RING_3(ItemID.EXPLORERS_RING_3, ItemChargeConfig.KEY_EXPLORERS_RING, ItemChargeType.EXPLORER_RING),
EXPLORERS_RING_4(ItemID.EXPLORERS_RING_4, ItemChargeConfig.KEY_EXPLORERS_RING, ItemChargeType.EXPLORER_RING),
RING_OF_FORGING(ItemID.RING_OF_FORGING, ItemChargeConfig.KEY_RING_OF_FORGING, ItemChargeType.RING_OF_FORGING),
AMULET_OF_CHEMISTRY(ItemID.AMULET_OF_CHEMISTRY, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, ItemChargeType.AMULET_OF_CHEMISTRY),
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);
private final int itemId;
private final String configKey;
private final ItemChargeType type;
private static final Map<Integer, ItemWithConfig> ID_MAP;
static
{
ImmutableMap.Builder<Integer, ItemWithConfig> builder = new ImmutableMap.Builder<>();
for (ItemWithConfig item : values())
{
builder.put(item.getItemId(), item);
}
ID_MAP = builder.build();
}
@Nullable
static ItemWithConfig findItem(int itemId)
{
return ID_MAP.get(itemId);
}
}

View File

@@ -1,55 +0,0 @@
/*
* Copyright (c) 2019, Tomas Slusny <slusnucky@gmail.com>
* Copyright (c) 2019, Aleios <https://github.com/aleios>
* Copyright (c) 2020, Unmoon <https://github.com/unmoon>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.itemcharges;
import com.google.common.collect.Sets;
import java.util.Set;
import lombok.Getter;
import net.runelite.api.EquipmentInventorySlot;
@Getter
enum ItemWithSlot
{
ABYSSAL_BRACELET(ItemChargeType.ABYSSAL_BRACELET, EquipmentInventorySlot.GLOVES),
AMULET_OF_CHEMISTY(ItemChargeType.AMULET_OF_CHEMISTRY, EquipmentInventorySlot.AMULET),
AMULET_OF_BOUNTY(ItemChargeType.AMULET_OF_BOUNTY, EquipmentInventorySlot.AMULET),
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),
CHRONICLE(ItemChargeType.CHRONICLE, EquipmentInventorySlot.SHIELD),
TELEPORT(ItemChargeType.TELEPORT, EquipmentInventorySlot.WEAPON, EquipmentInventorySlot.AMULET, EquipmentInventorySlot.GLOVES, EquipmentInventorySlot.RING);
private final ItemChargeType type;
private final Set<EquipmentInventorySlot> slots;
ItemWithSlot(final ItemChargeType type, final EquipmentInventorySlot... slots)
{
this.type = type;
this.slots = Sets.newHashSet(slots);
}
}

View File

@@ -128,6 +128,7 @@ public class LootTrackerPlugin extends Plugin
// Activity/Event loot handling
private static final Pattern CLUE_SCROLL_PATTERN = Pattern.compile("You have completed [0-9]+ ([a-z]+) Treasure Trails?\\.");
private static final int THEATRE_OF_BLOOD_REGION = 12867;
private static final int THEATRE_OF_BLOOD_LOBBY = 14642;
// Herbiboar loot handling
@VisibleForTesting
@@ -551,7 +552,7 @@ public class LootTrackerPlugin extends Plugin
return;
}
int region = WorldPoint.fromLocalInstance(client, client.getLocalPlayer().getLocalLocation()).getRegionID();
if (region != THEATRE_OF_BLOOD_REGION)
if (region != THEATRE_OF_BLOOD_REGION && region != THEATRE_OF_BLOOD_LOBBY)
{
return;
}

View File

@@ -599,7 +599,10 @@ public class MusicPlugin extends Plugin
handle.setSpriteId(SpriteID.SETTINGS_SLIDER_HANDLE_BLUE);
}
this.icon.setOnOpListener((Object[]) null);
if (this.icon != null)
{
this.icon.setOnOpListener((Object[]) null);
}
Widget root = client.getWidget(this.root);
if (root != null)

View File

@@ -44,8 +44,6 @@ public interface SlayerConfig extends Config
String TASK_LOC_KEY = "taskLocation";
String STREAK_KEY = "streak";
String POINTS_KEY = "points";
String EXPEDITIOUS_CHARGES_KEY = "expeditious";
String SLAUGHTER_CHARGES_KEY = "slaughter";
@ConfigItem(
position = 1,

View File

@@ -77,8 +77,6 @@ class SlayerOverlay extends WidgetItemOverlay
ItemID.SLAYER_RING_ETERNAL,
ItemID.ENCHANTED_GEM,
ItemID.ETERNAL_GEM,
ItemID.BRACELET_OF_SLAUGHTER,
ItemID.EXPEDITIOUS_BRACELET,
ItemID.SLAYER_RING_1,
ItemID.SLAYER_RING_2,
ItemID.SLAYER_RING_3,
@@ -120,26 +118,11 @@ class SlayerOverlay extends WidgetItemOverlay
return;
}
int slaughterCount = plugin.getSlaughterChargeCount();
int expeditiousCount = plugin.getExpeditiousChargeCount();
graphics.setFont(FontManager.getRunescapeSmallFont());
final Rectangle bounds = widgetItem.getCanvasBounds();
final TextComponent textComponent = new TextComponent();
switch (itemId)
{
case ItemID.EXPEDITIOUS_BRACELET:
textComponent.setText(String.valueOf(expeditiousCount));
break;
case ItemID.BRACELET_OF_SLAUGHTER:
textComponent.setText(String.valueOf(slaughterCount));
break;
default:
textComponent.setText(String.valueOf(amount));
break;
}
textComponent.setText(String.valueOf(amount));
// Draw the counter in the bottom left for equipment, and top left for jewelry
textComponent.setPosition(new Point(bounds.x - 1, bounds.y - 1 + (SLAYER_JEWELRY.contains(itemId)

View File

@@ -105,13 +105,7 @@ public class SlayerPlugin extends Plugin
private static final String CHAT_CANCEL_MESSAGE_ZUK = "You no longer have a slayer task as you left the Inferno.";
private static final String CHAT_SUPERIOR_MESSAGE = "A superior foe has appeared...";
private static final String CHAT_BRACELET_SLAUGHTER = "Your bracelet of slaughter prevents your slayer";
private static final Pattern CHAT_BRACELET_SLAUGHTER_REGEX = Pattern.compile("Your bracelet of slaughter prevents your slayer count from decreasing. It has (\\d{1,2}) charges? left\\.");
private static final String CHAT_BRACELET_EXPEDITIOUS = "Your expeditious bracelet helps you progress your";
private static final Pattern CHAT_BRACELET_EXPEDITIOUS_REGEX = Pattern.compile("Your expeditious bracelet helps you progress your slayer (?:task )?faster. It has (\\d{1,2}) charges? left\\.");
private static final String CHAT_BRACELET_SLAUGHTER_CHARGE = "Your bracelet of slaughter has ";
private static final Pattern CHAT_BRACELET_SLAUGHTER_CHARGE_REGEX = Pattern.compile("Your bracelet of slaughter has (\\d{1,2}) charges? left\\.");
private static final String CHAT_BRACELET_EXPEDITIOUS_CHARGE = "Your expeditious bracelet has ";
private static final Pattern CHAT_BRACELET_EXPEDITIOUS_CHARGE_REGEX = Pattern.compile("Your expeditious bracelet has (\\d{1,2}) charges? left\\.");
private static final Pattern COMBAT_BRACELET_TASK_UPDATE_MESSAGE = Pattern.compile("^You still need to kill (\\d+) monsters to complete your current Slayer assignment");
//NPC messages
@@ -125,9 +119,6 @@ public class SlayerPlugin extends Plugin
private static final int GROTESQUE_GUARDIANS_REGION = 6727;
private static final int EXPEDITIOUS_CHARGE = 30;
private static final int SLAUGHTER_CHARGE = 30;
// Chat Command
private static final String TASK_COMMAND_STRING = "!task";
private static final Pattern TASK_STRING_VALIDATION = Pattern.compile("[^a-zA-Z0-9' -]");
@@ -200,14 +191,6 @@ public class SlayerPlugin extends Plugin
@Setter(AccessLevel.PACKAGE)
private String taskLocation;
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
private int expeditiousChargeCount;
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
private int slaughterChargeCount;
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
private String taskName;
@@ -235,8 +218,6 @@ public class SlayerPlugin extends Plugin
if (getIntProfileConfig(SlayerConfig.AMOUNT_KEY) != -1
&& !getStringProfileConfig(SlayerConfig.TASK_NAME_KEY).isEmpty())
{
setExpeditiousChargeCount(getIntProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY));
setSlaughterChargeCount(getIntProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY));
clientThread.invoke(() -> setTask(getStringProfileConfig(SlayerConfig.TASK_NAME_KEY),
getIntProfileConfig(SlayerConfig.AMOUNT_KEY),
getIntProfileConfig(SlayerConfig.INIT_AMOUNT_KEY),
@@ -288,8 +269,6 @@ public class SlayerPlugin extends Plugin
&& !getStringProfileConfig(SlayerConfig.TASK_NAME_KEY).isEmpty()
&& loginFlag)
{
setExpeditiousChargeCount(getIntProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY));
setSlaughterChargeCount(getIntProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY));
setTask(getStringProfileConfig(SlayerConfig.TASK_NAME_KEY),
getIntProfileConfig(SlayerConfig.AMOUNT_KEY),
getIntProfileConfig(SlayerConfig.INIT_AMOUNT_KEY),
@@ -332,8 +311,6 @@ public class SlayerPlugin extends Plugin
setProfileConfig(SlayerConfig.INIT_AMOUNT_KEY, initialAmount);
setProfileConfig(SlayerConfig.TASK_NAME_KEY, taskName);
setProfileConfig(SlayerConfig.TASK_LOC_KEY, taskLocation);
setProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY, expeditiousChargeCount);
setProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY, slaughterChargeCount);
}
@Subscribe
@@ -394,22 +371,6 @@ public class SlayerPlugin extends Plugin
}
}
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"))
{
slaughterChargeCount = SLAUGHTER_CHARGE;
setProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY, slaughterChargeCount);
}
else if (braceletText.contains("expeditious bracelet"))
{
expeditiousChargeCount = EXPEDITIOUS_CHARGE;
setProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY, expeditiousChargeCount);
}
}
Widget rewardsBarWidget = client.getWidget(WidgetInfo.SLAYER_REWARDS_TOPBAR);
if (rewardsBarWidget != null)
{
@@ -460,45 +421,11 @@ public class SlayerPlugin extends Plugin
if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER))
{
Matcher mSlaughter = CHAT_BRACELET_SLAUGHTER_REGEX.matcher(chatMsg);
amount++;
slaughterChargeCount = mSlaughter.find() ? Integer.parseInt(mSlaughter.group(1)) : SLAUGHTER_CHARGE;
setProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY, slaughterChargeCount);
}
if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS))
else if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS))
{
Matcher mExpeditious = CHAT_BRACELET_EXPEDITIOUS_REGEX.matcher(chatMsg);
amount--;
expeditiousChargeCount = mExpeditious.find() ? Integer.parseInt(mExpeditious.group(1)) : EXPEDITIOUS_CHARGE;
setProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY, expeditiousChargeCount);
}
if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS_CHARGE))
{
Matcher mExpeditious = CHAT_BRACELET_EXPEDITIOUS_CHARGE_REGEX.matcher(chatMsg);
if (!mExpeditious.find())
{
return;
}
expeditiousChargeCount = Integer.parseInt(mExpeditious.group(1));
setProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY, expeditiousChargeCount);
}
if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER_CHARGE))
{
Matcher mSlaughter = CHAT_BRACELET_SLAUGHTER_CHARGE_REGEX.matcher(chatMsg);
if (!mSlaughter.find())
{
return;
}
slaughterChargeCount = Integer.parseInt(mSlaughter.group(1));
setProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY, slaughterChargeCount);
}
if (chatMsg.startsWith("You've completed") && (chatMsg.contains("Slayer master") || chatMsg.contains("Slayer Master")))
@@ -939,8 +866,10 @@ public class SlayerPlugin extends Plugin
migrateConfigKey(SlayerConfig.TASK_LOC_KEY);
migrateConfigKey(SlayerConfig.STREAK_KEY);
migrateConfigKey(SlayerConfig.POINTS_KEY);
migrateConfigKey(SlayerConfig.EXPEDITIOUS_CHARGES_KEY);
migrateConfigKey(SlayerConfig.SLAUGHTER_CHARGES_KEY);
configManager.unsetConfiguration(SlayerConfig.GROUP_NAME, "expeditious");
configManager.unsetConfiguration(SlayerConfig.GROUP_NAME, "slaughter");
configManager.unsetRSProfileConfiguration(SlayerConfig.GROUP_NAME, "expeditious");
configManager.unsetRSProfileConfiguration(SlayerConfig.GROUP_NAME, "slaughter");
}
private void migrateConfigKey(String key)

View File

@@ -26,14 +26,15 @@
package net.runelite.client.plugins.worldmap;
import lombok.Getter;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.Quest;
import net.runelite.api.coords.WorldPoint;
// Some quests are in the same spot, but they are done in order. If multiple
// quests start in the same location, an array of quests is expected.
enum QuestStartLocation
{
//Free Quests
BELOW_ICE_MOUNTAIN(Quest.BELOW_ICE_MOUNTAIN, new WorldPoint(3001, 3436, 0)),
COOKS_ASSISTANT_RFD(Quest.COOKS_ASSISTANT, new WorldPoint(3211, 3216, 0)),
THE_CORSAIR_CURSE(Quest.THE_CORSAIR_CURSE, new WorldPoint(3029, 3273, 0)),
DEMON_SLAYER(Quest.DEMON_SLAYER, new WorldPoint(3204, 3424, 0)),

View File

@@ -380,7 +380,7 @@ public class ClientLoader implements Supplier<Applet>
log.warn("Failed to download gamepack from \"{}\"", url, e);
// With fallback config do 1 attempt (there are no additional urls to try)
if (config.isFallback() || attempt >= NUM_ATTEMPTS)
if (!javConfigUrl.equals(RuneLiteProperties.getJavConfig()) || config.isFallback() || attempt >= NUM_ATTEMPTS)
{
throw e;
}

View File

@@ -25,13 +25,9 @@
*/
package net.runelite.client.util;
import java.awt.Polygon;
import net.runelite.api.Client;
import net.runelite.api.Player;
import net.runelite.api.Varbits;
import net.runelite.api.WorldType;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.geometry.Cuboid;
public class PvPUtil
{

View File

@@ -994,3 +994,7 @@ R 33 79 33 80
// Nightmare dungeon (Morytania underground)
#0a0a0a
R 58 151 60 153
// ruins of camdozaal
#292030
R 45 89 47 91

View File

@@ -47,6 +47,8 @@ LOOK:
iconst 0
sound_synth
iconst 225
sconst "lookPreservePitch"
runelite_callback
iconst 5
randominc
add

View File

@@ -28,16 +28,16 @@ import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.testing.fieldbinder.Bind;
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.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.ConfigManager;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import org.junit.Before;
@@ -45,7 +45,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
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.junit.MockitoJUnitRunner;
@@ -84,18 +83,20 @@ public class ItemChargePluginTest
private static final String CHRONICLE_ADD_MULTIPLE_CHARGES = "You add 5 charges to your book. It now has 5 charges.";
private static final String CHRONICLE_ADD_FULL = "Your book is fully charged! It has 1,000 charges already.";
private static final String CHECK_BRACELET_OF_SLAUGHTER = "Your bracelet of slaughter has 25 charges left.";
private static final String CHECK_BRACELET_OF_SLAUGHTER_1 = "Your bracelet of slaughter has 1 charge left.";
private static final String ACTIVATE_BRACELET_OF_SLAUGHTER = "Your bracelet of slaughter prevents your slayer count from decreasing. It has 16 charges left.";
private static final String BREAK_BRACELET_OF_SLAUGHTER = "Your bracelet of slaughter prevents your slayer count from decreasing. <col=ff0000>It then crumbles to dust.</col>";
private static final String CHECK_EXPEDITIOUS_BRACELET = "Your expeditious bracelet has 6 charges left.";
private static final String CHECK_EXPEDITIOUS_BRACELET_1 = "Your expeditious bracelet has 1 charge left.";
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>";
@Mock
@Bind
private Client client;
@Mock
@Bind
private ScheduledExecutorService scheduledExecutorService;
@Mock
@Bind
private RuneLiteConfig runeLiteConfig;
@Mock
@Bind
private OverlayManager overlayManager;
@@ -116,6 +117,10 @@ public class ItemChargePluginTest
@Bind
private ConfigManager configManager;
@Mock
@Bind
private ItemManager itemManager;
@Inject
private ItemChargePlugin itemChargePlugin;
@@ -125,148 +130,295 @@ public class ItemChargePluginTest
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
}
// Dodgy necklace
@Test
public void testOnChatMessage()
public void testDodgyCheck()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_DODGY_NECKLACE, 10);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", PROTECT, "", 0);
@Test
public void testDodgyProtect()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", PROTECT, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_DODGY_NECKLACE, 9);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", PROTECT_1, "", 0);
@Test
public void testDodgyProtect1()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", PROTECT_1, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_DODGY_NECKLACE, 1);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK, "", 0);
@Test
public void testDodgyBreak()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_DODGY_NECKLACE, 10);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_RING_OF_FORGING_ONE, "", 0);
// Ring of forging
@Test
public void testRofOne()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_RING_OF_FORGING_ONE, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_RING_OF_FORGING, 1);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_RING_OF_FORGING_FULL, "", 0);
@Test
public void testRofFull()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_RING_OF_FORGING_FULL, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_RING_OF_FORGING, 140);
reset(configManager);
}
@Test
public void testRof()
{
when(configManager.getRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_RING_OF_FORGING, Integer.class)).thenReturn(90);
// Create equipment inventory with ring of forging
ItemContainer equipmentItemContainer = mock(ItemContainer.class);
when(client.getItemContainer(InventoryID.EQUIPMENT)).thenReturn(equipmentItemContainer);
when(equipmentItemContainer.contains(ItemID.RING_OF_FORGING)).thenReturn(true);
when(equipmentItemContainer.getItems()).thenReturn(new Item[0]);
// Run message
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_RING_OF_FORGING, "", 0);
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_RING_OF_FORGING, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_RING_OF_FORGING, 89);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_RING_OF_FORGING, "", 0);
@Test
public void testRofBreak()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_RING_OF_FORGING, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_RING_OF_FORGING, 140);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_AMULET_OF_CHEMISTRY, "", 0);
// Chemistry
@Test
public void testChemistryCheck()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_AMULET_OF_CHEMISTRY, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 5);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_AMULET_OF_CHEMISTRY_1, "", 0);
@Test
public void testChemistry1()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_AMULET_OF_CHEMISTRY_1, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 1);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_AMULET_OF_CHEMISTRY, "", 0);
@Test
public void testChemistryUsed4()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_AMULET_OF_CHEMISTRY, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 4);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_AMULET_OF_CHEMISTRY_3_DOSES, "", 0);
@Test
public void testChemistryUsed3()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_AMULET_OF_CHEMISTRY_3_DOSES, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 2);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_AMULET_OF_CHEMISTRY_2_DOSES, "", 0);
@Test
public void testChemistryUsed2()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_AMULET_OF_CHEMISTRY_2_DOSES, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 1);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_AMULET_OF_CHEMISTRY, "", 0);
@Test
public void testChemistryBreak()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_AMULET_OF_CHEMISTRY, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 5);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_AMULET_OF_CHEMISTRY_3_DOSES, "", 0);
@Test
public void testChemistryBreak3()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_AMULET_OF_CHEMISTRY_3_DOSES, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
}
@Test
public void testChemistryBreak2()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_AMULET_OF_CHEMISTRY_2_DOSES, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 5);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_AMULET_OF_CHEMISTRY_2_DOSES, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 5);
reset(configManager);
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_CHECK_CHARGES_FULL, "", 0);
// Chronicle
@Test
public void testChronicleCheckFull()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_CHECK_CHARGES_FULL, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 1000);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_CHECK_CHARGES_ONE, "", 0);
@Test
public void testChronicleChargeOne()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_CHECK_CHARGES_ONE, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 1);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_CHECK_CHARGES_EMPTY, "", 0);
@Test
public void testChronicleChargeEmpty()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_CHECK_CHARGES_EMPTY, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 0);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT, "", 0);
@Test
public void testChronicleTeleport()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 999);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT_ONE, "", 0);
@Test
public void testChronicleTeleportOne()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT_ONE, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 1);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT_EMPTY, "", 0);
@Test
public void testChronicleTeleportEmpty()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT_EMPTY, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 0);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT_FAIL, "", 0);
@Test
public void testChronicleTeleportFail()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT_FAIL, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 0);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_SINGLE_CHARGE, "", 0);
@Test
public void testChronicleAddSingleCharge()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_SINGLE_CHARGE, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 1);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_SINGLE_CHARGE_FULL, "", 0);
@Test
public void testChronicleAddSingleChargeFull()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_SINGLE_CHARGE_FULL, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 1000);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_MULTIPLE_CHARGES, "", 0);
@Test
public void testChronicleAddMultipleCharges()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_MULTIPLE_CHARGES, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 5);
reset(configManager);
}
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_FULL, "", 0);
@Test
public void testChronicleAddFull()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_FULL, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 1000);
reset(configManager);
}
// Bracelet of Slaughter
@Test
public void testSlaughterCheck()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_BRACELET_OF_SLAUGHTER, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, 25);
}
@Test
public void testSlaughterCheck1()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_BRACELET_OF_SLAUGHTER_1, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, 1);
}
@Test
public void testSlaughterActivate()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", ACTIVATE_BRACELET_OF_SLAUGHTER, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, 16);
}
@Test
public void testSlaughterBreak()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_BRACELET_OF_SLAUGHTER, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, 30);
}
// Expeditious Bracelet
@Test
public void testExpeditiousCheck()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_EXPEDITIOUS_BRACELET, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, 6);
}
@Test
public void testExpeditiousCheck1()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_EXPEDITIOUS_BRACELET_1, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, 1);
}
@Test
public void testExpeditiousActivate()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", ACTIVATE_EXPEDITIOUS_BRACELET, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, 11);
}
@Test
public void testExpeditiousBreak()
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_EXPEDITIOUS_BRACELET, "", 0);
itemChargePlugin.onChatMessage(chatMessage);
verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, 30);
}
}

View File

@@ -120,21 +120,6 @@ public class SlayerPluginTest
private static final String BRACLET_SLAUGHTER = "Your bracelet of slaughter prevents your slayer count from decreasing. It has 9 charges left.";
private static final String BRACLET_EXPEDITIOUS = "Your expeditious bracelet helps you progress your slayer task faster. It has 9 charges left.";
private static final String BRACLET_SLAUGHTER_V2 = "Your bracelet of slaughter prevents your slayer count from decreasing. It has 1 charge left.";
private static final String BRACLET_EXPEDITIOUS_V2 = "Your expeditious bracelet helps you progress your slayer faster. It has 1 charge left.";
private static final String BRACLET_SLAUGHTER_V3 = "Your bracelet of slaughter prevents your slayer count from decreasing. It then crumbles to dust.";
private static final String BRACLET_EXPEDITIOUS_V3 = "Your expeditious bracelet helps you progress your slayer faster. It then crumbles to dust.";
private static final String CHAT_BRACELET_SLAUGHTER_CHARGE = "Your bracelet of slaughter has 12 charges left.";
private static final String CHAT_BRACELET_EXPEDITIOUS_CHARGE = "Your expeditious bracelet has 12 charges left.";
private static final String CHAT_BRACELET_SLAUGHTER_CHARGE_ONE = "Your bracelet of slaughter has 1 charge left.";
private static final String CHAT_BRACELET_EXPEDITIOUS_CHARGE_ONE = "Your expeditious bracelet has 1 charge left.";
private static final String BREAK_SLAUGHTER = "The bracelet shatters. Your next bracelet of slaughter<br>will start afresh from 30 charges.";
private static final String BREAK_EXPEDITIOUS = "The bracelet shatters. Your next expeditious bracelet<br>will start afresh from 30 charges.";
@Mock
@Bind
Client client;
@@ -730,47 +715,10 @@ public class SlayerPluginTest
public void testBraceletSlaughter()
{
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_SLAUGHTER, null, 0);
slayerPlugin.setAmount(42);
slayerPlugin.setSlaughterChargeCount(10);
slayerPlugin.onChatMessage(chatMessageEvent);
assertEquals(9, slayerPlugin.getSlaughterChargeCount());
assertEquals(43, slayerPlugin.getAmount());
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", CHAT_BRACELET_SLAUGHTER_CHARGE, null, 0);
slayerPlugin.onChatMessage(chatMessageEvent);
assertEquals(12, slayerPlugin.getSlaughterChargeCount());
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", CHAT_BRACELET_SLAUGHTER_CHARGE_ONE, null, 0);
slayerPlugin.onChatMessage(chatMessageEvent);
assertEquals(1, slayerPlugin.getSlaughterChargeCount());
slayerPlugin.setSlaughterChargeCount(1);
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_SLAUGHTER_V3, null, 0);
slayerPlugin.onChatMessage(chatMessageEvent);
assertEquals(30, slayerPlugin.getSlaughterChargeCount());
Widget braceletBreakWidget = mock(Widget.class);
when(braceletBreakWidget.getText()).thenReturn(BREAK_SLAUGHTER);
when(client.getWidget(WidgetInfo.DIALOG_SPRITE_TEXT)).thenReturn(braceletBreakWidget);
slayerPlugin.setSlaughterChargeCount(-1);
slayerPlugin.onGameTick(new GameTick());
assertEquals(30, slayerPlugin.getSlaughterChargeCount());
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_SLAUGHTER_V2, null, 0);
slayerPlugin.setAmount(42);
slayerPlugin.setSlaughterChargeCount(2);
slayerPlugin.onChatMessage(chatMessageEvent);
assertEquals(1, slayerPlugin.getSlaughterChargeCount());
assertEquals(43, slayerPlugin.getAmount());
}
@@ -778,48 +726,11 @@ public class SlayerPluginTest
public void testBraceletExpeditious()
{
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_EXPEDITIOUS, null, 0);
slayerPlugin.setAmount(42);
slayerPlugin.setExpeditiousChargeCount(10);
slayerPlugin.onChatMessage(chatMessageEvent);
assertEquals(41, slayerPlugin.getAmount());
assertEquals(9, slayerPlugin.getExpeditiousChargeCount());
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", CHAT_BRACELET_EXPEDITIOUS_CHARGE, null, 0);
slayerPlugin.onChatMessage(chatMessageEvent);
assertEquals(12, slayerPlugin.getExpeditiousChargeCount());
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", CHAT_BRACELET_EXPEDITIOUS_CHARGE_ONE, null, 0);
slayerPlugin.onChatMessage(chatMessageEvent);
assertEquals(1, slayerPlugin.getExpeditiousChargeCount());
slayerPlugin.setExpeditiousChargeCount(1);
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_EXPEDITIOUS_V3, null, 0);
slayerPlugin.onChatMessage(chatMessageEvent);
assertEquals(30, slayerPlugin.getExpeditiousChargeCount());
Widget braceletBreakWidget = mock(Widget.class);
when(braceletBreakWidget.getText()).thenReturn(BREAK_EXPEDITIOUS);
when(client.getWidget(WidgetInfo.DIALOG_SPRITE_TEXT)).thenReturn(braceletBreakWidget);
slayerPlugin.setExpeditiousChargeCount(-1);
slayerPlugin.onGameTick(new GameTick());
assertEquals(30, slayerPlugin.getExpeditiousChargeCount());
chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_EXPEDITIOUS_V2, null, 0);
slayerPlugin.setAmount(42);
slayerPlugin.setExpeditiousChargeCount(2);
slayerPlugin.onChatMessage(chatMessageEvent);
assertEquals(41, slayerPlugin.getAmount());
assertEquals(1, slayerPlugin.getExpeditiousChargeCount());
}
@Test