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
- Direct Known Subclasses:
KamiCommon
public abstract class KamiPlugin
extends JavaPlugin
implements Listener, Named, CoreMethods, ObservableConfig
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
compareVersions
(String minVer, String currentVer) Requires ver format to be int.int.int...@NotNull KamiConfigExt
Can override if feature configs are stored in a subpackage of the jar@NotNull KamiConfigExt
@NotNull KamiConfigExt
Can override if module configs are stored in a subpackage of the jarboolean
Should we automatically load the KamiConfig on enable?final void
abstract void
Called First in JavaPlugin.onDisable()void
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 shutdownsfinal void
onEnable()
abstract void
void
boolean
void
onLoad()
void
void
void
final int
registerCommands
(KamiCommand... commands) Registers the provided commands with this plugin.boolean
registerConfigObserver
(@NotNull ConfigObserver observer) Registers an observer with the default KamiPlugin config (if not already registered)
Refer to theConfigObserver
docs for information on its lifecycle events.final int
registerDisableables
(Disableable... disableables) Registers one or more disableable objects for this plugin.
The disableables will be automatically disabled when the plugin is disabled.void
registerFeature
(Feature... features) <F extends Feature>
voidregisterFeature
(Class<F> clazz) final int
registerListeners
(Listener... listeners) Registers one or more listeners for this plugin.
The listeners will be automatically unregistered when the plugin is disabled.void
registerModule
(Module... modules) <M extends Module>
voidregisterModule
(Class<M> clazz) final int
registerTasks
(BukkitTask... tasks) Registers one or more tasks for this plugin.
The tasks will be automatically cancelled when the plugin is disabled.void
void
void
Reload the default KamiConfig for this plugin, notifying all registered observers of the change.
Equivalent toreloadKamiConfig()
void
final int
Unregisters ALL commands that this plugin has registered.final int
unregisterCommands
(KamiCommand... commands) Unregisters the specified commands, if this plugin has registered them prior.void
unregisterConfigObserver
(@NotNull ConfigObserver observer) Unregisters an observer from this plugin's default KamiConfigvoid
Unregisters ALL observers from this plugin's default KamiConfig.
Intended for shutdown logic, but can be used at any time.final int
Unregisters ALL disableable objects from this plugin.final int
unregisterDisableables
(Disableable... disableables) Unregisters one or more disableable objects from this plugin.final int
Unregisters ALL listeners from this plugin.final int
unregisterListeners
(Listener... listeners) Unregisters one or more listeners from this plugin.final int
Unregisters ALL tasks from this plugin.final int
unregisterTasks
(BukkitTask... tasks) Unregisters one or more tasks from this plugin.boolean
verifyPluginVersion
(com.google.gson.JsonObject o, String key, String pluginName, @Nullable KamiPlugin.ErrorPropertiesCallback callback) boolean
verifyPluginVersion
(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, 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.command.TabCompleter
onTabComplete
-
Constructor Details
-
KamiPlugin
public KamiPlugin()
-
-
Method Details
-
onLoad
public void onLoad()- Specified by:
onLoad
in interfacePlugin
- Overrides:
onLoad
in classJavaPlugin
-
onLoadPre
public void onLoadPre() -
onLoadInner
public void onLoadInner() -
onLoadPost
public void onLoadPost() -
onEnable
public final void onEnable()- Specified by:
onEnable
in interfacePlugin
- Overrides:
onEnable
in 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:
getKamiConfig
in interfaceCoreMethods
-
reloadKamiConfig
public void reloadKamiConfig() -
reloadConfig
public void reloadConfig()- Specified by:
reloadConfig
in interfaceCoreMethods
- Specified by:
reloadConfig
in interfacePlugin
- Overrides:
reloadConfig
in classJavaPlugin
-
saveConfig
public void saveConfig()- Specified by:
saveConfig
in interfaceCoreMethods
- Specified by:
saveConfig
in interfacePlugin
- Overrides:
saveConfig
in classJavaPlugin
-
onDisable
public final void onDisable()- Specified by:
onDisable
in interfacePlugin
- Overrides:
onDisable
in 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:
registerListeners
in 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:
unregisterListeners
in 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:
unregisterListeners
in 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:
registerDisableables
in 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:
unregisterDisableables
in 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:
unregisterDisableables
in 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:
registerTasks
in 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:
unregisterTasks
in 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:
unregisterTasks
in 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:
registerCommands
in 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:
unregisterCommands
in 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:
unregisterCommands
in interfaceCoreMethods
- Returns:
- The number of commands that were unregistered
-
registerModule
-
registerModule
-
registerFeature
-
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
-
getFeaturesConfig
-
registerConfigObserver
Registers an observer with the default KamiPlugin config (if not already registered)
Refer to theConfigObserver
docs for information on its lifecycle events.- Specified by:
registerConfigObserver
in 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:
unregisterConfigObserver
in 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:
unregisterConfigObservers
in interfaceObservableConfig
-
reloadObservableConfig
public void reloadObservableConfig()Reload the default KamiConfig for this plugin, notifying all registered observers of the change.
Equivalent toreloadKamiConfig()
- Specified by:
reloadObservableConfig
in interfaceObservableConfig
-