Skip to content

Commit

Permalink
perf(loot): skip allow list regex if item on deny list (pajlads#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
iProdigy authored Oct 12, 2024
1 parent 70e730f commit 5da1b85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Unreleased

- Bugfix: Enforce value threshold for always-dropped loot when rarity threshold is 1 and require both value and rarity is true. (#560)
- Dev: Optimize regex performance for looted items on the item denylist. (#565)

## 1.10.11

Expand Down
11 changes: 6 additions & 5 deletions src/main/java/dinkplugin/notifiers/LootNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,14 @@ private void handleNotify(Collection<ItemStack> items, String dropper, LootRecor
shouldSend = totalPrice >= minValue || MathUtils.lessThanOrEqual(rarity.orElse(1), rarityThreshold);
}

shouldSend |= matches(itemNameAllowlist, stack.getName());

boolean denied = matches(itemNameDenylist, stack.getName());
if (denied) {
shouldSend = false;
} else if (max == null || totalPrice > max.getTotalPrice()) {
max = stack;
} else {
shouldSend |= matches(itemNameAllowlist, stack.getName());
if (max == null || totalPrice > max.getTotalPrice()) {
max = stack;
}
}

if (shouldSend) {
Expand Down Expand Up @@ -218,7 +219,7 @@ private void handleNotify(Collection<ItemStack> items, String dropper, LootRecor
}

if (sendMessage) {
if (npcId == null && (type == LootRecordType.NPC || type == LootRecordType.PICKPOCKET)) {
if (npcId == null && (type == LootRecordType.NPC || type == LootRecordType.PICKPOCKET)) {
npcId = client.getTopLevelWorldView().npcs().stream()
.filter(npc -> dropper.equals(npc.getName()))
.findAny()
Expand Down

0 comments on commit 5da1b85

Please sign in to comment.