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, io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner, org.bukkit.command.CommandExecutor, org.bukkit.command.TabCompleter, org.bukkit.command.TabExecutor, org.bukkit.plugin.Plugin

@ParametersAreNonnullByDefault public abstract class AbstractAddon extends org.bukkit.plugin.java.JavaPlugin implements io.github.thebusybiscuit.slimefun4.api.SlimefunAddon
An abstract SlimefunAddon class that contains some utilities.

Extend this as your main class to use them.

Modified from InfinityLib

  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractAddon(String githubUser, String githubRepo, String githubBranch, String autoUpdateKey)
    Live addon constructor.
    protected
    AbstractAddon(org.bukkit.plugin.java.JavaPluginLoader loader, org.bukkit.plugin.PluginDescriptionFile description, File dataFolder, File file, String githubUser, String githubRepo, String githubBranch, String autoUpdateKey)
    Testing addon constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Called when auto update is enabled
    static org.bukkit.NamespacedKey
    Creates a NamespacedKey from the given string
    protected abstract void
    Called when disabling
    protected abstract void
    Called when enabling
    Get the AddonConfig
    This returns the default bug tracker URL by the given GitHub username and repository in constructor.
    final org.bukkit.configuration.file.FileConfiguration
    Get the AddonConfig
    Get the current Environment
     
     
     
    static <T extends AbstractAddon>
    T
    Get an instance of extended class of AbstractAddon
    final org.bukkit.plugin.java.JavaPlugin
    Used for Slimefun to get instance of this JavaPlugin
    static org.bukkit.command.PluginCommand
    Get the PluginCommand of AbstractAddon.
    static Scheduler
    Get the Scheduler
    static int
    Returns the total number of Slimefun ticks that have occurred
    final boolean
    If the auto update is enabled
    protected void
    Called when loading
    static void
    log(Level level, String message, Object... args)
    Call the logger to log a message with arguments.
    static void
    log(Level level, Throwable ex, String message, Object... args)
    Call the logger to log a message with arguments.
    final void
    Use disable() instead.
    final void
    Use enable() instead
    final void
    Use load() instead
    final void
    Save default config.
    static void
    sendConsole(String message, Object... args)
    Call the ConsoleCommandSender to send a message with arguments.

    Methods inherited from class org.bukkit.plugin.java.JavaPlugin

    getClassLoader, getCommand, getDataFolder, getDefaultBiomeProvider, getDefaultWorldGenerator, getDescription, getFile, getLifecycleManager, getLogger, getPlugin, getPluginLoader, getPluginMeta, getProvidingPlugin, getResource, getServer, getTextResource, init, init, isEnabled, isNaggable, onCommand, onTabComplete, registerCommand, registerCommand, registerCommand, registerCommand, reloadConfig, saveConfig, saveResource, setEnabled, setNaggable, toString

    Methods inherited from class org.bukkit.plugin.PluginBase

    equals, getName, hashCode

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.bukkit.plugin.Plugin

    getComponentLogger, getDataPath, getLog4JLogger, getSLF4JLogger

    Methods inherited from interface io.github.thebusybiscuit.slimefun4.api.SlimefunAddon

    getLogger, getName, getPluginVersion, hasDependency
  • Constructor Details

    • AbstractAddon

      protected AbstractAddon(String githubUser, String githubRepo, String githubBranch, String autoUpdateKey)
      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
    • AbstractAddon

      protected AbstractAddon(org.bukkit.plugin.java.JavaPluginLoader loader, org.bukkit.plugin.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 org.bukkit.command.PluginCommand getPluginCommand(@Nonnull String command)
      Get the PluginCommand of AbstractAddon.
      Returns:
      the PluginCommand of AbstractAddon.
    • createKey

      @Nonnull public static org.bukkit.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 org.bukkit.plugin.Plugin
      Overrides:
      onLoad in class org.bukkit.plugin.java.JavaPlugin
    • onEnable

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

      public final void onDisable()
      Use disable() instead.
      Specified by:
      onDisable in interface org.bukkit.plugin.Plugin
      Overrides:
      onDisable in class org.bukkit.plugin.java.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 org.bukkit.plugin.java.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 final 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 org.bukkit.configuration.file.FileConfiguration getConfig()
      Get the AddonConfig
      Specified by:
      getConfig in interface org.bukkit.plugin.Plugin
      Overrides:
      getConfig in class org.bukkit.plugin.java.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 org.bukkit.plugin.Plugin
      Overrides:
      saveDefaultConfig in class org.bukkit.plugin.java.JavaPlugin
    • getGithubUser

      public String getGithubUser()
    • getGithubRepo

      public String getGithubRepo()
    • getGithubBranch

      public String getGithubBranch()