Class ArtificialEnchantmentsPlugin
- All Implemented Interfaces:
io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner,net.kyori.adventure.key.Namespaced,org.bukkit.command.CommandExecutor,org.bukkit.command.TabCompleter,org.bukkit.command.TabExecutor,org.bukkit.plugin.Plugin
This plugin provides custom enchantment capabilities for Paper 1.21+ servers. It initializes the API on enable, registers all event listeners, and manages the lifecycle of internal services including the optional PacketEvents integration.
Lifecycle:
1. onEnable() - Initializes API, registers listeners, starts tick task
2. onDisable() - Stops tick task, disables PacketEvents, shuts down spine
Services:
- Enchantment table listener for custom enchantments in tables
- Anvil listener for combining and applying enchantments
- Block break loot listener for drop modifications
- Effect listener for dispatching enchantment effects
- Tick task for periodic held/armor effects
- Optional PacketEvents adapter for per-player visuals
- Since:
- 0.1.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable PacketEventsAdapterGets the PacketEvents adapter if available and enabled.booleanChecks if PacketEvents integration is active.voidDisables the plugin, stopping all tasks and cleaning up resources.voidonEnable()Enables the plugin, initializing the API and registering all listeners.Methods inherited from class org.bukkit.plugin.java.JavaPlugin
getClassLoader, getCommand, getConfig, getDataFolder, getDefaultBiomeProvider, getDefaultWorldGenerator, getDescription, getFile, getLifecycleManager, getLogger, getPlugin, getPluginLoader, getPluginMeta, getProvidingPlugin, getResource, getServer, getTextResource, init, init, isEnabled, isNaggable, onCommand, onLoad, onTabComplete, registerCommand, registerCommand, registerCommand, registerCommand, reloadConfig, saveConfig, saveDefaultConfig, saveResource, setEnabled, setNaggable, toStringMethods inherited from class org.bukkit.plugin.PluginBase
equals, getName, hashCode, namespaceMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.bukkit.plugin.Plugin
getComponentLogger, getDataPath, getLog4JLogger, getSLF4JLogger
-
Constructor Details
-
ArtificialEnchantmentsPlugin
public ArtificialEnchantmentsPlugin()Creates a new plugin instance.This constructor is called by Bukkit's plugin loader. The actual initialization happens in
onEnable().
-
-
Method Details
-
onEnable
public void onEnable()Enables the plugin, initializing the API and registering all listeners.This method:
- Creates or retrieves the shared API instance
- Registers enchantment table listener for custom enchantments
- Registers anvil listener for enchantment combination
- Registers block break loot listener for drop modifications
- Registers effect listener for enchantment triggers
- Starts the tick task for periodic effects
- Initializes PacketEvents integration if available
- Specified by:
onEnablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onEnablein classorg.bukkit.plugin.java.JavaPlugin
-
onDisable
public void onDisable()Disables the plugin, stopping all tasks and cleaning up resources.This method:
- Stops the tick task
- Disables PacketEvents adapter if enabled
- Shuts down the effect dispatch spine
- Specified by:
onDisablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onDisablein classorg.bukkit.plugin.java.JavaPlugin
-
getPacketEventsAdapter
Gets the PacketEvents adapter if available and enabled.- Returns:
- the adapter, or null if PacketEvents is not present or not enabled
-
isPacketEventsActive
public boolean isPacketEventsActive()Checks if PacketEvents integration is active.- Returns:
- true if PacketEvents adapter is enabled and ready
-