Class StarPlayer
java.lang.Object
me.gamercoder215.starcosmetics.api.player.StarPlayer
Represents a player used by StarCosmetics to manage their configuration.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSelection(@NotNull SoundEventSelection s) Adds an event selection to this player.voidaddSelections(@NotNull Iterable<SoundEventSelection> it) Adds an iterable of SoundEventSelections to this player.voidaddSelections(@NotNull SoundEventSelection... selections) Adds an array of SoundEventSelections to this player.voidRemoves all event selections from this player.@NotNull FileConfigurationFetches the Main FileConfiguration of this StarPlayer.@NotNull FileFetches the File thatgetConfig()is stored in.@NotNull FileFetches the Folder this player's configuration files are stored in.@NotNull StringgetName()Fetches the player's name.@NotNull OfflinePlayerFetches the OfflinePlayer used to construct this StarPlayer.@Nullable CosmeticLocation<?>getSelectedCosmetic(@Nullable Class<? extends Cosmetic> clazz) Fetches the selected cosmetic.@Nullable CosmeticLocation<?>getSelectedTrail(@NotNull TrailType type) Fetches the selected trail cosmetic.intFetches the limit of sound event selections this player can have.<T> TgetSetting(@NotNull PlayerSetting<T> s) Fetches the setting's value.<T> TgetSetting(@NotNull PlayerSetting<T> setting, T def) Fetches the setting's value.@NotNull List<SoundEventSelection>Fetches a list of entries that this player has for sound events.@Nullable PetFetches the Pet this player has active.@NotNull UUIDFetches the player's UUID.booleanhasCompleted(@NotNull Completion c) Whether or not the player has completed the specified completion.booleanhasSelectedCosmetic(@Nullable Class<? extends Cosmetic> clazz) Whether this StarPlayer has a selected cosmetic for this class.booleanisOnline()Utility method to check whether a player is online.voidremoveSelection(@NotNull Class<? extends Event> clazz) Removes an event selection from this player.voidremoveSelection(@NotNull SoundEventSelection selection) Removes an event selection from this player.voidremoveSelection(@NotNull Sound s) Removes an event selection from this player.voidsave()Saves all of this StarPlayer's configuration.voidsendNotification(@Nullable String message) Sends a Notification to this StarPlayer.voidsetCompleted(@NotNull Completion c) Sets the completion of the specified completion to true.voidsetCompleted(@NotNull Completion c, boolean b) Sets the completion of the specified completion to the specified value.voidsetSelectedCosmetic(@NotNull Class<? extends Cosmetic> clazz, @Nullable CosmeticLocation<?> loc) Sets the selected cosmetic.voidsetSelectedTrail(@NotNull TrailType type, @Nullable CosmeticLocation<?> cosmetic) Sets the selected Trail Cosmetic for the specified Trail Type.voidsetSelectionLimit(int limit) Sets the limit of sound event selections this player can have.<T> TsetSetting(@NotNull PlayerSetting<T> setting, T value) Sets the specified setting to the specified value.voidtick()Ticks this StarPlayer, running any necessary tasks (i.e.
-
Constructor Details
-
StarPlayer
Constructs a new StarPlayer.- Parameters:
player- OfflinePlayer to use
-
-
Method Details
-
getPlayer
Fetches the OfflinePlayer used to construct this StarPlayer.- Returns:
- OfflinePlayer used
-
getName
Fetches the player's name.- Returns:
- Player Name
-
isOnline
public boolean isOnline()Utility method to check whether a player is online.- Returns:
- true if the player is online, false otherwise
- See Also:
-
getUniqueId
Fetches the player's UUID.- Returns:
- Player UUID
-
getFolder
Fetches the Folder this player's configuration files are stored in.- Returns:
- Player's Data Folder
-
getConfig
Fetches the Main FileConfiguration of this StarPlayer.- Returns:
- Main FileConfiguration Instance
-
getConfigFile
Fetches the File thatgetConfig()is stored in.- Returns:
- Main Configuration File
-
hasCompleted
Whether or not the player has completed the specified completion.- Parameters:
c- The completion to check.- Returns:
- true if completed, false otherwise
-
setCompleted
Sets the completion of the specified completion to the specified value.- Parameters:
c- The completion to set.b- The value to set the completion to.
-
sendNotification
Sends a Notification to this StarPlayer.- Parameters:
message- Message to Send
-
setCompleted
Sets the completion of the specified completion to true.- Parameters:
c- The completion to set.
-
getSetting
Fetches the setting's value.- Type Parameters:
T- The type of the setting.- Parameters:
s- The setting to check.- Returns:
- Setting Value, or default value if not found
-
getSetting
Fetches the setting's value.- Type Parameters:
T- The type of the setting.- Parameters:
setting- The setting to check.def- The default value to return if the setting is not set.- Returns:
- Setting Value, or default value if not found
-
setSetting
Sets the specified setting to the specified value.- Type Parameters:
T- Setting Type- Parameters:
setting- The setting to set.value- The value to set the setting to.- Returns:
- value set
-
getSelectedCosmetic
@Nullable public @Nullable CosmeticLocation<?> getSelectedCosmetic(@Nullable @Nullable Class<? extends Cosmetic> clazz) Fetches the selected cosmetic.- Parameters:
clazz- The class of the cosmetic to fetch.- Returns:
- Selected Cosmetic for this Cosmetic Class
-
tick
public void tick()Ticks this StarPlayer, running any necessary tasks (i.e. particle shapes) every tick. Ran asynchronously and is thread safe. -
hasSelectedCosmetic
Whether this StarPlayer has a selected cosmetic for this class.- Parameters:
clazz- The class of the cosmetic to set.- Returns:
- true if selected, false otherwise
-
getSelectedTrail
Fetches the selected trail cosmetic.- Parameters:
type-TrailTypeto use- Returns:
- Selected Cosmetic for this Trail Type
-
setSelectedTrail
public void setSelectedTrail(@NotNull @NotNull TrailType type, @Nullable @Nullable CosmeticLocation<?> cosmetic) Sets the selected Trail Cosmetic for the specified Trail Type.- Parameters:
type- Trail Type to usecosmetic- The cosmetic to set.
-
setSelectedCosmetic
public void setSelectedCosmetic(@NotNull @NotNull Class<? extends Cosmetic> clazz, @Nullable @Nullable CosmeticLocation<?> loc) Sets the selected cosmetic.- Parameters:
clazz- The class of the cosmetic to set.loc- The location to set the cosmetic to.
-
getSoundSelections
Fetches a list of entries that this player has for sound events.- Returns:
- List of Sound Event Entries
-
addSelection
Adds an event selection to this player.- Parameters:
s- Selection to Add- Throws:
IllegalArgumentException- if added selections exceed limit or does not match owner
-
addSelections
public void addSelections(@NotNull @NotNull Iterable<SoundEventSelection> it) throws IllegalArgumentException Adds an iterable of SoundEventSelections to this player.- Parameters:
it- Iterable of SoundEventSelections to add- Throws:
IllegalArgumentException- if added selections exceed limit or does not match owner
-
addSelections
public void addSelections(@NotNull @NotNull SoundEventSelection... selections) throws IllegalArgumentException Adds an array of SoundEventSelections to this player.- Parameters:
selections- Array of SoundEventSelections to add- Throws:
IllegalArgumentException- if added selections exceed limit or does not match owner
-
removeSelection
Removes an event selection from this player.- Parameters:
selection- Selection to Remove
-
removeSelection
Removes an event selection from this player.- Parameters:
clazz- Class of the selection's event to remove
-
removeSelection
Removes an event selection from this player.- Parameters:
s- Sound to remove
-
clearEventSelections
public void clearEventSelections()Removes all event selections from this player. -
getSelectionLimit
public int getSelectionLimit()Fetches the limit of sound event selections this player can have.- Returns:
SoundEventSelectionLimit
-
setSelectionLimit
Sets the limit of sound event selections this player can have.- Parameters:
limit- Limit to set- Throws:
IllegalArgumentException- if limit is less than 0 or bigger than 35
-
getSpawnedPet
Fetches the Pet this player has active.- Returns:
- Pet Spawned, or null if not spawned
-
save
public void save()Saves all of this StarPlayer's configuration.
Methods that edit the configuration automatically save the configuration, so an additional call is not necessary.
-