Methods

With the methods parser there are several methods available.

Note: At the moment it is planned to introduce the methods parser with 0.9! Thus all methods aren't available yet!

Note: This methods list isn't complete yet!

How to use

The parser iterate through each line and tests if there is a method call. In front of each method name is a prefix which is by default %. A method has a space in front to be detected. At the end it is possible to add brackets or a space.

There are following types of parameters:

  • Integers – A integer number with one of the following formats: <value>_<radix>, 0x<hexadecimal value>, 0b<binary value>, 0<octal value>, <decimal value>. If the decimal value is only one character it will be interpreted as hexadecimal value.
  • Boolean – A boolean could be either true or false. Yes is an alias for true and no an alias for false.
  • Text – Any text.

Case sensitive methods

Some methods are “case sensitive methods” (marked with a (c)) which accepts none, one or three parameters. The first parameter defines how the text should be handled:

  • none – No changes and default if no parameters are given.
  • upper – Calls String.toUpperCase().
  • lower – Calls String.toLowerCase().
  • first – The first character will be uppercase and the rest lowercased.
  • camel – After any white space (Defined with Character.isWhitespace(char)) it changes the first letter (Defined with Character.isLetter(char)) to uppercase.
  • custom – Similar to the camel mode, but the text in the second parameter defines which characters triggers (like the whitespaces) and which characters will be uppercased (like the letters).

Only the custom mode allows three parameters. For the rest it is only allowed to use at most one parameter.

Boolean method

All boolean methods are also case sensitive methods and are marked with a (b). It is possible to define what text will be returned if it is true and if it is false. By default they are Yes (if true) and No (if false).

Offline player methods

All these methods could be called without that the triggering player is online.

Player's name

nm()

Returns the name of the triggering player.

Operator status (b)

op()

Shows it the player is an operator.

Banned status (b)

banned()

This method returns if the player is banned.

Whitelisted status (b)

white()

Returns if the player is whitelisted.

Offline/Online status (c)

status()

Shows the general offline/online status of the player. Following states are possible:

  • Offline
  • Online
  • AFK (Only plugin “AdminCmd” supported yet)

Online player methods

The triggering player has to be online to made these methods to work.

Player's display name

dpnm()

Returns the display name of the triggering player.

Display player's world

world()

Shows the name of the world where the player is in.

Show food level

food([halfsteps])

Prints the food level of the player. By default it shows the value with 0.5 steps and a maximum of 10 (full). If the parameter is false, it uses steps of 1 and has a maximum of 20 (full).

Show health level

health([halfsteps])

Prints the health level of the player. By default it shows the value with 0.5 steps and a maximum of 10 (full). If the parameter is false, it uses steps of 1 and has a maximum of 20 (full).

Is asleep (c)

asleep([case mode[, triggers, uppercased]])

Prints out if the player is asleep.

Game mode (c)

mode([case mode[, triggers, uppercased]])

Prints out in which game mode the player is.

Not player related methods

All these methods aren't related to the triggering player.

Online list

onlist([prefix, suffix], [use display names], [delimiter]) onlist([name])

Prints out all online players. If will place the prefix before each name and a suffix after all. By default it uses the normal name (which is nm) but if use display names is true it will use the display name of a player. If the prefix or the suffix is a hexadecimal character (0-9, a-f, A-F) it will be interpreted as a color.

With only one parameter it will be interpreted as a specific list name. (Acts then like the old %ol_name)

Conditional branches

ifequals

ifequals(<tested value>, <condition>, <if equals>, [if not equals])

Tests if tested value and condition are equals in the terms of String.equals(Object). If they are both equals they call the third parameter (if equals) otherwise it calls the optional if not equals parameter.

ifnotequals

ifequals(<tested value>, <condition>, <if not equals>, [if equals])

Tests if tested value and condition are equals in the terms of String.equals(Object). If they are different it calls the third parameter (if not equals) otherwise it calls the optional if equals parameter.

ifequalsignorecase

ifequalsignorecase(<tested value>, <condition>, <if equals>, [if not equals])

Similar to ifequals but calls String.equalsIgnoreCase(String) instead of String.equals(Object).

ifnotequalsignorecase

ifnotequalsignorecase(<tested value>, <condition>, <if not equals>, [if equals])

Similar to ifnotequals but calls String.equalsIgnoreCase(String) instead of String.equals(Object).

ifset

ifset(<tested value>, <if not null>, [if null])

Tests if the tested value returns null. At the moment it is impossible to get a real null as the text “null” isn't really null.

ifnotset

ifnotset(<tested value>, <if null>, [if not null])

Tests if the tested value returns null. At the moment it is impossible to get a real null as the text “null” isn't really null.

ifgreater

ifgreater(<tested value>, <condition>, <if greater>, [if not greater])

Calls the if greater branch if the tested value is greater than the condition. In all other cases it calls the optional if not greater branch.

ifgreaterequals

ifgreaterequals(<tested value>, <condition>, <if greater equals>, [if lower])

Calls the if greater equals branch if the tested value is greater equals than the condition. In all other cases it calls the optional if lower branch.

iflower

iflower(<tested value>, <condition>, <if lower>, [if not lower])

Calls the if lower branch if the tested value is lower than the condition. In all other cases it calls the optional if not lower branch.

iflowerequals

iflowerequals(<tested value>, <condition>, <if lower equals>, [if greater])

Calls the if lower equals branch if the tested value is greater equals than the condition. In all other cases it calls the optional if greater branch.

caseequals

caseequals(<tested value>, [condition #1], [if cond. #1 matches], … [condition #n], [if cond. #n matches], [default])

Similar to the switch-case construct in most programming langages. This method needs at minimum two parameters (tested value and default branch). It iterates through all conditions and calls the first branch where the condition matches.

Miscellaneous methods

random

random(<value 1>, [value 2], … [value n])

Returns randomly one value all with the same chance.

print

print(<value 1>, [value 2], … [value n])

Directly print out all values separated by one space. The parameters aren't interpreted so it is possible to print out method calls without call them.

call

call(<value 1>, [value 2], … [value n])

Similar to print but it interprets the parameter.

Progress bar

bar(<part>, <maximum>, [width], [left color], [right color], [single bar character], [right bar charcter])

Shows a progress bar. By default a single bar character is the pipe, the left color is red (0xC) and the right color is green (0xA). The color could be integers from 0 - 16. It is possible to make the right color opaque by setting it to opaque.


Comments

Posts Quoted:
Reply
Clear All Quotes