public class Localizable
extends java.lang.Object
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.
Modifier and Type | Method and Description |
---|---|
void |
broadcast()
Broadcasts this
Localizable to all players on the server,
applying the respective locale for each player. |
void |
broadcast(org.bukkit.World... worlds)
Broadcasts this
Localizable to all players in the given
World s. |
java.lang.String |
getKey()
Gets the key associated with this
Localizable 's message. |
LocaleManager |
getParent()
Gets the parent
LocaleManager for this Localizable . |
java.lang.String |
localize()
Localizes this
Localizable in the owning LocaleManager 's
default locale. |
java.lang.String |
localizeFor(org.bukkit.command.CommandSender sender)
Localizes this
Localizable for the given CommandSender . |
java.lang.String |
localizeIn(java.lang.String locale,
java.lang.String... fallbacks)
Localizes this
Localizable in the given locale. |
void |
sendTo(org.bukkit.command.CommandSender sender)
Sends this
Localizable to the given CommandSender . |
Localizable |
withPrefix(java.lang.String prefix)
Sets the prefix to prepend to this
Localizable when it is
localized. |
Localizable |
withReplacements(Localizable... replacements)
Sets the replacements for placeholder sequences in this
Localizable as Localizable objects. |
Localizable |
withReplacements(java.lang.String... replacements)
Sets the replacements for placeholder sequences in this
Localizable . |
Localizable |
withSuffix(java.lang.String suffix)
Sets the suffix to append to this
Localizable when it is
localized. |
public LocaleManager getParent()
LocaleManager
for this Localizable
.LocaleManager
for this Localizable
.public java.lang.String getKey()
Localizable
's message.Localizable
's messagepublic Localizable withReplacements(java.lang.String... replacements)
Localizable
.
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
.
replacements
- The replacement strings to set for this
Localizable
Localizable
object, for chaining)public Localizable withReplacements(Localizable... replacements)
Localizable
as Localizable
objects. These objects will be
localized appropriately when the parent Localizable
(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
.
replacements
- The replacement sequences to set for this
Localizable
Localizable
object, for chainingpublic Localizable withPrefix(java.lang.String prefix)
Localizable
when it is
localized.prefix
- The prefix to prepend to this Localizable
when it
is localized.Localizable
object, for chainingpublic Localizable withSuffix(java.lang.String suffix)
Localizable
when it is
localized.suffix
- The suffix to append to this Localizable
when it
is localized.Localizable
object, for chainingpublic java.lang.String localizeIn(java.lang.String locale, java.lang.String... fallbacks)
Localizable
in the given locale.
It is unnecessary to include alternate dialects of a locale as
fallbacks (e.g. en_GB
as a fallback for en_US
), as they
are included by default by the library.
locale
- The locale to localize this Localizable
infallbacks
- Locales to fall back upon if this Localizable
is not available in the player's locale (the parent
LocaleManager
's default locale will be used if all fallbacks
are exhausted, and if this is unavailable, the value of
getKey()
will be used instead)Localizable
's internal key if no localizations are availablepublic java.lang.String localize()
Localizable
in the owning LocaleManager
's
default locale.Localizable
.public java.lang.String localizeFor(org.bukkit.command.CommandSender sender)
Localizable
for the given CommandSender
.
If the CommandSender
is also a Player
, the message will
be localized in their respective locale. Otherwise, it will be localized
in the parent LocaleManager
's default locale.
It is unnecessary to include alternate dialects of a locale as
fallbacks (e.g. en_GB
as a fallback for en_US
), as they
are included by default by the library.
sender
- The CommandSender
to localize this Localizable
forLocalizable
's internal key if no localizations are availablepublic void sendTo(org.bukkit.command.CommandSender sender)
Localizable
to the given CommandSender
. If the
CommandSender
is also a Player
, the message will be
localized in their respective locale. Otherwise, it will be localized in
the parent LocaleManager
's default locale.
It is unnecessary to include alternate dialects of a locale as
fallbacks (e.g. en_GB
as a fallback for en_US
), as they
are included by default by the library.
sender
- The CommandSender
to send this Localizable
topublic void broadcast()
Localizable
to all players on the server,
applying the respective locale for each player.public void broadcast(org.bukkit.World... worlds)
Localizable
to all players in the given
World
s.worlds
- The World
s to broadcast to