Class 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
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
FieldsModifier and TypeFieldDescriptionstatic booleanEnables apparate locations, disables apparating by coordinates.static booleanTurns on backup archiving to save previous backups.static booleanEnables book learning.static org.bukkit.MaterialSets the material to use for broomsticks.static org.bukkit.ChatColorSets the color for chat messages from the plugin.static intstatic booleanEnables debug mode.static intSets the maximum Minecraft days that a prophecy will come to pass.static booleanEnables spell and potion experience loss on death.static booleanEnables non-verbal casting.static booleanEnables random wand drops by Witch entities.static org.bukkit.MaterialSets the material to use for floo powder.static booleanTurns on hourly plugin data backup.static booleanTrue if the libsDisguises plugin is found and enabledstatic booleanEnables max spell level.static final StringThe plugin data directory on the serverstatic booleanFor use by tests onlystatic booleanEnables hostile mobs for animagus forms.static booleanEnables spell journals.static booleanEnables strict Animagus conditions.static booleanTurns on translations for strings that support them.static booleanWhether to use school years to affect spell casting success chances.static booleanTrue if the WorldGuard plugin is found and enabledstatic Ollivanders2WorldGuardThe WorldGuard management class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTeleportAction(@NotNull org.bukkit.entity.Player p, @NotNull org.bukkit.Location to) Add a teleport action to the queuevoidaddTeleportAction(@NotNull org.bukkit.entity.Player p, @NotNull org.bukkit.Location to, boolean explosionOnTeleport) Add a teleport action with an explosion effectvoidaddTempBlock(@NotNull org.bukkit.block.Block block, @NotNull org.bukkit.Material originalMaterial) Deprecated.booleancanCast(@NotNull org.bukkit.entity.Player player, @NotNull O2SpellType spell, boolean verbose) Can this player cast this spell?@NotNull O2PlayergetO2Player(@NotNull org.bukkit.entity.Player player) Gets the O2Player associated with the PlayerGets the set of all player UUIDs.intgetSpellCount(@NotNull org.bukkit.entity.Player player, @NotNull O2SpellType spell) Get the spell use count for the player for this spellGet all pending teleport actions.org.bukkit.MaterialgetTempBlockOriginalMaterial(@NotNull org.bukkit.block.Block block) Deprecated.booleangivePotion(@NotNull org.bukkit.entity.Player sender, @NotNull org.bukkit.entity.Player player, @NotNull String potionName) Give a specific potion to a player.intincrementSpellCount(@NotNull org.bukkit.entity.Player player, @NotNull O2SpellType spell) Increment the spell use count for a player.booleanisTempBlock(@NotNull org.bukkit.block.Block block) Deprecated.booleanonCommand(@NotNull org.bukkit.command.CommandSender sender, org.bukkit.command.Command cmd, @NotNull String commandLabel, @NotNull String[] args) Handle command eventsvoidCleanup when the Minecraft server shuts down.voidonEnable()Plugin initialization when the Minecraft server is starting up.voidRemove a teleport action.voidrevertTempBlock(@NotNull org.bukkit.block.Block block) Deprecated.booleanrunApparateLocation(@NotNull org.bukkit.command.CommandSender sender, @NotNull String[] args) Run the apparate location subcommandbooleanrunPotions(@NotNull org.bukkit.command.CommandSender sender, @NotNull String[] args) Potions subcommandbooleanrunProphecies(@NotNull org.bukkit.command.CommandSender sender) Prophecies sub-commandvoidSave persistent plugin data to disk.voidsetO2Player(@NotNull org.bukkit.entity.Player player, @NotNull O2Player o2p) Sets the player's OPlayer by their player namevoidsetSpellCount(@NotNull org.bukkit.entity.Player player, @NotNull O2SpellType spell, int count) Set the spell use count for a player.voidspellCannotBeCastMessage(@NotNull org.bukkit.entity.Player player) Send a message when a player attempts to cast a spell in a protected location (e.g., WorldGuard).voidspellCoolDownMessage(@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, toStringMethods inherited from class org.bukkit.plugin.PluginBase
equals, getName, hashCodeMethods 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
-
Field Details
-
chatDropoff
public static int chatDropoff -
chatColor
public static org.bukkit.ChatColor chatColorSets the color for chat messages from the plugin.- See Also:
-
bookLearning
public static boolean bookLearningEnables book learning.- See Also:
-
maxSpellLevel
public static boolean maxSpellLevelEnables max spell level.- See Also:
-
enableNonVerbalSpellCasting
public static boolean enableNonVerbalSpellCastingEnables non-verbal casting.- See Also:
-
useSpellJournal
public static boolean useSpellJournalEnables spell journals.- See Also:
-
useHostileMobAnimagi
public static boolean useHostileMobAnimagiEnables hostile mobs for animagus forms.- See Also:
-
enableDeathExpLoss
public static boolean enableDeathExpLossEnables spell and potion experience loss on death.- See Also:
-
apparateLocations
public static boolean apparateLocationsEnables apparate locations, disables apparating by coordinates.- See Also:
-
divinationMaxDays
public static int divinationMaxDaysSets the maximum Minecraft days that a prophecy will come to pass.- See Also:
-
useYears
public static boolean useYearsWhether to use school years to affect spell casting success chances.- See Also:
-
debug
public static boolean debugEnables debug mode.- See Also:
-
flooPowderMaterial
public static org.bukkit.Material flooPowderMaterialSets the material to use for floo powder.- See Also:
-
broomstickMaterial
public static org.bukkit.Material broomstickMaterialSets the material to use for broomsticks.- See Also:
-
enableWitchDrop
public static boolean enableWitchDropEnables random wand drops by Witch entities.- See Also:
-
hourlyBackup
public static boolean hourlyBackupTurns on hourly plugin data backup.- See Also:
-
archivePreviousBackup
public static boolean archivePreviousBackupTurns on backup archiving to save previous backups.- See Also:
-
useTranslations
public static boolean useTranslationsTurns on translations for strings that support them. Whether to load localization strings from the config file -
useStrictAnimagusConditions
public static boolean useStrictAnimagusConditionsEnables strict Animagus conditions.- See Also:
-
worldGuardEnabled
public static boolean worldGuardEnabledTrue if the WorldGuard plugin is found and enabled -
libsDisguisesEnabled
public static boolean libsDisguisesEnabledTrue if the libsDisguises plugin is found and enabled -
worldGuardO2
The WorldGuard management class -
pluginDir
The plugin data directory on the server- See Also:
-
testMode
public static boolean testModeFor use by tests only
-
-
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:
onDisablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onDisablein classorg.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:
onEnablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onEnablein classorg.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:
onCommandin interfaceorg.bukkit.command.CommandExecutor- Overrides:
onCommandin classorg.bukkit.plugin.java.JavaPlugin- Parameters:
sender- the player who issued the commandcmd- the command entered by the playercommandLabel- required arg for the plugin onCommand call from the serverargs- the arguments to the command, if any- Returns:
- true if the command was successful, false otherwise
-
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 teleportto- 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 teleportto- teleport destinationexplosionOnTeleport- whether to do an explosion effect
-
removeTeleportAction
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 forspell- 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 forspell- the spell to set the count forcount- 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 forspell- the spell to increment- Returns:
- the incremented use count for this player for this spell
-
getO2Player
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 playero2p- the OPlayer associated with the player
-
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 checkspell- spell to checkverbose- 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 senderargs- 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 commandplayer- the player to give the potion topotionName- 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 senderargs- 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 addoriginalMaterial- the original material of this block
-
revertTempBlock
Deprecated.Reverts a temp block back to its original type.- Parameters:
block- the block to remove
-
isTempBlock
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
-