Add rtconfig for excluded dead npcs
This commit is contained in:
@@ -27,6 +27,7 @@ package net.runelite.client;
|
|||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.runelite.client.ui.FatalErrorDialog;
|
import net.runelite.client.ui.FatalErrorDialog;
|
||||||
@@ -41,6 +42,8 @@ public class RuntimeConfig
|
|||||||
private String outageMessage;
|
private String outageMessage;
|
||||||
private Map<String, String> outageLinks;
|
private Map<String, String> outageLinks;
|
||||||
|
|
||||||
|
private Set<Integer> ignoreDeadNpcs;
|
||||||
|
|
||||||
public boolean showOutageMessage()
|
public boolean showOutageMessage()
|
||||||
{
|
{
|
||||||
if (Strings.isNullOrEmpty(getOutageMessage()))
|
if (Strings.isNullOrEmpty(getOutageMessage()))
|
||||||
|
|||||||
@@ -25,11 +25,22 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.game;
|
package net.runelite.client.game;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.NpcID;
|
import net.runelite.api.NpcID;
|
||||||
|
import net.runelite.client.RuntimeConfig;
|
||||||
|
|
||||||
public class NpcUtil
|
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
|
* 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
|
* 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
|
* @param npc NPC to check whether it is dying
|
||||||
* @return {@code true} if the NPC 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();
|
final int id = npc.getId();
|
||||||
switch (id)
|
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
|
case NpcID.KALPHITE_QUEEN_963: // KQ's first form sometimes regenerates 1hp after reaching 0hp, thus not dying
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
|
Set<Integer> ignoredNpcs = runtimeConfig.getIgnoreDeadNpcs();
|
||||||
|
if (ignoredNpcs != null && ignoredNpcs.contains(id))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return npc.isDead();
|
return npc.isDead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ public class EntityHiderPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private Hooks hooks;
|
private Hooks hooks;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private NpcUtil npcUtil;
|
||||||
|
|
||||||
private boolean hideOthers;
|
private boolean hideOthers;
|
||||||
private boolean hideOthers2D;
|
private boolean hideOthers2D;
|
||||||
private boolean hideFriends;
|
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
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,6 +191,9 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private ChatMessageManager chatMessageManager;
|
private ChatMessageManager chatMessageManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private NpcUtil npcUtil;
|
||||||
|
|
||||||
private boolean configuringShiftClick = false;
|
private boolean configuringShiftClick = false;
|
||||||
private boolean configuringLeftClick = false;
|
private boolean configuringLeftClick = false;
|
||||||
|
|
||||||
@@ -1275,7 +1278,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
.filter(e ->
|
.filter(e ->
|
||||||
{
|
{
|
||||||
final NPC npc = e.getNpc();
|
final NPC npc = e.getNpc();
|
||||||
return npc == null || !NpcUtil.isDying(npc);
|
return npc == null || !npcUtil.isDying(npc);
|
||||||
})
|
})
|
||||||
.toArray(MenuEntry[]::new);
|
.toArray(MenuEntry[]::new);
|
||||||
if (oldEntries.length != newEntries.length)
|
if (oldEntries.length != newEntries.length)
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import java.util.Set;
|
|||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.client.RuneLite;
|
import net.runelite.client.RuneLite;
|
||||||
import net.runelite.client.RuneLiteModule;
|
import net.runelite.client.RuneLiteModule;
|
||||||
|
import net.runelite.client.RuntimeConfig;
|
||||||
import net.runelite.client.config.Config;
|
import net.runelite.client.config.Config;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
import net.runelite.client.eventbus.EventBus;
|
import net.runelite.client.eventbus.EventBus;
|
||||||
@@ -93,7 +94,7 @@ public class PluginManagerTest
|
|||||||
.thenThrow(new RuntimeException("in plugin manager test"));
|
.thenThrow(new RuntimeException("in plugin manager test"));
|
||||||
|
|
||||||
Injector injector = Guice.createInjector(Modules
|
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_SESSION_FILE,
|
||||||
RuneLite.DEFAULT_CONFIG_FILE))
|
RuneLite.DEFAULT_CONFIG_FILE))
|
||||||
.with(BoundFieldModule.of(this)));
|
.with(BoundFieldModule.of(this)));
|
||||||
|
|||||||
Reference in New Issue
Block a user