Add Overlay for Silver Jewelry to Slayer Plugin
Add overlay to display charge counter on Expeditious Bracelet and Bracelet of Slaughter.
This commit is contained in:
@@ -175,4 +175,40 @@ public interface SlayerConfig extends Config
|
||||
description = ""
|
||||
)
|
||||
void points(int points);
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "expeditious",
|
||||
name = "",
|
||||
description = "",
|
||||
hidden = true
|
||||
)
|
||||
default int expeditious()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "expeditious",
|
||||
name = "",
|
||||
description = ""
|
||||
)
|
||||
void expeditious(int expeditious);
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "slaughter",
|
||||
name = "",
|
||||
description = "",
|
||||
hidden = true
|
||||
)
|
||||
default int slaughter()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "slaughter",
|
||||
name = "",
|
||||
description = ""
|
||||
)
|
||||
void slaughter(int slaughter);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,9 @@ class SlayerOverlay extends Overlay
|
||||
ItemID.TURQUOISE_SLAYER_HELMET_I,
|
||||
ItemID.SLAYER_RING_ETERNAL,
|
||||
ItemID.ENCHANTED_GEM,
|
||||
ItemID.ETERNAL_GEM
|
||||
ItemID.ETERNAL_GEM,
|
||||
ItemID.BRACELET_OF_SLAUGHTER,
|
||||
ItemID.EXPEDITIOUS_BRACELET
|
||||
);
|
||||
|
||||
@Inject
|
||||
@@ -106,6 +108,9 @@ class SlayerOverlay extends Overlay
|
||||
return null;
|
||||
}
|
||||
|
||||
int slaughterCount = plugin.getSlaughterChargeCount();
|
||||
int expeditiousCount = plugin.getExpeditiousChargeCount();
|
||||
|
||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||
|
||||
for (WidgetItem item : getSlayerWidgetItems())
|
||||
@@ -119,7 +124,20 @@ class SlayerOverlay extends Overlay
|
||||
|
||||
final Rectangle bounds = item.getCanvasBounds();
|
||||
final TextComponent textComponent = new TextComponent();
|
||||
textComponent.setText(String.valueOf(amount));
|
||||
|
||||
if (item.getId() == ItemID.EXPEDITIOUS_BRACELET)
|
||||
{
|
||||
textComponent.setText(String.valueOf(expeditiousCount));
|
||||
}
|
||||
else if (item.getId() == ItemID.BRACELET_OF_SLAUGHTER)
|
||||
{
|
||||
textComponent.setText(String.valueOf(slaughterCount));
|
||||
}
|
||||
else
|
||||
{
|
||||
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, bounds.y + (slayerJewelry.contains(itemId)
|
||||
? bounds.height
|
||||
@@ -135,7 +153,7 @@ class SlayerOverlay extends Overlay
|
||||
Query inventoryQuery = new InventoryWidgetItemQuery();
|
||||
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
|
||||
|
||||
Query equipmentQuery = new EquipmentItemQuery().slotEquals(WidgetInfo.EQUIPMENT_HELMET, WidgetInfo.EQUIPMENT_RING);
|
||||
Query equipmentQuery = new EquipmentItemQuery().slotEquals(WidgetInfo.EQUIPMENT_HELMET, WidgetInfo.EQUIPMENT_RING, WidgetInfo.EQUIPMENT_GLOVES);
|
||||
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
|
||||
|
||||
WidgetItem[] items = concat(inventoryWidgetItems, equipmentWidgetItems, WidgetItem.class);
|
||||
|
||||
@@ -41,6 +41,7 @@ import javax.inject.Inject;
|
||||
import joptsimple.internal.Strings;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
@@ -80,6 +81,8 @@ public class SlayerPlugin extends Plugin
|
||||
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 count decreasing.";
|
||||
private static final String CHAT_BRACELET_EXPEDITIOUS = "Your expeditious bracelet helps you progress your slayer task faster.";
|
||||
private static final String CHAT_BRACELET_SLAUGHTER_CHARGE = "Your bracelet of slaughter has ";
|
||||
private static final String CHAT_BRACELET_EXPEDITIOUS_CHARGE = "Your expeditious bracelet has ";
|
||||
|
||||
//NPC messages
|
||||
private static final Pattern NPC_ASSIGN_MESSAGE = Pattern.compile(".*Your new task is to kill (\\d*) (.*)\\.");
|
||||
@@ -88,6 +91,9 @@ public class SlayerPlugin extends Plugin
|
||||
//Reward UI
|
||||
private static final Pattern REWARD_POINTS = Pattern.compile("Reward points: (\\d*)");
|
||||
|
||||
private static final int EXPEDITIOUS_CHARGE = 30;
|
||||
private static final int SLAUGHTER_CHARGE = 30;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@@ -126,6 +132,12 @@ public class SlayerPlugin extends Plugin
|
||||
private int cachedXp;
|
||||
private Instant infoTimer;
|
||||
private boolean loginFlag;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private int expeditiousChargeCount;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private int slaughterChargeCount;
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
@@ -136,6 +148,8 @@ public class SlayerPlugin extends Plugin
|
||||
{
|
||||
setPoints(config.points());
|
||||
setStreak(config.streak());
|
||||
setExpeditiousChargeCount(config.expeditious());
|
||||
setSlaughterChargeCount(config.slaughter());
|
||||
clientThread.invokeLater(() -> setTask(config.taskName(), config.amount()));
|
||||
}
|
||||
}
|
||||
@@ -171,6 +185,8 @@ public class SlayerPlugin extends Plugin
|
||||
{
|
||||
setPoints(config.points());
|
||||
setStreak(config.streak());
|
||||
setExpeditiousChargeCount(config.expeditious());
|
||||
setSlaughterChargeCount(config.slaughter());
|
||||
setTask(config.taskName(), config.amount());
|
||||
loginFlag = false;
|
||||
}
|
||||
@@ -184,6 +200,8 @@ public class SlayerPlugin extends Plugin
|
||||
config.taskName(taskName);
|
||||
config.points(points);
|
||||
config.streak(streak);
|
||||
config.expeditious(expeditiousChargeCount);
|
||||
config.slaughter(slaughterChargeCount);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -201,12 +219,29 @@ public class SlayerPlugin extends Plugin
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String taskName = found1 ? mAssign.group(2) : mCurrent.group(1);
|
||||
int amount = Integer.parseInt(found1 ? mAssign.group(1) : mCurrent.group(2));
|
||||
|
||||
setTask(taskName, amount);
|
||||
}
|
||||
|
||||
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;
|
||||
config.slaughter(slaughterChargeCount);
|
||||
}
|
||||
else if (braceletText.contains("expeditious bracelet"))
|
||||
{
|
||||
expeditiousChargeCount = EXPEDITIOUS_CHARGE;
|
||||
config.expeditious(expeditiousChargeCount);
|
||||
}
|
||||
}
|
||||
|
||||
Widget rewardsBarWidget = client.getWidget(WidgetInfo.SLAYER_REWARDS_TOPBAR);
|
||||
if (rewardsBarWidget != null)
|
||||
{
|
||||
@@ -255,11 +290,30 @@ public class SlayerPlugin extends Plugin
|
||||
if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER))
|
||||
{
|
||||
amount++;
|
||||
slaughterChargeCount = --slaughterChargeCount <= 0 ? SLAUGHTER_CHARGE : slaughterChargeCount;
|
||||
config.slaughter(slaughterChargeCount);
|
||||
}
|
||||
|
||||
if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS))
|
||||
{
|
||||
amount--;
|
||||
expeditiousChargeCount = --expeditiousChargeCount <= 0 ? EXPEDITIOUS_CHARGE : expeditiousChargeCount;
|
||||
config.expeditious(expeditiousChargeCount);
|
||||
}
|
||||
|
||||
if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS_CHARGE))
|
||||
{
|
||||
expeditiousChargeCount = Integer.parseInt(chatMsg
|
||||
.replace(CHAT_BRACELET_EXPEDITIOUS_CHARGE, "")
|
||||
.replace(" charges left.", ""));
|
||||
config.expeditious(expeditiousChargeCount);
|
||||
}
|
||||
if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER_CHARGE))
|
||||
{
|
||||
slaughterChargeCount = Integer.parseInt(chatMsg
|
||||
.replace(CHAT_BRACELET_SLAUGHTER_CHARGE, "")
|
||||
.replace(" charges left.", ""));
|
||||
config.slaughter(slaughterChargeCount);
|
||||
}
|
||||
|
||||
if (chatMsg.endsWith("; return to a Slayer master."))
|
||||
|
||||
Reference in New Issue
Block a user