Class O2Player

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

public class O2Player extends Object
Ollivanders2 player
  • Constructor Details

    • O2Player

      public O2Player(@NotNull @NotNull UUID id, @NotNull @NotNull String name, @NotNull @NotNull Ollivanders2 plugin)
      Constructor.
      Parameters:
      id - the UUID of the player
      name - the name of the player
      plugin - a reference to the plugin
  • Method Details

    • getDestinedWandWood

      @NotNull public @NotNull String getDestinedWandWood()
      Get the player's destined wand wood type.
      Returns:
      the player's destined wand wood type
    • getDestinedWandCore

      @NotNull public @NotNull String getDestinedWandCore()
      Get the player's destined wand core type.
      Returns:
      the player's destined wand core type
    • setWandWood

      public void setWandWood(@NotNull @NotNull String wood)
      Set the player's destined wand wood type. This overrides the current value.
      Parameters:
      wood - sets the destined wand wood type
    • setWandCore

      public void setWandCore(@NotNull @NotNull String core)
      Set the player's destined wand core type. This overrides the current value.
      Parameters:
      core - set the destined wand core type
    • getPlayerName

      @NotNull public @NotNull String getPlayerName()
      Get the name of this player for use in commands like listing out house membership. Since player names can change, this should not be used to identify a player. Instead, use the UUID of player and the O2Players map to find their O2Player object.
      Returns:
      the player's name
    • setPlayerName

      public void setPlayerName(@NotNull @NotNull String name)
      Sets the name of this player for use in commands like listing out house membership.
      Parameters:
      name - the name to set for this player
    • getSpellCount

      public int getSpellCount(@NotNull @NotNull O2SpellType spell)
      Get the casting count for a spell
      Parameters:
      spell - the spell to get a count for
      Returns:
      the number of times a player has cast this spell
    • getPotionCount

      public int getPotionCount(@NotNull @NotNull O2PotionType potionType)
      Get the brewing count for a potion
      Parameters:
      potionType - the spell to get a count for
      Returns:
      the number of times a player has cast this spell
    • getSpellLastCastTime

      @NotNull public @NotNull Long getSpellLastCastTime(@NotNull @NotNull O2SpellType spellType)
      Get the casting count for a spell
      Parameters:
      spellType - the spell to get a count for
      Returns:
      the number of times a player has cast this spell
    • getKnownSpells

      @NotNull public @NotNull Map<O2SpellType,Integer> getKnownSpells()
      Get the list of known spells for this player.
      Returns:
      a map of all the known spells and the spell count for each.
    • getKnownPotions

      @NotNull public @NotNull Map<O2PotionType,Integer> getKnownPotions()
      Get the list of known potions for this player.
      Returns:
      a map of all the known potions and potion brew count for each.
    • getRecentSpells

      @NotNull public @NotNull Map<O2SpellType,Long> getRecentSpells()
      Get the list of recently cast spells for this player.
      Returns:
      a map of all recent spells and the time they were cast.
    • setSpellCount

      public void setSpellCount(@NotNull @NotNull O2SpellType spell, int count)
      Set the spell count for a spell. This will override the existing values for this spell and should not be used when increment is intended.
      Parameters:
      spell - the spell to set the count for
      count - the count to set
    • getLastSpell

      @Nullable public @Nullable O2SpellType getLastSpell()
      Get the last spell cast by this player.
      Returns:
      the last spell cast
    • setPriorIncantatem

      public void setPriorIncantatem(@NotNull @NotNull O2SpellType spell)
      Set the last spell successfully cast by this player's wand.
      Parameters:
      spell - the spell they most recently cast
    • getPriorIncantatem

      @Nullable public @Nullable O2SpellType getPriorIncantatem()
      Get the last spell cast by this player's wand.
      Returns:
      the last spell cast by this player with a wand
    • setPotionCount

      public void setPotionCount(@NotNull @NotNull O2PotionType potionType, int count)
      Set the potion count for a potion. This will override the existing values for this potion and should not be used when increment is intended.
      Parameters:
      potionType - the potion to set the count for
      count - the count to set
    • setSpellRecentCastTime

      public void setSpellRecentCastTime(@NotNull @NotNull O2SpellType spellType)
      Set the most recent cast time for a spell. This will override the existing values for this spell.
      Parameters:
      spellType - the spell to set the time for
    • setMasterSpell

      public void setMasterSpell(@NotNull @NotNull O2SpellType spell)
      Set the wand's mastered spell.
      Parameters:
      spell - the mastered spell
    • incrementSpellCount

      public void incrementSpellCount(@NotNull @NotNull O2SpellType spellType)
      Increment the spell count by 1.
      Parameters:
      spellType - the spell to increment
    • incrementPotionCount

      public void incrementPotionCount(@NotNull @NotNull O2PotionType potionType)
      Increment the potion count by 1.
      Parameters:
      potionType - the potion to increment
    • resetSpellCount

      public void resetSpellCount()
      Resets the known spells for this player to none.
    • resetPotionCount

      public void resetPotionCount()
      Resets the known spells for this player to none.
    • getWandSpell

      @Nullable public @Nullable O2SpellType getWandSpell()
      Get the spell currently loaded in to the player's wand.
      Returns:
      the loaded spell
    • setWandSpell

      public void setWandSpell(@Nullable @Nullable O2SpellType spell)
      Loads a spell in to the player's wand.
      Parameters:
      spell - the spell to load
    • isMuggle

      public boolean isMuggle()
      Determine if player is a muggle. Admins are never muggles.
      Returns:
      true if they are a muggle, false otherwise
    • setMuggle

      public void setMuggle(boolean isMuggle)
      Set if a player is a muggle. Admins are never muggles.
      Parameters:
      isMuggle - true if the player is a muggle
    • getSouls

      public int getSouls()
      Get the number of souls this player has collected.
      Returns:
      the number of souls this player has collected
    • setSouls

      public void setSouls(int souls)
      Set the number of souls this player has collected.
      Parameters:
      souls - the number of souls the player has collected
    • addSoul

      public void addSoul()
      Add a soul to this player.
    • subtractSoul

      public void subtractSoul()
      Remove a soul from this player.
    • getYear

      @NotNull public @NotNull Year getYear()
      Get the year this player is in.
      Returns:
      The year the player is in
    • setYear

      public void setYear(@NotNull @NotNull Year year)
      Set the year this player is in.
      Parameters:
      year - The year to set them to
    • resetSouls

      public void resetSouls()
      Reset the soul count to zero.
    • initFoundWand

      protected void initFoundWand(boolean found)
      Initializer for the foundWand class variable for loading the player from saved data. This is different from setFoundWand which triggers a found wand event.
      Parameters:
      found - the value to set for foundWand
    • setFoundWand

      public void setFoundWand(boolean found)
      Set whether the player has found their destined wand before. Once a player finds their destined wand they are also no longer a muggle since they can do magic. This should not be called when loading from saved data, use initFoundWand().
      Parameters:
      found - set whether the player has found their destined wand
    • foundWand

      public boolean foundWand()
      Has this player found their destined wand?
      Returns:
      true if they have, false if not
    • getSpellJournal

      @Nullable public @Nullable org.bukkit.inventory.ItemStack getSpellJournal()
      Returns this player's spell journal, a book with all known spells and their level.
      Returns:
      the player's spell journal
    • shiftMasterSpell

      @Deprecated public void shiftMasterSpell()
      Deprecated.
      Shift the wand's master spell to the next spell.
    • shiftMasterSpell

      public void shiftMasterSpell(boolean reverse)
      Shift the wand's master spell to the next spell.
      Parameters:
      reverse - if set to true, iterates backwards through spell list
    • getMasterSpell

      @Nullable public @Nullable O2SpellType getMasterSpell()
      Get the wand's master spell.
      Returns:
      the wand's master spell
    • setIsAnimagus

      public void setIsAnimagus()
      Sets that this player is an Animagus.
    • setAnimagusForm

      public void setAnimagusForm(@NotNull @NotNull org.bukkit.entity.EntityType type)
      Sets the Animagus form for this player.
      Parameters:
      type - the player's Animagus form.
    • getAnimagusForm

      @Nullable public @Nullable org.bukkit.entity.EntityType getAnimagusForm()
      Get the Animagus form for this player.
      Returns:
      the player's Animagus form or null if they are not an Animagus
    • getAnimagusColor

      @Nullable public @Nullable String getAnimagusColor()
      Get the color variation for this animagus.
      Returns:
      the color variation or null if not applicable
    • isAnimagus

      public boolean isAnimagus()
      Determine if this player an Animagus.
      Returns:
      true if they have an Animagus form, false otherwise
    • getID

      @NotNull public @NotNull UUID getID()
      Get the player's UUID
      Returns:
      the UUID of the player this O2Player represents
    • onJoin

      public void onJoin()
      Do player onJoin set up
    • onQuit

      public void onQuit()
      Do player onQuit clean up
    • onDeath

      public void onDeath()
      Do player onDeath actions
    • fix

      protected void fix()
      Called after a player's data has been read from save to fix changes made to the plugin between versions.
    • isOnline

      public boolean isOnline()
      Is this player currently online? For use when we have an O2Player and not a player (which has an isOnline() method in Spigot)
      Returns:
      true if they are online, false otherwise