Class Ollivanders2

java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
net.pottercraft.ollivanders2.Ollivanders2
All Implemented Interfaces:
io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner, org.bukkit.command.CommandExecutor, org.bukkit.command.TabCompleter, org.bukkit.command.TabExecutor, org.bukkit.plugin.Plugin

public class Ollivanders2 extends org.bukkit.plugin.java.JavaPlugin
Ollivanders2 plugin - Main plugin class for Ollivanders2.

Manages the lifecycle of the Ollivanders2 plugin including initialization, configuration, and shutdown. Coordinates all resource managers (spells, potions, books, items, houses, players, stationary spells, prophecies, and owl post). Handles player spell casting permissions, cooldowns, and animagus form restrictions.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static boolean
    Enables apparate locations, disables apparating by coordinates.
    static boolean
    Turns on backup archiving to save previous backups.
    static boolean
    Enables book learning.
    static org.bukkit.Material
    Sets the material to use for broomsticks.
    static org.bukkit.ChatColor
    Sets the color for chat messages from the plugin.
    static int
    static boolean
    Enables debug mode.
    static int
    Sets the maximum Minecraft days that a prophecy will come to pass.
    static boolean
    Enables spell and potion experience loss on death.
    static boolean
    Enables non-verbal casting.
    static boolean
    Enables random wand drops by Witch entities.
    static org.bukkit.Material
    Sets the material to use for floo powder.
    static boolean
    Turns on hourly plugin data backup.
    static boolean
    True if the libsDisguises plugin is found and enabled
    static boolean
    Enables max spell level.
    static final String
    The plugin data directory on the server
    static boolean
    For use by tests only
    static boolean
    Enables hostile mobs for animagus forms.
    static boolean
    Enables spell journals.
    static boolean
    Enables strict Animagus conditions.
    static boolean
    Turns on translations for strings that support them.
    static boolean
    Whether to use school years to affect spell casting success chances.
    static boolean
    True if the WorldGuard plugin is found and enabled
    The WorldGuard management class
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addTeleportAction(@NotNull org.bukkit.entity.Player p, @NotNull org.bukkit.Location to)
    Add a teleport action to the queue
    void
    addTeleportAction(@NotNull org.bukkit.entity.Player p, @NotNull org.bukkit.Location to, boolean explosionOnTeleport)
    Add a teleport action with an explosion effect
    void
    addTempBlock(@NotNull org.bukkit.block.Block block, @NotNull org.bukkit.Material originalMaterial)
    Deprecated.
    boolean
    canCast(@NotNull org.bukkit.entity.Player player, @NotNull O2SpellType spell, boolean verbose)
    Can this player cast this spell?
    @NotNull O2Player
    getO2Player(@NotNull org.bukkit.entity.Player player)
    Gets the O2Player associated with the Player
    @NotNull ArrayList<UUID>
    Gets the set of all player UUIDs.
    int
    getSpellCount(@NotNull org.bukkit.entity.Player player, @NotNull O2SpellType spell)
    Get the spell use count for the player for this spell
    Get all pending teleport actions.
    org.bukkit.Material
    getTempBlockOriginalMaterial(@NotNull org.bukkit.block.Block block)
    Deprecated.
    boolean
    givePotion(@NotNull org.bukkit.entity.Player sender, @NotNull org.bukkit.entity.Player player, @NotNull String potionName)
    Give a specific potion to a player.
    int
    incrementSpellCount(@NotNull org.bukkit.entity.Player player, @NotNull O2SpellType spell)
    Increment the spell use count for a player.
    boolean
    isTempBlock(@NotNull org.bukkit.block.Block block)
    Deprecated.
    boolean
    onCommand(@NotNull org.bukkit.command.CommandSender sender, org.bukkit.command.Command cmd, @NotNull String commandLabel, @NotNull String[] args)
    Handle command events
    void
    Cleanup when the Minecraft server shuts down.
    void
    Plugin initialization when the Minecraft server is starting up.
    void
    Remove a teleport action.
    void
    revertTempBlock(@NotNull org.bukkit.block.Block block)
    Deprecated.
    boolean
    runApparateLocation(@NotNull org.bukkit.command.CommandSender sender, @NotNull String[] args)
    Run the apparate location subcommand
    boolean
    runPotions(@NotNull org.bukkit.command.CommandSender sender, @NotNull String[] args)
    Potions subcommand
    boolean
    runProphecies(@NotNull org.bukkit.command.CommandSender sender)
    Prophecies sub-command
    void
    Save persistent plugin data to disk.
    void
    setO2Player(@NotNull org.bukkit.entity.Player player, @NotNull O2Player o2p)
    Sets the player's OPlayer by their player name
    void
    setSpellCount(@NotNull org.bukkit.entity.Player player, @NotNull O2SpellType spell, int count)
    Set the spell use count for a player.
    void
    spellCannotBeCastMessage(@NotNull org.bukkit.entity.Player player)
    Send a message when a player attempts to cast a spell in a protected location (e.g., WorldGuard).
    void
    spellCoolDownMessage(@NotNull org.bukkit.entity.Player player)
    Send a cooldown message when a player attempts to cast a spell too quickly.

    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, onLoad, onTabComplete, registerCommand, registerCommand, registerCommand, registerCommand, reloadConfig, saveConfig, 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.plugin.Plugin

    getComponentLogger, getDataPath, getLog4JLogger, getSLF4JLogger
  • Field Details

  • Constructor Details

    • Ollivanders2

      public Ollivanders2()
  • Method Details

    • onDisable

      public void onDisable()
      Cleanup when the Minecraft server shuts down.

      Called when the Ollivanders2 plugin is being disabled. Orchestrates the complete shutdown process by delegating cleanup to all resource managers, saving persistent data, and reverting temporary world changes.

      Shutdown Operations:

      • Delegate shutdown to all resource managers (spells, potions, books, items, houses, players, stationary spells, prophecies, owl post)
      • Save APPARATE teleport locations
      • Revert all temporary block changes made by spells
      • Ensure plugin config file exists
      • Log plugin shutdown completion
      Specified by:
      onDisable in interface org.bukkit.plugin.Plugin
      Overrides:
      onDisable in class org.bukkit.plugin.java.JavaPlugin
    • savePluginData

      public void savePluginData()
      Save persistent plugin data to disk.

      Saves stationary spells, prophecies, houses, players, player effects, and APPARATE teleport locations to their respective data files.

    • onEnable

      public void onEnable()
      Plugin initialization when the Minecraft server is starting up.

      Orchestrates the complete plugin startup process:

      • Initializes all resource managers (spells, potions, books, items, houses, players, stationary spells, prophecies, owl post)
      • Loads and initializes the plugin API
      • Ensures plugin data directory exists
      • Reads and applies configuration settings
      • Registers event listeners
      • Schedules the main plugin scheduler
      • Loads dependency plugins (LibsDisguises, WorldGuard)
      • Initializes player data and houses
      • Initializes items, stationary spells, and spells
      • Initializes potions and books
      • Logs plugin startup completion
      Specified by:
      onEnable in interface org.bukkit.plugin.Plugin
      Overrides:
      onEnable in class org.bukkit.plugin.java.JavaPlugin
    • onCommand

      public boolean onCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, org.bukkit.command.Command cmd, @NotNull @NotNull String commandLabel, @NotNull @NotNull String[] args)
      Handle command events
      Specified by:
      onCommand in interface org.bukkit.command.CommandExecutor
      Overrides:
      onCommand in class org.bukkit.plugin.java.JavaPlugin
      Parameters:
      sender - the player who issued the command
      cmd - the command entered by the player
      commandLabel - required arg for the plugin onCommand call from the server
      args - the arguments to the command, if any
      Returns:
      true if the command was successful, false otherwise
    • getTeleportActions

      @NotNull public @NotNull List<Ollivanders2TeleportActions.O2TeleportAction> getTeleportActions()
      Get all pending teleport actions.
      Returns:
      a list of teleport actions
    • addTeleportAction

      public void addTeleportAction(@NotNull @NotNull org.bukkit.entity.Player p, @NotNull @NotNull org.bukkit.Location to)
      Add a teleport action to the queue
      Parameters:
      p - the player to teleport
      to - teleport destination
    • addTeleportAction

      public void addTeleportAction(@NotNull @NotNull org.bukkit.entity.Player p, @NotNull @NotNull org.bukkit.Location to, boolean explosionOnTeleport)
      Add a teleport action with an explosion effect
      Parameters:
      p - the player to teleport
      to - teleport destination
      explosionOnTeleport - whether to do an explosion effect
    • removeTeleportAction

      public void removeTeleportAction(@NotNull Ollivanders2TeleportActions.O2TeleportAction action)
      Remove a teleport action.
      Parameters:
      action - the action to remove
    • getSpellCount

      public int getSpellCount(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull O2SpellType spell)
      Get the spell use count for the player for this spell
      Parameters:
      player - the player to get the count for
      spell - the spell to get the count for
      Returns:
      the spell count
    • setSpellCount

      public void setSpellCount(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull O2SpellType spell, int count)
      Set the spell use count for a player.
      Parameters:
      player - the player to set the spell count for
      spell - the spell to set the count for
      count - the count to set
    • incrementSpellCount

      public int incrementSpellCount(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull O2SpellType spell)
      Increment the spell use count for a player.
      Parameters:
      player - the player to increment the count for
      spell - the spell to increment
      Returns:
      the incremented use count for this player for this spell
    • getO2Player

      @NotNull public @NotNull O2Player getO2Player(@NotNull @NotNull org.bukkit.entity.Player player)
      Gets the O2Player associated with the Player
      Parameters:
      player - the player to get
      Returns:
      O2Player object for this player
    • setO2Player

      public void setO2Player(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull O2Player o2p)
      Sets the player's OPlayer by their player name
      Parameters:
      player - the player
      o2p - the OPlayer associated with the player
    • getO2PlayerIDs

      @NotNull public @NotNull ArrayList<UUID> getO2PlayerIDs()
      Gets the set of all player UUIDs.
      Returns:
      a list of all player MC UUIDs
    • canCast

      public boolean canCast(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull O2SpellType spell, boolean verbose)
      Can this player cast this spell?
      Parameters:
      player - player to check
      spell - spell to check
      verbose - whether to inform the player of why they cannot cast a spell
      Returns:
      True if the player can cast this spell, false if not
    • spellCannotBeCastMessage

      public void spellCannotBeCastMessage(@NotNull @NotNull org.bukkit.entity.Player player)
      Send a message when a player attempts to cast a spell in a protected location (e.g., WorldGuard).

      This is not the message to use for bookLearning enforcement. Used when O2Spells.isSpellTypeAllowed(org.bukkit.Location, O2SpellType) returns false.

      Parameters:
      player - the player that attempted to cast the spell
    • spellCoolDownMessage

      public void spellCoolDownMessage(@NotNull @NotNull org.bukkit.entity.Player player)
      Send a cooldown message when a player attempts to cast a spell too quickly.

      Used when a spell is on cooldown and the player cannot cast it yet. The cooldown time is stored in the player's O2Player data.

      Parameters:
      player - the player who attempted to cast while on cooldown
    • runPotions

      public boolean runPotions(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String[] args)
      Potions subcommand
      Parameters:
      sender - the command sender
      args - args to the command
      Returns:
      true if the command succeeded, false otherwise
    • givePotion

      public boolean givePotion(@NotNull @NotNull org.bukkit.entity.Player sender, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String potionName)
      Give a specific potion to a player.
      Parameters:
      sender - the player who did the command
      player - the player to give the potion to
      potionName - the potion to give the player
      Returns:
      true if the command succeeded, false otherwise
    • runProphecies

      public boolean runProphecies(@NotNull @NotNull org.bukkit.command.CommandSender sender)
      Prophecies sub-command
      Parameters:
      sender - the command sender
      Returns:
      true unless an error occurred
    • runApparateLocation

      public boolean runApparateLocation(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String[] args)
      Run the apparate location subcommand
      Parameters:
      sender - the command sender
      args - the arguments to this command
      Returns:
      true if the command succeeded, false otherwise
    • addTempBlock

      @Deprecated public void addTempBlock(@NotNull @NotNull org.bukkit.block.Block block, @NotNull @NotNull org.bukkit.Material originalMaterial)
      Deprecated.
      Add a temporary block. A temp block is a block that has been temporarily changed to a different type.
      Parameters:
      block - the block to add
      originalMaterial - the original material of this block
    • revertTempBlock

      @Deprecated public void revertTempBlock(@NotNull @NotNull org.bukkit.block.Block block)
      Deprecated.
      Reverts a temp block back to its original type.
      Parameters:
      block - the block to remove
    • isTempBlock

      @Deprecated public boolean isTempBlock(@NotNull @NotNull org.bukkit.block.Block block)
      Deprecated.
      Is a block a temp block or not.
      Parameters:
      block - the block to check
      Returns:
      true if it is a temp block, false otherwise
    • getTempBlockOriginalMaterial

      @Deprecated public org.bukkit.Material getTempBlockOriginalMaterial(@NotNull @NotNull org.bukkit.block.Block block)
      Deprecated.
      Returns the original material for a temp block.
      Parameters:
      block - the temp block
      Returns:
      the material, if found, null otherwise