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
ConstructorsConstructorDescriptionPlayerProfile(org.bukkit.OfflinePlayer p, int backpackNum) PlayerProfile(org.bukkit.OfflinePlayer p, int backpackNum, Set<Research> researches) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWaypoint(Waypoint waypoint) booleanstatic Optional<PlayerProfile> find(org.bukkit.OfflinePlayer p) This method tries to search for aPlayerProfileof the givenOfflinePlayer.static booleanfromUUID(UUID uuid, Consumer<PlayerProfile> callback) static booleanget(org.bukkit.OfflinePlayer p, Consumer<PlayerProfile> callback) Get thePlayerProfilefor aOfflinePlayerasynchronously.getArmor()This method provides a fast way to access the armor of aPlayer.intThis returns theGuideHistoryof thisPlayer.org.bukkit.OfflinePlayergetOwner()org.bukkit.entity.PlayerThis 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) This method returns whether thePlayerhas unlocked the givenResearchbooleanThis 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.intvoidremoveWaypoint(Waypoint waypoint) static booleanrequest(org.bukkit.OfflinePlayer p) This requests an instance ofPlayerProfileto be loaded for the givenOfflinePlayer.voidsave()This method will save the Player's Researches and Backpacks to the hard drivevoidThis method will save the Player's waypoint to the hard drivevoidsendStats(org.bukkit.command.CommandSender sender) This sends the statistics for the specifiedCommandSenderto theCommandSender.voidsetBackpackCount(int count) voidsetResearched(Research research, boolean unlock) This method sets the Player's "researched" status for this Research.toString()
-
Constructor Details
-
PlayerProfile
public PlayerProfile(@Nonnull org.bukkit.OfflinePlayer p, int backpackNum) -
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
-
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 -
saveAsync
public void saveAsync()This method will save the Player's waypoint 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
This method returns whether thePlayerhas unlocked the givenResearch -
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. -
nextBackpackNum
public int nextBackpackNum() -
getBackpackCount
public int getBackpackCount() -
setBackpackCount
public void setBackpackCount(int count) -
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
public void sendStats(@Nonnull org.bukkit.command.CommandSender sender) 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
@Nullable public org.bukkit.entity.Player 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
public static boolean get(@Nonnull org.bukkit.OfflinePlayer p, @Nonnull Consumer<PlayerProfile> callback) Get thePlayerProfilefor aOfflinePlayerasynchronously.- Parameters:
p- TheOfflinePlayerwho'sPlayerProfileto retrievecallback- The callback with thePlayerProfile- Returns:
- If the
OfflinePlayerwas cached or not.
-
request
public static boolean request(@Nonnull org.bukkit.OfflinePlayer p) 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
-
hasFullProtectionAgainst
-
hashCode
public int hashCode() -
equals
-
toString
-
getOwner
public org.bukkit.OfflinePlayer getOwner()
-