Hello everyone! Happy to anounce that after a long break 10.0.0 update is out. This updates adds changes to both spigot and bungeecord servers. Please, note that this is a global update and 9.2.0 configuration IS NOT campatible with 10.0.0 one. However, update to a new configuration should not take long. If you have problems with moving to 10.0.0, you can always contact me and I will help you as fast I can.
What's new: The most important thing this update offers is addition of format rules, expanding placeholders defenition, implementation of argument and diamond brackets and developing custom java extensions for AdvancedNMotd that can do something you missed in the plugin. Should be mentioned that plugin is almost fully recoded. Whole project structer was completely changed and now plugin is
distributed under GNU GENERAL PUBLIC LICENSE Version 2, June 1991, text of which can be found inside a jar you downloaded or at plugin github page. You can find plugins source code at github link to which is provided on the main plugin page. Minor changes include plugin command, adding bstats, changing updater.
Let's take a look at each innovation one by one.
Format rules:
These are the rules that transform the text before displaying it somehow. They are specified before the text to which they are to be applied and are separated from this text by ':' symbol. Format rules may have arguments. If they do, these arguments are specified in [...] brackets separated from each other with space. Arguments may or may not have values. Let's call arguments that don't have values flags. Arguments let you to modify format rule behaviour. More about argument brackets can be found out below in the section dedicated to them below.
Currently there are 4 built in format rules: global format rule '' (empty), text format rule 'text', format rule 'format', format rule 'calc'. After their description it will be shown the use of them.
Global format rule '':
Returns text the way it gets it without transformation. It is the only rule that has no name. Comes handy when used with diamond brackets or when you store certain string in custom placeholder defined in 'placeholders.yml' file (like your server name) to which can be applied any style you don't know which one ahead.
Example:
Code (Text):
': Hello World'
Format rule 'text': Converts color codes to colors, replaces placeholders with actual values. It's result is basically what you used to get when used 9.2.0 copy of AdvancedNMotd. More information about placeholders that this rule and the rules that extand it parse will be stated in the paragraph dedicated to them.
Example:
Code (Text):
'text: &aHello %#123456%World!'
Format rule 'format': Expands format rule 'text' by letting you to manage text alignment. You can specify which part of some text will be shown on the left side, which part on the right side, and which part in the center. If you want to use this rule for symbols other than english or standard special once, you should read text in the spoiler below.
If you want to use language, besides english and/or special characters,
besides standard ones, then it is recommended to create '.yml' file
in 'AdvancedNMotd/languages' folder with lines in the following format:
characterOfYourAlphabet: characterSizeIn|Symbol
Where before ':' goes concrete character of your alphabet
and after ':' goes its size in '|' symbols.
For example, size of letter 'a' in '|' symbols is 5
and size of letter 'i' in '|' symbols is 1.
Otherwise, you may not be satisfied with how format rule aligns text.
By default, AdvancedNMotd consider that every unknown symbol is of size 5.
So you can (and should) only mention characters of size different to 5.
Please note, that since there is no way to center text in minecraft motd,
except with spaces, calculation error can be no less than one space (should
not be more than one space).
Also note, that because of described above, alignment may be broken
when motd is viewed with texture pack other than standard.
If you made your own language file, please, consider sharing it with the
community, by sending it to discussion section at plugin page. By doing
this you agree that I will provide link to the file, you shared, at plugin
main page with mentioning somehow that this is your file.
Example:
Code (Text):
'format: l{left} c{middle} r{right}'
Format rule 'calc': Used to calculate anything you want. It expands format rule 'text' and thus you can use any of placeholders that returns integer in it. Useful with diamond brackets that let you to perform calculations with dynamic data returned by placeholders (for example, lets you to create placeholder that return online 1 player bigger than current). This rule supports 1 argumet 'returnType' that can take any value of the following:
adaptable - returns result as an integer if fractional part is 0 else as double.
integer - always discards the fractional part of the number.
double - returns result with fractional part even if it is 0.
boolean - returns 0 if calculation result equals to 0 else 1
If 'returnType' argument is not specified then default value is 'adaptable'.
'calc: %online% + 1'
'calc: 2 +7 *(8--- 4//((((1)))+ 7)) >> 1' # understands even such weird expressions
Placeholders:
AdvancedNMotd 10.0.0 expands placeholders meaning. Now placeholders are standardized and as well can have arguments. Placeholder name is separated from arguments with ':' symbol. Arguments are separated from each other with ',' symbol. If placeholder does not have arguments, then ':' symbol can (and should) be omitted.
Example:
Code (Text):
%online% # placeholder supports 0 arguments, so ':' is omitted
%s: 50% # 50 is an argument that means to place 50 spaces (useful for version motd when create motd to left side of server favicon)
Known to you hex color placeholders now also have name 'color'.
Example:
However, to support compatibility with older AdvancedNMotd this is the only case where placeholder name can be omitted. So the example below is also correct:
Example:
Code (Text):
%#123456%
%#123456->#F0F0F0: text; &l; &o%
%s: X% - display X spaces, If you need to place 1 space, you can ommit argument X, so placeholder will look like %s%. This placeholder is useful for version motd when creating a text to left of server favicon.
%qq% - display double quote in motd.
%q% - display single quote in motd.
(%q% and %qq% placeholders are useful when you want to display both kinds of quotes in one line)
Argument Brackets
These are [...] brackets. They are used to customize format rule behaviour. As you could see above, they go right after format rule name if format rule has arguments and can be omitted if format rule does not have them.
If format rule has argument or flag, but it was not directly specified by user in [...] default value will be applied (see calc format rule above for live example).
You can have more than one [...] which can go one after another or alternate with <...>. Having more than one [...] is useful when you want to separate arguments by some basis or when you want to test new rule configuration: add new flags in another [...], so you can remove it anytime if you are not satisfied with result without thinking later what configuration you had.
Diamond Brackets
Mechanism that lets you to write scripts that process a string even if that string is generated dynamically and is the result of a placeholder. This mechanism is plugin side and can be applied for every format rule (even developed by independent developer (about this later)).
Diamond brackets are filled with commands. Each command ends with ';' and has an output. This output can be saved to custom variable if you use '= "_variable_name"'. Variable name needs to start with '_' symbol to avoid possible conflicts with format rule plugin variables. Regardless of whether the result of the command is saved to a custom variable or not, the result of the command execution is saved to the '%this%' variable. Thus, the '%this%' variable always contains the result of the last command.
Diamond brackets support these commands:
string "line" - creates a string; if line contains variables known by diamond brakets these variables are replaced with their value. This command can also be used to concatinate two strings like so: 'string "%_var1%%_var2%";'.
substring [startIndex, endIndex, "line"] - gets a part of the string from startIndex to endIndex inclusively. Numeration starts from 0. Instead of 'line' can be passed line that consists of string and/or placeholder(s).
parse "formatRule[argument brackets]<diamond bracket commands>: text" - applies format rule to certain text. Format rules registered by extensions also can be used in this command.
file "path/to/file" - runs diamond brackets script from file. Should be used when there are too many commands in one line or when you want to reuse same code.
return "dataToReturn" - command that must be used at the end of each file and at the end of the script. dataToReturn can contain text and/or placeholder(s).
Some of advantages: Diamond brackets let you to apply as many different format rules developed by different developers to one text as you want (lets say you want one something from one rule and something from another one). You can get part of dynamically generated placeholder (what was impossible in the past) and even modify placeholder output (or part of its output) anyhow you want by adding any text/styles before/after these output. Diamond brackets let you to do some simple things without writing your own AdvancedNMotd java extension. And they let you to slightly modify extensions developed by other developers without permission conflicts, because they don't modify source code of extensions, but modify the output of these extensions when these extensions had already finished processing.
Example:
Code (Text):
'<file "path/to/file/a.txt"; return "%this%";>: I am sad you know!'
Diamond brackets can be used to describe custom placeholders and custom format rules.
To describe custom
placeholder, open file 'AdvancedNMotd/aliases/placeholders.yml'.
Syntax: placeholderName: 'R[A]<D>: T'
R - format rule
A - argument brackes arguments (can be omitted)
D - diamond brackets commands (can be omitted)
T - any custom text
Usage: %placeholderName% in format rule 'text' or any that extends it.
Placeholder is replaced with result of execution of what in '...' comes.
Examples:
Code (Text):
# Placeholders from colors.yml file [existed in AdvancedNMotd 9.2.0] must be moved here like this:
brown: 'text: %#A52A2A%'
orange: 'text: %#FFA500%'
# Placeholder that returns online one player bigger than current one:
onlinePlusOne: '<parse "calc: %online% + 1"; return "%this%";>:'
# Here we used global format rule, because we just want to store a string and any kind of style can be applied to this string when this placeholder is used:
serverName: ': ExampleNetwork'
To describe custom
format rule, open file 'AdvancedNMotd/aliases/rules.yml'.
Syntax: ruleName: 'description of rule using diamond brackets'
# description of rule using diamond brackets must start with '<' and end with '>' symbols.
Usage: 'ruleName<possible diamond brackets code>: your custom text'
Example:
Code (Text):
# Creating a rule that centers text.
# The '...' is filled with a description of the formatting rule using diamond brackets.
# Therefore, the string must begin and end with '<' and '>' respectively.
# Once every user specified bracket for rule 'center' is executed the one that represents rule 'center' is.
# This achieves same behaviour as if 'center' format rule was a real (programmed) one.
center: '<parse "format: c{%this%}"; return "%this%";>'
Developing extensions for AdvancedNMotd
As it was already mentioned, now you can develop your own extensions for AdvancedNMotd. These extensions can register their own format rules and placeholders. AdvancedNMotd provides an API to develop your own extension. Since description of API requires a lot of text to type and this text is already not small, I will just mention that documentation will be located at this page:
https://namerpro.github.io/Advanced...mentation/documentation_article_selector.html. If you are interested in how to develop for AdvancedNMotd, please refer to it. It is currently not fully filled, but it will be as soon as I can. It also worths to mention that format rules are the ones that make it possible to write your own extensions. Now it can be seen that they also play the role of a kind of "namespaces". Each extension has its own so-called "namespace" where it can do whatever it wants without conflicting with another one.
Command change
Players cannot execute commands anymore. Commands can be only run from console. Command name changed from 'anm' to 'advancedNMotd'.
BStats added
Now AdvancedNMotd uses bstats. If you don't like it you can always turn it off in bstats configuration. However, I would be pleased to see that the plugin is really needed by someone. This keeps me motivated to work on the project. You can read more about bstats here:
https://bstats.org/.
Updater update
Updater now way less annoying. It can be turened off and plugin now can run offline. You can manage updater settings in 'config.yml' file. If updater is enabled plugin will check for updates on startup and every 24 hours then. Updater will display it is up-to-date no more than once. Updater will notify there is an update available no more than once.