Skip to content

Commit

Permalink
chore: remove npc image from kill count notifications (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
iProdigy authored Nov 2, 2024
1 parent 8d2b780 commit 3697908
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 39 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased

- Minor: Remove boss image embed from kill count notifications with screenshots disabled. (#578)

## 1.10.12

- Minor: Add rarity information on select pickpocketing drops. (#571)
Expand Down
40 changes: 6 additions & 34 deletions src/main/java/dinkplugin/notifiers/KillCountNotifier.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package dinkplugin.notifiers;

import dinkplugin.message.Embed;
import dinkplugin.message.templating.Replacements;
import dinkplugin.message.templating.Template;
import dinkplugin.util.ItemUtils;
import dinkplugin.util.KillCountService;
import dinkplugin.util.TimeUtils;
import dinkplugin.util.Utils;
import dinkplugin.message.NotificationBody;
import dinkplugin.message.NotificationType;
import dinkplugin.notifiers.data.BossNotificationData;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.NPC;
import net.runelite.api.NpcID;
import net.runelite.api.Varbits;
import net.runelite.api.annotations.Varbit;
import net.runelite.api.events.WidgetLoaded;
Expand All @@ -25,9 +21,6 @@

import javax.inject.Singleton;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -144,34 +137,13 @@ private void handleKill(BossNotificationData data) {
.replacement("%TIME%", Replacements.ofText(time))
.build();

// Prepare body
NotificationBody.NotificationBodyBuilder<BossNotificationData> body =
NotificationBody.<BossNotificationData>builder()
.text(content)
.extra(data)
.playerName(player)
.type(NotificationType.KILL_COUNT);

// Add embed if not screenshotting
boolean screenshot = config.killCountSendImage();
if (!screenshot && config.discordRichEmbeds()) {
if (ba) {
body.embeds(Collections.singletonList(Embed.ofImage(ItemUtils.getNpcImageUrl(NpcID.PENANCE_QUEEN))));
} else {
Arrays.stream(client.getCachedNPCs())
.filter(Objects::nonNull)
.filter(npc -> data.getBoss().equalsIgnoreCase(npc.getName()))
.findAny()
.map(NPC::getId)
.map(ItemUtils::getNpcImageUrl)
.map(Embed::ofImage)
.map(Collections::singletonList)
.ifPresent(body::embeds);
}
}

// Call webhook
createMessage(screenshot, body.build());
createMessage(config.killCountSendImage(), NotificationBody.builder()
.text(content)
.extra(data)
.playerName(player)
.type(NotificationType.KILL_COUNT)
.build());
}

private boolean checkKillInterval(int killCount, @Nullable Boolean pb) {
Expand Down
5 changes: 0 additions & 5 deletions src/test/java/dinkplugin/notifiers/KillCountNotifierTest.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package dinkplugin.notifiers;

import com.google.inject.testing.fieldbinder.Bind;
import dinkplugin.message.Embed;
import dinkplugin.message.templating.Replacements;
import dinkplugin.message.templating.Template;
import dinkplugin.util.ItemUtils;
import dinkplugin.util.TimeUtils;
import dinkplugin.message.NotificationBody;
import dinkplugin.message.NotificationType;
import dinkplugin.notifiers.data.BossNotificationData;
import net.runelite.api.NPC;
import net.runelite.api.NpcID;
import net.runelite.api.Varbits;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.widgets.ComponentID;
Expand All @@ -22,7 +19,6 @@
import org.mockito.InjectMocks;

import java.time.Duration;
import java.util.Collections;
import java.util.stream.IntStream;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
Expand Down Expand Up @@ -479,7 +475,6 @@ void testNotifyBarbarianAssault() {
.extra(new BossNotificationData(boss, count, "The Queen is dead!", null, null))
.playerName(PLAYER_NAME)
.type(NotificationType.KILL_COUNT)
.embeds(Collections.singletonList(Embed.ofImage(ItemUtils.getNpcImageUrl(NpcID.PENANCE_QUEEN))))
.build()
);
}
Expand Down

0 comments on commit 3697908

Please sign in to comment.