Class Localizable
In the event that a Localizable
cannot be localized with the given
parameters or in its parent LocaleManager
's default locale, it will
output its internal key instead.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Broadcasts thisLocalizable
to all players on the server, applying the respective locale for each player.void
broadcast
(org.bukkit.World... worlds) Broadcasts thisLocalizable
to all players in the givenWorld
s.getKey()
Gets the key associated with thisLocalizable
's message.Gets the parentLocaleManager
for thisLocalizable
.localize()
Localizes thisLocalizable
in the owningLocaleManager
's default locale.localizeFor
(org.bukkit.command.CommandSender sender) Localizes thisLocalizable
for the givenCommandSender
.localizeIn
(String locale, String... fallbacks) Localizes thisLocalizable
in the given locale.void
sendTo
(org.bukkit.command.CommandSender sender) Sends thisLocalizable
to the givenCommandSender
.withPrefix
(String prefix) Sets the prefix to prepend to thisLocalizable
when it is localized.withReplacements
(String... replacements) Sets the replacements for placeholder sequences in thisLocalizable
.withReplacements
(Localizable... replacements) Sets the replacements for placeholder sequences in thisLocalizable
asLocalizable
objects.withSuffix
(String suffix) Sets the suffix to append to thisLocalizable
when it is localized.
-
Method Details
-
getParent
Gets the parentLocaleManager
for thisLocalizable
.- Returns:
- The parent
LocaleManager
for thisLocalizable
. - Since:
- 1.0
-
getKey
Gets the key associated with thisLocalizable
's message.- Returns:
- The key associated with this
Localizable
's message - Since:
- 1.0
-
withReplacements
Sets the replacements for placeholder sequences in thisLocalizable
.Placeholder sequences are defined as a percent symbol (%) followed by a number greater than or equal to 1. The first element of the replacement string array will replace any placeholder sequences matching
%1
, the second, sequences matching%2
, and so on.Note: Mutating the contents of the array passed as a parameter after calling this method will not impact this
Localizable
.- Parameters:
replacements
- The replacement strings to set for thisLocalizable
- Returns:
- This
Localizable
object, for chaining) - Since:
- 1.0
-
withReplacements
Sets the replacements for placeholder sequences in thisLocalizable
asLocalizable
objects. These objects will be localized appropriately when the parentLocalizable
(the object this method is invoked upon) is localized.Placeholder sequences are defined as a percent symbol (%) followed by a number greater than or equal to 1. The first element of the replacement string array will replace any placeholder sequences matching
%1
, the second, sequences matching%2
, and so on.Note: Mutating the contents of the array passed as a parameter after calling this method will not impact this
Localizable
.- Parameters:
replacements
- The replacement sequences to set for thisLocalizable
- Returns:
- This
Localizable
object, for chaining - Since:
- 1.1
-
withPrefix
Sets the prefix to prepend to thisLocalizable
when it is localized.- Parameters:
prefix
- The prefix to prepend to thisLocalizable
when it is localized.- Returns:
- This
Localizable
object, for chaining - Since:
- 1.0
-
withSuffix
Sets the suffix to append to thisLocalizable
when it is localized.- Parameters:
suffix
- The suffix to append to thisLocalizable
when it is localized.- Returns:
- This
Localizable
object, for chaining - Since:
- 1.0
-
localizeIn
Localizes thisLocalizable
in the given locale.It is unnecessary to include alternate dialects of a locale as fallbacks (e.g.
en_GB
as a fallback foren_US
), as they are included by default by the library.- Parameters:
locale
- The locale to localize thisLocalizable
infallbacks
- Locales to fall back upon if thisLocalizable
is not available in the player's locale (the parentLocaleManager
's default locale will be used if all fallbacks are exhausted, and if this is unavailable, the value ofgetKey()
will be used instead)- Returns:
- A string representing the localized message, or this
Localizable
's internal key if no localizations are available - Since:
- 1.0
-
localize
Localizes thisLocalizable
in the owningLocaleManager
's default locale.- Returns:
- The appropriate localization for this
Localizable
. - Since:
- 1.0
-
localizeFor
Localizes thisLocalizable
for the givenCommandSender
. If theCommandSender
is also aPlayer
, the message will be localized in their respective locale. Otherwise, it will be localized in the parentLocaleManager
's default locale.It is unnecessary to include alternate dialects of a locale as fallbacks (e.g.
en_GB
as a fallback foren_US
), as they are included by default by the library.- Parameters:
sender
- TheCommandSender
to localize thisLocalizable
for- Returns:
- A string representing the localized message, or this
Localizable
's internal key if no localizations are available - Since:
- 1.0
-
sendTo
public void sendTo(org.bukkit.command.CommandSender sender) Sends thisLocalizable
to the givenCommandSender
. If theCommandSender
is also aPlayer
, the message will be localized in their respective locale. Otherwise, it will be localized in the parentLocaleManager
's default locale.It is unnecessary to include alternate dialects of a locale as fallbacks (e.g.
en_GB
as a fallback foren_US
), as they are included by default by the library.- Parameters:
sender
- TheCommandSender
to send thisLocalizable
to- Since:
- 1.0
-
broadcast
public void broadcast()Broadcasts thisLocalizable
to all players on the server, applying the respective locale for each player.- Since:
- 1.0
-
broadcast
public void broadcast(org.bukkit.World... worlds) Broadcasts thisLocalizable
to all players in the givenWorld
s.- Parameters:
worlds
- TheWorld
s to broadcast to- Since:
- 1.0
-