Interface Message
By this, you're e.g. able to work with messages from the messages file or able to easily replace placeholders / chatcolors etc.
Start with build(String)
, buildByKey(String)
or buildByKey(String, String)
-
Method Summary
Modifier and TypeMethodDescriptionstatic Message
Creates an instance of a message.static Message
buildByKey
(String key) Creates an instance of a message.static Message
buildByKey
(String key, String def) Creates an instance of a message.void
Removes all previously added placeholders to this instance.Clones the current Message and creates a non-freeable variant.default String
done()
Will put the message into the MessageProccessor and returns the result.default String
done
(boolean freeInstance) Will put the message into the MessageProccessor and returns its result.default String
done
(@Nullable RemotePlayer sender) Same asdone(RemotePlayer, boolean)
and puts this instance automatically back into the pooldone
(@Nullable RemotePlayer sender, boolean freeInstance) Will put the message into the MessageProccessor and returns its result.default String
done
(@Nullable CommandSenderWrapper sender) Same asdone(CommandSenderWrapper, boolean)
and puts this instance automatically back into the pooldone
(@Nullable CommandSenderWrapper sender, boolean freeInstance) Will put the message into the MessageProccessor and returns its result.default String
done
(@Nullable CommandSender sender) Same asdone(CommandSender, boolean)
and puts this instance automatically back into the pooldone
(@Nullable CommandSender sender, boolean freeInstance) Will put the message into the MessageProccessor and returns its result.boolean
free()
Messages are stored in a pool to reduce memory usage.getRawMessage
(@Nullable String locale) This method is essential for the message processor.boolean
isFreed()
Returns whether the Message instance has been put back to the pool or not.default Message
placeholder
(String key, Object value) Adds a placeholder to the message.
It'll later reformat it from {key} to the value.placeholder
(String key, String value) Adds a placeholder to the message.default void
send
(RemotePlayer sender) Computes it and sends it to the personvoid
send
(RemotePlayer sender, boolean freeInstance) Computes it and sends it to the persondefault void
send
(CommandSenderWrapper sender) Computes it and sends it to the personvoid
send
(CommandSenderWrapper sender, boolean freeInstance) Computes it and sends it to the persondefault void
send
(CommandSender sender) Computes it and sends it to the personvoid
send
(CommandSender sender, boolean freeInstance) Computes it and sends it to the person
-
Method Details
-
getRawMessage
This method is essential for the message processor. It returns the String that shall be processed- Parameters:
locale
- Tries to find the message in the given locale. If it doesn't find any or if locale=null then it'll pick the default one- Returns:
- The raw/unformatted message
-
placeholder
Adds a placeholder to the message. It'll later reformat it from {key} to the value.- Parameters:
key
- The name of the placeholdervalue
- What the placeholder represents- Returns:
- This instance
-
placeholder
Adds a placeholder to the message.
It'll later reformat it from {key} to the value.- Parameters:
key
- The name of the placeholdervalue
- What the placeholder represents- Returns:
- This instance
-
clearPlaceholders
void clearPlaceholders()Removes all previously added placeholders to this instance. -
done
Will put the message into the MessageProccessor and returns its result.Message instances are stored in a pool to decrease memory usage.
By that they must be putten back when not used anymore. Or in other words: set "freeInstance" to false when you want to store this instance inside the memoryThis method also automatically replaces PAPI placeholders, in case this feature is enabled the user.
- Parameters:
sender
- Will take his language, otherwise the default language when nullfreeInstance
- If it should put this instance back into the pool or not- Returns:
- The final String
-
done
Same asdone(CommandSender, boolean)
and puts this instance automatically back into the pool- Parameters:
sender
- Will take his language, otherwise the default language when null- Returns:
- The final String
-
done
Will put the message into the MessageProccessor and returns its result.Message instances are stored in a pool to decrease memory usage.
By that they must be putten back when not used anymore. Or in other words: set "freeInstance" to false when you want to store this instance inside the memoryThis method also automatically replaces PAPI placeholders, in case this feature is enabled the user.
- Parameters:
sender
- Will take his language, otherwise the default language when nullfreeInstance
- If it should put this instance back into the pool or not- Returns:
- The final String
-
done
Same asdone(RemotePlayer, boolean)
and puts this instance automatically back into the pool- Parameters:
sender
- Will take his language, otherwise the default language when null- Returns:
- The final String
-
done
Will put the message into the MessageProccessor and returns its result.Message instances are stored in a pool to decrease memory usage.
By that they must be putten back when not used anymore. Or in other words: set "freeInstance" to false when you want to store this instance inside the memoryThis method also automatically replaces PAPI placeholders, in case this feature is enabled the user.
- Parameters:
sender
- Will take his language, otherwise the default language when nullfreeInstance
- If it should put this instance back into the pool or not- Returns:
- The final String
-
done
Same asdone(CommandSenderWrapper, boolean)
and puts this instance automatically back into the pool- Parameters:
sender
- Will take his language, otherwise the default language when null- Returns:
- The final String
-
done
Will put the message into the MessageProccessor and returns its result.Message instances are stored in a pool to decrease memory usage.
By that they must be putten back when not used anymore. Or in other words: set "freeInstance" to false when you want to store this instance inside the memoryThis method also automatically replaces PAPI placeholders, in case this feature is enabled the user.
- Parameters:
freeInstance
- If it should put this instance back into the pool or not- Returns:
- The final String
-
done
Will put the message into the MessageProccessor and returns the result.Does the same as
done(CommandSender)
, but passes null as sender.
Also puts this instance automatically back into the pool- Returns:
- The final String
-
send
Computes it and sends it to the person- Parameters:
sender
- The target
-
send
Computes it and sends it to the person- Parameters:
sender
- The target
-
send
Computes it and sends it to the person- Parameters:
sender
- The target
-
send
Computes it and sends it to the person- Parameters:
sender
- The targetfreeInstance
- If it should put this instance back into the pool or not
-
send
Computes it and sends it to the person- Parameters:
sender
- The targetfreeInstance
- If it should put this instance back into the pool or not
-
send
Computes it and sends it to the person- Parameters:
sender
- The targetfreeInstance
- If it should put this instance back into the pool or not
-
free
boolean free()Messages are stored in a pool to reduce memory usage. Invoke this method when you're done using it and want to put it back manually.
Keep in mind that the methodsdone()
anddone(CommandSender)
automatically are putting this instance back into memory unless told otherwise using the parameter "freeInstance".- Returns:
false
if it's already in the pool
-
isFreed
boolean isFreed()Returns whether the Message instance has been put back to the pool or not.- Returns:
- If it has been freed by now
-
cloneNonUpcyable
Message cloneNonUpcyable()Clones the current Message and creates a non-freeable variant.You may use it in sensible parts where you want to make sure that the instance 100% doesn't get freed at any moment.
- Returns:
- A new instance that can't be put back into the pool
-
build
Creates an instance of a message.It's being taken from a pool for greater performance.
Make sure that you won't use the instance after you randone()
ordone(CommandSender)
. Otherwise the system will break.- Parameters:
rawMessage
- The raw/unformatted message containing the placeholders, color codes etc.- Returns:
- An instance of Message to pass parameters
-
buildByKey
Creates an instance of a message.It's being taken from a pool for greater performance. Make sure that you won't reuse the instance after you ran
done()
ordone(CommandSender)
. Otherwise the system will break.
The difference to thebuild(String)
method is that this one will first try to get the key from the messages file. It'll use the given def String if it hasn't been found- Parameters:
key
- Will look for this key in the messages filedef
- Uses this if it hasn't found it in the messages file- Returns:
- An instance of Message to pass parameters
-
buildByKey
Creates an instance of a message.It's being taken from a pool for greater performance. Make sure that you won't reuse the instance after you ran
done()
ordone(CommandSender)
. Otherwise the system will break.
The difference to thebuild(String)
method is that this one will first try to get the key from the messages file. It'll use the given def String if it hasn't been foundUses they key itself if it does not exist
- Parameters:
key
- Will look for this key in the messages file- Returns:
- An instance of Message to pass parameters
-