Class AbstractAddon

java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
net.guizhanss.guizhanlib.slimefun.addon.AbstractAddon
All Implemented Interfaces:
io.github.thebusybiscuit.slimefun4.api.SlimefunAddon, CommandExecutor, TabCompleter, TabExecutor, Plugin

@ParametersAreNonnullByDefault public abstract class AbstractAddon extends JavaPlugin implements io.github.thebusybiscuit.slimefun4.api.SlimefunAddon
An abstract SlimefunAddon class that contains the updater and some utilities.

Extend this as your main class to use them.

Modified from InfinityLib

Author:
Mooy1, ybw0014
  • Constructor Details

    • AbstractAddon

      public AbstractAddon(String githubUser, String githubRepo, String githubBranch, String autoUpdateKey)
      Live addon constructor

      Updater lang key is not used any more since it is not included in the lib anymore.

      Parameters:
      githubUser - GitHub username of this project
      githubRepo - GitHub repository of this project
      githubBranch - GitHub branch of this project
      autoUpdateKey - Auto update key in the config
    • AbstractAddon

      @Deprecated public AbstractAddon(String githubUser, String githubRepo, String githubBranch, String autoUpdateKey, String updaterLangKey)
      Deprecated.
      Updater lang key is not used any more since it is not included in the lib anymore.
      Live addon constructor
      Parameters:
      githubUser - GitHub username of this project
      githubRepo - GitHub repository of this project
      githubBranch - GitHub branch of this project
      autoUpdateKey - Auto update key in the config
      updaterLangKey - Updater language key in the config. Leave this empty if you want updater be in English.
    • AbstractAddon

      public AbstractAddon(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file, String githubUser, String githubRepo, String githubBranch, String autoUpdateKey)
      Testing addon constructor
      Parameters:
      loader - the JavaPluginLoader
      description - the PluginDescriptionFile of plugin
      dataFolder - the File of plugin's data folder
      file - the File of plugin
      githubUser - GitHub username of this project
      githubRepo - GitHub repository of this project
      githubBranch - GitHub branch of this project
      autoUpdateKey - Auto update key in the config
  • Method Details

    • getInstance

      @Nonnull public static <T extends AbstractAddon> T getInstance()
      Get an instance of extended class of AbstractAddon
      Type Parameters:
      T - The class that extends AbstractAddon, which is the real addon main class
      Returns:
      The instance of extended class of AbstractAddon
    • getAddonConfig

      @Nonnull public static AddonConfig getAddonConfig()
      Get the AddonConfig
      Returns:
      the AddonConfig
    • getScheduler

      @Nonnull public static Scheduler getScheduler()
      Get the Scheduler
      Returns:
      the Scheduler
    • getSlimefunTickCount

      public static int getSlimefunTickCount()
      Returns the total number of Slimefun ticks that have occurred
      Returns:
      total number of Slimefun ticks
    • getPluginCommand

      @Nonnull public static PluginCommand getPluginCommand(@Nonnull String command)
      Returns:
      the PluginCommand of AbstractAddon.
    • createKey

      @Nonnull public static NamespacedKey createKey(String key)
      Creates a NamespacedKey from the given string
      Parameters:
      key - the String representation of the key
      Returns:
      the NamespacedKey created from given string
    • log

      public static void log(@Nonnull Level level, @Nonnull String message, @Nullable Object... args)
      Call the logger to log a message with arguments. ChatColor code will be translated automatically, and message is dealt with MessageFormat#format().
      Parameters:
      level - the log Level
      message - the message
      args - the arguments with in
      See Also:
    • log

      public static void log(@Nonnull Level level, @Nonnull Throwable ex, @Nonnull String message, @Nullable Object... args)
      Call the logger to log a message with arguments. ChatColor code will be translated automatically, and message is dealt with MessageFormat#format().
      Parameters:
      level - the log Level
      ex - the Throwable exception
      message - the message
      args - the arguments with in
      See Also:
    • sendConsole

      public static void sendConsole(@Nonnull String message, @Nullable Object... args)
      Call the ConsoleCommandSender to send a message with arguments. ChatColor code will be translated automatically, and message is dealt with MessageFormat#format().
      Parameters:
      message - the message
      args - the arguments with in
      See Also:
    • onLoad

      public final void onLoad()
      Use load() instead
      Specified by:
      onLoad in interface Plugin
      Overrides:
      onLoad in class JavaPlugin
    • onEnable

      public final void onEnable()
      Use enable() instead
      Specified by:
      onEnable in interface Plugin
      Overrides:
      onEnable in class JavaPlugin
    • onDisable

      public final void onDisable()
      Use disable() instead.
      Specified by:
      onDisable in interface Plugin
      Overrides:
      onDisable in class JavaPlugin
    • load

      protected void load()
      Called when loading
    • enable

      protected abstract void enable()
      Called when enabling
    • disable

      protected abstract void disable()
      Called when disabling
    • autoUpdate

      protected void autoUpdate()
      Called when auto update is enabled
    • getJavaPlugin

      @Nonnull public final JavaPlugin getJavaPlugin()
      Used for Slimefun to get instance of this JavaPlugin
      Specified by:
      getJavaPlugin in interface io.github.thebusybiscuit.slimefun4.api.SlimefunAddon
      Returns:
      the instance of this JavaPlugin
    • getBugTrackerURL

      @Nonnull public String getBugTrackerURL()
      This returns the default bug tracker URL by the given GitHub username and repository in constructor.

      Override it if you don't use GitHub issues as bug tracker

      Specified by:
      getBugTrackerURL in interface io.github.thebusybiscuit.slimefun4.api.SlimefunAddon
      Returns:
      the default bug tracker url
    • getEnvironment

      @Nonnull public Environment getEnvironment()
      Get the current Environment
      Returns:
      the current Environment
    • isAutoUpdateEnabled

      public final boolean isAutoUpdateEnabled()
      If the auto update is enabled
      Returns:
      if the auto update is enabled
    • getConfig

      @Nonnull public final FileConfiguration getConfig()
      Get the AddonConfig
      Specified by:
      getConfig in interface Plugin
      Overrides:
      getConfig in class JavaPlugin
      Returns:
      the AddonConfig
    • saveDefaultConfig

      public final void saveDefaultConfig()
      Save default config. Overridden and does nothing since it is handled in #onEnable()
      Specified by:
      saveDefaultConfig in interface Plugin
      Overrides:
      saveDefaultConfig in class JavaPlugin