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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addWaypoint
(Waypoint waypoint) createBackpack
(int size) boolean
static Optional<PlayerProfile>
This method tries to search for aPlayerProfile
of the givenOfflinePlayer
.static boolean
fromUUID
(UUID uuid, Consumer<PlayerProfile> callback) static boolean
get
(OfflinePlayer p, Consumer<PlayerProfile> callback) Get thePlayerProfile
for aOfflinePlayer
asynchronously.getArmor()
This method provides a fast way to access the armor of aPlayer
.getBackpack
(int id) static void
getBackpack
(ItemStack item, Consumer<PlayerBackpack> callback) io.github.bakedlibs.dough.config.Config
Deprecated.This returns theGuideHistory
of thisPlayer
.This returns thePlayer
who thisPlayerProfile
belongs to.This Method will return all Researches that thisPlayer
has unlockedgetTitle()
This method gets the research title, as defined inconfig.yml
, of thisPlayerProfile
based on the fraction of unlockedResearch
es of this player.getUUID()
This returns theUUID
thisPlayerProfile
is linked to.boolean
int
hashCode()
boolean
hasUnlocked
(Research research) boolean
This method returns whether thisPlayer
has unlocked allResearches
.boolean
isDirty()
This method returns whether the Profile has unsaved changesboolean
This method returns whether thePlayer
has logged off.static Iterator<PlayerProfile>
iterator()
final void
Call this method if this Profile has unsaved changes.final void
Call this method if the Player has left.void
removeWaypoint
(Waypoint waypoint) static boolean
This requests an instance ofPlayerProfile
to be loaded for the givenOfflinePlayer
.void
save()
This method will save the Player's Researches and Backpacks to the hard drivevoid
sendStats
(CommandSender sender) This sends the statistics for the specifiedCommandSender
to theCommandSender
.void
setResearched
(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 theConfig
which is used to store the data. Only intended for internal usage.- Returns:
- The
Config
associated with thisPlayerProfile
-
getUUID
This returns theUUID
thisPlayerProfile
is linked to.- Returns:
- The
UUID
of ourPlayerProfile
-
isMarkedForDeletion
public boolean isMarkedForDeletion()This method returns whether thePlayer
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
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 thisPlayer
has unlocked allResearches
.- Returns:
- Whether they unlocked every
Research
-
getResearches
This Method will return all Researches that thisPlayer
has unlocked- Returns:
- A
Hashset<Research>
of all Researches thisPlayer
has unlocked
-
getWaypoints
-
addWaypoint
- Parameters:
waypoint
- TheWaypoint
to add
-
removeWaypoint
- Parameters:
waypoint
- TheWaypoint
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
-
getBackpack
-
getTitle
This method gets the research title, as defined inconfig.yml
, of thisPlayerProfile
based on the fraction of unlockedResearch
es of this player.- Returns:
- The research title of this
PlayerProfile
-
sendStats
This sends the statistics for the specifiedCommandSender
to theCommandSender
. This includes research title, research progress and total xp spent.- Parameters:
sender
- TheCommandSender
for which to get the statistics and send them to.
-
getPlayer
This returns thePlayer
who thisPlayerProfile
belongs to. If thePlayer
is offline, null will be returned.- Returns:
- The
Player
of thisPlayerProfile
or null
-
getGuideHistory
This returns theGuideHistory
of thisPlayer
. It is basically that player's browsing history.- Returns:
- The
GuideHistory
of thisPlayer
-
fromUUID
-
get
Get thePlayerProfile
for aOfflinePlayer
asynchronously.- Parameters:
p
- TheOfflinePlayer
who'sPlayerProfile
to retrievecallback
- The callback with thePlayerProfile
- Returns:
- If the
OfflinePlayer
was cached or not.
-
request
This requests an instance ofPlayerProfile
to be loaded for the givenOfflinePlayer
. This method will return true if thePlayerProfile
was already found.- Parameters:
p
- TheOfflinePlayer
to request thePlayerProfile
for.- Returns:
- Whether the
PlayerProfile
was already loaded
-
find
This method tries to search for aPlayerProfile
of the givenOfflinePlayer
. The result of this method is anOptional
, if noPlayerProfile
was found, an emptyOptional
will be returned.- Parameters:
p
- TheOfflinePlayer
to get thePlayerProfile
for- Returns:
- An
Optional
describing 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.