Class StarPlayer

java.lang.Object
me.gamercoder215.starcosmetics.api.player.StarPlayer

public final class StarPlayer extends Object
Represents a player used by StarCosmetics to manage their configuration.
  • Constructor Details

    • StarPlayer

      public StarPlayer(@NotNull @NotNull OfflinePlayer player)
      Constructs a new StarPlayer.
      Parameters:
      player - OfflinePlayer to use
  • Method Details

    • getPlayer

      @NotNull public @NotNull OfflinePlayer getPlayer()
      Fetches the OfflinePlayer used to construct this StarPlayer.
      Returns:
      OfflinePlayer used
    • getName

      @NotNull public @NotNull String 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

      @NotNull public @NotNull UUID getUniqueId()
      Fetches the player's UUID.
      Returns:
      Player UUID
    • getFolder

      @NotNull public @NotNull File getFolder()
      Fetches the Folder this player's configuration files are stored in.
      Returns:
      Player's Data Folder
    • getConfig

      @NotNull public @NotNull FileConfiguration getConfig()
      Fetches the Main FileConfiguration of this StarPlayer.
      Returns:
      Main FileConfiguration Instance
    • getConfigFile

      @NotNull public @NotNull File getConfigFile()
      Fetches the File thatgetConfig() is stored in.
      Returns:
      Main Configuration File
    • hasCompleted

      public boolean hasCompleted(@NotNull @NotNull Completion c)
      Whether or not the player has completed the specified completion.
      Parameters:
      c - The completion to check.
      Returns:
      true if completed, false otherwise
    • setCompleted

      public void setCompleted(@NotNull @NotNull Completion c, boolean b)
      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

      public void sendNotification(@Nullable @Nullable String message)
      Sends a Notification to this StarPlayer.
      Parameters:
      message - Message to Send
    • setCompleted

      public void setCompleted(@NotNull @NotNull Completion c)
      Sets the completion of the specified completion to true.
      Parameters:
      c - The completion to set.
    • getSetting

      @Nullable public <T> T getSetting(@NotNull @NotNull PlayerSetting<T> s)
      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

      @Nullable public <T> T getSetting(@NotNull @NotNull PlayerSetting<T> setting, T def)
      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

      @Nullable public <T> T setSetting(@NotNull @NotNull PlayerSetting<T> setting, @Nullable T value)
      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

      public boolean hasSelectedCosmetic(@Nullable @Nullable Class<? extends Cosmetic> clazz)
      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

      @Nullable public @Nullable CosmeticLocation<?> getSelectedTrail(@NotNull @NotNull TrailType type)
      Fetches the selected trail cosmetic.
      Parameters:
      type - TrailType to 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 use
      cosmetic - 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

      @NotNull public @NotNull List<SoundEventSelection> getSoundSelections()
      Fetches a list of entries that this player has for sound events.
      Returns:
      List of Sound Event Entries
    • addSelection

      public void addSelection(@NotNull @NotNull SoundEventSelection s) throws IllegalArgumentException
      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

      public void removeSelection(@NotNull @NotNull SoundEventSelection selection)
      Removes an event selection from this player.
      Parameters:
      selection - Selection to Remove
    • removeSelection

      public void removeSelection(@NotNull @NotNull Class<? extends Event> clazz)
      Removes an event selection from this player.
      Parameters:
      clazz - Class of the selection's event to remove
    • removeSelection

      public void removeSelection(@NotNull @NotNull Sound s)
      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:
      SoundEventSelection Limit
    • setSelectionLimit

      public void setSelectionLimit(int limit) throws IllegalArgumentException
      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

      @Nullable public @Nullable Pet getSpawnedPet()
      Fetches the Pet this player has active.
      Returns:
      Pet Spawned, or null if not spawned
    • getHologramMessage

      @NotNull public @NotNull String getHologramMessage()
      Gets the message that will be displayed on the player's armor stand above their head.
      Returns:
      Message to Display, or an empty string if not set
    • setHologramMessage

      public void setHologramMessage(@Nullable @Nullable String message)
      Sets the message that will be displayed on the player's armor stand above their head. If the inputted message is null, the message will be set to an empty string.
      Parameters:
      message - Message to set
    • emote

      public void emote(@NotNull @NotNull Emote emote)
      Performs the specified emote.
      Parameters:
      emote - Emote to perform
    • isEmoting

      public boolean isEmoting()
    • 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.