Added Npcs#getClosest(Filter | int...)

This commit is contained in:
Clisprail
2014-08-05 20:23:21 +02:00
parent 235392dc4b
commit af9dd581bb
+26
View File
@@ -64,6 +64,32 @@ public class Npcs {
public static final Npc[] getNpcs() {
return getNpcs(ALL_FILTER);
}
/**
* Gets the closest npc which matches the given filter
* @param filter
* @return closest npc
*/
public static final Npc getClosest(final Filter<Npc> filter) {
Npc[] npcs = getNearest(filter);
if(npcs == null || npcs.length == 0) {
return null;
}
return npcs[0];
}
/**
* Gets the closest npc which matches the given ids
* @param ids
* @return closest npc
*/
public static final Npc getClosest(int... ids) {
Npc[] npcs = getNearest(ids);
if(npcs == null || npcs.length == 0) {
return null;
}
return npcs[0];
}
/**
* Returns array with the first index to be the nearest Npc