Module gomint.api

Class Plugin


  • public class Plugin
    extends Object

    Base class for any plugin to be created for use with the GoMint system. Below you will find an in-depth explanation of the GoMint plugin system.

    When creating a plugin you should take care that the plugin implementation class directly inherits from the base Plugin class. It is important that the implementation will not be considered a valid plugin by GoNets plugin loader in case it only indirectly inherits from plugin. There are also several annotation which are required on any plugin and which you need to specify under all circumstances so that your plugin will actually be loaded. Namely, these are:

    • @Name( "NameOfPlugin" ) - The name of your plugin; for internal use only.
    • @Version( major = 1, minor = 0 ) - The current version of your plugin; for incremental updates.
    Furthermore you may specify additional annotation as needed, for example a @Startup annotation to specify upmost priority in loading the specified plugin.

    Any plugin will live through up to 4 different stages which will be explained in detail below. Please note that only the very first stage is obligatory (assumed you have been able to put your - correct - implementation, as shown above, into the right folder of the application), that is the DETECTION stage.

    1. DETECTION - In this stage only the bare meta-information provided by annotations is actually loaded.
    2. INSTALLATION - In this stage the classes of the plugin are loaded and the startup hook will be invoked.
    3. RUNTIME - The main stage your plugin will (probably) be in most of the time (expect your plugin is full of shit nobody wants to install).
    4. UNINSTALLATION - In this stage your plugin will be removed and - as the name obviously indicates - uninstalled.

    Version:
    1.0
    Author:
    BlackyPaw
    • Constructor Detail

      • Plugin

        public Plugin()
    • Method Detail

      • onStartup

        public void onStartup()
        Implementation hook. This hook is invoked once the plugin is being installed.
      • onInstall

        public void onInstall()
        Implementation hook. This hook is invoked once the plugin enters the runtime stage.
      • onUninstall

        public void onUninstall()
        Implementation hook. This hook is invoked once the plugin is being uninstalled.
      • isInstalled

        public boolean isInstalled()
        Check plugin installation status.
        Returns:
        Plugin installation status
      • registerCommand

        public void registerCommand​(Command command)
        Register a new command to this plugin
        Parameters:
        command - which should be registered
      • registerListener

        public void registerListener​(EventListener listener)
        Register a new listener to this plugin
        Parameters:
        listener - The listener which should be registered
      • unregisterListener

        public void unregisterListener​(EventListener listener)
        Unregister a listener
        Parameters:
        listener - which should be unregistered
      • uninstall

        protected void uninstall()
        Disables the plugin if - and only if - the plugin is currently in the runtime stage. Under all other circumstances invocation of this method will show no effect.
      • getResourceAsStream

        public final InputStream getResourceAsStream​(String name)
        Get a resource from within this plugins jar or container. Care must be taken to close the returned stream.
        Parameters:
        name - the full path name of this resource
        Returns:
        the stream for getting this resource, or null if it does not exist
      • getDataFolder

        public final File getDataFolder()
        Gets the data folder where this plugin may store arbitrary data.
        Returns:
        the data folder of this plugin