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 Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractAddon(String githubUser, String githubRepo, String githubBranch, String autoUpdateKey) Live addon constructor.protectedAbstractAddon(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file, String githubUser, String githubRepo, String githubBranch, String autoUpdateKey) Testing addon constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCalled when auto update is enabledstatic NamespacedKeyCreates aNamespacedKeyfrom the given stringprotected abstract voiddisable()Called when disablingprotected abstract voidenable()Called when enablingstatic AddonConfigGet theAddonConfigThis returns the default bug tracker URL by the given GitHub username and repository in constructor.final FileConfigurationGet theAddonConfigfinal EnvironmentGet the currentEnvironmentstatic <T extends AbstractAddon>
TGet an instance of extended class ofAbstractAddonfinal JavaPluginUsed for Slimefun to get instance of thisJavaPluginstatic PluginCommandgetPluginCommand(String command) Get thePluginCommandofAbstractAddon.static SchedulerGet theSchedulerstatic intReturns the total number of Slimefun ticks that have occurredfinal booleanIf the auto update is enabledprotected voidload()Called when loadingstatic voidCall the logger to log a message with arguments.static voidCall the logger to log a message with arguments.final voidUse disable() instead.final voidonEnable()Use enable() insteadfinal voidonLoad()Use load() insteadfinal voidSave default config.static voidsendConsole(String message, Object... args) Call theConsoleCommandSenderto send a message with arguments.Methods inherited from class org.bukkit.plugin.java.JavaPlugin
getClassLoader, getCommand, getDataFolder, getDefaultBiomeProvider, getDefaultWorldGenerator, getDescription, getFile, getLogger, getPlugin, getPluginLoader, getProvidingPlugin, getResource, getServer, getTextResource, isEnabled, isNaggable, onCommand, onTabComplete, reloadConfig, saveConfig, saveResource, setEnabled, setNaggable, toStringMethods inherited from class org.bukkit.plugin.PluginBase
equals, getName, hashCodeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.bukkit.plugin.Plugin
getComponentLogger, getLog4JLogger, getSLF4JLoggerMethods inherited from interface io.github.thebusybiscuit.slimefun4.api.SlimefunAddon
getLogger, getName, getPluginVersion, getWikiURL, hasDependency
-
Constructor Details
-
AbstractAddon
protected AbstractAddon(String githubUser, String githubRepo, String githubBranch, String autoUpdateKey) Live addon constructor.- Parameters:
githubUser- GitHub username of this projectgithubRepo- GitHub repository of this projectgithubBranch- GitHub branch of this projectautoUpdateKey- Auto update key in the config
-
AbstractAddon
protected AbstractAddon(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file, String githubUser, String githubRepo, String githubBranch, String autoUpdateKey) Testing addon constructor- Parameters:
loader- theJavaPluginLoaderdescription- thePluginDescriptionFileof plugindataFolder- theFileof plugin's data folderfile- theFileof plugingithubUser- GitHub username of this projectgithubRepo- GitHub repository of this projectgithubBranch- GitHub branch of this projectautoUpdateKey- Auto update key in the config
-
-
Method Details
-
getInstance
Get an instance of extended class ofAbstractAddon- Type Parameters:
T- The class that extendsAbstractAddon, which is the real addon main class- Returns:
- The instance of extended class of
AbstractAddon
-
getAddonConfig
Get theAddonConfig- Returns:
- the
AddonConfig
-
getScheduler
Get theScheduler- 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
Get thePluginCommandofAbstractAddon.- Returns:
- the
PluginCommandofAbstractAddon.
-
createKey
Creates aNamespacedKeyfrom the given string- Parameters:
key- theStringrepresentation of the key- Returns:
- the
NamespacedKeycreated from given string
-
log
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 logLevelmessage- the messageargs- 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(). -
sendConsole
Call theConsoleCommandSenderto send a message with arguments. ChatColor code will be translated automatically, and message is dealt with MessageFormat#format().- Parameters:
message- the messageargs- the arguments with in- See Also:
-
onLoad
public final void onLoad()Use load() instead- Specified by:
onLoadin interfacePlugin- Overrides:
onLoadin classJavaPlugin
-
onEnable
public final void onEnable()Use enable() instead- Specified by:
onEnablein interfacePlugin- Overrides:
onEnablein classJavaPlugin
-
onDisable
public final void onDisable()Use disable() instead.- Specified by:
onDisablein interfacePlugin- Overrides:
onDisablein classJavaPlugin
-
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
Used for Slimefun to get instance of thisJavaPlugin- Specified by:
getJavaPluginin interfaceio.github.thebusybiscuit.slimefun4.api.SlimefunAddon- Returns:
- the instance of this
JavaPlugin
-
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:
getBugTrackerURLin interfaceio.github.thebusybiscuit.slimefun4.api.SlimefunAddon- Returns:
- the default bug tracker url
-
getEnvironment
Get the currentEnvironment- Returns:
- the current
Environment
-
isAutoUpdateEnabled
public final boolean isAutoUpdateEnabled()If the auto update is enabled- Returns:
- if the auto update is enabled
-
getConfig
Get theAddonConfig- Specified by:
getConfigin interfacePlugin- Overrides:
getConfigin classJavaPlugin- Returns:
- the
AddonConfig
-
saveDefaultConfig
public final void saveDefaultConfig()Save default config. Overridden and does nothing since it is handled in #onEnable()- Specified by:
saveDefaultConfigin interfacePlugin- Overrides:
saveDefaultConfigin classJavaPlugin
-