Class PlayerProfile
java.lang.Object
io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWaypoint(Waypoint waypoint) createBackpack(int size) booleanstatic Optional<PlayerProfile>This method tries to search for aPlayerProfileof the givenOfflinePlayer.static booleanfromUUID(UUID uuid, Consumer<PlayerProfile> callback) static booleanget(OfflinePlayer p, Consumer<PlayerProfile> callback) Get thePlayerProfilefor aOfflinePlayerasynchronously.getArmor()This method provides a fast way to access the armor of aPlayer.getBackpack(int id) static voidgetBackpack(ItemStack item, Consumer<PlayerBackpack> callback) io.github.bakedlibs.dough.config.ConfigDeprecated.This returns theGuideHistoryof thisPlayer.This returns thePlayerwho thisPlayerProfilebelongs to.This Method will return all Researches that thisPlayerhas unlockedgetTitle()This method gets the research title, as defined inconfig.yml, of thisPlayerProfilebased on the fraction of unlockedResearches of this player.getUUID()This returns theUUIDthisPlayerProfileis linked to.booleaninthashCode()booleanhasUnlocked(Research research) booleanThis method returns whether thisPlayerhas unlocked allResearches.booleanisDirty()This method returns whether the Profile has unsaved changesbooleanThis method returns whether thePlayerhas logged off.static Iterator<PlayerProfile>iterator()final voidCall this method if this Profile has unsaved changes.final voidCall this method if the Player has left.voidremoveWaypoint(Waypoint waypoint) static booleanThis requests an instance ofPlayerProfileto be loaded for the givenOfflinePlayer.voidsave()This method will save the Player's Researches and Backpacks to the hard drivevoidsendStats(CommandSender sender) This sends the statistics for the specifiedCommandSenderto theCommandSender.voidsetResearched(Research research, boolean unlock) This method sets the Player's "researched" status for this Research.toString()
-
Constructor Details
-
PlayerProfile
-
-
Method Details
-
getArmor
This method provides a fast way to access the armor of aPlayer. It returns a cached version, represented byHashedArmorpiece.- Returns:
- The cached armor for this
Player
-
getConfig
Deprecated.Look atgetPlayerData()instead for reading data.This returns theConfigwhich is used to store the data. Only intended for internal usage.- Returns:
- The
Configassociated with thisPlayerProfile
-
getUUID
This returns theUUIDthisPlayerProfileis linked to.- Returns:
- The
UUIDof ourPlayerProfile
-
isMarkedForDeletion
public boolean isMarkedForDeletion()This method returns whether thePlayerhas 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
This method sets the Player's "researched" status for this Research. Use the boolean to unlock or lock theResearch -
hasUnlocked
-
hasUnlockedEverything
public boolean hasUnlockedEverything()This method returns whether thisPlayerhas unlocked allResearches.- Returns:
- Whether they unlocked every
Research
-
getResearches
This Method will return all Researches that thisPlayerhas unlocked- Returns:
- A
Hashset<Research>of all Researches thisPlayerhas unlocked
-
getWaypoints
-
addWaypoint
- Parameters:
waypoint- TheWaypointto add
-
removeWaypoint
- Parameters:
waypoint- TheWaypointto 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
-
getBackpack
-
getTitle
This method gets the research title, as defined inconfig.yml, of thisPlayerProfilebased on the fraction of unlockedResearches of this player.- Returns:
- The research title of this
PlayerProfile
-
sendStats
This sends the statistics for the specifiedCommandSenderto theCommandSender. This includes research title, research progress and total xp spent.- Parameters:
sender- TheCommandSenderfor which to get the statistics and send them to.
-
getPlayer
This returns thePlayerwho thisPlayerProfilebelongs to. If thePlayeris offline, null will be returned.- Returns:
- The
Playerof thisPlayerProfileor null
-
getGuideHistory
This returns theGuideHistoryof thisPlayer. It is basically that player's browsing history.- Returns:
- The
GuideHistoryof thisPlayer
-
fromUUID
-
get
Get thePlayerProfilefor aOfflinePlayerasynchronously.- Parameters:
p- TheOfflinePlayerwho'sPlayerProfileto retrievecallback- The callback with thePlayerProfile- Returns:
- If the
OfflinePlayerwas cached or not.
-
request
This requests an instance ofPlayerProfileto be loaded for the givenOfflinePlayer. This method will return true if thePlayerProfilewas already found.- Parameters:
p- TheOfflinePlayerto request thePlayerProfilefor.- Returns:
- Whether the
PlayerProfilewas already loaded
-
find
This method tries to search for aPlayerProfileof the givenOfflinePlayer. The result of this method is anOptional, if noPlayerProfilewas found, an emptyOptionalwill be returned.- Parameters:
p- TheOfflinePlayerto get thePlayerProfilefor- Returns:
- An
Optionaldescribing the result
-
iterator
-
getBackpack
public static void getBackpack(@Nullable ItemStack item, @Nonnull Consumer<PlayerBackpack> callback) -
hasFullProtectionAgainst
-
getPlayerData
-
hashCode
public int hashCode() -
equals
-
toString
-
getPlayerData()instead for reading data.