Class O2Players

java.lang.Object
net.pottercraft.ollivanders2.player.O2Players

public class O2Players extends Object
Player management class for all player-specific data and functions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Effects manager for player effects.
  • Constructor Summary

    Constructors
    Constructor
    Description
    O2Players(@NotNull Ollivanders2 plugin)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull O2Player
    addPlayer(@NotNull UUID pid, @NotNull String name)
    Add a new O2Player.
    void
    fixPlayerAnimagusColorVariant(@NotNull UUID pid, @NotNull String correctedVariant)
    Correct a player's animagus color form - for use when valueOf() on the current value fails
    @Nullable O2Player
    getPlayer(@NotNull String playerName)
    Get an O2Player by name.
    @Nullable O2Player
    getPlayer(@NotNull UUID pid)
    Get an O2Player by UUID
    @NotNull ArrayList<UUID>
    Get a list of all player unique ids.
    void
    Load players from save file
    void
    Cleanup when the plugin disables.
    void
    Load player and player effects on plugin enable
    void
    playerSummary(@NotNull org.bukkit.command.CommandSender sender, @NotNull org.bukkit.entity.Player player)
    Displays a summary of player info for the Ollivanders2 plugin
    void
    removePlayer(@NotNull UUID pid)
    Remove a player
    boolean
    runAnimagus(@NotNull org.bukkit.command.CommandSender sender, @NotNull String[] args)
    The year subCommand for managing everything related to animagus.
    boolean
    runSummary(@NotNull org.bukkit.command.CommandSender sender, @NotNull String[] args)
    Commands related to players.
    boolean
    runYear(@NotNull org.bukkit.command.CommandSender sender, @NotNull String[] args)
    The year subCommand for managing everything related to years.
    void
    Write all players to the plugin config directory
    void
    updatePlayer(@NotNull UUID pid, @NotNull O2Player o2p)
    Update an existing O2Player.
    void
    usageSummary(org.bukkit.command.CommandSender sender)
    Usage summary for player commands
    void
    usageSummaryAdmin(org.bukkit.command.CommandSender sender)
    Usage summary for admins
    void
    usageSummaryPlayer(org.bukkit.command.CommandSender sender)
    Usage summary for players

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • playerEffects

      public O2Effects playerEffects
      Effects manager for player effects.
  • Constructor Details

    • O2Players

      public O2Players(@NotNull @NotNull Ollivanders2 plugin)
      Constructor
      Parameters:
      plugin - the MC plugin
  • Method Details

    • onEnable

      public void onEnable()
      Load player and player effects on plugin enable
    • onDisable

      public void onDisable()
      Cleanup when the plugin disables.

      Called when the Ollivanders2 plugin is being shut down. The O2Players manager persists all player-specific data to disk and delegates effect cleanup to the player effects manager. This ensures that player progress, achievements, and active effects are preserved across server restarts.

      Shutdown Operations:

      • Serialize all player data to JSON (names, wand data, souls, spells, potions, etc.)
      • Write player data to persistent storage via GsonDAO
      • Delegate player effect cleanup to O2Effects.onDisable()
      • Player effects saves all active magical effects applied to players
      See Also:
    • addPlayer

      @NotNull public @NotNull O2Player addPlayer(@NotNull @NotNull UUID pid, @NotNull @NotNull String name)
      Add a new O2Player.
      Parameters:
      pid - the UUID of this player
      name - the effectType of this player
      Returns:
      the O2Player that was added
    • updatePlayer

      public void updatePlayer(@NotNull @NotNull UUID pid, @NotNull @NotNull O2Player o2p)
      Update an existing O2Player.
      Parameters:
      pid - the UUID of this player
      o2p - the O2Player object for this player
    • getPlayer

      @Nullable public @Nullable O2Player getPlayer(@NotNull @NotNull UUID pid)
      Get an O2Player by UUID
      Parameters:
      pid - the UUID of the player
      Returns:
      the O2Player if found, null otherwise.
    • getPlayer

      @Nullable public @Nullable O2Player getPlayer(@NotNull @NotNull String playerName)
      Get an O2Player by name. This is inefficient compared to by UUID and should only be used when UUID is not available.
      Parameters:
      playerName - the name of the player
      Returns:
      the O2Player if found, null otherwise.
    • removePlayer

      public void removePlayer(@NotNull @NotNull UUID pid)
      Remove a player
      Parameters:
      pid - the id of the player to remove
    • getPlayerIDs

      @NotNull public @NotNull ArrayList<UUID> getPlayerIDs()
      Get a list of all player unique ids.
      Returns:
      a list of all known player MC UUIDs
    • saveO2Players

      public void saveO2Players()
      Write all players to the plugin config directory
    • loadO2Players

      public void loadO2Players()
      Load players from save file
    • fixPlayerAnimagusColorVariant

      public void fixPlayerAnimagusColorVariant(@NotNull @NotNull UUID pid, @NotNull @NotNull String correctedVariant)
      Correct a player's animagus color form - for use when valueOf() on the current value fails
      Parameters:
      pid - the player to correct
      correctedVariant - the corrected value
    • runSummary

      public boolean runSummary(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String[] args)
      Commands related to players.
      Parameters:
      sender - the command sender
      args - the args for the command
      Returns:
      true if the command succeeded
    • usageSummary

      public void usageSummary(org.bukkit.command.CommandSender sender)
      Usage summary for player commands
      Parameters:
      sender - the command sender
    • usageSummaryPlayer

      public void usageSummaryPlayer(org.bukkit.command.CommandSender sender)
      Usage summary for players
      Parameters:
      sender - the command sender
    • usageSummaryAdmin

      public void usageSummaryAdmin(org.bukkit.command.CommandSender sender)
      Usage summary for admins
      Parameters:
      sender - the command sender
    • runYear

      public boolean runYear(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String[] args)
      The year subCommand for managing everything related to years.
      Parameters:
      sender - the player that issued the command
      args - the arguments for the command, if any
      Returns:
      true unless an error occurred
    • playerSummary

      public void playerSummary(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull org.bukkit.entity.Player player)
      Displays a summary of player info for the Ollivanders2 plugin
      Parameters:
      sender - the player who issued the command
      player - the player to send the info for
    • runAnimagus

      public boolean runAnimagus(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String[] args)
      The year subCommand for managing everything related to animagus.
      Parameters:
      sender - the player that issued the command
      args - the arguments for the command, if any
      Returns:
      true unless an error occurred