Add rtconfig for excluded dead npcs

This commit is contained in:
Adam
2022-06-18 22:28:41 -04:00
parent 6b68ba9806
commit 6aadd3ba26
5 changed files with 31 additions and 4 deletions

View File

@@ -27,6 +27,7 @@ package net.runelite.client;
import com.google.common.base.Strings;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import javax.swing.SwingUtilities;
import lombok.Data;
import net.runelite.client.ui.FatalErrorDialog;
@@ -41,6 +42,8 @@ public class RuntimeConfig
private String outageMessage;
private Map<String, String> outageLinks;
private Set<Integer> ignoreDeadNpcs;
public boolean showOutageMessage()
{
if (Strings.isNullOrEmpty(getOutageMessage()))

View File

@@ -25,11 +25,22 @@
*/
package net.runelite.client.game;
import java.util.Set;
import javax.inject.Inject;
import net.runelite.api.NPC;
import net.runelite.api.NpcID;
import net.runelite.client.RuntimeConfig;
public class NpcUtil
{
private final RuntimeConfig runtimeConfig;
@Inject
private NpcUtil(RuntimeConfig runtimeConfig)
{
this.runtimeConfig = runtimeConfig;
}
/**
* Returns whether an NPC is dying and can no longer be interacted with, or if it is still alive or in some special
* state where it can be 0hp without dying. (For example, Gargoyles and other slayer monsters with item weaknesses
@@ -38,7 +49,7 @@ public class NpcUtil
* @param npc NPC to check whether it is dying
* @return {@code true} if the NPC is dying
*/
public static boolean isDying(final NPC npc)
public boolean isDying(final NPC npc)
{
final int id = npc.getId();
switch (id)
@@ -79,6 +90,12 @@ public class NpcUtil
case NpcID.KALPHITE_QUEEN_963: // KQ's first form sometimes regenerates 1hp after reaching 0hp, thus not dying
return false;
default:
Set<Integer> ignoredNpcs = runtimeConfig.getIgnoreDeadNpcs();
if (ignoredNpcs != null && ignoredNpcs.contains(id))
{
return false;
}
return npc.isDead();
}
}

View File

@@ -59,6 +59,9 @@ public class EntityHiderPlugin extends Plugin
@Inject
private Hooks hooks;
@Inject
private NpcUtil npcUtil;
private boolean hideOthers;
private boolean hideOthers2D;
private boolean hideFriends;
@@ -191,7 +194,7 @@ public class EntityHiderPlugin extends Plugin
}
// dead npcs can also be interacting so prioritize it over the interacting check
if (NpcUtil.isDying(npc) && hideDeadNpcs)
if (npcUtil.isDying(npc) && hideDeadNpcs)
{
return false;
}

View File

@@ -191,6 +191,9 @@ public class MenuEntrySwapperPlugin extends Plugin
@Inject
private ChatMessageManager chatMessageManager;
@Inject
private NpcUtil npcUtil;
private boolean configuringShiftClick = false;
private boolean configuringLeftClick = false;
@@ -1275,7 +1278,7 @@ public class MenuEntrySwapperPlugin extends Plugin
.filter(e ->
{
final NPC npc = e.getNpc();
return npc == null || !NpcUtil.isDying(npc);
return npc == null || !npcUtil.isDying(npc);
})
.toArray(MenuEntry[]::new);
if (oldEntries.length != newEntries.length)

View File

@@ -48,6 +48,7 @@ import java.util.Set;
import net.runelite.api.Client;
import net.runelite.client.RuneLite;
import net.runelite.client.RuneLiteModule;
import net.runelite.client.RuntimeConfig;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.eventbus.EventBus;
@@ -93,7 +94,7 @@ public class PluginManagerTest
.thenThrow(new RuntimeException("in plugin manager test"));
Injector injector = Guice.createInjector(Modules
.override(new RuneLiteModule(okHttpClient, () -> null, () -> null, true, false,
.override(new RuneLiteModule(okHttpClient, () -> null, () -> mock(RuntimeConfig.class), true, false,
RuneLite.DEFAULT_SESSION_FILE,
RuneLite.DEFAULT_CONFIG_FILE))
.with(BoundFieldModule.of(this)));