13
0
geforkt von Mirrors/Velocity

Warn when using Guava Subscribe annotation.

Additionally, registration of listeners will not be fatal if an
exception was thrown.
Dieser Commit ist enthalten in:
Andrew Steinborn 2018-12-02 01:58:21 -05:00
Ursprung a3bfa292c6
Commit 65ca41cdb5
2 geänderte Dateien mit 16 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -225,11 +225,16 @@ public class VelocityServer implements ProxyServer {
logger.error("Couldn't load plugins", e);
}
// Register the plugin main classes so that we may proceed with firing the proxy initialize event
// Register the plugin main classes so that we can fire the proxy initialize event
for (PluginContainer plugin : pluginManager.getPlugins()) {
Optional<?> instance = plugin.getInstance();
if (instance.isPresent()) {
try {
eventManager.register(instance.get(), instance.get());
} catch (Exception e) {
logger.error("Unable to register plugin listener for {}",
plugin.getDescription().getName(), e);
}
}
}

Datei anzeigen

@ -70,6 +70,15 @@ public class VelocityEventManager implements EventManager {
if (plugin == listener && registeredListenersByPlugin.containsEntry(plugin, plugin)) {
throw new IllegalArgumentException("The plugin main instance is automatically registered.");
}
for (Method method : listener.getClass().getDeclaredMethods()) {
if (method.isAnnotationPresent(com.google.common.eventbus.Subscribe.class)) {
throw new IllegalArgumentException("Method " + listener.getClass().getName() + "#"
+ method.getName() + " has a Guava @Subscribe annotation. Use the Velocity @Subscribe "
+ "annotation instead.");
}
}
registeredListenersByPlugin.put(plugin, listener);
methodAdapter.register(listener);
}