Class ArtificialEnchantmentsPlugin

java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
io.artificial.enchantments.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

public class ArtificialEnchantmentsPlugin extends org.bukkit.plugin.java.JavaPlugin
Main plugin class for Artificial Enchantments library.

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
    Constructor
    Description
    Creates a new plugin instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the PacketEvents adapter if available and enabled.
    boolean
    Checks if PacketEvents integration is active.
    void
    Disables the plugin, stopping all tasks and cleaning up resources.
    void
    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, toString

    Methods inherited from class org.bukkit.plugin.PluginBase

    equals, getName, hashCode, namespace

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods 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:

      1. Creates or retrieves the shared API instance
      2. Registers enchantment table listener for custom enchantments
      3. Registers anvil listener for enchantment combination
      4. Registers block break loot listener for drop modifications
      5. Registers effect listener for enchantment triggers
      6. Starts the tick task for periodic effects
      7. Initializes PacketEvents integration if available
      Specified by:
      onEnable in interface org.bukkit.plugin.Plugin
      Overrides:
      onEnable in class org.bukkit.plugin.java.JavaPlugin
    • onDisable

      public void onDisable()
      Disables the plugin, stopping all tasks and cleaning up resources.

      This method:

      1. Stops the tick task
      2. Disables PacketEvents adapter if enabled
      3. Shuts down the effect dispatch spine
      Specified by:
      onDisable in interface org.bukkit.plugin.Plugin
      Overrides:
      onDisable in class org.bukkit.plugin.java.JavaPlugin
    • getPacketEventsAdapter

      @Nullable public @Nullable PacketEventsAdapter 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