diff --git a/src/fr/neatmonster/nocheatplus/NoCheatPlus.java b/src/fr/neatmonster/nocheatplus/NoCheatPlus.java
index ed626fb8..1e781abf 100644
--- a/src/fr/neatmonster/nocheatplus/NoCheatPlus.java
+++ b/src/fr/neatmonster/nocheatplus/NoCheatPlus.java
@@ -33,6 +33,7 @@ import fr.neatmonster.nocheatplus.checks.inventory.InventoryListener;
import fr.neatmonster.nocheatplus.checks.moving.MovingListener;
import fr.neatmonster.nocheatplus.command.CommandHandler;
import fr.neatmonster.nocheatplus.command.INotifyReload;
+import fr.neatmonster.nocheatplus.components.ComponentWithName;
import fr.neatmonster.nocheatplus.components.INeedConfig;
import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI;
import fr.neatmonster.nocheatplus.config.ConfPaths;
@@ -182,6 +183,9 @@ public class NoCheatPlus extends JavaPlugin implements Listener, NoCheatPlusAPI
private boolean manageListeners = true;
+ /**
+ * Interfaces checked for managed listeners: IHaveMethodOrder (method), ComponentWithName (tag)
+ */
@Override
public void addComponent(final Object obj) {
if (obj instanceof Listener) {
@@ -195,10 +199,18 @@ public class NoCheatPlus extends JavaPlugin implements Listener, NoCheatPlusAPI
}
dataMan.addComponent(obj);
}
-
+
+ /**
+ * Interfaces checked for managed listeners: IHaveMethodOrder (method), ComponentWithName (tag)
+ * @param listener
+ */
private void addListener(final Listener listener) {
if (manageListeners){
- listenerManager.registerAllEventHandlers(listener, "NoCheatPlus");
+ String tag = "NoCheatPlus";
+ if (listener instanceof ComponentWithName){
+ tag = ((ComponentWithName) listener).getComponentName();
+ }
+ listenerManager.registerAllEventHandlers(listener, tag);
listeners.add(listener);
}
else{
diff --git a/src/fr/neatmonster/nocheatplus/event/ListenerManager.java b/src/fr/neatmonster/nocheatplus/event/ListenerManager.java
index 1b9759a5..b3166bca 100644
--- a/src/fr/neatmonster/nocheatplus/event/ListenerManager.java
+++ b/src/fr/neatmonster/nocheatplus/event/ListenerManager.java
@@ -13,6 +13,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
+import fr.neatmonster.nocheatplus.components.ComponentWithName;
import fr.neatmonster.nocheatplus.event.GenericListener.MethodEntry;
import fr.neatmonster.nocheatplus.event.GenericListener.MethodEntry.MethodOrder;
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
@@ -93,6 +94,7 @@ public class ListenerManager {
/**
* This registers all declared methods that have the @EventHandler annotation.
+ * Interfaces checked if arguments are not given: IHaveMethodOrder (order), ComponentWithName (tag)
* NOTE: Does not do any super class checking.
* @param listener
* @param tag Identifier for the registering plugin / agent, null is not discouraged, but null entries are ignored concerning sortin order.
@@ -103,6 +105,7 @@ public class ListenerManager {
/**
* This registers all methods that have the @EventHandler annotation.
+ * Interfaces checked if arguments are not given: IHaveMethodOrder (order), ComponentWithName (tag)
* NOTE: Does not do any super class checking.
* @param listener
* @param tag Identifier for the registering plugin / agent, null is not discouraged, but null entries are ignored concerning sortin order.
@@ -112,6 +115,10 @@ public class ListenerManager {
if (order == null && listener instanceof IHaveMethodOrder){
order = ((IHaveMethodOrder) listener).getMethodOrder();
}
+ if (tag == null && listener instanceof ComponentWithName){
+ // TODO: maybe change to an interface only defined here.
+ tag = ((ComponentWithName) listener).getComponentName();
+ }
Class> clazz = listener.getClass();
Set allMethods = new HashSet();
for (Method method : clazz.getMethods()){
@@ -146,15 +153,6 @@ public class ListenerManager {
}
}
- protected static boolean extendsEvent(Class> eventType) {
- Class> superClass = eventType.getSuperclass();
- while (superClass != null && superClass != Object.class){
- if (superClass == Event.class) return true;
- superClass = superClass.getSuperclass();
- }
- return false;
- }
-
/**
* TODO: more methods for tags ? (+ return something?).
* @param listener