diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/registry/store/RegisteredItemStore.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/registry/store/RegisteredItemStore.java index d6c01774..56fe79f0 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/registry/store/RegisteredItemStore.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/registry/store/RegisteredItemStore.java @@ -1,5 +1,7 @@ package fr.neatmonster.nocheatplus.components.registry.store; +import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -41,6 +43,10 @@ public class RegisteredItemStore { */ static class ItemNode implements IGetRegistrationOrder, Comparable> { + /* + * TODO: Looking ahead, should probably rather equal on base of the + * stored item (HashSet). Sorting by internalId may use a Comparator. + */ // TODO: implement IGetItem final RegistrationOrder order; @@ -78,6 +84,13 @@ public class RegisteredItemStore { }; static final class ItemList { + + /* + * Looking ahead: Should probably rather use a LinkedHashSet for + * itemNodes, for faster removal and contains check. Sorting by + * internalId may use a Comparator. + */ + /** I bit heavy on the tip of the blade, java. */ private final SortItemNode typedSort = new SortItemNode(); // TODO: always fetch an array and store as sorted. @@ -374,6 +387,23 @@ public class RegisteredItemStore { return true; } + /** + * Unregister each of all given items from all types it had been registered + * for. + * + * @param items + * @return + * @throws NullPointerException + * If items or any of the items within items is null. + */ + public boolean unregister(final Collection items) { + boolean had = false; + for (final Object item : items) { + had |= unregister(item); + } + return had; + } + /** * Test if an item is registered for a given type. * @@ -429,6 +459,15 @@ public class RegisteredItemStore { return items.containsKey(item); } + /** + * Retrieve a copy of all registered items. + * + * @return + */ + public List getAllRegisteredItems() { + return new ArrayList(items.keySet()); + } + /** * Ensure all contained lists are sorted and optimized. */