npchider: change method by which npcs are hidden by name (#1573)
* npchider: change method by which npcs are hidden by name * fix bug on client startup/shutdown where nothing gets hidden * entityhider: change method by which npcs are hidden on death
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
|
||||
* Copyright (c) 2019, ThatGamerBlue <thatgamerblue@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -40,6 +41,10 @@ import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Entity Hider",
|
||||
description = "Hide players, NPCs, and/or projectiles",
|
||||
@@ -69,6 +74,9 @@ public class EntityHiderPlugin extends Plugin
|
||||
{
|
||||
updateConfig();
|
||||
addSubscriptions();
|
||||
|
||||
Text.fromCSV(config.hideNPCsNames()).forEach(client::addHiddenNpcName);
|
||||
Text.fromCSV(config.hideNPCsOnDeath()).forEach(client::addHiddenNpcDeath);
|
||||
}
|
||||
|
||||
private void addSubscriptions()
|
||||
@@ -82,6 +90,30 @@ public class EntityHiderPlugin extends Plugin
|
||||
if (event.getGroup().equals("entityhider"))
|
||||
{
|
||||
updateConfig();
|
||||
|
||||
if (event.getKey().equals("hideNPCsNames"))
|
||||
{
|
||||
List<String> oldList = Text.fromCSV(event.getOldValue());
|
||||
List<String> newList = Text.fromCSV(event.getNewValue());
|
||||
|
||||
ArrayList<String> removed = oldList.stream().filter(s -> !newList.contains(s)).collect(Collectors.toCollection(ArrayList::new));
|
||||
ArrayList<String> added = newList.stream().filter(s -> !oldList.contains(s)).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
removed.forEach(client::removeHiddenNpcName);
|
||||
added.forEach(client::addHiddenNpcName);
|
||||
}
|
||||
|
||||
if (event.getKey().equals("hideNPCsOnDeath"))
|
||||
{
|
||||
List<String> oldList = Text.fromCSV(event.getOldValue());
|
||||
List<String> newList = Text.fromCSV(event.getNewValue());
|
||||
|
||||
ArrayList<String> removed = oldList.stream().filter(s -> !newList.contains(s)).collect(Collectors.toCollection(ArrayList::new));
|
||||
ArrayList<String> added = newList.stream().filter(s -> !oldList.contains(s)).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
removed.forEach(client::removeHiddenNpcDeath);
|
||||
added.forEach(client::addHiddenNpcDeath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +141,8 @@ public class EntityHiderPlugin extends Plugin
|
||||
|
||||
client.setNPCsHidden(config.hideNPCs());
|
||||
client.setNPCsHidden2D(config.hideNPCs2D());
|
||||
client.setNPCsNames(Text.fromCSV(config.hideNPCsNames()));
|
||||
client.setNPCsHiddenOnDeath(Text.fromCSV(config.hideNPCsOnDeath()));
|
||||
//client.setNPCsNames(Text.fromCSV(config.hideNPCsNames()));
|
||||
//client.setNPCsHiddenOnDeath(Text.fromCSV(config.hideNPCsOnDeath()));
|
||||
|
||||
client.setAttackersHidden(config.hideAttackers());
|
||||
|
||||
@@ -143,6 +175,9 @@ public class EntityHiderPlugin extends Plugin
|
||||
client.setProjectilesHidden(false);
|
||||
|
||||
client.setDeadNPCsHidden(false);
|
||||
|
||||
Text.fromCSV(config.hideNPCsNames()).forEach(client::removeHiddenNpcName);
|
||||
Text.fromCSV(config.hideNPCsOnDeath()).forEach(client::removeHiddenNpcDeath);
|
||||
}
|
||||
|
||||
private boolean isPlayerRegionAllowed()
|
||||
|
||||
Reference in New Issue
Block a user