entityhider: add blacklist for hiding dead npcs. (#2231)

This commit is contained in:
Ganom
2020-01-16 09:01:32 -05:00
committed by Kyle
parent 8545e7f161
commit 7e1c211005
6 changed files with 64 additions and 8 deletions

View File

@@ -1596,6 +1596,14 @@ public interface Client extends GameShell
*/
void setDeadNPCsHidden(boolean state);
/**
* The provided ids will not be hidden when the
* entity-hider attempts to hide dead {@link NPC}'s.
*
* @param blacklist set of npc ids.
*/
void setBlacklistDeadNpcs(Set<Integer> blacklist);
/**
* Gets an array of tile collision data.
* <p>

View File

@@ -38,7 +38,7 @@ public class Text
{
private static final StringBuilder SB = new StringBuilder(64);
private static final Splitter COMMA_SPLITTER = Splitter
public static final Splitter COMMA_SPLITTER = Splitter
.on(",")
.omitEmptyStrings()
.trimResults();

View File

@@ -235,10 +235,24 @@ public interface EntityHiderConfig extends Config
}
@ConfigItem(
position = 18,
keyName = "hidePets",
name = "Hide Pets",
description = "Configures whether or not other player pets are hidden"
position = 18,
keyName = "blacklistDeadNpcs",
name = "Hide on Death Blacklist",
description = "Configures which NPCs NOT to hide when they die",
titleSection = "npcsTitle",
hidden = true,
unhide = "hideDeadNPCs"
)
default String blacklistDeadNpcs()
{
return "";
}
@ConfigItem(
position = 19,
keyName = "hidePets",
name = "Hide Pets",
description = "Configures whether or not other player pets are hidden"
)
default boolean hidePets()
{
@@ -249,7 +263,7 @@ public interface EntityHiderConfig extends Config
keyName = "miscTitle",
name = "Miscellaneous",
description = "",
position = 19
position = 20
)
default Title miscTitle()
{
@@ -257,7 +271,7 @@ public interface EntityHiderConfig extends Config
}
@ConfigItem(
position = 20,
position = 21,
keyName = "hideProjectiles",
name = "Hide Projectiles",
description = "Configures whether or not projectiles are hidden",

View File

@@ -28,7 +28,9 @@ package net.runelite.client.plugins.entityhider;
import com.google.inject.Provides;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -83,6 +85,22 @@ public class EntityHiderPlugin extends Plugin
{
updateConfig();
final Set<Integer> blacklist = new HashSet<>();
for (String s : Text.COMMA_SPLITTER.split(config.blacklistDeadNpcs()))
{
try
{
blacklist.add(Integer.parseInt(s));
}
catch (NumberFormatException ignored)
{
}
}
client.setBlacklistDeadNpcs(blacklist);
if (event.getOldValue() == null || event.getNewValue() == null)
{
return;

View File

@@ -27,7 +27,9 @@ package net.runelite.mixins;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSClient;
@@ -83,6 +85,9 @@ public abstract class EntityHiderBridgeMixin implements RSClient
@Inject
public static List<String> hideSpecificPlayers = new ArrayList<>();
@Inject
public static Set<Integer> blacklistDeadNpcs = new HashSet<>();
@Inject
@Override
public void setIsHidingEntities(boolean state)
@@ -225,6 +230,13 @@ public abstract class EntityHiderBridgeMixin implements RSClient
hideSpecificPlayers = players;
}
@Inject
@Override
public void setBlacklistDeadNpcs(Set<Integer> blacklist)
{
blacklistDeadNpcs = blacklist;
}
@Inject
@Override
public void setPetsHidden(boolean state)

View File

@@ -27,6 +27,7 @@ package net.runelite.mixins;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
@@ -80,6 +81,9 @@ public abstract class EntityHiderMixin implements RSScene
@Shadow("hideSpecificPlayers")
private static List<String> hideSpecificPlayers;
@Shadow("blacklistDeadNpcs")
private static Set<Integer> blacklistDeadNpcs;
@Shadow("hideNPCs2D")
private static boolean hideNPCs2D;
@@ -199,7 +203,7 @@ public abstract class EntityHiderMixin implements RSScene
}
}
if (hideDeadNPCs && npc.getHealthRatio() == 0)
if (hideDeadNPCs && npc.getHealthRatio() == 0 && !blacklistDeadNpcs.contains(npc.getId()))
{
return false;
}