Package co.crystaldev.alpinecore
Class AlpinePlugin
java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
co.crystaldev.alpinecore.AlpinePlugin
- All Implemented Interfaces:
org.bukkit.command.CommandExecutor
,org.bukkit.command.TabCompleter
,org.bukkit.command.TabExecutor
,org.bukkit.event.Listener
,org.bukkit.plugin.Plugin
public abstract class AlpinePlugin
extends org.bukkit.plugin.java.JavaPlugin
implements org.bukkit.event.Listener
The base class for Alpine plugins. Use this
instead of
JavaPlugin
.- Since:
- 0.1.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
-
Field Summary
Modifier and TypeFieldDescriptionprotected dev.rollczi.litecommands.LiteCommands<org.bukkit.command.CommandSender>
Manages anyAlpineCommand
s for the pluginprotected ConfigManager
Manages anyAlpineConfig
s for the plugin -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
addActivatable
(Activatable activatable) Registers anActivatable
to the plugin.final <T extends AlpineConfig>
TgetConfiguration
(@NotNull Class<T> clazz) Retrieves a configuration instance from the manager.long
Retrieves the current server tick.final void
Logs an information message with color formatting.final void
Logs a severe message and error with color formatting.final void
Logs a message at a given level with color formatting.boolean
onActivatablePreload
(@NotNull String activatableClasspath) Internally invoked before loading an activatable object.final void
final void
onEnable()
void
onStart()
Called when the plugin is enabling.void
onStop()
Called when the plugin is disabling.void
registerSerializers
(@NotNull SerializerRegistry serializerRegistry) Register custom serializers with the providedSerializerRegistry
.final void
removeActivatable
(Activatable activatable) Unegisters anActivatable
from the plugin.void
setupCommandManager
(@NotNull dev.rollczi.litecommands.LiteCommandsBuilder<org.bukkit.command.CommandSender, dev.rollczi.litecommands.bukkit.LiteBukkitSettings, ?> builder) Configures the command manager for the plugin with custom commands, settings, and message handlers.void
setupDefaultConfiguration
(@NotNull co.crystaldev.alpinecore.config.AlpineCoreConfig config) Configures the default configuration settings for this AlpineCore plugin.void
setupDefaultStyles
(@NotNull AlpinePlugin.StyleConsumer styleConsumer) Configures default styles for text formatting within the plugin.void
setupDefaultVariables
(@NotNull AlpinePlugin.VariableConsumer variableConsumer) Sets up default variables for use within the plugin.@NotNull net.kyori.adventure.text.minimessage.MiniMessage
setupMiniMessage
(net.kyori.adventure.text.minimessage.MiniMessage.Builder builder) Configures the MiniMessage parser with custom tag resolvers and other settings.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, onLoad, onTabComplete, reloadConfig, removeDDL, saveConfig, saveDefaultConfig, saveResource, setEnabled, setNaggable, toString
Methods inherited from class org.bukkit.plugin.PluginBase
equals, getName, hashCode
-
Field Details
-
configManager
Manages anyAlpineConfig
s for the plugin -
commandManager
protected dev.rollczi.litecommands.LiteCommands<org.bukkit.command.CommandSender> commandManagerManages anyAlpineCommand
s for the plugin
-
-
Constructor Details
-
AlpinePlugin
public AlpinePlugin()
-
-
Method Details
-
onStart
public void onStart()Called when the plugin is enabling. -
onStop
public void onStop()Called when the plugin is disabling. -
onActivatablePreload
Internally invoked before loading an activatable object. Determines whether an activatable object should be initialized. By default, it allows all activatable objects to proceed with initialization.- Parameters:
activatableClasspath
- The classpath of the activatable object.- Returns:
- boolean True to initialize the activatable object, false otherwise.
-
registerSerializers
Register custom serializers with the providedSerializerRegistry
.
This method allows developers to register custom serializers for specific data types with a centralSerializerRegistry
instance.- Parameters:
serializerRegistry
- TheSerializerRegistry
where custom serializers should be registered.
-
setupCommandManager
public void setupCommandManager(@NotNull @NotNull dev.rollczi.litecommands.LiteCommandsBuilder<org.bukkit.command.CommandSender, dev.rollczi.litecommands.bukkit.LiteBukkitSettings, ?> builder) Configures the command manager for the plugin with custom commands, settings, and message handlers. This method sets up theLiteCommandsBuilder
with the necessary configurations for command parsing. It allows for further customization by invoking an overridable method that plugins can implement to modify the command manager settings or add additional commands.- Parameters:
builder
- the pre-configuredLiteCommandsBuilder
ready for plugin-specific configurations.- See Also:
-
LiteCommandsBuilder
LiteCommandsBukkit.builder(String)
-
setupDefaultStyles
Configures default styles for text formatting within the plugin. This method is used to add custom tags that modify the appearance of text.
It provides a straightforward way to enrich text presentation by associating custom style tags with their corresponding formatting instructions.- Parameters:
styleConsumer
- The consumer that accepts style definitions.
-
setupDefaultVariables
Sets up default variables for use within the plugin.
Unlike styles, variables are placeholders that are not processed for formatting. This method allows for the registration of default variables providing a simple way to incorporate dynamic content.- Parameters:
variableConsumer
- The consumer that accepts variable definitions.
-
setupDefaultConfiguration
public void setupDefaultConfiguration(@NotNull @NotNull co.crystaldev.alpinecore.config.AlpineCoreConfig config) Configures the default configuration settings for this AlpineCore plugin.
Implementations can override this method to apply custom configurations or adjust the existing ones.- Parameters:
config
- the configuration.- See Also:
-
AlpineCoreConfig
-
setupMiniMessage
@NotNull public @NotNull net.kyori.adventure.text.minimessage.MiniMessage setupMiniMessage(@NotNull net.kyori.adventure.text.minimessage.MiniMessage.Builder builder) Configures the MiniMessage parser with custom tag resolvers and other settings. This method allows for customization of the MiniMessage parser.- Parameters:
builder
- The MiniMessageMiniMessage.Builder
instance to be configured with custom settings.- Returns:
- The MiniMessage instance.
- See Also:
-
MiniMessage
-
onEnable
public final void onEnable()- Specified by:
onEnable
in interfaceorg.bukkit.plugin.Plugin
- Overrides:
onEnable
in classorg.bukkit.plugin.java.JavaPlugin
-
onDisable
public final void onDisable()- Specified by:
onDisable
in interfaceorg.bukkit.plugin.Plugin
- Overrides:
onDisable
in classorg.bukkit.plugin.java.JavaPlugin
-
getConfiguration
Retrieves a configuration instance from the manager.- Type Parameters:
T
- The configuration type- Parameters:
clazz
- The configuration class- Returns:
- The configuration instance
-
getCurrentTick
public long getCurrentTick()Retrieves the current server tick.- Returns:
- The current tick.
-
log
Logs an information message with color formatting.- Parameters:
message
- The message to log
-
log
Logs a severe message and error with color formatting.- Parameters:
message
- The message to logthrowable
- The error or exception
-
log
Logs a message at a given level with color formatting.- Parameters:
level
- The log levelmessage
- The message to log
-
addActivatable
Registers anActivatable
to the plugin.- Parameters:
activatable
- The activatable
-
removeActivatable
Unegisters anActivatable
from the plugin.- Parameters:
activatable
- The activatable
-