add removeHooks convenience method

This commit is contained in:
asofold 2012-08-07 19:00:51 +02:00
parent 5771c20d2e
commit 7d3ba1e3eb

View File

@ -4,9 +4,11 @@ package me.asofold.bpl.cncp.hooks.ncp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -333,6 +335,20 @@ public final class NCPHookManager {
return hook;
}
/**
* Remove a collection of hooks.
* @param hooks
* @return A set of the removed hooks ids.
*/
public static Set<Integer> removeHooks( Collection<NCPHook> hooks){
Set<Integer> ids = new HashSet<Integer>();
for (NCPHook hook : hooks){
Integer id = removeHook(hook);
if (id != null) ids.add(id);
}
return ids;
}
public static Collection<NCPHook> removeAllHooks(){
Collection<NCPHook> hooks = getAllHooks();
for (NCPHook hook : hooks){