Class SocialService
java.lang.Object
net.flectone.pulse.service.SocialService
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 Summary
ConstructorsConstructorDescriptionSocialService(SocialRepository socialRepository, ProxyRegistry proxyRegistry, ProxySender proxySender) -
Method Summary
Modifier and TypeMethodDescriptionbooleancanSeeVanished(@NonNull FEntity fTarget, @NonNull FEntity fViewer) Determines whether a viewer can see a target entity that may be in vanish mode.booleancanSeeVanished(@NonNull FEntity fTarget, @NonNull FEntity fViewer, boolean targetVanished) Determines whether a viewer can see a target entity with a known vanish status.voiddeleteIgnore(@NonNull FPlayer fPlayer, @NonNull Ignore ignore) Deletes an ignore relationship and notifies proxy if enabled.voiddeleteMail(@NonNull Mail mail) Deletes a mail message from the database.getReceiverMails(FPlayer fPlayer) Gets all mail messages received by a player.getSenderMails(FPlayer fPlayer) Gets all mail messages sent by a player.@NonNull StringgetSetting(@NonNull FPlayer fPlayer, @Nullable String moduleName) Gets a player's boolean setting value as a string ("1" or "0").@NonNull StringgetSetting(@NonNull FPlayer fPlayer, @NonNull ModuleName moduleName) Gets a player's setting value as a string by module name.@Nullable StringgetSetting(@NonNull FPlayer fPlayer, @Nullable SettingText settingText) Gets a player's text setting value by SettingText enum.voidinvalidate(UUID uuid) Invalidates all cached social data for a player including colors, settings, and ignores.booleanChecks if a player is ignoring another player.booleanChecks if a player has a boolean setting enabled by name.booleanisSetting(@NonNull FPlayer fPlayer, @NonNull ModuleName messageType) Checks if a player has a boolean setting enabled by module name.booleanisVanished(@NonNull FEntity fEntity) Checks whether a given entity is currently in vanish mode (invisible to other players).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.@NonNull Map<FColor.Type, Set<FColor>> loadColors(FPlayer fPlayer) Loads all colors for a player with caching enabled.@NonNull Map<FColor.Type, Set<FColor>> loadColors(FPlayer fPlayer, boolean cache) Loads all colors for a player with optional cache control.loadIgnores(FPlayer fPlayer) Loads all ignore relationships for a player with caching enabled.loadIgnores(FPlayer fPlayer, boolean cache) Loads all ignore relationships for a player with optional cache control.@NonNull SocialRepository.SettingsloadSettings(FPlayer fPlayer) Loads all settings for a player with caching enabled.@NonNull SocialRepository.SettingsloadSettings(FPlayer fPlayer, boolean cache) Loads all settings for a player with optional cache control.voidsaveColors(@NonNull FPlayer fPlayer, @NonNull Map<FColor.Type, Set<FColor>> colors) Saves all colors for a player and notifies proxy if enabled.voidsaveColors(@NonNull FPlayer fPlayer, @NonNull FColor.Type type, @Nullable Set<FColor> newColors) Saves colors of a specific type for a player, merging with existing colors.saveIgnore(@NonNull FPlayer fPlayer, @NonNull FPlayer fTarget) Saves an ignore relationship between two players and notifies proxy if enabled.Saves a mail message from one player to another.voidsaveSetting(@NonNull FPlayer fPlayer, @NonNull String setting, boolean value) Saves a boolean setting for a player and notifies proxy if enabled.voidsaveSetting(@NonNull FPlayer fPlayer, @NonNull SettingText setting, @Nullable String value) Saves a text setting for a player and notifies proxy if enabled.booleanupdateLocale(@NonNull FPlayer fPlayer, @NonNull String newLocale) Updates a player's locale setting based on Triton integration or provided value.
-
Constructor Details
-
SocialService
@Inject public SocialService(SocialRepository socialRepository, ProxyRegistry proxyRegistry, ProxySender proxySender)
-
-
Method Details
-
invalidate
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
Gets a player's setting value as a string by module name.- Parameters:
fPlayer- the player to get the setting formoduleName- the module name to retrieve the setting for- Returns:
- the setting value as a string
-
getSetting
Gets a player's text setting value by SettingText enum.- Parameters:
fPlayer- the player to get the setting forsettingText- the SettingText enum representing the setting type- Returns:
- the text setting value, or null if not set
-
getSetting
Gets a player's boolean setting value as a string ("1" or "0").- Parameters:
fPlayer- the player to get the setting formoduleName- the setting name to retrieve- Returns:
- "1" if the setting is true or not set, "0" if false
-
isSetting
Checks if a player has a boolean setting enabled by module name.- Parameters:
fPlayer- the player to check the setting formessageType- the module name to check- Returns:
- true if the setting is enabled or not set, false if disabled
-
isSetting
Checks if a player has a boolean setting enabled by name.- Parameters:
fPlayer- the player to check the setting formoduleName- 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 forsetting- the SettingText enum representing the setting typevalue- the text value to set, can be null
-
saveSetting
-
loadSettings
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
Loads all settings for a player with optional cache control.- Parameters:
fPlayer- the player to load settings forcache- if true, use cached settings; if false, invalidate cache and reload from database- Returns:
- Settings object containing boolean and text settings
-
loadColors
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 fortype- the color type to load- Returns:
- map of color numbers to color names, empty if no colors found
-
loadColors
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
Loads all colors for a player with optional cache control.- Parameters:
fPlayer- the player to load colors forcache- 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 fortype- the color type to savenewColors- the set of new colors to save, can be null or empty to clear
-
saveColors
Saves all colors for a player and notifies proxy if enabled.- Parameters:
fPlayer- the player to save colors forcolors- map of color types to sets of FColor objects to save
-
isIgnored
-
loadIgnores
-
loadIgnores
Loads all ignore relationships for a player with optional cache control.- Parameters:
fPlayer- the player to load ignores forcache- if true, use cached ignores; if false, invalidate cache and reload from database- Returns:
- list of ignore relationships
-
getReceiverMails
-
getSenderMails
-
saveIgnore
Saves an ignore relationship between two players and notifies proxy if enabled.- Parameters:
fPlayer- the player who is ignoringfTarget- 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 messagefTarget- the recipient of the mail messagemessage- the content of the mail message- Returns:
- Optional containing the created mail record, or empty if creation failed
-
deleteIgnore
-
deleteMail
Deletes a mail message from the database.- Parameters:
mail- the mail record to delete
-
updateLocale
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 updatednewLocale- 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
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
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 nullfViewer- 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 nullfViewer- the viewer entity attempting to see the target, must not be nulltargetVanished- 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
-