Class SocialService

java.lang.Object
net.flectone.pulse.service.SocialService

public class SocialService extends Object
Service for managing social interactions and player settings in FlectonePulse. Handles player preferences including settings, colors, ignore lists, and mail messages. Integrates with proxy systems to synchronize social data across servers.
Since:
1.10.1
See Also:
  • Constructor Details

  • Method Details

    • invalidate

      public void invalidate(UUID uuid)
      Invalidates all cached social data for a player including colors, settings, and ignores.
      Parameters:
      uuid - the UUID of the player whose social data cache should be cleared
    • getSetting

      public @NonNull String getSetting(@NonNull FPlayer fPlayer, @NonNull ModuleName moduleName)
      Gets a player's setting value as a string by module name.
      Parameters:
      fPlayer - the player to get the setting for
      moduleName - the module name to retrieve the setting for
      Returns:
      the setting value as a string
    • getSetting

      public @Nullable String getSetting(@NonNull FPlayer fPlayer, @Nullable SettingText settingText)
      Gets a player's text setting value by SettingText enum.
      Parameters:
      fPlayer - the player to get the setting for
      settingText - the SettingText enum representing the setting type
      Returns:
      the text setting value, or null if not set
    • getSetting

      public @NonNull String getSetting(@NonNull FPlayer fPlayer, @Nullable String moduleName)
      Gets a player's boolean setting value as a string ("1" or "0").
      Parameters:
      fPlayer - the player to get the setting for
      moduleName - the setting name to retrieve
      Returns:
      "1" if the setting is true or not set, "0" if false
    • isSetting

      public boolean isSetting(@NonNull FPlayer fPlayer, @NonNull ModuleName messageType)
      Checks if a player has a boolean setting enabled by module name.
      Parameters:
      fPlayer - the player to check the setting for
      messageType - the module name to check
      Returns:
      true if the setting is enabled or not set, false if disabled
    • isSetting

      public boolean isSetting(@NonNull FPlayer fPlayer, @Nullable String moduleName)
      Checks if a player has a boolean setting enabled by name.
      Parameters:
      fPlayer - the player to check the setting for
      moduleName - the setting name to check
      Returns:
      true if the setting is enabled or not set, false if disabled
    • saveSetting

      public void saveSetting(@NonNull FPlayer fPlayer, @NonNull SettingText setting, @Nullable String value)
      Saves a text setting for a player and notifies proxy if enabled.
      Parameters:
      fPlayer - the player to save the setting for
      setting - the SettingText enum representing the setting type
      value - the text value to set, can be null
    • saveSetting

      public void saveSetting(@NonNull FPlayer fPlayer, @NonNull String setting, boolean value)
      Saves a boolean setting for a player and notifies proxy if enabled.
      Parameters:
      fPlayer - the player to save the setting for
      setting - the setting name to save
      value - the boolean value to set
    • loadSettings

      public @NonNull SocialRepository.Settings loadSettings(FPlayer fPlayer)
      Loads all settings for a player with caching enabled.
      Parameters:
      fPlayer - the player to load settings for
      Returns:
      Settings object containing boolean and text settings
    • loadSettings

      public @NonNull SocialRepository.Settings loadSettings(FPlayer fPlayer, boolean cache)
      Loads all settings for a player with optional cache control.
      Parameters:
      fPlayer - the player to load settings for
      cache - if true, use cached settings; if false, invalidate cache and reload from database
      Returns:
      Settings object containing boolean and text settings
    • loadColors

      public @NonNull Map<Integer,String> loadColors(@NonNull FPlayer fPlayer, @NonNull FColor.Type type)
      Loads colors of a specific type for a player and converts them to a number-to-name map.
      Parameters:
      fPlayer - the player to load colors for
      type - the color type to load
      Returns:
      map of color numbers to color names, empty if no colors found
    • loadColors

      public @NonNull Map<FColor.Type, Set<FColor>> loadColors(FPlayer fPlayer)
      Loads all colors for a player with caching enabled.
      Parameters:
      fPlayer - the player to load colors for
      Returns:
      map of color types to sets of FColor objects
    • loadColors

      public @NonNull Map<FColor.Type, Set<FColor>> loadColors(FPlayer fPlayer, boolean cache)
      Loads all colors for a player with optional cache control.
      Parameters:
      fPlayer - the player to load colors for
      cache - if true, use cached colors; if false, invalidate cache and reload from database
      Returns:
      map of color types to sets of FColor objects
    • saveColors

      public void saveColors(@NonNull FPlayer fPlayer, @NonNull FColor.Type type, @Nullable Set<FColor> newColors)
      Saves colors of a specific type for a player, merging with existing colors.
      Parameters:
      fPlayer - the player to save colors for
      type - the color type to save
      newColors - the set of new colors to save, can be null or empty to clear
    • saveColors

      public void saveColors(@NonNull FPlayer fPlayer, @NonNull Map<FColor.Type, Set<FColor>> colors)
      Saves all colors for a player and notifies proxy if enabled.
      Parameters:
      fPlayer - the player to save colors for
      colors - map of color types to sets of FColor objects to save
    • isIgnored

      public boolean isIgnored(@NonNull FPlayer fPlayer, @NonNull FPlayer fTarget)
      Checks if a player is ignoring another player.
      Parameters:
      fPlayer - the player who might be ignoring
      fTarget - the potential target being ignored
      Returns:
      true if fPlayer is ignoring fTarget, false otherwise
    • loadIgnores

      public @NonNull List<Ignore> loadIgnores(FPlayer fPlayer)
      Loads all ignore relationships for a player with caching enabled.
      Parameters:
      fPlayer - the player to load ignores for
      Returns:
      list of ignore relationships
    • loadIgnores

      public @NonNull List<Ignore> loadIgnores(FPlayer fPlayer, boolean cache)
      Loads all ignore relationships for a player with optional cache control.
      Parameters:
      fPlayer - the player to load ignores for
      cache - if true, use cached ignores; if false, invalidate cache and reload from database
      Returns:
      list of ignore relationships
    • getReceiverMails

      public @NonNull List<Mail> getReceiverMails(FPlayer fPlayer)
      Gets all mail messages received by a player.
      Parameters:
      fPlayer - the player who received the mail messages
      Returns:
      list of received mail messages
    • getSenderMails

      public @NonNull List<Mail> getSenderMails(FPlayer fPlayer)
      Gets all mail messages sent by a player.
      Parameters:
      fPlayer - the player who sent the mail messages
      Returns:
      list of sent mail messages
    • saveIgnore

      public @NonNull Optional<Ignore> saveIgnore(@NonNull FPlayer fPlayer, @NonNull FPlayer fTarget)
      Saves an ignore relationship between two players and notifies proxy if enabled.
      Parameters:
      fPlayer - the player who is ignoring
      fTarget - the player being ignored
      Returns:
      Optional containing the created ignore record, or empty if creation failed
    • saveMail

      public @NonNull Optional<Mail> saveMail(@NonNull FPlayer fPlayer, @NonNull FPlayer fTarget, @NonNull String message)
      Saves a mail message from one player to another.
      Parameters:
      fPlayer - the sender of the mail message
      fTarget - the recipient of the mail message
      message - the content of the mail message
      Returns:
      Optional containing the created mail record, or empty if creation failed
    • deleteIgnore

      public void deleteIgnore(@NonNull FPlayer fPlayer, @NonNull Ignore ignore)
      Deletes an ignore relationship and notifies proxy if enabled.
      Parameters:
      fPlayer - the player who was ignoring
      ignore - the ignore record to delete
    • deleteMail

      public void deleteMail(@NonNull Mail mail)
      Deletes a mail message from the database.
      Parameters:
      mail - the mail record to delete
    • updateLocale

      public boolean updateLocale(@NonNull FPlayer fPlayer, @NonNull String newLocale)
      Updates a player's locale setting based on Triton integration or provided value. Only updates if the locale has changed and the player is not unknown.
      Parameters:
      fPlayer - the player whose locale is being updated
      newLocale - the new locale to set if Triton locale is unavailable
      Returns:
      true if the locale was updated, false if unchanged or player is unknown
    • isVanished

      public boolean isVanished(@NonNull FEntity fEntity)
      Checks whether a given entity is currently in vanish mode (invisible to other players).

      This method first checks if the entity is a player with a configured vanish status setting. If not found locally, it delegates to the integration module to check external vanish providers.

      Parameters:
      fEntity - the entity to check for vanish status
      Returns:
      true if the entity is vanished, false otherwise
    • canSeeVanished

      public boolean canSeeVanished(@NonNull FEntity fTarget, @NonNull FEntity fViewer)
      Determines whether a viewer can see a target entity that may be in vanish mode.

      This is a convenience overload that automatically checks if the target is vanished.

      Parameters:
      fTarget - the target entity that might be vanished, must not be null
      fViewer - the viewer entity attempting to see the target, must not be null
      Returns:
      true if the viewer can see the target, false if the target is vanished and the viewer lacks permission
    • canSeeVanished

      public boolean canSeeVanished(@NonNull FEntity fTarget, @NonNull FEntity fViewer, boolean targetVanished)
      Determines whether a viewer can see a target entity with a known vanish status.

      The following rules apply:

      • An entity can always see itself
      • Console entities can always see vanished players
      • If the target is not vanished, any viewer can see them
      • If the target is vanished, only viewers with the appropriate permission can see them
      Parameters:
      fTarget - the target entity that might be vanished, must not be null
      fViewer - the viewer entity attempting to see the target, must not be null
      targetVanished - pre-computed vanish status of the target entity
      Returns:
      true if the viewer can see the target, false if the target is vanished and the viewer lacks permission