hooksByName it shoudlbne for names arent unique.

This commit is contained in:
asofold 2012-08-08 00:22:15 +02:00
parent ab670c3a75
commit 23442aef66

View File

@ -272,11 +272,11 @@ public final class NCPHookManager {
* @param hookName * @param hookName
* @return * @return
*/ */
public static NCPHook removeHook(String hookName){ public static Collection<NCPHook> removeHook(String hookName){
NCPHook hook = getHookByName(hookName); Collection<NCPHook> hooks = getHooksByName(hookName);
if (hook == null) return null; if (hooks.isEmpty()) return null;
removeHook(hook); removeHooks(hooks);
return hook; return hooks;
} }
/** /**
@ -306,12 +306,13 @@ public final class NCPHookManager {
* @param hookName case sensitive (exact match). * @param hookName case sensitive (exact match).
* @return NCPHook if found, null otherwise. * @return NCPHook if found, null otherwise.
*/ */
public static NCPHook getHookByName(String hookName){ public static Collection<NCPHook> getHooksByName(String hookName){
List<NCPHook> hooks = new LinkedList<NCPHook>();
for (Integer refId : allHooks.keySet()){ for (Integer refId : allHooks.keySet()){
NCPHook hook = allHooks.get(refId); NCPHook hook = allHooks.get(refId);
if (hook.getHookName().equals(hookName)) return hook; if (hook.getHookName().equals(hookName) && !hooks.contains(hook)) hooks.add(hook);
} }
return null; return hooks;
} }
/** /**