Class PlayerProfile

java.lang.Object
io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile

public class PlayerProfile extends Object
A class that can store a Player's Research progress for caching purposes. It also holds the backpacks of a Player.
Author:
TheBusyBiscuit
See Also:
  • Constructor Details

    • PlayerProfile

      public PlayerProfile(@Nonnull org.bukkit.OfflinePlayer p, int backpackNum)
    • PlayerProfile

      public PlayerProfile(@Nonnull org.bukkit.OfflinePlayer p, int backpackNum, Set<Research> researches)
  • Method Details

    • getArmor

      @Nonnull public HashedArmorpiece[] getArmor()
      This method provides a fast way to access the armor of a Player. It returns a cached version, represented by HashedArmorpiece.
      Returns:
      The cached armor for this Player
    • getUUID

      @Nonnull public UUID getUUID()
      This returns the UUID this PlayerProfile is linked to.
      Returns:
      The UUID of our PlayerProfile
    • isMarkedForDeletion

      public boolean isMarkedForDeletion()
      This method returns whether the Player has logged off. If this is true, then the Profile can be removed from RAM.
      Returns:
      Whether the Profile is marked for deletion
    • isDirty

      public boolean isDirty()
      This method returns whether the Profile has unsaved changes
      Returns:
      Whether there are unsaved changes
    • save

      public void save()
      This method will save the Player's Researches and Backpacks to the hard drive
    • setResearched

      public void setResearched(@Nonnull Research research, boolean unlock)
      This method sets the Player's "researched" status for this Research. Use the boolean to unlock or lock the Research
      Parameters:
      research - The Research that should be unlocked or locked
      unlock - Whether the Research should be unlocked or locked
    • hasUnlocked

      public boolean hasUnlocked(@Nullable Research research)
      This method returns whether the Player has unlocked the given Research
      Parameters:
      research - The Research that is being queried
      Returns:
      Whether this Research has been unlocked
    • hasUnlockedEverything

      public boolean hasUnlockedEverything()
      This method returns whether this Player has unlocked all Researches.
      Returns:
      Whether they unlocked every Research
    • getResearches

      @Nonnull public Set<Research> getResearches()
      This Method will return all Researches that this Player has unlocked
      Returns:
      A Hashset<Research> of all Researches this Player has unlocked
    • getWaypoints

      @Nonnull public List<Waypoint> getWaypoints()
      This returns a List of all Waypoints belonging to this PlayerProfile.
      Returns:
      A List containing every Waypoint
    • addWaypoint

      public void addWaypoint(@Nonnull Waypoint waypoint)
      This adds the given Waypoint to the List of Waypoints of this PlayerProfile.
      Parameters:
      waypoint - The Waypoint to add
    • removeWaypoint

      public void removeWaypoint(@Nonnull Waypoint waypoint)
      This removes the given Waypoint from the List of Waypoints of this PlayerProfile.
      Parameters:
      waypoint - The Waypoint to remove
    • markForDeletion

      public final void markForDeletion()
      Call this method if the Player has left. The profile can then be removed from RAM.
    • markDirty

      public final void markDirty()
      Call this method if this Profile has unsaved changes.
    • nextBackpackNum

      public int nextBackpackNum()
    • getBackpackCount

      public int getBackpackCount()
    • setBackpackCount

      public void setBackpackCount(int count)
    • getTitle

      @Nonnull public String getTitle()
      This method gets the research title, as defined in config.yml, of this PlayerProfile based on the fraction of unlocked Researches of this player.
      Returns:
      The research title of this PlayerProfile
    • sendStats

      public void sendStats(@Nonnull org.bukkit.command.CommandSender sender)
      This sends the statistics for the specified CommandSender to the CommandSender. This includes research title, research progress and total xp spent.
      Parameters:
      sender - The CommandSender for which to get the statistics and send them to.
    • getPlayer

      @Nullable public org.bukkit.entity.Player getPlayer()
      This returns the Player who this PlayerProfile belongs to. If the Player is offline, null will be returned.
      Returns:
      The Player of this PlayerProfile or null
    • getGuideHistory

      @Nonnull public GuideHistory getGuideHistory()
      This returns the GuideHistory of this Player. It is basically that player's browsing history.
      Returns:
      The GuideHistory of this Player
    • fromUUID

      public static boolean fromUUID(@Nonnull UUID uuid, @Nonnull Consumer<PlayerProfile> callback)
    • get

      public static boolean get(@Nonnull org.bukkit.OfflinePlayer p, @Nonnull Consumer<PlayerProfile> callback)
      Get the PlayerProfile for a OfflinePlayer asynchronously.
      Parameters:
      p - The OfflinePlayer who's PlayerProfile to retrieve
      callback - The callback with the PlayerProfile
      Returns:
      If the OfflinePlayer was cached or not.
    • request

      public static boolean request(@Nonnull org.bukkit.OfflinePlayer p)
      This requests an instance of PlayerProfile to be loaded for the given OfflinePlayer. This method will return true if the PlayerProfile was already found.
      Parameters:
      p - The OfflinePlayer to request the PlayerProfile for.
      Returns:
      Whether the PlayerProfile was already loaded
    • find

      @Nonnull public static Optional<PlayerProfile> find(@Nonnull org.bukkit.OfflinePlayer p)
      This method tries to search for a PlayerProfile of the given OfflinePlayer. The result of this method is an Optional, if no PlayerProfile was found, an empty Optional will be returned.
      Parameters:
      p - The OfflinePlayer to get the PlayerProfile for
      Returns:
      An Optional describing the result
    • iterator

      @Nonnull public static Iterator<PlayerProfile> iterator()
    • hasFullProtectionAgainst

      public boolean hasFullProtectionAgainst(@Nonnull ProtectionType type)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getOwner

      public org.bukkit.OfflinePlayer getOwner()
    • markInvalid

      public void markInvalid()
    • isInvalid

      public boolean isInvalid()