13
0
geforkt von Mirrors/Velocity

Warn if someone tries to register the plugin instance as a listener

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-09-29 03:15:49 -04:00
Ursprung 79d566bcee
Commit 97d541d146

Datei anzeigen

@ -58,6 +58,9 @@ public class VelocityEventManager implements EventManager {
Preconditions.checkNotNull(plugin, "plugin");
Preconditions.checkNotNull(listener, "listener");
Preconditions.checkArgument(pluginManager.fromInstance(plugin).isPresent(), "Specified plugin is not loaded");
if (plugin == listener && registeredListenersByPlugin.containsEntry(plugin, plugin)) {
throw new IllegalArgumentException("Trying to register the plugin main instance. Velocity already takes care of this for you.");
}
registeredListenersByPlugin.put(plugin, listener);
bus.register(listener);
}