/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package fr.neatmonster.nocheatplus.event.mini;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import fr.neatmonster.nocheatplus.components.registry.order.IGetRegistrationOrder;
import fr.neatmonster.nocheatplus.components.registry.order.RegistrationOrder;
import fr.neatmonster.nocheatplus.components.registry.order.RegistrationOrder.RegisterEventsWithOrder;
import fr.neatmonster.nocheatplus.components.registry.order.RegistrationOrder.RegisterWithOrder;
/**
*
* One registry for MiniListener instances.
*
*
*
* Supports registration of MiniListener instances with order (FCFS):
*
*
Implement the interface
* {@link fr.neatmonster.nocheatplus.components.registry.order.IGetRegistrationOrder}
* (Method annotations are not supported for the MiniListener class.)
*
*
* @param
* Event base type, e.g. Event (Bukkit).
* @param
* Priority type of the underlying event system, e.g. EventPriority
* (Bukkit).
*
* @author asofold
*
*/
public abstract class MiniListenerRegistry {
public static interface NodeFactory {
public MiniListenerNode newNode(Class eventClass, P basePriority);
}
///////////////
// Instance.
///////////////
/**
* Override for efficient stuff.
*/
protected NodeFactory nodeFactory = new NodeFactory() {
@Override
public MiniListenerNode newNode(Class eventClass, P basePriority) {
return new MiniListenerNode(basePriority);
}
};
/**
* Map event class -> base priority -> node. Note that this does no merging
* based on super-classes like the Bukkit implementation of the Listener
* registry would do.
*/
protected final Map, Map
>> classMap = new HashMap, Map
>>();
/**
* Store attached MiniListener instances by anchor objects.
*/
protected final Map