mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-29 11:57:59 +01:00
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:
parent
7e26e7e030
commit
22f2a5c248
16
src/fr/neatmonster/nocheatplus/event/IHaveMethodOrder.java
Normal file
16
src/fr/neatmonster/nocheatplus/event/IHaveMethodOrder.java
Normal 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();
|
||||
}
|
@ -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()){
|
||||
|
Loading…
Reference in New Issue
Block a user