java.lang.Object
dev.truewinter.twiliocallrouter.plugin.Plugin

public abstract class Plugin extends Object
All plugins must extend this class
  • 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 the getPluginByName(String) method.
    • registerListeners

      protected final void registerListeners(@NotNull Plugin plugin, @NotNull Listener listener)
      Use this method to register event listeners
      Parameters:
      plugin - An instance of the plugin
      listener - An instance of the event listener class
    • getLogger

      @NotNull protected final Logger 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 the ExternalPlugin.onAllPluginsLoaded() method has been called. The requesting plugin (the one calling this method) must implement ExternalPlugin to 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 implement ExternalPlugin
      IllegalStateException - if this method is called before all plugins have loaded