Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Warn when using Guava Subscribe annotation.
Additionally, registration of listeners will not be fatal if an exception was thrown.
Dieser Commit ist enthalten in:
Ursprung
a3bfa292c6
Commit
65ca41cdb5
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren