Add interface IHaveMethodOrder.

This allows to add a Listener with MethodOrder in case the
ListenerManager instance is not directly accessible.
This commit is contained in:
asofold 2012-11-08 04:39:53 +01:00
parent 7e26e7e030
commit 22f2a5c248
2 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package fr.neatmonster.nocheatplus.event;
import fr.neatmonster.nocheatplus.event.GenericListener.MethodEntry.MethodOrder;
/**
* Implement to register Listeners via delegation that does not allow for passinf MethodOrder directly.
* @author mc_dev
*
*/
public interface IHaveMethodOrder {
/**
*
* @return
*/
public MethodOrder getMethodOrder();
}

View File

@ -109,6 +109,9 @@ public class ListenerManager {
* @param order Allows to register before other tags or just first. Expect MethodOrder to change in near future. The method order of already registered methods will not be compared to.
*/
public void registerAllEventHandlers(Listener listener, String tag, MethodOrder order){
if (order == null && listener instanceof IHaveMethodOrder){
order = ((IHaveMethodOrder) listener).getMethodOrder();
}
Class<?> clazz = listener.getClass();
Set<Method> allMethods = new HashSet<Method>();
for (Method method : clazz.getMethods()){