From af9dd581bb440805ac36374355999fb0c9cb5ff8 Mon Sep 17 00:00:00 2001 From: Clisprail Date: Tue, 5 Aug 2014 20:23:21 +0200 Subject: [PATCH] Added Npcs#getClosest(Filter | int...) --- src/org/rev317/min/api/methods/Npcs.java | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/org/rev317/min/api/methods/Npcs.java b/src/org/rev317/min/api/methods/Npcs.java index cacb3db..8adcce8 100644 --- a/src/org/rev317/min/api/methods/Npcs.java +++ b/src/org/rev317/min/api/methods/Npcs.java @@ -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 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