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

  • 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
    • getConfig

      @Deprecated @Nonnull public io.github.bakedlibs.dough.config.Config getConfig()
      Deprecated.
      Look at getPlayerData() instead for reading data.
      This returns the Config which is used to store the data. Only intended for internal usage.
      Returns:
      The Config associated with this PlayerProfile
    • 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.
    • createBackpack

      @Nonnull public PlayerBackpack createBackpack(int size)
    • getBackpack

      @Nonnull public Optional<PlayerBackpack> getBackpack(int id)
    • 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 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 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 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 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 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()
    • getBackpack

      public static void getBackpack(@Nullable ItemStack item, @Nonnull Consumer<PlayerBackpack> callback)
    • hasFullProtectionAgainst

      public boolean hasFullProtectionAgainst(@Nonnull ProtectionType type)
    • getPlayerData

      public PlayerData getPlayerData()
    • 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