Class Plugin

java.lang.Object
com.avrix.plugin.Plugin

public abstract class Plugin extends Object
Basic template for implementing the plugin entry point.
  • Constructor Details

    • Plugin

      public Plugin(Metadata metadata)
      Constructs a new Plugin with the specified metadata. Metadata is transferred when the plugin is loaded into the game context.
      Parameters:
      metadata - The Metadata associated with this plugin.
  • Method Details

    • getDefaultConfig

      public final YamlFile getDefaultConfig()
      Returns the default configuration file.
      Returns:
      a YamlFile object, or null
    • getConfigFolder

      public final File getConfigFolder()
      Returns a File object representing the configuration directory for this plugin. The directory path is normalized to prevent problems with various file systems.
      Returns:
      A File object pointing to the normalized path to the plugin configuration directory.
    • getMetadata

      public final Metadata getMetadata()
      Returns the Metadata associated with this plugin.
      Returns:
      The Metadata of the plugin.
    • loadDefaultConfig

      public final void loadDefaultConfig()
      Loading the default configuration file. If there is no config in the plugin resources folder, it is saved from the Jar archive and then loaded.

      If the configuration file cannot be loaded (for example, it is not in the Jar folder), then a new empty config is created.

    • copyConfigFromJar

      public void copyConfigFromJar(String fileName, File destination)
      Copies a configuration file from the jar archive to the specified destination.
      Parameters:
      fileName - the name of the configuration file to be copied
      destination - the destination file where the configuration will be copied
    • loadConfig

      public final YamlFile loadConfig(String configPath)
      Loading the configuration file. If there is no config in the plugin resources folder, it is saved from the Jar archive and then loaded.

      If the configuration file cannot be loaded (for example, it is not in the Jar folder), then a new empty config is created.

      Parameters:
      configPath - path to the configuration file, relative to the plugin resources folder/root folder inside the Jar
      Returns:
      returns a YamlFile object, which is a configuration file.
    • onInitialize

      public abstract void onInitialize()
      Called when the plugin is initialized.

      Implementing classes should override this method to provide the initialization logic.