Package com.kamikazejam.kamicommon
Class KamiPlugin
java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
com.kamikazejam.kamicommon.KamiPlugin
- All Implemented Interfaces:
ObservableConfig,CoreMethods,Named,CommandExecutor,TabCompleter,TabExecutor,Listener,Plugin
public abstract class KamiPlugin
extends JavaPlugin
implements Listener, Named, CoreMethods, ObservableConfig
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancompareVersions(String minVer, String currentVer) Requires ver format to be int.int.int...@NotNull KamiConfigExt@NotNull KamiConfigExt@NotNull KamiConfigExtfinal @NotNull KamiConfigExtCan override if feature configs are stored in a subpackage of the jarfinal @NotNull KamiConfigExtfinal @NotNull KamiConfigExtCan override if module configs are stored in a subpackage of the jarbooleanShould we automatically load the KamiConfig on enable?final voidabstract voidCalled First in JavaPlugin.onDisable()voidCalled after both onDisableInner and listeners, tasks, and disableables are unregistered
Also called after modules, features, and commands are unregistered
You can use this method to cleanup databases or anything else that should come after module/features shutdownsfinal voidonEnable()abstract voidvoidbooleanvoidonLoad()voidvoidvoidfinal intregisterCommands(KamiCommand... commands) Registers the provided commands with this plugin.booleanregisterConfigObserver(@NotNull ConfigObserver observer) Registers an observer with the default KamiPlugin config (if not already registered)
Refer to theConfigObserverdocs for information on its lifecycle events.final intregisterDisableables(Disableable... disableables) Registers one or more disableable objects for this plugin.
The disableables will be automatically disabled when the plugin is disabled.voidregisterFeature(Feature... features) final intregisterListeners(Listener... listeners) Registers one or more listeners for this plugin.
The listeners will be automatically unregistered when the plugin is disabled.voidregisterModule(Module... modules) final intregisterTasks(BukkitTask... tasks) Registers one or more tasks for this plugin.
The tasks will be automatically cancelled when the plugin is disabled.voidvoidvoidReload the default KamiConfig for this plugin, notifying all registered observers of the change.
Equivalent toreloadKamiConfig()voidfinal intUnregisters ALL commands that this plugin has registered.final intunregisterCommands(KamiCommand... commands) Unregisters the specified commands, if this plugin has registered them prior.voidunregisterConfigObserver(@NotNull ConfigObserver observer) Unregisters an observer from this plugin's default KamiConfigvoidUnregisters ALL observers from this plugin's default KamiConfig.
Intended for shutdown logic, but can be used at any time.final intUnregisters ALL disableable objects from this plugin.final intunregisterDisableables(Disableable... disableables) Unregisters one or more disableable objects from this plugin.final intUnregisters ALL listeners from this plugin.final intunregisterListeners(Listener... listeners) Unregisters one or more listeners from this plugin.final intUnregisters ALL tasks from this plugin.final intunregisterTasks(BukkitTask... tasks) Unregisters one or more tasks from this plugin.booleanverifyPluginVersion(com.google.gson.JsonObject o, String key, String pluginName, @Nullable KamiPlugin.ErrorPropertiesCallback callback) booleanverifyPluginVersion(String minVer, String pluginName, @Nullable KamiPlugin.ErrorPropertiesCallback callback) Methods inherited from class org.bukkit.plugin.java.JavaPlugin
getClassLoader, getCommand, getConfig, getDatabase, getDatabaseClasses, getDataFolder, getDefaultWorldGenerator, getDescription, getFile, getLogger, getPlugin, getPluginLoader, getProvidingPlugin, getResource, getServer, getTextResource, initialize, installDDL, isEnabled, isInitialized, isNaggable, onCommand, onTabComplete, removeDDL, saveDefaultConfig, 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.command.TabCompleter
onTabComplete
-
Constructor Details
-
KamiPlugin
public KamiPlugin()
-
-
Method Details
-
onLoad
public void onLoad()- Specified by:
onLoadin interfacePlugin- Overrides:
onLoadin classJavaPlugin
-
onLoadPre
public void onLoadPre() -
onLoadInner
public void onLoadInner() -
onLoadPost
public void onLoadPost() -
onEnable
public final void onEnable()- Specified by:
onEnablein interfacePlugin- Overrides:
onEnablein classJavaPlugin
-
onEnablePre
public boolean onEnablePre() -
onEnableInner
public abstract void onEnableInner() -
isAutoLoadKamiConfig
public boolean isAutoLoadKamiConfig()Should we automatically load the KamiConfig on enable? -
onEnablePost
public void onEnablePost() -
getKamiConfig
- Specified by:
getKamiConfigin interfaceCoreMethods
-
reloadKamiConfig
public void reloadKamiConfig() -
createKamiConfig
-
reloadConfig
public void reloadConfig()- Specified by:
reloadConfigin interfaceCoreMethods- Specified by:
reloadConfigin interfacePlugin- Overrides:
reloadConfigin classJavaPlugin
-
saveConfig
public void saveConfig()- Specified by:
saveConfigin interfaceCoreMethods- Specified by:
saveConfigin interfacePlugin- Overrides:
saveConfigin classJavaPlugin
-
onDisable
public final void onDisable()- Specified by:
onDisablein interfacePlugin- Overrides:
onDisablein classJavaPlugin
-
onDisableInner
public abstract void onDisableInner()Called First in JavaPlugin.onDisable() -
onDisablePost
public void onDisablePost()Called after both onDisableInner and listeners, tasks, and disableables are unregistered
Also called after modules, features, and commands are unregistered
You can use this method to cleanup databases or anything else that should come after module/features shutdowns -
getModuleYmlPath
Can override if module configs are stored in a subpackage of the jar -
getFeatureYmlPath
Can override if feature configs are stored in a subpackage of the jar -
registerListeners
Registers one or more listeners for this plugin.
The listeners will be automatically unregistered when the plugin is disabled.
Previously registered listeners will not be registered again.- Specified by:
registerListenersin interfaceCoreMethods- Parameters:
listeners- The listeners to register- Returns:
- The number of listeners that were registered from this call
-
unregisterListeners
Unregisters one or more listeners from this plugin.- Specified by:
unregisterListenersin interfaceCoreMethods- Parameters:
listeners- The listeners to unregister- Returns:
- The number of listeners that were unregistered from this call
-
unregisterListeners
public final int unregisterListeners()Unregisters ALL listeners from this plugin.- Specified by:
unregisterListenersin interfaceCoreMethods- Returns:
- The number of listeners that were unregistered from this call
-
registerDisableables
Registers one or more disableable objects for this plugin.
The disableables will be automatically disabled when the plugin is disabled.
Previously registered disableables will not be registered again.- Specified by:
registerDisableablesin interfaceCoreMethods- Parameters:
disableables- The disableable objects to register- Returns:
- The number of disableables that were registered from this call
-
unregisterDisableables
Unregisters one or more disableable objects from this plugin.- Specified by:
unregisterDisableablesin interfaceCoreMethods- Parameters:
disableables- The disableable objects to unregister- Returns:
- The number of disableables that were unregistered from this call
-
unregisterDisableables
public final int unregisterDisableables()Unregisters ALL disableable objects from this plugin.- Specified by:
unregisterDisableablesin interfaceCoreMethods- Returns:
- The number of disableables that were unregistered from this call
-
registerTasks
Registers one or more tasks for this plugin.
The tasks will be automatically cancelled when the plugin is disabled.
Previously registered tasks will not be registered again.- Specified by:
registerTasksin interfaceCoreMethods- Parameters:
tasks- The tasks to register- Returns:
- The number of tasks that were registered from this call
-
unregisterTasks
Unregisters one or more tasks from this plugin.- Specified by:
unregisterTasksin interfaceCoreMethods- Parameters:
tasks- The tasks to unregister- Returns:
- The number of tasks that were unregistered from this call
-
unregisterTasks
public final int unregisterTasks()Unregisters ALL tasks from this plugin.- Specified by:
unregisterTasksin interfaceCoreMethods- Returns:
- The number of tasks that were unregistered from this call
-
registerCommands
Registers the provided commands with this plugin.
Previously registered commands will not be registered again.- Specified by:
registerCommandsin interfaceCoreMethods- Parameters:
commands- The commands to register- Returns:
- The number of commands that were registered with this plugin
-
unregisterCommands
Unregisters the specified commands, if this plugin has registered them prior.
! If a KamiCommand is passed here that was not registered by this plugin, it will not be unregistered !- Specified by:
unregisterCommandsin interfaceCoreMethods- Returns:
- The number of commands that were unregistered from this plugin
-
unregisterCommands
public final int unregisterCommands()Unregisters ALL commands that this plugin has registered.- Specified by:
unregisterCommandsin interfaceCoreMethods- Returns:
- The number of commands that were unregistered
-
registerModule
-
registerFeature
-
verifyPluginVersion
public boolean verifyPluginVersion(com.google.gson.JsonObject o, String key, String pluginName, @Nullable @Nullable KamiPlugin.ErrorPropertiesCallback callback) -
verifyPluginVersion
public boolean verifyPluginVersion(String minVer, String pluginName, @Nullable @Nullable KamiPlugin.ErrorPropertiesCallback callback) -
compareVersions
Requires ver format to be int.int.int... (ints separated by periods)- Returns:
- If currentVer satisfies minVer
-
getModulesConfig
-
createModulesConfig
-
getFeaturesConfig
-
createFeaturesConfig
-
registerConfigObserver
Registers an observer with the default KamiPlugin config (if not already registered)
Refer to theConfigObserverdocs for information on its lifecycle events.- Specified by:
registerConfigObserverin interfaceObservableConfig- Returns:
- If the observer was successfully registered from this call (false if already registered)
-
unregisterConfigObserver
Unregisters an observer from this plugin's default KamiConfig- Specified by:
unregisterConfigObserverin interfaceObservableConfig
-
unregisterConfigObservers
public void unregisterConfigObservers()Unregisters ALL observers from this plugin's default KamiConfig.
Intended for shutdown logic, but can be used at any time.- Specified by:
unregisterConfigObserversin interfaceObservableConfig
-
reloadObservableConfig
public void reloadObservableConfig()Reload the default KamiConfig for this plugin, notifying all registered observers of the change.
Equivalent toreloadKamiConfig()- Specified by:
reloadObservableConfigin interfaceObservableConfig
-