Localisation - mdsimmo/bomberman GitHub Wiki

Virtually every message and command name in Bomberman is fully customisable to suit whatever language/preferences your server uses.

Write any changes in plugin/Bomberman/messages.yml. All default messages are defined in english.yml.

Message syntax

Bomberman uses it's own micro language for ease of writing messages.

Functions can be called as {#function|arg0|arg1|...}. All functions will expand into text which can then be used by wrapping functions. Custom functions are possible through {#|...}. Available builtin functions are described below.

Some messages have additional objects which are accessed as {object|modifier...}. The type of the object defines what arguments can be requested of it. The objects available to each message is defined in english.yml. The types are defined below.

Everything is case-insensitive.

Use \ to escape special characters. Note, yaml also uses \ as an escape character when quoted with ", so you need to use \\ to get a single \.

A entire brace can be escaped by adding a ! after the opening brace. {#green|{!#func|{#=|1+2}}} is identical to {#green|\{#func\|\{#=\|1+2\}\}}. This is typically used with list functions to provide a delayed expansion.

Functions

Colours

Messages can be coloured like so:

My message is {#Green|colored in {blue|{bold|many} different} colours}.

Note that this is much better than using the Minecraft formatting codes as it starts and ends colours and formats in the right places. Also, messages embedded into other messages will be formatted correctly.

The following colours and formats are possible:

Colours:

  • aqua
  • black
  • blue
  • dark_aqua
  • dark_blue
  • dark_gray
  • dark_green
  • dark_purple
  • dark_red
  • gold
  • gray
  • green
  • light_purple
  • red
  • white
  • yellow

These formats are available:

  • bold
  • italic
  • magic
  • strikethrough
  • underline

Equations

Math can be performed using

{=|equation}

Example: 5+6sin(90)={=|5+6sin(90)} will display as 5+6*sin(90)=11

Standard operator precedence is applied

The equation parser uses exp4j (they get all the credit here).

Operators

In order of precedence:

  • ^: exponential
  • +, -, !: Unary plus, Unary minus, Not
  • +, -: Plus, Minus
  • *, /, %: Multiply, Divide, Modulo
  • <=, >=, <, >: Greater/Less than
  • ==, !=: Equals, Not Equal

Binary operators treat any non-zero number as true

Functions

  • abs: absolute value
  • acos: arc cosine
  • asin: arc sine
  • atan: arc tangent
  • cbrt: cubic root
  • ceil: nearest upper integer
  • cos: cosine
  • cosh: hyperbolic cosine
  • exp: exponetial (e^x)
  • floor: nearest lower integer
  • log: logarithm (base e)
  • log10: logarithm (base 10)
  • log2: logarithm (base 2)
  • round: round (0.5 goes to +inf)
  • sin: sine
  • sinh: hyperbolic sine
  • sqrt: square root
  • tan: tangent
  • tanh: hyperbolic tangent
  • signum: signum (+1 possive, -1 negative, 0 zero)

Angles are in degrees

Constants

  • pi, π: Pi (3.14...)
  • e: Eulers number (2.718...)
  • φ: Golden ratio (1.618...)

Switch clause

The switch statement can be used similar to a if-else tree. It's syntax is:

{#switch|value|test1|result1|...|testn|resultn|default}

This is the same as the pseudo code:

    if value == test1:
      return result1
    ...
    else if value == testn:
      return resultn
    else if has_default
      return default
    else
      return ""

The comparison is a string comparison, so, "10.0" is not equal to "10" or "1e1". It also compares color formats. Use {=|...} to manipulate the strings to numbers (e.g {#switch|{#=|10.0}|{=|1e1}|same|different} will produce same)

Raw

{#raw}

All messages will by default be wrapped in format.message. Use {#raw} to stop this behavior.

Title

{#title|title|subtitle|fadeInTicks=0|stayTicks=20|fadeOutTicks=0}

Displays the messages as a title popup.

If this function used inside a separate message, the function will expand to an empty string. Both the content in the title and the outer message will be sent to the player. It is possible to have an optional title displayed with {#switch|...}

Execute

{#exec|command}

Runs the command as the console. Returns an empty string. If {#exec|...} is inside {#switch|...}, then the command will only be executed if the selected switch block is chosen.

Regex

{#regex|text|pattern|replace}

Runs a regex over the text. Regular expressions are (Java style)[https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html]

Sub

{#sub|text|start|[length]}

Gets a sub string of text.

If start is positive (or zero), defines zero based start index of the first character to be returned.

{#sub|icecream|3} returns cream

If start is negative, specifies the number of characters to return from the end of the string

{#sub|icecream|-3} returns eam

If length is present and possitive, defines how many characters past the start position to return

{#sub|icecream|3|2} returns cr {#sub|icecream|-3|2} returns ea

If length is present and negative, defines how many characters before the end of the string to cut off

{#sub|icecream|3|-2} returns cre {#sub|icecream|-3|-2} returns e

It is safe to exceed the bounds of the text {#sub|icecream|10} returns `{#sub|icecream|3|7}` returns `cream` `{#sub|icecream|3|-7}` returns

Pad Left

{#padl|text|length|padding=' '}

Left pads a string to a specific size with given characters (defaults to spaces)

{#padl|7|3|0} returns 007

If padding is multiple characters, then it will be applied repeating until the length is reached.

{#padl|ab|7|xyz} returns xyzxyab

If the text is longer that the length, than the entire text is returned

{#padl|longtext|3} returns longtext

Pad Right

{#padr|text|length|padding=' '}

Same as #padl, but pads on the right side.

Rand

{#rand|min=0|max=1}

Returns a random floating point number between min (inclusive) and max (exclusive).

  • If no arguments are supplied, result is between 0 and 1.
  • If one argument given, result is between 0 and max
  • If two arguments given, result is between min and max

Custom Functions

{#|path|arg0|arg1|...}

Evaluates the path with the given arguments. Generally used to define new format styles - it is used in-game to define map, list and heading styles.

The astute observer will notice that in combination with {=|...}, and {#sub|...} messages can be really complex code. Recursion is permitted, however, it will quickly fill up the stack (will maybe improve this a latter version). I think messages are Turing complete.

Object Types

Many of the messages will have arguments passed to them. The arguments passed to each message are stated in english.yml

A message can use that argument like so:

The value of 'value' is: {value}

"{value}" will then be replaced with whatever "value" was.

Some arguments take sub arguments which can be specified with the '|' symbol:

The game has {game|players} players

You can also chain arguments together if the returned value takes further arguments

The game is {game|schema|ysize} blocks tall

Arguments can be used in functions:

The volume of {arena} is {Green|{=|{arena|xsize}*{arena|ysize}*{arena|zsize}} blocks}

Sub argument lookup chart

Argument Sub-args
game none: same as name
name: the game's name
schema: the game's schematic's name
players: a list of players currently joined
spawns: a list of spawn points. (each spawn point has x,y,z,world)
power: the amount of power a player starts with
bombs: the amount of tnt a player starts with
lives: the amount of lives a player starts with
<x,y,z>: the x.y.z location of the game
world: the world name the game is in
running: has the game started. Either true or false
arena none: same as name
name: the area's name
<x,y,z>size: the size in the x,y and z directions
command none: same as name
name: the name of the command
path: the full path of the command (without leading slash)
children: (group commands only!) A list of child commands
usage: the commands usage
description: the commands description
extra: extra information about the command (if any)
example: an example (if any)
flags: List of flags. Each flag has name, ext (extension assignment) and description
player none: same as name
name: the player's name
exec: executes the next argument as the player. Always returns an empty string.
msg: sends the next argument to the player. Returns an empty string
item none: same as type
type: the block's type namespace (e.g minecrat:dirt)
qty: the amount of item
list none: same as length
foreach: see below
sort: see below
filter: see below
get: see below
length: the size of the list

List Foreach

{list|foreach|<function>|separator=' '}

Expands the list by evaluating function to each item with index as the zero based index and it as the item. Between each expansion, separator is concatenated.

For example:

If {list} is a List object containing ["One", "Two", "Three"], then

[{list|foreach|({!index}: {!it})|, }]

will return

[(0: One), (1: Two), (2: Three)]

Note the use of ! after the opening braces. This delays the function from being evaluated before being passed to the foreach

List Sort

{list|sort|<function>|...}

Sorts the list by applying function to each item and sorting alphabetically. The sorted list is returned so further list operations can be applied. {it} is the item in the list and {index} is the index.

For example:

If {list} is a List object containing ["One", "Two", "Three"], then

[{list|sort|{!#sub|{it}|1}|foreach|{!it}|, }]

will return (ordered by second character):

[Three, One, Two]

List Filter

{list|filter|<predicate>|...}

Filters elements in the list by applying predicate to each item and only keeping items that return a non empty, non zero string. {it} is the item in the list and {index} is the index.

For example:

If {list} is a List object containing ["One", "Two", "Three"], then

[{list|sort|{!#regex|{it}|[^Oo]|}|foreach|{!it}|, }]

will return (words containing O):

[One Two]

List Get

{list|get|<value>|<keyFunction>|<function>}

Finds the first item in the list where keyFunction is the value, and then applies function to the item. Both functions take it as the item and index as the index.

If no match is made, an empty string is returned.

If only one parameter is supplied, then both keyFunction and function are evaluated as {!it}.

If two parameters are supplied, keyFunction is {!it}.

For example:

If {list} is a List object containing ["One", "Two", "Three"], then

{list|get|One}

will return:

One

{list|get|One|Found: {!it}}

will return:

Found: One

{list|get|wo|{!#sub|{it}|1}|Found: {!it}}

will return:

Found: Two

⚠️ **GitHub.com Fallback** ⚠️