Class Message
java.lang.Object
me.wiefferink.interactivemessenger.processing.Message
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionAppend lines to the messageAppend lines to the messageAppend a message to this messageApply all replacements to the messagedoReplacements(Limit limit)
Apply replacements to the message using a certain Limit (intended for internal and testing use)static Message
empty()
Empty message objectstatic Message
Construct a message from a language key Requires a MessageProvider to be setstatic Message
Construct a message from a string liststatic Message
fromString(String message)
Construct a message from a stringget()
Get the message with all replacements donegetKey()
Get the key that has been used to initialize this message (if any)static String
getMessageStart(Message message, int maximumLength)
Get a start of the message with a maximum lengthgetPlain()
Get a plain string for the message (for example for using in the console)getRaw()
Get the raw message without replacing anythingGet the message with all replacements doneGet the message with all replacements doneGet raw message as stringstatic void
init(MessageProvider provider, Logger logger)
Initialize the Message classinline()
Mark this message as inline, used for insertion into other messagesboolean
isEmpty()
Check if the message is emptyTurn off language replacements for this messageprefix()
Add the default prefix to the messageprefix(boolean doIt)
Add the default prefix to the message (if the message is not empty)Prepend lines to the messagePrepend lines to the messagePrepend a message to this messagereplacements(Object... replacements)
Set the replacements to apply to the messageSend the message to a targettoString()
static void
useColorsInConsole(boolean enabled)
Enable or disable the use of colors when sending a message to a target that is not a Player (console, log, etcetera)static void
useFancyMessages(boolean enabled)
Enable or disable the use of fancy messages
-
Field Details
-
VARIABLE_START
- See Also:
- Constant Field Values
-
VARIABLE_END
- See Also:
- Constant Field Values
-
LANGUAGE_KEY_PREFIX
- See Also:
- Constant Field Values
-
VARIABLE_PATTERN
-
LANGUAGE_VARIABLE_PATTERN
-
CHATLANGUAGEVARIABLE
- See Also:
- Constant Field Values
-
REPLACEMENTLIMIT
public static final int REPLACEMENTLIMIT- See Also:
- Constant Field Values
-
MAXIMUMJSONLENGTH
public static final int MAXIMUMJSONLENGTH- See Also:
- Constant Field Values
-
-
Method Details
-
init
Initialize the Message class- Parameters:
provider
- The provider to use for getting messages based on keyslogger
- The logger to use for logging warning and error messages
-
empty
Empty message object- Returns:
- this
-
fromKey
Construct a message from a language key Requires a MessageProvider to be set- Parameters:
key
- The key of the message to use- Returns:
- this
-
fromString
Construct a message from a string- Parameters:
message
- The message to use- Returns:
- this
-
fromList
Construct a message from a string list- Parameters:
message
- The message to use- Returns:
- this
-
useFancyMessages
public static void useFancyMessages(boolean enabled)Enable or disable the use of fancy messages- Parameters:
enabled
- true to enable, false to disable
-
useColorsInConsole
public static void useColorsInConsole(boolean enabled)Enable or disable the use of colors when sending a message to a target that is not a Player (console, log, etcetera)- Parameters:
enabled
- true to enable, false to disable
-
get
Get the message with all replacements done- Returns:
- Message as a list
-
getSingle
Get the message with all replacements done- Returns:
- Message as a string
-
getSingle
Get the message with all replacements done- Parameters:
limit
- Limit to use while processing- Returns:
- Message as a string
- Throws:
ReplacementLimitReachedException
- when the limit is reached
-
getRaw
Get the raw message without replacing anything- Returns:
- The message
-
getSingleRaw
Get raw message as string- Returns:
- The raw message
-
getPlain
Get a plain string for the message (for example for using in the console)- Returns:
- The message as simple string
-
isEmpty
public boolean isEmpty()Check if the message is empty- Returns:
- true if the message is empty, otherwise false
-
prefix
Add the default prefix to the message (if the message is not empty)- Parameters:
doIt
- true if the prefix should be added, otherwise false- Returns:
- this
-
prefix
Add the default prefix to the message- Returns:
- this
-
replacements
Set the replacements to apply to the message- Parameters:
replacements
- The replacements to apply - GeneralRegion: All region replacements are applied - Message: Message is inserted - other: index tag is replaced, like %0%- Returns:
- this
-
append
Append lines to the message- Parameters:
lines
- The lines to append- Returns:
- this
-
append
Append a message to this message- Parameters:
message
- The message to append- Returns:
- this
-
append
Append lines to the message- Parameters:
line
- The line to append- Returns:
- this
-
prepend
Prepend lines to the message- Parameters:
lines
- The lines to prepend- Returns:
- this
-
prepend
Prepend a message to this message- Parameters:
message
- The message to prepend- Returns:
- this
-
prepend
Prepend lines to the message- Parameters:
line
- The line to prepend- Returns:
- this
-
noLanguageReplacements
Turn off language replacements for this message- Returns:
- this
-
inline
Mark this message as inline, used for insertion into other messages- Returns:
- this
-
send
Send the message to a target- Parameters:
target
- The target to send the message to (Player, CommandSender, Logger)- Returns:
- this
-
getKey
Get the key that has been used to initialize this message (if any)- Returns:
- Key used to create this message, or null if none
-
doReplacements
Apply all replacements to the message- Returns:
- this
-
doReplacements
Apply replacements to the message using a certain Limit (intended for internal and testing use)- Parameters:
limit
- Limit to apply- Returns:
- this
- Throws:
ReplacementLimitReachedException
- When the limit has been hit before replacement is finished
-
toString
-
getMessageStart
Get a start of the message with a maximum length- Parameters:
message
- The messagemaximumLength
- The maximum length to return- Returns:
- The start of the message with at most maximumLength characters
-