Class Plugin
java.lang.Object
dev.truewinter.twiliocallrouter.plugin.Plugin
All plugins must extend this class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final Loggerprotected final PlugingetPluginByName(String name) This method allows plugin developers to get an instance of another plugin installed on the same instance of TwilioCallRouter.abstract voidonLoad()This method is called when the plugin is loaded.abstract voidonUnload()This method is called when the plugin is unloaded.protected final voidregisterListeners(Plugin plugin, Listener listener) Use this method to register event listeners
-
Constructor Details
-
Plugin
public Plugin()
-
-
Method Details
-
onLoad
public abstract void onLoad()This method is called when the plugin is loaded. It is only safe to interact with TwilioCallRouter after this is called.- See Also:
-
onUnload
public abstract void onUnload()This method is called when the plugin is unloaded. This will happen when TwilioCallRouter is shut down, or when an exception is thrown while the plugin is loading, registering listeners, or incorrectly using thegetPluginByName(String)method. -
registerListeners
Use this method to register event listeners- Parameters:
plugin- An instance of the pluginlistener- An instance of the event listener class
-
getLogger
- Returns:
- the logger
-
getPluginByName
@Nullable protected final Plugin getPluginByName(@NotNull String name) throws ClassCastException, IllegalStateException This method allows plugin developers to get an instance of another plugin installed on the same instance of TwilioCallRouter. Using this method is only allowed after theExternalPlugin.onAllPluginsLoaded()method has been called. The requesting plugin (the one calling this method) must implementExternalPluginto use this.- Parameters:
name- The name of the plugin to get, as set in the plugin's plugin.yml- Returns:
- The plugin, or null if it isn't loaded
- Throws:
ClassCastException- if the requesting plugin does not implementExternalPluginIllegalStateException- if this method is called before all plugins have loaded
-