Need help? Ask on the forum, ask a fellow user or developer (join us on IRC), or contact sk89q.
Contribute to the wiki, edit this page! Register an account, or login with Facebook first.
HEY! Do you integrate (or want to) a plugin into yours? Do you help work on WE/WG/etc.? Please subscribe to our mailing list!
CommandHelper
Staged
API
Command Helper uses a language called MethodScript, which greatly extend the capabilities of the plugin, and make the plugin a fully Turing Complete language. There are several functions defined, and they are grouped into "classes".
Each function has its own page for documentation, where you can put examples for how to use particular functions. Because this is a wiki, it is encouraged that you edit the pages if you see errors, or can think of a better example to show. Please copy over this template and use it.
ArrayHandling
This class contains functions that provide a way to manipulate arrays. To create an array, use the array function. For more detailed information on array usage, see the page on arrays
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| array_contains() | boolean | array, testValue | CastException | Checks to see if testValue is in array. (Examples...) |
3.0.1 | No
|
| array_contains_ic() | boolean | array, testValue | CastException | Works like array_contains, except the comparison ignores case. (Examples...) |
3.3.0 | No
|
| array_get() | mixed | array, index, [default] | CastException |
Returns the element specified at the index of the array. See More... (Examples...) |
3.0.1 | No
|
| array_implode() | string | array, [glue] | CastException | Given an array and glue, to-strings all the elements in the array (just the values, not the keys), and joins them with the glue, defaulting to a space. For instance array_implode(array(1, 2, 3), '-') will return "1-2-3". (Examples...) |
3.3.0 | No
|
| array_index() | mixed | array, value | CastException | Works exactly like array_indexes(array, value)[0], except in the case where the value is not found, returns null. That is to say, if the value is contained in an array (even multiple times) the index of the first element is returned. (Examples...) |
3.3.1 | No
|
| array_index_exists() | boolean | array, index | CastException | Checks to see if the specified array has an element at index (Examples...) |
3.1.2 | No
|
| array_indexes() | array | array, value | CastException | Returns an array with all the keys of the specified array at which the specified value is equal. That is, for the array(1, 2, 2, 3), if value were 2, would return array(1, 2). If the value cannot be found in the array at all, an empty array will be returned. (Examples...) |
3.3.1 | No
|
| array_insert() | void | array, item, index | CastException |
Inserts an item at the specified index, and shifts all other items in the array to the right one. If index is greater than the size of the array, an IndexOverflowException is thrown, though the index may be equal to the size, in which case this works just like array_push. The array must be normal though, associative arrays are not supported. (Examples...) |
3.3.1 | No
|
| array_keys() | array | array | CastException | Returns the keys in this array as a normal array. If the array passed in is already a normal array, the keys will be 0 -> (array_size(array) - 1) (Examples...) |
3.3.0 | No
|
| array_merge() | array | array1, array2, [arrayN...] | InsufficientArgumentsException |
Merges the specified arrays from left to right, and returns a new array. If the array merged is associative, it will overwrite the keys from left to right, but if the arrays are normal, the keys are ignored, and values are simply pushed. (Examples...) |
3.3.0 | No
|
| array_normalize() | array | array | CastException | Returns a new normal array, given an associative array. (If the array passed in is not associative, a copy of the array is returned). (Examples...) |
3.3.0 | No
|
| array_push() | void | array, value, [value2...] | CastException | Pushes the specified value(s) onto the end of the array (Examples...) |
3.0.1 | No
|
| array_rand() | array | array, [number, [getKeys]] | RangeException |
Returns a random selection of keys or values from an array. The array may be either normal or associative. Number defaults to 1, and getKey defaults to true. If number is greater than the size of the array, a RangeException is thrown. No value will be returned twice from the array however, one it is "drawn" from the array, it is not placed back in. The order of the elements in the array will also be random, if order is important, use array_sort(). (Examples...) |
3.3.1 | No
|
| array_remove() | mixed | array, index | RangeException |
Removes an index from an array. If the array is a normal array, all values' indicies are shifted left one. If the array is associative, the index is simply removed. If the index doesn't exist, the array remains unchanged. The value removed is returned. (Examples...) |
3.3.0 | No
|
| array_remove_values() | void | array, value | CastException | Removes all instances of value from the specified array. For instance, array_remove_values(array(1, 2, 2, 3), 2) would produce the array(1, 3). Note that it returns void however, so it will simply in place modify the array passed in, much like array_remove. (Examples...) |
3.3.1 | No
|
| array_resize() | void | array, size, [fill] | CastException | Resizes the given array so that it is at least of size size, filling the blank spaces with fill, or null by default. If the size of the array is already at least size, nothing happens; in other words this function can only be used to increase the size of the array. (Examples...) |
3.2.0 | No
|
| array_reverse() | void | array | CastException | Reverses an array in place. However, if the array is associative, throws a CastException, since associative arrays are more like a map. (Examples...) |
3.3.1 | No
|
| array_set() | void | array, index, value | CastException |
Sets the value of the array at the specified index. array_set(array, index, value). Returns void. If the element at the specified index isn't already set, throws an exception. Use array_push to avoid this. (Examples...) |
3.0.1 | No
|
| array_size() | int | array | CastException | Returns the size of this array as an integer. (Examples...) |
3.0.1 | No
|
| array_sort() | array | array, [sortType] | CastException |
Sorts an array in place, and also returns a reference to the array. See More... (Examples...) |
3.3.1 | No
|
| array_sort_async() | void | array, [sortType], closure(array) | CastException | Works like array_sort, but does the sort on another thread, then calls the closure and sends it the sorted array. This is useful if the array is large enough to actually "stall" the server when doing the sort. Sort type should be one of REGULAR, NUMERIC, STRING or STRING_IC | 3.3.1 | No
|
| array_unique() | array | array, [compareTypes] | CastException | Removes all non-unique values from an array. See More... (Examples...) |
3.3.1 | No
|
| cslice() | slice | from, to | CastException | Dynamically creates an array slice, which can be used with array_get (or the [bracket notation]) to get a range of elements. cslice(0, 5) is equivalent to 0..5 directly in code, however with this function you can also do cslice(@var, @var), or other more complex expressions, which are not possible in static code. (Examples...) |
3.3.1 | No
|
| range() | array | start, finish, [increment] finish |
CastException | Returns an array of numbers from start to (finish - 1) skipping increment integers per count. start defaults to 0, and increment defaults to 1. All inputs must be integers. If the input doesn't make sense, it will reasonably degrade, and return an empty array. (Examples...) |
3.2.0 | No
|
BasicLogic
These functions provide basic logical operations.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| and() | boolean | var1, [var2...] | CastException | Returns the boolean value of a logical AND across all arguments. Uses lazy determination, so once an argument returns false, the function returns. (Examples...) |
3.0.1 | No
|
| bit_and() | int | int1, [int2...] | CastException |
Returns the bitwise AND of the values (Examples...) |
3.3.0 | No
|
| bit_not() | int | int1 | CastException | Returns the bitwise NOT of the given value (Examples...) |
3.3.0 | No
|
| bit_or() | int | int1, [int2...] | CastException |
Returns the bitwise OR of the specified values (Examples...) |
3.3.0 | No
|
| equals() | boolean | var1, var2[, varX...] | InsufficientArgumentsException | Returns true or false if all the arguments are equal (Examples...) |
3.0.1 | No
|
| equals_ic() | boolean | val1, val2[, valX...] | InsufficientArgumentsException | Returns true if all the values are equal to each other, while ignoring case. (Examples...) |
3.2.0 | No
|
| gt() | boolean | var1, var2 | CastException | Returns the result of a greater than operation (Examples...) |
3.0.1 | No
|
| gte() | boolean | var1, var2 | CastException | Returns the result of a greater than or equal to operation (Examples...) |
3.0.1 | No
|
| if() | mixed | cond, trueRet, [falseRet] | CastException | If the first argument evaluates to a true value, the second argument is returned, otherwise the third argument is returned. If there is no third argument, it returns void. (Examples...) |
3.0.1 | No
|
| ifelse() | mixed | [boolean1, code]..., [elseCode] | InsufficientArgumentsException | Provides a more convenient method for running if/else chains. If none of the conditions are true, and there is no 'else' condition, void is returned. (Examples...) |
3.3.0 | No
|
| lshift() | int | value, bitsToShift | CastException | Left shifts the value bitsToShift times (Examples...) |
3.3.0 | No
|
| lt() | boolean | var1, var2 | CastException | Returns the results of a less than operation (Examples...) |
3.0.1 | No
|
| lte() | boolean | var1, var2 | CastException | Returns the result of a less than or equal to operation (Examples...) |
3.0.1 | No
|
| nand() | boolean | val1, [val2...] | CastException | Return the equivalent of not(and()) (Examples...) |
3.3.0 | No
|
| nequals() | boolean | val1, val2 | Returns true if the two values are NOT equal, or false otherwise. Equivalent to not(equals(val1, val2)) (Examples...) |
3.3.0 | No
| |
| nequals_ic() | boolean | val1, val2 | Returns true if the two values are NOT equal to each other, while ignoring case. (Examples...) |
3.3.0 | No
| |
| nor() | boolean | val1, [val2...] | CastException | Returns the equivalent of not(or()) (Examples...) |
3.3.0 | No
|
| not() | boolean | var1 | CastException | Returns the boolean value of a logical NOT for this argument (Examples...) |
3.0.1 | No
|
| or() | boolean | var1, [var2...] | CastException | Returns the boolean value of a logical OR across all arguments. Uses lazy determination, so once an argument resolves to true, the function returns. (Examples...) |
3.0.1 | No
|
| ref_equals() | boolean | val1, val2 | Returns true if and only if the two values are actually the same reference. Primitives that are equal will always be the same reference, this method is only useful for object/array comparisons. (Examples...) |
3.3.1 | No
| |
| rshift() | int | value, bitsToShift | CastException | Right shifts the value bitsToShift times (Examples...) |
3.3.0 | No
|
| sequals() | boolean | val1, val2 | Uses a strict equals check, which determines if two values are not only equal, but also the same type. So, while equals('1', 1) returns true, sequals('1', 1) returns false, because the first one is a string, and the second one is an int. More often than not, you want to use plain equals(). (Examples...) |
3.3.0 | No
| |
| snequals() | boolean | val1, val2 | Equivalent to not(sequals(val1, val2)) (Examples...) |
3.3.1 | No
| |
| switch() | mixed | value, [equals, code]..., [defaultCode] | InsufficientArgumentsException | Provides a switch statement. If none of the conditions match, and no default is provided, void is returned. See the documentation on Logic for more information. See More... (Examples...) |
3.3.0 | No
|
| urshift() | int | value, bitsToShift | CastException | Right shifts value bitsToShift times, pushing a 0, making this an unsigned right shift. (Examples...) |
3.3.0 | No
|
| xnor() | boolean | val1, val2 | CastException | Returns the xnor of the two values (Examples...) |
3.3.0 | No
|
| xor() | boolean | val1, val2 | CastException | Returns the xor of the two values. (Examples...) |
3.3.0 | No
|
ByteArrays
This class contains all the methods needed to manipulate a byte array primitive. Since byte arrays would be very inefficient to implement using a normal array, this data type allows for more efficient operations, while still allowing for low level data access. Most data transferred within scripts is higher level, and does not require access to a byte array, however, code that interacts with external processes may require use of these functions to properly manipulate the data. Note that all the methods deal with low level types, so the following definitions apply: a byte is 8 bits, a short is 16 bits, an int is 32 bits, a long is 64 bits. UTF-8 strings are supported directly. The byte array is automatically resized as needed.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| ba_as_array() | array | byte_array | CastException | Returns a new read only copy of the underlying byte array. This array is much more efficient than if the array were made manually, however, it is read only. If you need to manipulate the array's contents, then you can clone the array, however, the returned array (and any clones) cannot be automatically interfaced with the byte array primitives. This operation is discouraged, because normal arrays are very inefficient for dealing with low level bit data. | 3.3.1 | No
|
| ba_get_byte() | int | byte_array, [pos] | CastException |
Returns an int, read in as an 8 bit byte, from the given position, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_get_bytes() | byte_array | byte_array, length, [pos] | CastException |
Returns a new byte_array primitive, starting from pos (or wherever the marker is by default) to length. | 3.3.1 | No
|
| ba_get_char() | string | byte_array, [pos] | CastException |
Returns a one character string, read in as an 32 bit char, from the given position, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_get_double() | double | byte_array, [pos] | CastException |
Returns a double, read in as a 64 bit double, from the given position, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_get_float() | double | byte_array, [pos] | CastException |
Returns a double, read in as a 32 bit float, from the given position, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_get_int() | int | byte_array, [pos] | CastException |
Returns an int, read in as a 32 bit int, from the given position, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_get_long() | int | byte_array, [pos] | CastException |
Returns an int, read in as a 64 bit long, from the given position, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_get_short() | int | byte_array, [pos] | CastException |
Returns an int, read in as a 16 bit short, from the given position, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_get_string() | string | byte_array, [pos], [encoding] | CastException |
Returns a UTF-8 encoded string, from the given position, or wherever the marker is currently at by default. The string is assumed to have encoded the length of the string with a 32 bit integer, then the string bytes. (This will be the case is the byte_array was encoded with ba_set_string.) The encoding of the string may be set, but defaults to UTF-8. | 3.3.1 | No
|
| ba_put_byte() | void | byte_array, int, [pos] | CastException | Writes an int, interpreted as an 8 bit byte, starting from the given position, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_put_bytes() | void | destination_byte_array, source_byte_array, [pos] | CastException | Writes the contents of the source_byte_array into this byte array, starting at pos, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_put_char() | void | byte_array, string, [pos] | CastException | Writes the first character of the string, interpreted as an 32 bit char, starting from the given position, or wherever the marker is currently at by default. If the string is empty, a \0 is written instead. | 3.3.1 | No
|
| ba_put_double() | void | byte_array, double, [pos] | CastException | Writes a double, interpreted as a 64 bit double, starting from the given position, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_put_float() | void | byte_array, double, [pos] | CastException | Writes a double, interpreted as a 32 bit float, starting from the given position, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_put_int() | void | byte_array, int, [pos] | CastException | Writes an int, interpreted as a 32 bit int, starting from the given position, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_put_long() | void | byte_array, int, [pos] | CastException | Writes an int, interpreted as a 64 bit, starting from the given position, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_put_short() | void | byte_array, int, [pos] | CastException | Writes an int, interpreted as an 16 bit short, starting from the given position, or wherever the marker is currently at by default. | 3.3.1 | No
|
| ba_put_string() | void | byte_array, string, [pos], [encoding] | CastException | Writes the length of the string to the byte array, as a short, (interpreted as UTF-8), then writes the UTF-8 string itself. If an external application requires the string to be serialized in a different manner, then use the string-byte_array conversion methods in StringHandling, however strings written in this manner are compatible with ba_get_string. The encoding may be set, but defaults to UTF-8. | 3.3.1 | No
|
| ba_rewind() | void | byte_array | CastException | Rewinds the byte array marker to 0. | 3.3.1 | No
|
| byte_array() | byte_array | Returns a new byte array primitive, which can be operated on with the ba_ series of functions. | 3.3.1 | No
|
Cmdline
This class contains functions that are mostly only useful for command line scripts, but in general may be used by any script. For more information on running MethodScript from the command line, see this wiki page.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| exit() | void | [int] | Exits the program. If this is being run from the command line, works by exiting the interpreter, with the specified exit code (defaulting to 0). If this is being run from in-game, works just like die(). (Examples...) |
3.3.1 | No
| |
| get_env() | mixed | [variableName] | Returns the environment variable specified, if variableName is set. Otherwise, returns an associative array of all the environment variables. | 3.3.1 | Yes
| |
| set_env() | void | variableName, value | Sets the value of an environment variable. This only changes the environment value in this process, not system-wide. This uses some hackery to work, and may not be 100% reliable in all cases, and shouldn't be relied on heavily. It will always work with get_env, however, so you can rely on that mechanism. The value will always be interpreted as a string, so if you are expecting a particular data type on a call to get_env, you will need to manually cast the variable. Arrays will be toString'd as well, but will be accepted. | 3.3.1 | Yes
| |
| sys_err() | void | text | Writes the text to the system's std err. Unlike console(), this does not use anything else to format the output, though in many cases they will behave nearly the same. However, colors and other formatting characters will not "bleed" through, so sys_err(color(RED) . 'This is red') will not cause the next line to also be red, so if you need to print multiple lines out, you should manually add \n to create your linebreaks, and only make one call to sys_err. (Examples...) |
3.3.1 | Yes
| |
| sys_out() | void | text | Writes the text to the system's std out. Unlike console(), this does not use anything else to format the output, though in many cases they will behave the same. However, colors and other formatting characters will not "bleed" through, so sys_out(color(RED) . 'This is red') will not cause the next line to also be red, so if you need to print multiple lines out, you should manually add \n to create your linebreaks, and only make one call to sys_out. (Examples...) |
3.3.1 | Yes
| |
| sys_properties() | mixed | [propertyName] | If propertyName is set, that single property is returned, or null if that property doesn't exist. If propertyName is not set, an associative array with all the system properties is returned. This mechanism hooks into Java's system property mechanism, and is just a wrapper for that. System properties are more reliable than environmental variables, and so are preferred in cases where they exist. For more information about system properties, see http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html (Examples...) |
3.3.1 | Yes
|
Crypto
Provides common cryptographic functions
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| bcrypt() | string | val, [workload] | CastException | Encrypts a value using bcrypt, using the specified workload, or 5 if none provided. BCrypt is supposedly more secure than SHA1, and certainly more secure than md5. Note that using bcrypt is slower, which is one of its security advantages, however, setting the workload to higher numbers will take exponentially more time. A workload of 5 is a moderate operation, which should complete in under a second, however, setting it to 10 will take many seconds, and setting it to 15 will take a few minutes. See the documentation for check_bcrypt for full usage. (Examples...) |
3.3.1 | No
|
| check_bcrypt() | boolean | plaintext, hash | Checks to see if this plaintext password does in fact hash to the hash specified. Unlike md5 or sha1, simply comparing hashes won't work. Consider the following usage: assign(@plain, 'plaintext') assign(@hash, bcrypt(@plain)) msg(if(check_bcrypt(@plain, @hash), 'They match!', 'They do not match!')) (Examples...) |
3.3.1 | No
| |
| md5() | string | val | PluginInternalException | Returns the md5 hash of the specified string. The md5 hash is no longer considered secure, so you should not use it for storage of sensitive data, however for general hashing, it is a quick and easy solution. md5 is a one way hashing algorithm. (Examples...) |
3.3.0 | No
|
| rot13() | string | val | Returns the rot13 version of val. Note that rot13(rot13(val)) returns val (Examples...) |
3.3.0 | No
| |
| sha1() | string | val | PluginInternalException | Returns the sha1 hash of the specified string. Note that sha1 is considered more secure than md5, and is typically used when storing sensitive data. It is a one way hashing algorithm. (Examples...) |
3.3.0 | No
|
| sha256() | string | val | PluginInternalException | Returns the sha256 hash of the specified string. Note that sha256 is considered more secure than sha1 and md5, and is typically used when storing sensitive data. It is a one way hashing algorithm. (Examples...) |
3.3.1 | No
|
DataHandling
This class provides various methods to control script data and program flow.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| array() | array | [var1, [var2...]] | Creates an array of values. (Examples...) |
3.0.1 | No
| |
| assign() | ivariable | ivar, mixed | CastException | Accepts an ivariable ivar as a parameter, and puts the specified value mixed in it. Returns the variable that was assigned. (Examples...) |
3.0.1 | No
|
| associative_array() | array | [args...] | Works exactly like array(), except the array created will be an associative array, even if the array has been created with no elements. This is the only use case where this is neccessary, vs using the normal array() function, or in the case where you assign sequential keys anyways, and the same array could have been created using array(). (Examples...) |
3.3.1 | No
| |
| boolean() | boolean | item | Returns a new construct that has been cast to a boolean. The item is cast according to the boolean conversion rules. Since all data types can be cast to a a boolean, this function will never throw an exception. (Examples...) |
3.3.0 | No
| |
| break() | nothing | [int] | CastException | Stops the current loop. If int is specified, and is greater than 1, the break travels that many loops up. So, if you had a loop embedded in a loop, and you wanted to break in both loops, you would call break(2). If this function is called outside a loop (or the number specified would cause the break to travel up further than any loops are defined), the function will fail. If no argument is specified, it is the same as calling break(1). (Examples...) |
3.1.0 | No
|
| call_proc() | mixed | proc_name, [var1...] | InvalidProcedureException | Dynamically calls a user defined procedure. call_proc(_myProc, 'var1') is the equivalent of _myProc('var1'), except you could dynamically build the procedure name if need be. This is useful for dynamic coding, however, closures work best for callbacks. Throws an InvalidProcedureException if the procedure isn't defined. If you are hardcoding the first parameter, a warning will be issued, because it is much more efficient and safe to directly use a procedure if you know what its name is beforehand. | 3.2.0 | Yes
|
| call_proc_array() | mixed | proc_name, array | InvalidProcedureException |
Works like call_proc, but allows for variable or unknown number of arguments to be passed to a proc. The array parameter is "flattened", and call_proc is essentially called. If the array is associative, an exception is thrown. | 3.3.1 | Yes
|
| closure() | closure | [varNames...,] code | Returns a closure on the provided code. A closure is a datatype that represents some code as code, not the results of some code after it is run. Code placed in a closure can be used as a string, or executed by other functions using the eval() function. If a closure is "to string'd" it will not necessarily look like the original code, but will be functionally equivalent. The current environment is "snapshotted" and stored with the closure, however, this information is only stored in memory, it isn't retained during a serialization operation. Also, the special variable @arguments is automatically created for you, and contains an array of all the arguments passed to the closure, much like procedures. See the wiki article on closures for more details and examples. | 3.3.0 | Yes
| |
| continue() | void | [int] | CastException | Skips the rest of the code in this loop, and starts the loop over, with it continuing at the next index. If this function is called outside of a loop, the command will fail. If int is set, it will skip 'int' repetitions. If no argument is specified, 1 is used. (Examples...) |
3.1.0 | No
|
| double() | double | item | CastException | Returns a new construct that has been cast to an double. This function will throw a CastException if is_numeric would return false for this item, but otherwise, it will be cast properly. (Examples...) |
3.3.0 | No
|
| dowhile() | void | code, condition | Like while, but always runs the code at least once. The condition is checked after each run of the code, and if it is true, the code is run again. break and continue work inside a dowhile, but continuing more than once is pointless, since the loop isn't inherently keeping track of any counters anyways. Breaking multiple times still works however. (Examples...) |
3.3.1 | No
| |
| execute() | void | [values...,] closure | CastException | Executes the given closure. You can also send arguments to the closure, which it may or may not use, depending on the particular closure's definition. | 3.3.1 | Yes
|
| export() | void | ivar key[, namespace, ...,], value |
InsufficientArgumentsException | Stores a value in the global storage register. When using the first mode, the ivariable is stored so it can be imported later, and when using the second mode, an arbitrary value is stored with the give key, and can be retreived using the secode mode of import. If the value is already stored, it is overwritten. See import() and importing/exporting | 3.3.0 | Yes
|
| for() | void | assign, condition, expression1, expression2 | CastException | Acts as a typical for loop. The assignment is first run. Then, a condition is checked. If that condition is checked and returns true, expression2 is run. After that, expression1 is run. In java syntax, this would be: for(assign; condition; expression1){expression2}. assign must be an ivariable, either a pre defined one, or the results of the assign() function. condition must be a boolean. (Examples...) |
3.0.1 | No
|
| foreach() | void | array, [key], ivar, code | CastException |
Walks through array, setting ivar equal to each element in the array, then running code. In addition, foreach(1..4, @i, code()) is also valid, setting @i to 1, 2, 3, 4 each time. The same syntax is valid as in an array slice. If key is set (it must be an ivariable) then the index of each iteration will be set to that. See the examples for a demonstration. (Examples...) |
3.0.1 | No
|
| foreachelse() | void | array, ivar, code, else | CastException |
Works like a foreach, except if the array is empty, the else code runs instead. That is, if the code would not run at all, the else condition would. (Examples...) |
3.3.1 | No
|
| forelse() | void | assign, condition, expression1, expression2, else | Works like a normal for, but if upon checking the condition the first time, it is determined that it is false (that is, NO code loops are going to be run) the else code is run instead. If the loop runs, even once, it will NOT run the else branch. | 3.3.1 | No
| |
| import() | mixed | ivar key[, namespace, ...,] |
This function imports a value from the global value register. In the first mode, it looks for an ivariable with the specified name, and stores the value in the variable, and returns void. In the second mode, it looks for a value stored with the specified key, and returns that value. Items can be stored with the export function. If the specified ivar doesn't exist, the ivar will be assigned an empty string, and if the specified string key doesn't exist, null is returned. See the documentation on imports/exports for more information. | 3.3.0 | Yes
| |
| include() | void | path | IncludeException | Includes external code at the specified path. | 3.2.0 | Yes
|
| integer() | integer | item | CastException | Returns a new construct that has been cast to an integer. This function will throw a CastException if is_numeric would return false for this item, but otherwise, it will be cast properly. Data may be lost in this conversion. For instance, 4.5 will be converted to 4, by using integer truncation. You can use is_integral to see if this data loss would occur. (Examples...) |
3.3.0 | No
|
| is_array() | boolean | item | Returns whether or not the item is an array (Examples...) |
3.1.2 | No
| |
| is_associative() | boolean | array | CastException | Returns whether or not the array is associative. If the parameter is not an array, throws a CastException. (Examples...) |
3.3.0 | No
|
| is_boolean() | boolean | item | Returns whether the given item is of the boolean datatype. Note that all datatypes can be used as booleans, however this function checks the specific datatype of the given item. (Examples...) |
3.1.2 | No
| |
| is_closure() | boolean | arg | Returns true if the argument is a closure (could be executed) or false otherwise (Examples...) |
3.3.1 | No
| |
| is_double() | boolean | item | Returns whether or not the given item is a double. Note that numeric strings and integers can usually be used as a double, however this function checks the actual datatype of the item. If you just want to see if an item can be used as a number, use is_numeric() instead. (Examples...) |
3.1.2 | No
| |
| is_integer() | boolean | item | Returns whether or not the given item is an integer. Note that numeric strings can usually be used as integers, however this function checks the actual datatype of the item. If you just want to see if an item can be used as a number, use is_integral() or is_numeric() instead. (Examples...) |
3.1.2 | No
| |
| is_integral() | boolean | item | CastException | Returns true if the numeric value represented by a given double or numeric string could be cast to an integer without losing data (or if it's an integer). For instance, is_numeric(4.5) would return true, and integer(4.5) would work, however, equals(4.5, integer(4.5)) returns false, because the value was narrowed to 4. (Examples...) |
3.3.0 | No
|
| is_null() | boolean | item | Returns whether or not the given item is null. (Examples...) |
3.1.2 | No
| |
| is_numeric() | boolean | item | Returns false if the item would fail if it were used as a numeric value. If it can be parsed or otherwise converted into a numeric value, true is returned. (Examples...) |
3.3.0 | No
| |
| is_proc() | boolean | procName | Returns whether or not the given procName is currently defined, i.e. if calling this proc wouldn't throw an exception. | 3.2.0 | Yes
| |
| is_string() | boolean | item | Returns whether or not the item is actually a string datatype. If you just care if some data can be used as a string, use is_stringable(). (Examples...) |
3.3.1 | No
| |
| is_stringable() | boolean | item | Returns whether or not the item is convertable to a string. Everything but arrays can be used as strings. (Examples...) |
3.3.1 | No
| |
| proc() | void | [name], [ivar...], procCode | FormatException | Creates a new user defined procedure (also known as "function") that can be called later in code. Please see the more detailed documentation on procedures for more information. | 3.1.3 | Yes
|
| return() | nothing | mixed | Returns the specified value from this procedure. It cannot be called outside a procedure. | 3.2.0 | No
| |
| string() | string | item | Creates a new construct that is the "toString" of an item. For arrays, an human readable version is returned; this should not be used directly, as the format is not guaranteed to remain consistent. Booleans return "true" or "false" and null returns "null". (Examples...) |
3.3.0 | No
| |
| while() | void | condition, code | While the condition is true, the code is executed. break and continue work inside a dowhile, but continuing more than once is pointless, since the loop isn't inherently keeping track of any counters anyways. Breaking multiple times still works however. (Examples...) |
3.3.1 | No
|
DataTransformations
This class provides functions that are able to transform data from native objects to their serialized forms, i.e. json, ini, etc.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| ini_decode() | array | string | FormatException | Returns an array, given an INI format input. INI files are loosely defined as a set of key->value pairs, which lends itself to an associative array format. Key value pairs are denoted usually by a key=value format. The specific rules for decoding an INI file can be found here. An associative array is returned.
|
3.3.1 | No
|
| ini_encode() | string | array, [comment] | FormatException |
Encodes an array into an INI format output. An associative array is expected, and a format exception is thrown if it is a normal array. The comment is optional, but if provided will be added to the header of the returned string. All values are toString'd before output, so things like arrays, if stored as a value, will not be returned as arrays. | 3.3.1 | No
|
| json_decode() | array | string | FormatException | Takes a JSON encoded string, and returns an array, either normal or associative, depending on the contents of the JSON string. If the JSON string is improperly formatted, a FormatException is thrown. | 3.3.1 | No
|
| json_encode() | string | array | CastException | Converts an array into a JSON encoded string. Both normal and associative arrays are supported. | 3.3.1 | No
|
| xml_read() | mixed | xml, xpath | FormatException | Reads a field from some xml using an XPath address. The XPath address is assumed to be absolute, even if it doesn't start with a '/'. | 3.3.1 | No
|
| yml_decode() | array | string | Takes a YML encoded string, and returns an associative array, depending on the contents of the YML string. If the YML string is improperly formatted, a FormatException is thrown. | 3.3.1 | No
| |
| yml_encode() | string | array, [prettyPrint] | CastException | Converts an array into a YML encoded string. Only associative arrays are supported. prettyPrint defaults to false. | 3.3.1 | No
|
Debug
Provides methods for viewing data about both CommandHelper and the other plugins in your server. Though not meant to be called by normal scripts, these methods are available everywhere other methods are available. Note that for some of these functions to even work, play-dirty mode must set to on. These are most useful in conjuction with interpreter mode.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| debug() | void | message | IOException | Manually logs a timestamped message to the debug log and the console, if debug-mode is set to true in the preferences | 3.3.0 | Yes
|
| dump_threads() | array | Returns an array of all thread names that are currently running in the JVM. This is a debugging tool for your server, and less of a CommandHelper specific thing. | 3.3.1 | Yes
| ||
| heap_dump() | void | PluginInternalException | Creates a heap dump file, and places it in the working directory, as "dump.bin". This might throw a PluginInternalException if the heap dump tools aren't available in your JVM. Once dumped, the heap dump can be analyzed using tools such as jhat. More information about jhat can be found here. | 3.3.1 | Yes
| |
| trace() | void | ivar | CastException | If debug mode is on, outputs debug information about a variable. Unlike debug, this only accepts an ivar; it is a meta function. The runtime will then take the variable, and output information about it, in a human readable format, including the variable's name and value. If debug mode is off, the function is ignored. | 3.3.1 | Yes
|
Echoes
These functions allow you to echo information to the screen
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| broadcast() | void | message, [permission] | NullPointerException | Broadcasts a message to all players on the server. If permission is given, only players with that permission will see the broadcast. | 3.0.1 | Yes
|
| chat() | void | string | PlayerOfflineException | Echoes string to the chat, as if the user simply typed something into the chat bar. | 3.0.1 | Yes
|
| chatas() | void | player, msg | PlayerOfflineException | Sends a chat message to the server, as the given player. Otherwise the same as the chat function | 3.0.2 | Yes
|
| color() | string | name | Returns the color modifier given a color name. If the given color name isn't valid, white is used instead. The list of valid colors is: BLACK, DARK_BLUE, DARK_GREEN, DARK_AQUA, DARK_RED, DARK_PURPLE, GOLD, GRAY, DARK_GRAY, BLUE, GREEN, AQUA, RED, LIGHT_PURPLE, YELLOW, WHITE, RANDOM, BOLD, STRIKETHROUGH, UNDERLINE, ITALIC, or PLAIN_WHITE, in addition the integers 0-15 will work, or the hex numbers from 0-F, and k, l, m, n, o, and r, which represent styles. Unlike manually putting in the color symbol, using this function will return the platform's color code, so if you are wanting to keep your scripts platform independant, it is a much better idea to use this function as opposed to hard coding your own color codes. | 3.0.1 | Yes
| |
| colorize() | mixed | text, [symbol] | Replaces all the colorizable text in the string. For instance, colorize('&aText') would be equivalent to (color('a').'Text'). By default, the symbol is '&', but that can be any arbitrary string that you specify. If text is not a string, that value is simply returned. If you need to "escape" a symbol, (that is have a literal symbol followed by a letter that is a valid color) just repeat the symbol twice, for instance '&&c' would return a literal '&c' instead of a red modifier. | 3.3.1 | Yes
| |
| console() | void | message, [prefix] | CastException | Logs a message to the console. If prefix is true, prepends "CommandHelper:" to the message. Default is true. | 3.0.2 | Yes
|
| die() | nothing | [var1, var2...,] | Kills the command immediately, without completing it. A message is optional, but if provided, displayed to the user. | 3.0.1 | No
| |
| msg() | void | var1, [var2...] | PlayerOfflineException | Echoes a message to the player running the command | 3.0.1 | No
|
| strip_colors() | string | toStrip | Strips all the color codes from a given string | 3.3.0 | No
| |
| tmsg() | void | player, msg, [...] | PlayerOfflineException |
Displays a message on the specified players screen, similar to msg, but targets a specific user. | 3.0.1 | Yes
|
Economy
Provides functions to hook into the server's economy plugin. To use any of these functions, you must have one of the following economy plugins installed: iConomy 4,5,6, BOSEconomy 6 & 7, EssentialsEcon, 3Co, MultiCurrency, MineConomy, eWallet, EconXP, CurrencyCore, CraftConomy. In addition, you must download the Vault plugin. Beyond this, there is no special setup to get the economy functions working, assuming they work for you in game using the plugin's default controls. Bank controls may not be supported in your particular plugin, check the details of that particular plugin.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| acc_add() | void | account_name, to_add | PluginInternalException |
Adds an amount to the specified account | 3.2.0 | Yes
|
| acc_balance() | double | account_name | PluginInternalException |
Returns the balance of the given account name. | 3.2.0 | Yes
|
| acc_divide() | void | account_name, to_divide | PluginInternalException |
Divides the account by the given amount | 3.2.0 | Yes
|
| acc_multiply() | void | account_name, to_multiply | PluginInternalException |
Multiplies the account balance by the given amount | 3.2.0 | Yes
|
| acc_remove() | void | account_name | PluginInternalException |
Removes the specified account from the game - Currently unimplemented, due to lack of support in Vault. Calling this function will currently always throw an exception. | 3.2.0 | Yes
|
| acc_set() | void | account_name, value | PluginInternalException |
Sets the account's balance to the given amount | 3.2.0 | Yes
|
| acc_subtract() | void | account_name, to_subtract | PluginInternalException |
Subtracts the given amount from the specified account | 3.2.0 | Yes
|
| bacc_add() | void | bank_name, value | PluginInternalException |
Adds the specified amount to the bank account's balance | 3.2.0 | Yes
|
| bacc_balance() | void | bank_name | PluginInternalException |
Gets the specified bank account's balance | 3.2.0 | Yes
|
| bacc_divide() | void | bank_name, value | PluginInternalException |
Divides the bank account's balance by the given value | 3.2.0 | Yes
|
| bacc_multiply() | void | bank_name, value | PluginInternalException |
Multiplies the given bank account's balance by the given value | 3.2.0 | Yes
|
| bacc_remove() | void | bank_name | PluginInternalException |
Removes the given bank account from the game | 3.2.0 | Yes
|
| bacc_set() | void | bank_name, value | PluginInternalException |
Sets the bank account's balance to the given amount | 3.2.0 | Yes
|
| bacc_subtract() | void | bank_name, value | PluginInternalException |
Subtracts the specified amount from the bank account's balance | 3.2.0 | Yes
|
Enchantments
Provides methods for dealing with enchanted items
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| can_enchant_target() | boolean | name, targetItem | EnchantmentException |
Given an enchantment name, and target item id, returns wether or not that item can be enchanted with that enchantment. Throws an EnchantmentException if the name is not a valid enchantment type. | 3.3.0 | No
|
| enchant_inv() | void | [player], slot, type, level | CastException |
Adds an enchantment to an item in the player's inventory. Type can be a single string, or an array of enchantment names. If slot is null, the currently selected slot is used. If the enchantment cannot be applied to the specified item, an EnchantmentException is thrown, and if the level specified is not valid, a RangeException is thrown. If type is an array, level must also be an array, with equal number of values in it, with each int corresponding to the appropriate type. You may use either the bukkit names for enchantments, or the name shown on the wiki: [1], and level may be a roman numeral as well. | 3.3.0 | Yes
|
| enchant_rm_inv() | void | [player], slot, type | CastException |
Removes an enchantment from an item. type may be a valid enchantment, or an array of enchantment names. It can also be null, and all enchantments will be removed. If an enchantment is specified, and the item is not enchanted with that, it is simply ignored. | 3.3.0 | Yes
|
| enchantment_list() | array | Returns an informational list of all valid enchantment names. Note that this will simply cover all enchantment types, but may not be a comprehensive list of names that can be accepted, there may be more, however, the list returned here is "comprehensive" and "official". Additionally, this may vary from server type to server type. | 3.3.1 | No
| ||
| get_enchant_inv() | array | [player], slot | PlayerOfflineException |
Returns an array of arrays of the enchantments and their levels on the given item. For example: array(array(DAMAGE_ALL, DAMAGE_UNDEAD), array(1, 2)) | 3.3.0 | Yes
|
| get_enchant_max() | int | name | EnchantmentException | Given an enchantment name, returns the max level it can be. If name is not a valid enchantment, an EnchantException is thrown. | 3.3.0 | No
|
| get_enchants() | array | item | CastException | Given an item id, returns the enchantments that can be validly added to this item. This may return an empty array. | 3.3.0 | No
|
| is_enchantment() | boolean | name | Returns true if this name is a valid enchantment type. Note that either the bukkit names or the wiki names are valid. | 3.3.0 | No
|
EntityManagement
This class of functions allow entities to be managed.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| all_entities() | array | [world, [x, z]] [locationArray] |
InvalidWorldException |
Returns an array of IDs for all entities in the given scope. With no args, this will return all entities loaded on the entire server. If the first argument is given and is a location, only entities in the chunk containin that location will be returned, or if it is a world only entities in that world will be returned. If all three arguments are given, only entities in the chunk with those coords will be returned. This can take chunk coords (ints) or location coords (doubles). (Examples...) |
3.3.1 | Yes
|
| entities_in_radius() | array | location array, distance, [type] location array, distance, [arrayTypes] |
CastException |
Returns an array of all entities within the given radius. Set type argument to filter entities to a specific type. You can pass an array of types. Valid types (case doesn't matter): DROPPED_ITEM, EXPERIENCE_ORB, PAINTING, ARROW, SNOWBALL, FIREBALL, SMALL_FIREBALL, ITEM_FRAME, WITHER_SKULL, WITHER, BAT, WITCH, ENDER_PEARL, ENDER_SIGNAL, THROWN_EXP_BOTTLE, PRIMED_TNT, FALLING_BLOCK, MINECART, BOAT, CREEPER, SKELETON, SPIDER, GIANT, ZOMBIE, SLIME, GHAST, PIG_ZOMBIE, ENDERMAN, CAVE_SPIDER, SILVERFISH, BLAZE, MAGMA_CUBE, ENDER_DRAGON, PIG, SHEEP, COW, CHICKEN, SQUID, WOLF, MUSHROOM_COW, SNOWMAN, OCELOT, IRON_GOLEM, VILLAGER, ENDER_CRYSTAL, SPLASH_POTION, EGG, FISHING_HOOK, LIGHTNING, WEATHER, PLAYER, COMPLEX_PART, FIREWORK, MINECART_CHEST, MINECART_FURNACE, MINECART_TNT, MINECART_HOPPER, MINECART_MOB_SPAWNER, or UNKNOWN | 3.3.1 | Yes
|
| entity_loc() | locationArray | entityID | CastException |
Returns the location array for this entity, if it exists. This array will be compatible with any function that expects a location. (Examples...) |
3.3.1 | Yes
|
| entity_onfire() | int | entityID | CastException |
Returns the number of seconds until this entity stops being on fire, 0 if it already isn't. | 3.3.1 | Yes
|
| entity_remove() | void | entityID | CastException |
Removes the specified entity from the world, without any drops or animations. Note: you can't remove players. As a safety measure for working with NPC plugins, it will not work on anything human, even if it is not a player. | 3.3.1 | Yes
|
| entity_type() | mixed | entityID | CastException | Returns the EntityType of the entity with the specified ID. Returns null if the entity does not exist. | 3.3.1 | Yes
|
| entity_velocity() | array | entityID | CastException |
Returns an associative array indicating the x/y/z components of this entity's velocity. As a convenience, the magnitude is also included. (Examples...) |
3.3.1 | Yes
|
| get_entity_age() | int | entityID | CastException |
Returns the entity age as an integer, represented by server ticks. | 3.3.1 | Yes
|
| get_entity_rider() | mixed | entityID | CastException |
Returns the ID of the given entity's rider, or null if it doesn't have one. | 3.3.1 | Yes
|
| get_entity_vehicle() | mixed | entityID | CastException |
Returns the ID of the given entity's vehicle, or null if it doesn't have one. | 3.3.1 | Yes
|
| get_max_health() | int | entityID | CastException |
Returns the maximum health of this living entity. | 3.3.1 | Yes
|
| get_mob_age() | int | entityID | UnageableMobException |
Returns the mob's age as an integer. Zero represents the point of adulthood. Throws an UnageableMobException if the mob is not a type that ages | 3.3.1 | Yes
|
| get_mob_effects() | array | entityID | CastException |
Returns an array of potion arrays showing the effects on this mob. (Examples...) |
3.3.1 | Yes
|
| get_mob_equipment() | equipmentArray | entityID | CastException |
Returns an associative array showing the equipment this entity is wearing. (Examples...) |
3.3.1 | Yes
|
| get_mob_name() | string | entityID | CastException |
Returns the name of the given mob. | 3.3.1 | Yes
|
| play_entity_effect() | void | entityID, effect | FormatException |
Plays the given visual effect on the entity. Non-applicable effects simply won't happen. Note: the death effect makes the mob invisible to players and immune to melee attacks. When used on players, they are shown the respawn menu, but because they are not actually dead, they can only log out. Possible effects are: DEATH, HURT, SHEEP_EAT, WOLF_HEARTS, WOLF_SHAKE, or WOLF_SMOKE | 3.3.1 | Yes
|
| set_entity_age() | void | entityID, int | CastException |
Sets the age of the entity to the specified int, represented by server ticks. | 3.3.1 | Yes
|
| set_entity_loc() | boolean | entityID, locationArray | BadEntityException |
Teleports the entity to the given location and returns whether the action was successful. Note this can set both location and direction. (Examples...) |
3.3.1 | Yes
|
| set_entity_onfire() | void | entityID, seconds | FormatException |
Sets the entity on fire for the given number of seconds. Throws a FormatException if seconds is less than 0. | 3.3.1 | Yes
|
| set_entity_rider() | boolean | horse, rider | FormatException |
Sets the way two entities are stacked. Horse and rider are entity ids. If rider is null, horse will eject its current rider, if it has one. If horse is null, rider will leave whatever it is riding. If horse and rider are both valid entities, rider will ride horse. The function returns the success of whatever operation is done. If horse and rider are both null, or otherwise the same, a FormatException is thrown. | 3.3.1 | Yes
|
| set_entity_velocity() | void | entityID, array | FormatException |
Sets the velocity of this entity according to the supplied xyz array. All 3 values default to 0, so an empty array will simply stop the entity's motion. Both normal and associative arrays are accepted. (Examples...) |
3.3.1 | Yes
|
| set_max_health() | void | entityID, int | FormatException |
Sets the max health of this living entity. this is persistent for players, and will not reset even after server restarts. (Examples...) |
3.3.1 | Yes
|
| set_mob_age() | void | entityID, int[, lockAge] | UnageableMobException |
sets the age of the mob to the specified int, and locks it at that age if lockAge is true, but by default it will not. Throws a UnageableMobException if the mob does not age naturally. | 3.3.1 | Yes
|
| set_mob_effect() | boolean | entityId, potionID, strength, [seconds], [ambient] | CastException |
Effect is 1-19. Seconds defaults to 30. If the potionID is out of range, a RangeException is thrown, because out of range potion effects cause the client to crash, fairly hardcore. See http://www.minecraftwiki.net/wiki/Potion_effects for a complete list of potions that can be added. To remove an effect, set the seconds to 0. Strength is the number of levels to add to the base power (effect level 1). Ambient takes a boolean of whether the particles should be less noticeable. The function returns true if the effect was added or removed as desired, and false if it wasn't (however, this currently only will happen if an effect is attempted to be removed, yet isn't already on the mob). | 3.3.1 | Yes
|
| set_mob_equipment() | void | entityID, array | FormatException |
Takes an associative array with keys representing equipment slots and values of itemArrays, the same used by set_pinv. The equipment slots are: WEAPON, BOOTS, LEGGINGS, CHESTPLATE, or HELMET (Examples...) |
3.3.1 | Yes
|
| set_mob_name() | void | entityID, name | FormatException |
Sets the name of the given mob. This automatically truncates if it is more than 64 characters. | 3.3.1 | Yes
|
| shoot_projectile() | int | [player[, projectile]] [entityID[, projectile]] |
BadEntityException |
shoots a projectile from the entity or player specified, or the current player if no arguments are passed. If no projectile is specified, it defaults to a fireball. Returns the EntityID of the projectile. Valid projectiles: ARROW, EGG, ENDER_PEARL, FIREBALL, SMALL_FIREBALL, SNOWBALL, SPLASH_POTION, or WITHER_SKULL | 3.3.1 | Yes
|
| spawn_entity() | array | entityType, [qty], [location] | CastException FormatException |
Spawns the specified number of entities of the given type at the given location. Returns an array of entityIDs of what is spawned. Qty defaults to 1 and location defaults to the location of the commandsender, if it is a block or player. If the commandsender is console, location must be supplied. See More... | 3.3.1 | Yes
|
Environment
Allows you to manipulate the environment around the player
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| break_block() | void | locationArray | FormatException | Mostly simulates a block break at a location. Does not trigger an event. Only works with craftbukkit. | 3.3.0 | Yes
|
| explosion() | void | Locationarray, [size], [safe] | FormatException |
Creates an explosion with the given size at the given location.Size defaults to size of a creeper (3), and null uses the default. If safe is true, (defaults to false) the explosion won't hurt the surrounding blocks. If size is 0, and safe is true, you will still see the animation and hear the sound, but players won't be hurt, and neither will the blocks. | 3.3.1 | Yes
|
| get_biome() | string | x, z, [world] locationArray |
FormatException |
Returns the biome type of this block column. The location array's y value is ignored. See More... | 3.3.1 | Yes
|
| get_block_at() | string | x, y, z, [world] xyzArray, [world] |
FormatException |
Gets the id of the block at x, y, z. This function expects either 1 or 3 arguments. If 1 argument is passed, it should be an array with the x, y, z coordinates. The format of the return will be x:y where x is the id of the block, and y is the meta data for the block. All blocks will return in this format, but blocks that don't have meta data normally will return 0 in y. If world isn't specified, the current player's world is used. | 3.0.2 | Yes
|
| get_block_info() | array | locationArray | CastException |
Returns an associative array with various information about a block See More... | 3.3.1 | Yes
|
| get_highest_block_at() | array | x, z, [world] xyzArray, [world] |
FormatException |
Gets the xyz of the highest block at a x and a z.It works the same as get_block_at, except that it doesn't matter now what the Y is.You can set it to -1000 or to 92374 it will just be ignored. | 3.3.1 | Yes
|
| get_sign_text() | array | xyzLocation | RangeException |
Given a location array, returns an array of 4 strings of the text in the sign at that location. If the location given isn't a sign, then a RangeException is thrown. | 3.3.0 | Yes
|
| is_sign_at() | boolean | xyzLocation | FormatException | Returns true if the block at this location is a sign. | 3.3.0 | Yes
|
| play_note() | void | [player], instrument, note, [location] | CastException |
Plays a note for the given player, at the given location. Player defaults to the current player, and location defaults to the player's location. Instrument may be one of: PIANO, BASS_DRUM, SNARE_DRUM, STICKS, or BASS_GUITAR, and note is an associative array with 2 values, array(octave: 0, tone: 'F#') where octave is either 0, 1, or 2, and tone is one of the notes G, A, B, C, D, E, or F, optionally suffixed with a pound symbol, which denotes a sharp. (Not all notes can be sharped.) | 3.3.1 | Yes
|
| play_sound() | void | locationArray, soundArray[, players] | InvalidWorldException |
Plays a sound at the given location. SoundArray is in an associative array with keys 'sound', 'volume', 'pitch', where volume and pitch are optional and default to 1. Players can be a single player or an array of players to play the sound to, if not given, all players can potentially hear it. See More... | 3.3.1 | Yes
|
| set_biome() | void | x, z, [world], biome locationArray, biome |
FormatException |
Sets the biome of the specified block column. The location array's y value is ignored. See More... | 3.3.1 | Yes
|
| set_block_at() | void | x, y, z, id, [world] locationArray, id |
CastException |
Sets the id of the block at the x y z coordinates specified. If the first argument passed is an array, it should be x, y, z, world coordinates. id must be a blocktype identifier similar to the type returned from get_block_at, except if the meta value is not specified, 0 is used. If world isn't specified, the current player's world is used. | 3.0.2 | Yes
|
| set_sign_text() | void | xyzLocation, lineArray xyzLocation, line1, [line2, [line3, [line4]]] |
RangeException |
Sets the text of the sign at the given location. If the block at x,y,z isn't a sign, a RangeException is thrown. If the text on a line overflows 15 characters, it is simply truncated. | 3.3.0 | Yes
|
EventBinding
This class of functions provide methods to hook deep into the server's event architecture
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| bind() | string | event_name, options, prefilter, event_obj, [custom_params], <code> | BindException | Binds some functionality to an event, so that when said event occurs, the event handler will fire. Returns the id of this event, so it can be unregistered later, if need be. | 3.3.0 | Yes
|
| cancel() | void | [state] | BindException | Cancels the event (if applicable). If the event is not cancellable, or is already cancelled, nothing happens. If called from outside an event handler, a BindException is thrown. By default, state is true, but you can uncancel an event (if possible) by calling cancel(false). | 3.3.0 | Yes
|
| consume() | void | BindException | Consumes an event, so that lower priority handlers don't even recieve the event. Monitor level handlers will still recieve it, however, and they can check to see if the event was consumed. | 3.3.0 | Yes
| |
| dump_events() | array | Returns an array of all the events currently registered on the server. Mostly meant for debugging, however it would be possible to parse this response to cherry pick events to unregister. | 3.3.0 | Yes
| ||
| event_meta() | array | BindException | Returns meta information about the activity in regards to this event. This is meant as a debug tool. | 3.3.0 | Yes
| |
| is_cancelled() | boolean | BindException | Returns whether or not the underlying event is cancelled or not. If the event is not cancellable in the first place, false is returned. If called from outside an event, a BindException is thrown | 3.3.0 | Yes
| |
| is_consumed() | boolean | BindException | Returns whether or not this event has been consumed. Usually only useful for Monitor level handlers, it could also be used for highly robust code, as an equal priority handler could have consumed the event, but this handler would still recieve it. | 3.3.0 | Yes
| |
| is_locked() | boolean | parameter | BindException | Returns whether or not a call to modify_event() would fail, based on the parameter being locked by a higher priority handler. If this returns false, it is still not a guarantee that the event would be successfully modified, just that it isn't locked. | 3.3.0 | Yes
|
| lock() | void | <none> parameterArray parameter, [parameter...] |
BindException | Locks the specified event parameter(s), or all of them, if specified with no arguments. Locked parameters become read only for lower priority event handlers. | 3.3.0 | Yes
|
| modify_event() | boolean | parameter, value, [throwOnFailure] | CastException |
Modifies the underlying event object, if applicable. The documentation for each event will explain what parameters can be modified, and what their expected values are. See More... | 3.3.0 | Yes
|
| trigger() | void | eventName, eventObject, [serverWide] | CastException | Manually triggers bound events. The event object passed to this function is sent directly as-is to the bound events. Check the documentation for each event to see what is required. No checks will be done on the data here, but it is not recommended to fail to send all parameters required. If serverWide is true, the event is triggered directly in the server, unless it is a CommandHelper specific event, in which case, serverWide is irrelevant. Defaults to false, which means that only CommandHelper code will receive the event. | 3.3.0 | Yes
|
| unbind() | void | [eventID] | BindException | Unbinds an event, which causes it to not run anymore. If called from within an event handler, eventID is optional, and defaults to the current event id. | 3.3.0 | Yes
|
Exceptions
This class contains functions related to Exception handling in MethodScript
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| set_uncaught_exception_handler() | void | closure(@ex) | CastException | Sets the uncaught exception handler. If code throws an exception, instead of doing the default (displaying the error to the user/console) it will run your code instead. The exception that was thrown will be passed to the closure, and it is expected that the closure returns either null, true, or false. See More... | 3.3.1 | Yes
|
| throw() | nothing | exceptionType, msg | FormatException | This function causes an exception to be thrown. If the exception type is null, it will be uncatchable. Otherwise, exceptionType may be any valid exception type. | 3.1.2 | No
|
| try() | void | tryCode, [varName, catchCode, [exceptionTypes]] tryCode, catchCode |
CastException |
This function works similar to a try-catch block in most languages. If the code in tryCode throws an exception, instead of killing the whole script, it stops running, and begins running the catchCode. var should be an ivariable, and it is set to an array containing the following information about the exception: 0 - The class of the exception; 1 - The message generated by the exception; 2 - The file the exception was generated from; 3 - The line the exception occured on. See More... | 3.1.2 | No
|
ExecutionQueue
An execution queue is a queue of closures, which are queued up to be run in sequence by the engine. Unlike set_timeout and set_interval, there is no time component, it's simply a queue of operations to execute sequentially. See the article on the learning trail for more information.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| queue_clear() | void | [queue] | Clears out all tasks that are on the queue. If no tasks were on the queue, nothing happens. | 3.3.1 | Yes
| |
| queue_delay() | void | x, [queue] | CastException | Queues up a non-disruptive sleep at the end of the queue. This task will stall the execution thread for x milliseconds. | 3.3.1 | Yes
|
| queue_delay_front() | void | x, [queue] | CastException | Works like queue_delay, but puts the delay at the front of the queue. | 3.3.1 | Yes
|
| queue_push() | void | closure, [queue] | CastException | Queues a task up at the end of the specified queue. | 3.3.1 | Yes
|
| queue_push_front() | void | closure, [queue] | CastException | Queues a task at the front of the queue. | 3.3.1 | Yes
|
| queue_remove() | void | [queue] | Removes the last task at the end of the queue from the queue. | 3.3.1 | Yes
| |
| queue_remove_front() | void | [queue] | Removes a task from the front of the queue. That is, the next task that would have been run is removed. | 3.3.1 | Yes
| |
| queue_running() | boolean | [queue] | Returns true if the specified queue still has tasks running on it. | 3.3.1 | Yes
|
FileHandling
This class contains methods that help manage files on the file system. Most are restricted with the base-dir setting in your preferences.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| async_read() | void | file, callback | SecurityException | Asyncronously reads in a file. See More... | 3.3.1 | Yes
|
| file_size() | int | path | IOException |
Returns the size of a file on the file system. | 3.3.1 | Yes
|
| read() | string | file | IOException |
Reads in a file from the file system at location var1 and returns it as a string. The path is relative to the file that is being run, not CommandHelper. If the file is not found, or otherwise can't be read in, an IOException is thrown. If the file specified is not within base-dir (as specified in the preferences file), a SecurityException is thrown. The line endings for the string returned will always be \n, even if they originally were \r\n. | 3.0.1 | Yes
|
InventoryManagement
Provides methods for managing inventory related tasks.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| close_pinv() | void | [player] | PlayerOfflineException | Closes the inventory of the current player, or of the specified player. | 3.3.1 | Yes
|
| get_inventory_item() | array | entityID, slotNumber locationArray, slotNumber |
FormatException |
If a number is provided, it is assumed to be an entity, and if the entity supports inventories, it will be valid. Otherwise, if a location array is provided, it is assumed to be a block (chest, brewer, etc) and interpreted thusly. Depending on the inventory type, the max index will vary. If the index is too large, a RangeException is thrown, otherwise, the item at that location is returned as an item array, or null, if no item is there. You can determine the inventory type (and thus the max index count) with get_inventory_type(). An itemArray, like the one used by pinv/set_pinv is returned. | 3.3.1 | Yes
|
| get_inventory_size() | int | entityID locationArray |
FormatException |
Returns the max size of the inventory specified. If the block or entity can't have an inventory, a FormatException is thrown. | 3.3.1 | Yes
|
| get_inventory_type() | string | entityID locationArray |
CastException |
Returns the inventory type at the location specified, or of the entity specified. If the entity or location specified is not capable of having an inventory, a FormatException is thrown. See More... | 3.3.1 | Yes
|
| penchanting() | void | [player] | PlayerOfflineException | Shows an enchanting to the current player, or a specified player. Note that power is defined by how many bookcases are near. | 3.3.1 | Yes
|
| penderchest() | mixed | [player, [index]] | PlayerOfflineException |
Gets the inventory information for the specified player's enderchest, or the current player if none specified. If the index is specified, only the slot given will be returned. The index of the array in the array is 0 - 26, which corresponds to the slot in the enderchest inventory. If there is no item at the slot specified, null is returned. See More... | 3.3.1 | Yes
|
| pgive_item() | int | [player], itemID, qty, [meta] | CastException |
Gives a player the specified item * qty. The meta argument uses the same format as set_itemmeta. Unlike set_pinv(), this does not specify a slot. The qty is distributed in the player's inventory, first filling up slots that have the same item type, up to the max stack size, then fills up empty slots, until either the entire inventory is filled, or the entire amount has been given. The number of items actually given is returned, which will be less than or equal to the quantity provided. This function will not touch the player's armor slots however. Supports 'infinite' stacks by providing a negative number. If the player's inv is full, 0 is returned in this case instead of the amount given. | 3.3.0 | Yes
|
| phas_item() | int | [player], itemId | PlayerOfflineException |
Returns the quantity of the specified item that the player is carrying (including armor slots). This counts across all slots in inventory. Recall that 0 is false, and anything else is true, so this can be used to get the total, or just see if they have the item. itemId can be either a plain number, or a 0:0 number, indicating a data value. | 3.3.0 | Yes
|
| pinv() | mixed | [player, [index]] | PlayerOfflineException |
Gets the inventory information for the specified player, or the current player if none specified. If the index is specified, only the slot given will be returned. The index of the array in the array is 0 - 35, 100 - 103, which corresponds to the slot in the players inventory. To access armor slots, you may also specify the index. (100 - 103). The quick bar is 0 - 8. If index is null, the item in the player's hand is returned, regardless of what slot is selected. If there is no item at the slot specified, null is returned. See More... | 3.1.3 | Yes
|
| pinv_open() | void | [playerToShow,] playerInventory | PlayerOfflineException | Opens a player's inventory, shown to the player specified's screen. | 3.3.1 | Yes
|
| pitem_slot() | array | [player], itemID | CastException |
Given an item id, returns the slot numbers that the matching item has at least one item in. | 3.3.0 | Yes
|
| ptake_item() | int | [player], itemID, qty | CastException |
Works in reverse of pgive_item(), but returns the number of items actually taken, which will be from 0 to qty. | 3.3.0 | Yes
|
| pworkbench() | void | [player] | PlayerOfflineException | Shows a workbench to the current player, or a specified player. | 3.3.1 | Yes
|
| set_inventory_item() | void | entityID, index, itemArray locationArray, index, itemArray |
FormatException |
Sets the specified item in the specified slot given either an entityID or a location array of a container object. See get_inventory_type for more information. The itemArray is an array in the same format as pinv/set_pinv takes. | 3.3.1 | Yes
|
| set_penderchest() | void | [player], pinvArray | PlayerOfflineException |
Sets a player's enderchest's inventory to the specified inventory object. An inventory object is one that matches what is returned by penderchest(), so set_penderchest(penderchest()), while pointless, would be a correct call. See More... | 3.3.1 | Yes
|
| set_pinv() | void | [player], pinvArray | PlayerOfflineException |
Sets a player's inventory to the specified inventory object. An inventory object is one that matches what is returned by pinv(), so set_pinv(pinv()), while pointless, would be a correct call. See More... | 3.2.0 | Yes
|
| show_enderchest() | void | [player [, player]] | PlayerOfflineException | Shows the enderchest of either the current player or the specified player if given. If a second player is specified, shows the second player the contents of the first player's enderchest. | 3.3.1 | Yes
|
ItemMeta
These functions manipulate an item's meta data. The items are modified in a player's inventory.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| get_armor_color() | colorArray | [player], inventorySlot | CastException |
Returns a color array for the color of the leather armor at the given slot. A CastException is thrown if this is not leather armor at that slot. The color array returned will look like: array(r: 0, g: 0, b: 0) | 3.3.1 | Yes
|
| get_itemmeta() | mixed | [player,] inventorySlot | PlayerOfflineException |
Returns an associative array of known ItemMeta for the slot given, or null if there isn't any. All items can have a display(name), lore, and/or enchants, and more info will be available for the items that have it. See More... (Examples...) |
3.3.1 | Yes
|
| is_leather_armor() | boolean | [player], itemSlot | CastException |
Returns true if the item at the given slot is a piece of leather armor, that is, if dying it is allowed. | 3.3.1 | Yes
|
| set_armor_color() | void | [player], slot, colorArray | CastException |
Sets the color of the leather armor at the given slot. colorArray should be an array that matches one of the formats: array(r: 0, g: 0, b: 0) array(red: 0, green: 0, blue: 0) array(0, 0, 0) | 3.3.1 | Yes
|
| set_itemmeta() | void | [player,] inventorySlot, ItemMetaArray | PlayerOfflineException |
Applies the data from the given array to the item at the specified slot. Unused fields will be ignored. If null or an empty array is supplied, or if none of the given fields are applicable, the item will become default, as this function overwrites any existing data. See More... (Examples...) |
3.3.1 | Yes
|
Marquee
This class provides methods for making a text "marquee", like a stock ticker. Because this is a threading operation, and could be potentially resource intensive, the heavy lifting has been implemented natively.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| marquee() | void | [marqueeName], text, stringWidth, delayTime, callback | CastException | Sets up a marquee, which will automatically split up a given string for you, and call the callback. The split string will automatically wrap, handle buffering spaces, and scroll through the text. See More... | 3.3.1 | Yes
|
| marquee_stop() | void | marqueeName | Stops a named marquee. | 3.3.1 | Yes
|
Math
Provides mathematical functions to scripts
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| abs() | double | arg | CastException | Returns the absolute value of the argument. (Examples...) |
3.1.2 | No
|
| acos() | double | number | CastException | Returns the arc cos of the number | 3.3.0 | No
|
| add() | mixed | var1, [var2...] | CastException | Adds all the arguments together, and returns either a double or an integer (Examples...) |
3.0.1 | No
|
| asin() | double | number | CastException | Returns the arc sin of the number | 3.3.0 | No
|
| atan() | double | number | CastException | Returns the arc tan of the number | 3.3.0 | No
|
| atan2() | double | y, x | CastException | Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta). This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi. | 3.3.0 | No
|
| ceil() | int | number | CastException | Returns the ceiling of any given number. For example, ceil(3.2) returns 4, and ceil(-1.1) returns -1 | 3.1.3 | No
|
| cos() | double | number | CastException | Returns the cos of the number | 3.3.0 | No
|
| dec() | ivar | var, [value] | CastException | Subtracts value from var, and stores the new value. Value defaults to 1. Equivalent to --var (or var -= value) in other languages. Expects ivar to be a variable, then returns the ivar, , or, if var is a constant number, simply adds x to it, and returns the new number. | 3.0.1 | No
|
| divide() | mixed | var1, [var2...] | CastException |
Divides the arguments from left to right, and returns either a double or an integer. If you divide by zero, a RangeException is thrown. (Examples...) |
3.0.1 | No
|
| expr() | double | expression, [valueArray] | CastException |
Sometimes, when you need to calculate an advanced mathematical expression, it is messy to write out everything in terms of functions. This function will allow you to evaluate a mathematical expression as a string, using common mathematical notation. For example, (2 + 3) * 4 would return 20. Variables can also be included, and their values given as an associative array. expr('(x + y) * z', array(x: 2, y: 3, z: 4)) would be the same thing as the above example. | 3.3.0 | No
|
| floor() | int | number | CastException | Returns the floor of any given number. For example, floor(3.8) returns 3, and floor(-1.1) returns 2 | 3.1.3 | No
|
| inc() | ivar | var, [x] | CastException | Adds x to var, and stores the new value. Equivalent to ++var in other languages. Expects ivar to be a variable, then returns the ivar, or, if var is a constant number, simply adds x to it, and returns the new number. (Examples...) |
3.0.1 | No
|
| logarithm() | double | val, [base] | CastException |
Return the log of a number to the specified base, or the mathematical constant e if no base is provided (or ln). If val is less than or equal to zero, a RangeException is thrown. Mathematically speaking, if val is 0, then the result would be negative infinity, and if it is less than 0 it is undefined (NaN), but since MethodScript has no way of representing either of these, a RangeException is thrown instead. (Examples...) |
3.3.1 | No
|
| max() | number | num1, [num2...] | CastException |
Returns the highest number in a given list of numbers. If any of the arguments are arrays, they are expanded into individual numbers, and also compared. | 3.2.0 | No
|
| min() | number | num1, [num2...] | CastException |
Returns the lowest number in a given list of numbers. If any of the arguments are arrays, they are expanded into individual numbers, and also compared. | 3.2.0 | No
|
| mod() | int | x, n | CastException | Returns x modulo n (Examples...) |
3.0.1 | No
|
| multiply() | mixed | var1, [var2...] | CastException | Multiplies the arguments together, and returns either a double or an integer (Examples...) |
3.0.1 | No
|
| neg() | number | number | CastException | Negates a number, essentially multiplying the number by -1 | 3.3.1 | No
|
| postdec() | ivar | var, [x] | CastException | Subtracts x from var, and stores the new value. Equivalent to var-- in other languages. Expects ivar to be a variable, then returns a copy of the old ivar, , or, if var is a constant number, simply adds x to it, and returns the new number. | 3.3.1 | No
|
| postinc() | ivar | var, [x] | CastException | Adds x to var, and stores the new value. Equivalent to var++ in other languages. Expects ivar to be a variable, then returns a copy of the old ivar, or, if var is a constant number, simply adds x to it, and returns the new number. | 3.3.1 | No
|
| pow() | double | x, n | CastException | Returns x to the power of n (Examples...) |
3.0.1 | No
|
| rand() | mixed | [] min/max, [max] |
RangeException |
Returns a random number from 0 to max, or min to max, depending on usage. Max is exclusive. Min must be less than max, and both numbers must be >= 0. This will return an integer. Alternatively, you can pass no arguments, and a random double, from 0 to 1 will be returned. (Examples...) |
3.0.1 | No
|
| round() | mixed | number, [precision] | CastException |
Unlike floor and ceil, rounds the number to the nearest integer. Precision defaults to 0, but if set to 1 or more, rounds decimal places. For instance, round(2.29, 1) would return 2.3. If precision is < 0, a RangeException is thrown. If precision is set to 0, an integer is always returned, and if precision is > 0, a double is always returned. (Examples...) |
3.3.0 | No
|
| sin() | double | number | CastException | Returns the sin of the number | 3.3.0 | No
|
| sqrt() | number | number | RangeException |
Returns the square root of a number. Note that this is mathematically equivalent to pow(number, .5). Imaginary numbers are not supported, so number must be positive. | 3.2.0 | No
|
| subtract() | mixed | var1, [var2...] | CastException | Subtracts the arguments from left to right, and returns either a double or an integer (Examples...) |
3.0.1 | No
|
| tan() | double | number | CastException | Returns the tan of the number | 3.3.0 | No
|
| to_degrees() | double | number | CastException | Converts the number to degrees (which is assumed to have been in radians) | 3.3.0 | No
|
| to_radians() | double | number | CastException | Converts the number to radians (which is assumed to have been in degrees) | 3.3.0 | No
|
Meta
These functions provide a way to run other commands
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| call_alias() | boolean | cmd | Allows a CommandHelper alias to be called from within another alias. Typically this is not possible, as a script that runs "/jail = /jail" for instance, would simply be calling whatever plugin that actually provides the jail functionality's /jail command. However, using this function makes the command loop back to CommandHelper only. See More... | 3.2.0 | No
| |
| capture_runas() | string | player, command | PlayerOfflineException | Works like runas, except any messages sent to the command sender during command execution are attempted to be intercepted, and are then returned as a string, instead of being sent to the command sender. Note that this is VERY easy for plugins to get around in such a way that this function will not work, this is NOT a bug in CommandHelper, nor is it necessarily a problem in the other plugin either, but the other plugin will have to make changes for it to work properly. | 3.3.1 | Yes
|
| eval() | string | script_string | Executes arbitrary MethodScript. Note that this function is very experimental, and is subject to changing or removal. | 3.1.0 | Yes
| |
| g() | string | func1, [func2...] | Groups any number of functions together, and returns void. | 3.0.1 | No
| |
| get_cmd() | mixed | Gets the command (as a string) that ended up triggering this script, exactly how it was entered by the player. This could be null, if for instance it is called from within an event. | 3.3.0 | No
| ||
| get_command_block() | locationArray | If this command was being run from a command block, this will return the location of the block. If a player or console ran this command, (or any other command sender) this will return null. | 3.3.1 | No
| ||
| is_alias() | boolean | cmd | IOException | Returns true if using call_alias with this cmd would trigger an alias. | 3.3.1 | Yes
|
| psetop() | string | [player], status | PlayerOfflineException | Sets whether or not a player has operator status. If no player is specified the player running the script is given. | 3.3.1 | Yes
|
| run() | void | var1 | FormatException | Runs a command as the current player. Useful for running commands in a loop. Note that this accepts commands like from the chat; with a forward slash in front. | 3.0.1 | No
|
| runas() | void | player, command | FormatException |
Runs a command as a particular user. The special user '~console' can be used to run it as a console user. Using '~op' is deprecated, and will be removed after the next release, use sudo() instead. Commands cannot be run as an offline player. If the first argument is an array of usernames, the command will be run in the context of each user in the array. | 3.0.1 | Yes
|
| scriptas() | void | player, [label], script | PlayerOfflineException | Runs the specified script in the context of a given player. A script that runs player() for instance, would return the specified player's name, not the player running the command. Setting the label allows you to dynamically set the label this script is run under as well (in regards to permission checking) | 3.3.0 | Yes
|
| sudo() | void | command | FormatException | Runs a single command for this user, as op. Works like runas(~op, '/command') used to work, before it was deprecated. | 3.3.1 | Yes
|
Minecraft
These functions provide a hook into game functionality.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| data_name() | string | int itemArray |
CastException |
Performs the reverse functionality as data_values. Given 1, returns 'Stone'. Note that the enum value given in bukkit's Material class is what is returned as a fallback, if the id doesn't match a value in the internally maintained list. If a completely invalid argument is passed in, null is returned. | 3.3.0 | No
|
| data_values() | int | var1 | Does a lookup to return the data value of a name. For instance, returns 1 for 'stone'. If an integer is given, simply returns that number. If the data value cannot be found, null is returned. | 3.0.1 | No
| |
| get_banned_players() | Array | An array of players banned on the server. | 3.3.1 | No
| ||
| get_entity_health() | int | entityID | CastException |
Returns the entity's health, as a percentage. If the specified entity doesn't exist, or is not a LivingEntity, a format exception is thrown. | 3.3.0 | Yes
|
| get_ip_bans() | array | Returns an array of entries from banned-ips.txt. | 3.3.1 | Yes
| ||
| get_mob_owner() | string | entityID | UntameableMobException |
Returns the owner's name, or null if the mob is unowned. An UntameableMobException is thrown if mob isn't tameable to begin with. | 3.3.0 | Yes
|
| get_server_info() | mixed | [value] | CastException |
Returns various information about server.If value is set, it should be an integer of one of the following indexes, and only that information for that index will be returned. See More... | 3.3.1 | No
|
| get_spawner_type() | string | locationArray | FormatException | Gets the spawner type of the specified mob spawner. See More... | 3.3.1 | Yes
|
| get_whitelisted_players() | Array | An array of players whitelisted on the server. | 3.3.1 | No
| ||
| is_tameable() | boolean | entityID | CastException |
Returns true or false if the specified entity is tameable | 3.3.0 | Yes
|
| launch_firework() | void | locationArray, [optionsArray] | FormatException | Launches a firework. The location array specifies where it is launched from, and the options array is an associative array described below. All parameters in the associative array are optional, and default to the specified values if not set. The default options being set will make it look like a normal firework, with a white explosion. See More... | 3.3.1 | Yes
|
| make_effect() | void | xyzArray, effect, [radius] | CastException |
Plays the specified effect (sound effect) at the given location, for all players within the radius (or 64 by default). The effect can be one of the following: BOW_FIRE, CLICK1, CLICK2, DOOR_TOGGLE, EXTINGUISH, RECORD_PLAY, GHAST_SHRIEK, GHAST_SHOOT, BLAZE_SHOOT, SMOKE, STEP_SOUND, POTION_BREAK, ENDER_SIGNAL, ZOMBIE_CHEW_WOODEN_DOOR, ZOMBIE_CHEW_IRON_DOOR, ZOMBIE_DESTROY_DOOR, or MOBSPAWNER_FLAMES. Additional data can be supplied with the syntax EFFECT:DATA. The RECORD_PLAY effect takes the item id of a disc as data, STEP_SOUND takes a blockID and SMOKE takes a direction bit (4 is upwards). | 3.1.3 | Yes
|
| material_info() | array | int | CastException |
Returns an array of info about the material. | 3.3.1 | Yes
|
| max_stack_size() | integer | itemType itemArray |
CastException |
Given an item type, returns the maximum allowed stack size. This method will accept either a single data value (i.e. 278) or an item array like is returned from pinv(). Additionally, if a single value, it can also be in the old item notation (i.e. '35:11'), though for the purposes of this function, the data is unneccesary. | 3.3.0 | No
|
| send_texturepack() | void | player, url | PlayerOfflineException | Sends a texturepack URL to the player's client. If the client has not been requested to change textures in the past, they will recieve a confirmation dialog before downloading and switching to the new pack. Clients that ignore server textures will not recieve the request, so this function will not affect them. | 3.3.1 | Yes
|
| set_entity_health() | void | entityID, healthPercent | CastException |
Sets the specified entity's health (0 kills it), or ignores this call if the entityID doesn't exist or isn'ta LivingEntity. | 3.3.0 | Yes
|
| set_ip_banned() | void | address, banned | If banned is true, address is added to banned-ips.txt, if false, the address is removed. | 3.3.1 | Yes
| |
| set_spawner_type() | void | locationArray, type | FormatException | Sets the mob spawner type at the location specified. If the location is not a mob spawner, or if the type is invalid, a FormatException is thrown. | 3.3.1 | Yes
|
| spawn_mob() | array | mobType, [qty], [location] | CastException |
Spawns qty mob of one of the following types at location. qty defaults to 1, and location defaults to the location of the player. See More... | 3.1.2 | Yes
|
| tame_mob() | void | [player], entityID | UntameableMobException |
Tames the entity specified to the player. Wolves and ocelots are supported. Offline players are supported, but this means that partial matches are NOT supported. You must type the players name exactly. Setting the player to null will untame the mob. If the entity doesn't exist, nothing happens. | 3.3.0 | Yes
|
Performance
This class provides functions for hooking into CommandHelper's powerful Performance measuring. To use the functions, you must have allow-profiling option set to true in your preferences file.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| enable_performance_logging() | void | boolean | SecurityException | Enables performance logging. The allow-profiling option must be set to true in your preferences file, and play-dirty mode must be active. If allow-profiling is set to false, a SecurityException is thrown. The debug filters are used by the performance logger, if you choose to filter through the events. See the documenation for more details on performance logging. | 3.3.0 | Yes
|
Permissions
Provides access to the server's underlying permissions system. Permissions functionality is only as good as the management system in place, however, and so not all functions may be supported on a given system.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| has_permission() | boolean | [player], permissionName | InsufficientPermissionException |
Using the built in permissions system, checks to see if the player has a particular permission. This is simply passed through to the permissions system. This function does not throw a PlayerOfflineException, because it works with offline players, but that means that names must be an exact match. If you notice, this function isn't restricted. However, it IS restricted if the player attempts to check another player's permissions. If run from the console, will always return true. | 3.3.0 | No
|
Persistance
Allows scripts to store data from execution to execution. See the guide on persistance for more information. In all the functions, you may send multiple arguments for the key, which will automatically be concatenated with a period (the namespace separator). No magic happens here, you can put periods yourself, or combine manually namespaced values or automatically namespaced values with no side effects.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| clear_value() | void | [namespace, ...,] key | IOException |
Completely removes a value from storage. Calling has_value(key) after this call will return false. | 3.3.0 | Yes
|
| get_value() | Mixed | [namespace, ...,] key | IOException |
Returns a stored value stored with store_value. If the key doesn't exist in storage, null is returned. On a more detailed note: If the value stored in the persistance database is not actually a construct, then null is also returned. | 3.0.2 | Yes
|
| get_values() | array | name[, space, ...] | IOException |
Returns all the values in a particular namespace as an associative array(key: value, key: value). Only full namespace matches are considered, so if the key 'users.data.username.hi' existed in the database, and you tried get_values('users.data.user'), nothing would be returned. The last segment in a key is also considered a namespace, so 'users.data.username.hi' would return a single value (in this case). | 3.3.0 | Yes
|
| has_value() | boolean | [namespace, ...,] key | IOException |
Returns whether or not there is data stored at the specified key in the Persistance database. | 3.1.2 | Yes
|
| store_value() | void | [namespace, ...,] key, value | FormatException |
Allows you to store a value, which can then be retrieved later. key must be a string containing only letters, numbers, underscores. Periods may also be used, but they form a namespace, and have special meaning. (See get_values()) | 3.0.2 | Yes
|
PlayerManagement
This class of functions allow players to be managed
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| all_players() | array | Returns an array of all the player names of all the online players on the server | 3.0.1 | Yes
| ||
| get_compass_target() | array | [player] | PlayerOfflineException | Gets the compass target of the specified player | 3.3.0 | Yes
|
| get_list_name() | string | [player] | PlayerOfflineException | Returns the list name of the specified player, or the current player if none specified. | 3.3.1 | Yes
|
| get_offline_players() | array | Returns an array of every player who has played on this server. (Examples...) |
3.3.1 | Yes
| ||
| get_peffect() | array | [player] | PlayerOfflineException | Returns an array of effects that are currently active on a given player. The array will be full of playerEffect objects, which contain three fields, "potionID", "strength", "seconds" remaining, and whether the effect is "ambient". | 3.3.1 | Yes
|
| get_pflyspeed() | void | [player] | PlayerOfflineException |
Gets the players speed. The speed must be between -1 or 1 | 3.3.1 | Yes
|
| get_pwalkspeed() | void | [player] | PlayerOfflineException |
Gets the players speed. The speed must be between -1 or 1 | 3.3.1 | Yes
|
| give_pexp() | void | [player], exp | PlayerOfflineException |
Gives the player the specified amount of xp. | 3.3.0 | Yes
|
| kick() | void | [playerName], [message] | PlayerOfflineException | Kicks the specified player, with an optional message. If no message is specified, "You have been kicked" is used. If no player is specified, the current player is used, with the default message. | 3.1.0 | Yes
|
| kill() | void | [playerName] | PlayerOfflineException | Kills the specified player, or the current player if it is omitted | 3.0.1 | Yes
|
| pbanned() | boolean | player | Returns whether or not this player is banned. Note that this will work with offline players, but the name must be exact. At this time, this function only works with the vanilla ban system. If you use a third party ban system, you should instead run the command for that plugin instead. | 3.3.0 | Yes
| |
| pbed_location() | array | [playerName] | Returns an array of x, y, z, coords of the bed of the player specified, or the player running the command otherwise.The array returned will also include the bed's world in index 3 of the array. This is set when a player sleeps or by set_pbed_location. | 3.3.1 | Yes
| |
| pcursor() | array | [player], [array] | PlayerOfflineException RangeException |
Returns an array with the (x, y, z, world) coordinates of the block the player has highlighted in their crosshairs. If player is omitted, the current player is used. If the block is too far, a RangeException is thrown. An array of ids to be considered transparent can be supplied, otherwise only air will be considered transparent. Providing an empty array will cause air to be considered a potential target, allowing a way to get the block containing the player's head. (Examples...) |
3.0.2 | Yes
|
| pexp() | int | [player] | CastException |
Gets the experience of a player within this level, as a percentage, from 0 to 99. (100 would be next level, therefore, 0.) | 3.1.3 | Yes
|
| pfacing() | mixed | F yaw, pitch player, F player, yaw, pitch player <none> |
PlayerOfflineException |
Sets the direction the player is facing. See More... | 3.1.3 | Yes
|
| pfirst_played() | int | [player] | Returns the time this player first logged onto this server, or 0 if they never have. This will not throw a PlayerOfflineException, so the name must be exact. (Examples...) |
3.3.1 | Yes
| |
| pfood() | int | [player] | PlayerOfflineException | Returns the player's current food level. | 3.1.3 | Yes
|
| pget_time() | int | [player] | PlayerOfflineException | Returns the time of the specified player, as an integer from 0 to 24000-1 | 3.3.1 | Yes
|
| pgroup() | array | [playerName] | PlayerOfflineException | Returns an array of the groups a player is in. If playerName is omitted, the current player is used. | 3.0.1 | Yes
|
| phas_flight() | boolean | [player] | PlayerOfflineException | Returns whether or not the player has the ability to fly | 3.3.1 | Yes
|
| phas_played() | boolean | player | Returns whether the given player has ever been on this server. This will not throw a PlayerOfflineException, so the name must be exact. (Examples...) |
3.3.1 | Yes
| |
| phunger() | int | [player] | PlayerOfflineException | Returns the player's hunger level | 3.3.1 | Yes
|
| pinfo() | mixed | [pName], [value] | PlayerOfflineException |
Returns various information about the player specified, or the current player if no argument was given. See More... | 3.1.0 | Yes
|
| pisop() | boolean | [player] | PlayerOfflineException | Returns whether or not the specified player (or the current player if not specified) is op | 3.3.0 | Yes
|
| plast_played() | int | [player] | Returns the time this player was last seen on this server, or 0 if they never were. This will not throw a PlayerOfflineException, so the name must be exact. (Examples...) |
3.3.1 | Yes
| |
| player() | string | [playerName] | PlayerOfflineException | Returns the full name of the partial Player name specified or the Player running the command otherwise. If the command is being run from the console, then the string '~console' is returned. If the command came from a CommandBlock, the block's name prefixed with # is returned. If the command is coming from elsewhere, returns a string chosen by the sender of this command (or null). Note that most functions won't support console or block names (they'll throw a PlayerOfflineException), but you can use this to determine where a command is being run from. | 3.0.1 | No
|
| players_in_radius() | array | [location array], distance | CastException |
Returns an array of all the player names of all the online players within the given radius | 3.3.1 | Yes
|
| plevel() | int | [player] | CastException |
Gets the player's level. | 3.1.3 | Yes
|
| ploc() | array | [playerName] | PlayerOfflineException | Returns an array of x, y, z coords of the player specified, or the player running the command otherwise. Note that the y coordinate is in relation to the block the player is standing on. The array returned will also include the player's world in index 3 of the array. | 3.0.1 | Yes
|
| pmode() | string | [player] | PlayerOfflineException | Returns the player's game mode. It will be one of "CREATIVE" or "SURVIVAL". | 3.1.3 | Yes
|
| ponfire() | int | [player] | PlayerOfflineException | Returns the number of ticks remaining that this player will be on fire for. If the player is not on fire, 0 is returned, which incidentally is false. | 3.3.0 | Yes
|
| ponline() | boolean | player | Returns whether or not the specified player is online. Note that the name must match exactly, but it will not throw a PlayerOfflineException if the player is not online, or if the player doesn't even exist. | 3.3.0 | Yes
| |
| preset_time() | void | [player] | InvalidWorldException |
Resets the time of the player to the time of the world. | 3.3.1 | Yes
|
| psaturation() | double | [player] | RangeException |
Returns the player's saturation level | 3.3.1 | Yes
|
| psend_block_change() | void | [player], locationArray, itemID | FormatException |
Changes a block, but only temporarily, and only for the specified player. This can be used to "fake" blocks for a player. ItemID is in the 1[:1] data format. | 3.3.1 | Yes
|
| pset_flight() | void | [player], flight | PlayerOfflineException | Sets whether or not this player is allowed to fly DEPRECATED(use set_pflight instead) | 3.3.1 | Yes
|
| pset_time() | void | [player], time | PlayerOfflineException |
Sets the time of a given player. Should be a number from 0 to 24000, if not, it is modulo scaled. Alternatively, common time notation (9:30pm, 4:00 am) is acceptable, and convenient english mappings also exist:
|
3.3.1 | Yes
|
| ptexp() | int | [player] | CastException |
Gets the total experience of a player. | 3.1.3 | Yes
|
| pvehicle() | mixed | [player] | PlayerOfflineException | Returns name of vehicle which player is in or null if player is outside the vehicle | 3.3.1 | Yes
|
| pvehicle_leave() | boolean | [player] | PlayerOfflineException | Leave vehicle by player or return false if player is outside the vehicle | 3.3.1 | Yes
|
| pwhitelisted() | boolean | player | Returns whether or not this player is whitelisted. Note that this will work with offline players, but the name must be exact. | 3.3.0 | Yes
| |
| pworld() | string | [playerName] | PlayerOfflineException | Gets the world of the player specified, or the current player, if playerName isn't specified. | 3.1.0 | Yes
|
| reset_display_name() | void | [playerName] | PlayerOfflineException | Resets a player's display name to their real name. If playerName isn't specified, defaults to the player running the command. | 3.1.2 | Yes
|
| set_compass_target() | array | [player], locationArray | PlayerOfflineException |
Sets the player's compass target, and returns the old location. | 3.3.0 | Yes
|
| set_display_name() | void | playerName, newDisplayName newDisplayName |
PlayerOfflineException | Sets a player's display name. If the second usage is used, it sets the display name of the player running the command. See reset_display_name also. playerName, as well as all CommandHelper commands expect the player's real name, not their display name. | 3.1.2 | Yes
|
| set_list_name() | void | [player], [listName] | PlayerOfflineException |
Sets the player's list name. The name cannot be longer than 16 characters, but colors are supported. Setting the name to null resets it. If the name specified is already taken, a FormatException is thrown, and if the length of the name is greater than 16 characters, a LengthException is thrown. | 3.3.1 | Yes
|
| set_pbanned() | void | player, isBanned | Sets the ban flag of the specified player. Note that this will work with offline players, but the name must be exact. At this time, this function only works with the vanilla ban system. If you use a third party ban system, you should instead run the command for that plugin instead. | 3.3.0 | Yes
| |
| set_pbed_location() | boolean | [player], locationArray [player], x, y, z |
CastException |
Sets the location of the bed of the player to the specified coordinates. If player is omitted, the current player is used. | 3.3.1 | Yes
|
| set_peffect() | boolean | player, potionID, strength, [seconds], [ambient] | PlayerOfflineException |
Effect is 1-19. Seconds defaults to 30. If the potionID is out of range, a RangeException is thrown, because out of range potion effects cause the client to crash, fairly hardcore. See http://www.minecraftwiki.net/wiki/Potion_effects for a complete list of potions that can be added. To remove an effect, set the seconds to 0. Strength is the number of levels to add to the base power (effect level 1). Ambient takes a boolean of whether the particles should be less noticeable. The function returns true if the effect was added or removed as desired, and false if it wasn't (however, this currently only will happen if an effect is attempted to be removed, yet isn't already on the player). (Examples...) |
3.3.0 | Yes
|
| set_pexp() | void | [player], xp | CastException |
Sets the experience of a player within the current level, as a percentage, from 0 to 100. | 3.1.3 | Yes
|
| set_pflight() | void | [player], flight | PlayerOfflineException | Sets whether or not this player is allowed to fly | 3.3.1 | Yes
|
| set_pflyspeed() | void | [player], speed | PlayerOfflineException |
Sets players fly speed. The speed must be between -1 or 1 | 3.3.1 | Yes
|
| set_pfood() | void | [player], level | PlayerOfflineException |
Sets the player's food level. This is an integer from 0-? | 3.1.3 | Yes
|
| set_phealth() | void | [player], health | CastException |
Sets the player's health. health should be an integer from 0-20. | 3.2.0 | Yes
|
| set_phunger() | void | [player], hunger | RangeException |
Sets a player's hunger level | 3.3.1 | Yes
|
| set_plevel() | void | [player], level | CastException |
Sets the level of a player. | 3.1.3 | Yes
|
| set_ploc() | boolean | [player], locationArray [player], x, y, z |
CastException |
Sets the location of the player to the specified coordinates. If the coordinates are not valid, or the player was otherwise prevented from moving, false is returned, otherwise true. If player is omitted, the current player is used. Note that 1 is automatically added to the y component, which means that sending a player to x, y, z coordinates shown with F3 will work as expected, instead of getting them stuck inside the floor. | 3.1.0 | Yes
|
| set_pmode() | void | [player], mode | PlayerOfflineException |
Sets the player's game mode. mode must be one of: SURVIVAL, CREATIVE, or ADVENTURE | 3.1.3 | Yes
|
| set_ponfire() | void | [player], ticks | PlayerOfflineException |
Sets the player on fire for the specified number of ticks. If a boolean is given for ticks, false is 0, and true is 20. | 3.3.0 | Yes
|
| set_psaturation() | void | [player], saturation | RangeException |
3.3.1 | Yes
| |
| set_ptexp() | void | [player], xp | CastException |
Sets the total experience of a player. | 3.1.3 | Yes
|
| set_ptime() | void | [player], time | PlayerOfflineException |
Sets the time of a given player. Should be a number from 0 to 24000, if not, it is modulo scaled. Alternatively, common time notation (9:30pm, 4:00 am) is acceptable, and convenient english mappings also exist:
|
3.3.1 | Yes
|
| set_pvelocity() | boolean | [player], vector [player], x, y, z |
CastException |
Sets a player's velocity. vector must be an associative array with x, y, and z keys defined (if magnitude is set, it is ignored). If the vector's magnitude is greater than 10, the command is cancelled, because the server won't allow the player to move faster than that. A warning is issued, and false is returned if this happens, otherwise, true is returned. | 3.3.1 | Yes
|
| set_pwalkspeed() | void | [player], speed | PlayerOfflineException |
Sets players speed. The speed must be between -1 or 1 | 3.3.1 | Yes
|
| set_pwhitelisted() | void | player, isWhitelisted | Sets the whitelist flag of the specified player. Note that this will work with offline players, but the name must be exact. | 3.3.0 | Yes
|
PluginMeta
This class contains the functions use to communicate with other plugins and the server in general.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| fake_incoming_plugin_message() | void | [player,] channel, message | CastException |
Fakes an incoming plugin message from the player. Channel should be a string (the channel name) and message should be a byte_array primitive. Depending on the plugin, these parameters will vary. If message is null an empty byte_array is sent. | 3.3.1 | Yes
|
| get_registered_channels() | array | Returns an array of strings containing the channels CommandHelper is listening on. | 3.3.1 | Yes
| ||
| is_channel_registered() | boolean | channel | Returns true if commandhelper is listening to the given plugin channel. | 3.3.1 | Yes
| |
| register_channel() | void | channel | PluginChannelException | Registers a plugin channel for CommandHelper to listen on. Incoming messages can be inspected by binding to 'plugin_message_received'. | 3.3.1 | Yes
|
| send_plugin_message() | void | [player,] channel, message | CastException |
Sends a plugin message to the player. Channel should be a string (the channel name) and message should be a byte_array primitive. Depending on the plugin, these parameters will vary. If message is null an empty byte_array is sent. | 3.3.1 | Yes
|
| unregister_channel() | void | channel | PluginChannelException | Unregisters a plugin channel CommandHelper is listening on, if any. | 3.3.1 | Yes
|
Reflection
This class of functions allows scripts to hook deep into the interpreter itself, and get meta information about the operations of a script. This is useful for debugging, testing, and ultra dynamic scripting. See the guide to reflection on the wiki for more details. In order to make the most of these functions, you should familiarize yourself with the general workings of the language. These functions explore extremely advanced concepts, and should normally not be used; especially if you are not familiar with the language.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| get_aliases() | array | Returns an array of the defined alias signatures (The part left of the = sign). | 3.3.1 | Yes
| ||
| get_events() | array | Returns an array of all registered event names. | 3.3.1 | Yes
| ||
| get_functions() | array | Returns an associative array of all loaded functions. The keys of this array are the names of the classes containing the functions (which you know as the sections of the API page), and the values are arrays of the names of the functions within those classes. | 3.3.1 | Yes
| ||
| reflect_docs() | string | element, docField |
FormatException | Returns the documentation for an element. There are 4 things that an element might have, and one of these should be passed as the docField argument: type, return, args, description. A valid element is either the name of an ivariable, or a function/proc. For instance, reflect_docs('reflect_docs', 'description') would return what you are reading right now. User defined variables and procs may not have any documentation, in which case null is returned. If the specified argument cannot be found, a FormatException is thrown. If no arguments are passed in, it returns the documentation for reflect_docs, that is, what you're reading right now. | 3.3.1 | Yes
|
| reflect_pull() | mixed | param, [args, ...] | FormatException | Returns information about the runtime in a usable format. Depending on the information returned, it may be useable directly, or it may be more of a referential format. See More... | 3.3.1 | Yes
|
Regex
This class provides regular expression functions. For more details, please see the page on regular expressions. Note that all the functions are just passthroughs to the Java regex mechanism. If you need to set a flag on the regex, where the api calls for a pattern, instead send array('pattern', 'flags') where flags is any of i, m, or s. Alternatively, using the embedded flag system that Java provides is also valid.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| reg_count() | int | pattern, subject | FormatException | Counts the number of occurances in the subject. | 3.2.0 | No
|
| reg_escape() | string | arg | Escapes arg so that it may be used directly in a regular expression, without fear that it will have special meaning; that is, it escapes all special characters. Use this if you need to use user input or similar as a literal search index. | 3.3.1 | No
| |
| reg_match() | array | pattern, subject | FormatException | Searches for the given pattern, and returns an array with the results. Captures are supported. If the pattern is not found anywhere in the subject, an empty array is returned. The indexes of the array follow typical regex fashion; the 0th element is the whole match, and 1-n are the captures specified in the regex. | 3.2.0 | No
|
| reg_match_all() | array | pattern, subject | FormatException | Searches subject for all matches to the regular expression given in pattern, unlike reg_match, which just returns the first match. | 3.2.0 | No
|
| reg_replace() | string | pattern, replacement, subject | FormatException | Replaces any occurances of pattern with the replacement in subject. Back references are allowed. | 3.2.0 | No
|
| reg_split() | array | pattern, subject | FormatException | Splits a string on the given regex, and returns an array of the parts. If nothing matched, an array with one element, namely the original subject, is returned. | 3.2.0 | No
|
Scheduling
This class contains methods for dealing with time and server scheduling.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| clear_task() | void | [id] | CastException |
Stops the interval or timeout that is specified. The id can be gotten by storing the integer returned from either set_timeout or set_interval. An invalid id is simply ignored. The clear_task function is more useful for set_timeout, where you may queue up some task to happen in the far future, yet have some trigger to prevent it from happening. ID is optional, but only if called from within a set_interval or set_timeout closure, in which case it defaults to the id of that particular task. | 3.3.1 | Yes
|
| nano_time() | int | Returns an arbitrary number based on the most accurate clock available on this system. Only useful when compared to other calls to nano_time(). The return is in nano seconds. See the Java API on System.nanoTime() for more information on the usage of this function. | 3.1.0 | No
| ||
| set_interval() | int | timeInMS, [initialDelayInMS,] closure | CastException | Sets a task to run every so often. This works similarly to set_timeout, except the task will automatically re-register itself to run again. Note that the resolution of the time is in ms, however, the server will only have a resolution of up to 50 ms, meaning that a time of 1-50ms is essentially the same as 50ms. The inital delay defaults to the same thing as timeInMS, that is, there will be a pause between registration and initial firing. However, this can be set to 0 (or some other number) to adjust how long of a delay there is before it begins. | 3.3.1 | Yes
|
| set_timeout() | int | timeInMS, closure | CastException | Sets a task to run in the specified number of ms in the future. The task will only run once. Note that the resolution of the time is in ms, however, the server will only have a resolution of up to 50 ms, meaning that a time of 1-50ms is essentially the same as 50ms. | 3.3.1 | Yes
|
| simple_date() | mixed | format, [time, [timezone]] | CastException | Returns a date of the current time (or the time specified) in the format you give. See More... (Examples...) |
3.3.1 | No
|
| time() | int | Returns the current unix time stamp, in milliseconds. The resolution of this is not guaranteed to be extremely accurate. If you need extreme accuracy, use nano_time() | 3.1.0 | No
|
Scoreboards
A class of functions for manipulating the server scoreboard.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| create_objective() | void | name, [criteria, [scoreboard]] | LengthException |
Adds a new objective to the scoreboard, throwing a ScoreboardException if the name is already in use. The vanilla criteria names are DEATHCOUNT, HEALTH, PLAYERKILLCOUNT, TOTALKILLCOUNT, and DUMMY. You can put anything, but if none of the other values match, 'dummy' will be used. Those values which are not 'dummy' are server-managed. Throws a LengthException if the name is more than 16 characters. Scoreboard defaults to 'main' if not given. | 3.3.1 | Yes
|
| create_scoreboard() | void | name | ScoreboardException | Creates a new scoreboard identified by the given name, and stores it internally for later use. Throws an exception if the name is already in use. | 3.3.1 | Yes
|
| create_team() | void | name, [scoreboard] | LengthException |
Adds a new team to the scoreboard, throws a ScoreboardException if a team already exists with the given name. Throws a LengthException if the team name is more than 16 characters. Scoreboard defaults to 'main' if not given. | 3.3.1 | Yes
|
| get_objectives() | array | [scoreboard], [criteria] | ScoreboardException | Returns an array of arrays about the objectives on the given scoreboard, which defaults to 'main' if not given. If criteria is given, only objectives with that criteria will be returned. The arrays contain the keys name, displayname, slot, modifiable, and criteria. | 3.3.1 | Yes
|
| get_pscore() | int | objectiveName, player, [scoreboard] | ScoreboardException | Returns the player's score for the given objective. Works for offline players, so the name must be exact. Scoreboard defaults to 'main' if not given. | 3.3.1 | Yes
|
| get_pscoreboard() | scoreboard | player | PlayerOfflineException |
Returns the id of the scoreboard assigned to a player. If it is not already cached, it will be added using the player's name. Using this method, it should be possible to import scoreboards created by other plugins. | 3.3.1 | Yes
|
| get_scoreboards() | array | Returns an array of the registered scoreboard ID's. The special scoreboard 'main' represents the server's main scoreboard which can be managed by the vanilla /scoreboard command. | 3.3.1 | Yes
| ||
| get_teams() | array | [scoreboard] | ScoreboardException | Returns an array of arrays about the teams on the given scoreboard, which defaults to 'main' if not given. The arrays contain the keys name, displayname, prefix, suffix, size, options, and players. | 3.3.1 | Yes
|
| remove_objective() | void | objectivename, [scoreboard] | ScoreboardException | Unregisters an objective from the scoreboard. Scoreboard defaults to 'main' if not given. | 3.3.1 | Yes
|
| remove_scoreboard() | void | scoreboard, [nullify] | ScoreboardException | Stops tracking the given scoreboard, unless it is 'main', because that never goes away. If nullify is true (defaults to true), all scores, teams, and objectives will be cleared, and all tracked players currently online will be switched to the main scoreboard, essentially removing all references to the board so it can be garbage-collected. | 3.3.1 | Yes
|
| remove_team() | void | teamname, [scoreboard] | ScoreboardException | Unregisters a team from the scoreboard. Scoreboard defaults to 'main' if not given. | 3.3.1 | Yes
|
| reset_all_pscores() | void | player, [scoreboard] | ScoreboardException | Resets all scores for a player tracked by the given scoreboard. This means they will not be show up on any displays. Scoreboard defaults to 'main' if not given. | 3.3.1 | Yes
|
| set_objective_display() | void | objectiveName, array, [scoreboard] objectiveName, displayname, [scoreboard] |
FormatException |
Sets the display name and/or slot of the given objective. If arg 2 is not an array, it is assumed to be the displayname, otherwise arg 2 should be an array with keys 'displayname' and/or 'slot', affecting their respective properties. Null name resets it to the actual name, and null slot removes it from all displays. Slot can be one of: BELOW_NAME, PLAYER_LIST, or SIDEBAR. Displayname can be a max of 32 characters, otherwise it throws a LengthException. Scoreboard defaults to 'main' if not given. | 3.3.1 | Yes
|
| set_pscore() | void | objectiveName, player, int, [scoreboard] | LengthException |
Sets the player's score for the given objective. Works for offline players, so the name must be exact. Alternatively, you can set scores for fake players to create custom displays, but the 16 character name limit still applies. Scoreboard defaults to 'main' if not given. | 3.3.1 | Yes
|
| set_pscoreboard() | void | player, [scoreboard] | PlayerOfflineException |
Sets the scoreboard to be used by a player. The scoreboard argument is the id of a registered scoreboard. Scoreboard defaults to 'main' if not given. | 3.3.1 | Yes
|
| set_team_display() | void | teamName, array, [scoreboard] teamName, displayname, [scoreboard] |
LengthException |
Sets the display name, prefix, and/or suffix of the given team. If arg 2 is not an array, it is assumed to be the displayname, otherwise arg 2 should be an array with keys 'displayname', 'prefix', and/or 'suffix', affecting their respective properties. Null name resets it to the actual name, and null prefix or suffix removes it from all displays. Displayname can be a max of 32 characters, prefix and suffix can only be 16, otherwise a LengthException is thrown. Scoreboard defaults to 'main' if not given. | 3.3.1 | Yes
|
| set_team_options() | void | teamName, array, [scoreboard] | ScoreboardException |
Sets various options about the team from an array, checking for keys 'friendlyfire' and 'friendlyinvisibles'. Scoreboard defaults to 'main' if not given. | 3.3.1 | Yes
|
| team_add_player() | void | teamName, player, [scoreboard] | LengthException |
Adds a player to a team, given the team exists. Offline players can be added, so the name must be exact. Alternatively, this allows you to add fake players, but names can still only be 16 characters. The player will be removed from any other team on the same scoreboard. Scoreboard defaults to 'main' if not given. | 3.3.1 | Yes
|
| team_remove_player() | boolean | teamname, player, [scoreboard] | ScoreboardException | Attempts to remove a player from a team, and returns true if successful, for false if the player was not part of the team.Scoreboard defaults to 'main' if not given. | 3.3.1 | Yes
|
StringHandling
These class provides functions that allow strings to be manipulated
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| cc() | string | args... | The cousin to concat, this function does some magic under the covers to remove the auto-concatenation effect in bare strings. Take the following example: cc(bare string) -> barestring (Examples...) |
3.3.1 | No
| |
| concat() | string | var1, [var2...] | Concatenates any number of arguments together, and returns a string (Examples...) |
3.0.1 | No
| |
| length() | int | str array |
Returns the character length of str, if the value is castable to a string, or the length of the array, if an array is given (Examples...) |
3.1.2 | No
| |
| parse_args() | array | string | Parses string into an array, where string is a space seperated list of arguments. Handy for turning $ into a usable array of items with which to script against. Extra spaces are ignored, so you would never get an empty string as an input. (Examples...) |
3.0.1 | No
| |
| replace() | string | subject, search, replacement | Replaces all instances of 'search' with 'replacement' in 'subject' (Examples...) |
3.0.1 | No
| |
| sconcat() | string | var1, [var2...] | Concatenates any number of arguments together, but puts a space between elements (Examples...) |
3.0.1 | No
| |
| split() | array | split, string | Splits a string into parts, using the split as the index. Though it can be used in every single case you would use reg_split, this does not use regex, and therefore can take a literal split expression instead of needing an escaped regex, and *may* perform better than the regex versions, as it uses an optimized tokenizer split, instead of Java regex. (Examples...) |
3.3.1 | No
| |
| sprintf() | string | formatString, parameters... formatString, array(parameters...) |
FormatException |
Returns a string formatted to the given formatString specification, using the parameters passed in. The formatString should be formatted according to this standard, with the caveat that the parameter types are automatically cast to the appropriate type, if possible. Calendar/time specifiers, (t and T) expect an integer which represents unix time, but are otherwise valid. All format specifiers in the documentation are valid. (Examples...) |
3.3.1 | No
|
| string_from_bytes() | string | byte_array, [encoding] | CastException |
Returns a new string, given the byte array encoding provided. The encoding defaults to UTF-8, but may be specified. A FormatException is thrown if the encoding type is invalid. | 3.3.1 | No
|
| string_get_bytes() | byte_array | string, [encoding] | CastException |
Returns this string as a byte_array, encoded using the specified encoding, or UTF-8 if no encoding is specified. Valid encodings are the encoding types that java supports. If the encoding is invalid, a FormatException is thrown. | 3.3.1 | No
|
| string_position() | int | haystack, needle | NullPointerException | Finds the numeric position of the first occurence of needle in haystack. haystack is the string to search in, and needle is the string to search with. Returns the position of the needle (starting with 0) or -1 if the string is not found at all. (Examples...) |
3.3.1 | No
|
| substr() | string | str, begin, [end] | RangeException |
Returns a substring of the given string str, starting from index begin, to index end, or the end of the string, if no index is given. If either begin or end are out of bounds of the string, an exception is thrown. substr('hamburger', 4, 8) returns "urge", substr('smiles', 1, 5) returns "mile", and substr('lightning', 5) returns "ning". See also length(). (Examples...) |
3.1.2 | No
|
| to_lower() | string | str | Returns an all lower case version of str (Examples...) |
3.1.2 | No
| |
| to_upper() | string | str | Returns an all caps version of str (Examples...) |
3.1.2 | No
| |
| trim() | string | s | Returns the string s with leading and trailing whitespace cut off (Examples...) |
3.0.1 | No
| |
| triml() | string | s | Returns the string s with leading whitespace cut off (Examples...) |
3.3.1 | No
| |
| trimr() | string | s | Returns the string s with trailing whitespace cut off (Examples...) |
3.3.1 | No
|
Weather
Provides functions to control the weather
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| has_storm() | boolean | [world] | InvalidWorldException | Returns whether the world (defaults to player's world) has a storm. | 3.3.1 | No
|
| has_thunder() | boolean | [world] | InvalidWorldException | Returns whether the world (defaults to player's world) has thunder. | 3.3.1 | No
|
| lightning() | int | strikeLocArray, [safe] x, y, z, [safe] |
CastException |
Makes lightning strike at the x y z coordinates specified in the array(x, y, z). Safe defaults to false, but if true, lightning striking a player will not hurt them. Returns the entityID of the lightning bolt. | 3.0.1 | Yes
|
| set_thunder() | void | boolean, [world], [int] | InvalidWorldException |
Sets whether or not the weather can have thunder. The third argument can specify how long the thunder should last. | 3.3.1 | Yes
|
| storm() | void | isStorming, [world], [int] | CastException |
Creates a (rain) storm if isStorming is true, stops a storm if isStorming is false. The third argument allows setting how long this weather setting will last. | 3.0.1 | Yes
|
Web
Contains various methods to make HTTP requests.
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| http_clear_session_cookies() | void | cookieJar | CastException | Clears out "session" cookies, that is cookies that weren't set with an expiration (which translates to 0 in an individual cookie). | 3.3.1 | No
|
| http_request() | void | url, callback url, settings |
FormatException | Makes an HTTP request to the given url. See More... (Examples...) |
3.3.1 | Yes
|
World
Provides functions for manipulating a world
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| create_world() | void | name, [type, environment, seed,] [generator] | FormatException |
Creates a new world with the specified options. If the world already exists, it will be loaded from disk, and the last 3 arguments may be ignored. name is the name of the world, type is one of NORMAL, FLAT, VERSION_1_1, LARGE_BIOMES, environment is one of NORMAL, NETHER, THE_END, and seed is an integer. Generator is the name of a world generator loaded on the server. | 3.3.1 | Yes
|
| get_chunk_loc() | array | [location array] | FormatException |
Returns an array of x, z, world coords of the chunk of either the location specified or the location of the player running the command. | 3.3.1 | No
|
| get_spawn() | array | [world] | InvalidWorldException |
Returns a location array for the specified world, or the current player's world, if not specified. | 3.3.0 | Yes
|
| get_world_time() | int | [world] | InvalidWorldException | Returns the time of the specified world, as an integer from 0 to 24000-1 | 3.3.0 | Yes
|
| get_worlds() | array | Returns a list of all currently loaded worlds. | 3.3.1 | Yes
| ||
| refresh_chunk() | void | [world], x, z [world], locationArray |
CastException |
Resends the chunk data to all clients, using the specified world, or the current players world if not provided. | 3.3.0 | Yes
|
| regen_chunk() | void | x, z, [world] locationArray, [world] |
CastException |
Regenerate the chunk, using the specified world, or the current players world if not provided. Beware that this is destructive! Any data in this chunk will be lost! | 3.3.1 | Yes
|
| set_spawn() | void | locationArray [world], x, y, z |
InvalidWorldException |
Sets the spawn of the world. Note that in some cases, a plugin may set the spawn differently, and this method will do nothing. In that case, you should use the plugin's commands to set the spawn. | 3.3.1 | Yes
|
| set_world_time() | void | [world], time | InvalidWorldException |
Sets the time of a given world. Should be a number from 0 to 24000, if not, it is modulo scaled. See More... | 3.3.0 | Yes
|
| spawn_falling_block() | integer | location array, id[:type], [vector array ie. array(x, y, z)] | FormatException | Spawns a falling block of the specified id and type at the specified location, applying vector array as a velocity if given. Values for the vector array are doubles, and 1.0 seems to imply about 3 times walking speed. Gravity applies for y. | 3.3.1 | Yes
|
| world_info() | array | world | InvalidWorldException | Returns an associative array of all the info needed to duplicate the world. The keys are name, seed, environment, generator, and worldtype. | 3.3.1 | Yes
|
WorldEdit
Provides various methods for programmatically hooking into WorldEdit and WorldGuard
| Function Name | Returns | Arguments | Throws | Description | Since | Restricted |
|---|---|---|---|---|---|---|
| sk_all_regions() | array | [world] | Returns all the regions in all worlds, or just the one world, if specified. | 3.2.0 | Yes
| |
| sk_can_build() | boolean | [player,] locationArray | InvalidPluginException PlayerOfflineException |
Returns whether or not player can build at the location, according to WorldGuard. If player is not given, the current player is used. | 3.2.0 | Yes
|
| sk_current_regions() | mixed | [player] | PlayerOfflineException |
Returns the list regions that player is in. If no player specified, then the current player is used. If region is found, an array of region names are returned, else an empty is returned | 3.2.0 | Yes
|
| sk_pos1() | mixed | [player], locationArray [player] |
PlayerOfflineException |
Sets the player's point 1, or returns it if the array to set isn't specified. If the location is returned, it is returned as a 4 index array:(x, y, z, world) | 3.2.0 | Yes
|
| sk_pos2() | mixed | [player], array [player] |
PlayerOfflineException |
Sets the player's point 2, or returns it if the array to set isn't specified | 3.2.0 | Yes
|
| sk_region_addmember() | void | region, [world], [member1] region, [world], [array(member1, memberN, ...)] |
InvalidWorldException |
Add member(s) to given region. | 3.3.1 | Yes
|
| sk_region_addowner() | void | region, [world], [owner1] region, [world], [array(owner1, ownerN, ...)] |
InvalidWorldException |
Add owner(s) to given region. | 3.3.1 | Yes
|
| sk_region_create() | void | [world], name, array(locationArrayPos1, locationArrayPos2, [[locationArrayPosN]...]) | InvalidWorldException |
Create region of the given name in the given world. | 3.3.1 | Yes
|
| sk_region_exists() | void | [world], name | InvalidWorldException | Check if a given region exists. | 3.3.1 | Yes
|
| sk_region_flag() | void | world, region, flagName, flagValue, [group] | InvalidWorldException |
Add/change/remove flag for selected region. FlagName should be any supported flag from this list. For the flagValue, use types which are supported by WorldGuard. Add group argument if you want to add WorldGuard group flag (read more about group flag types here). Set flagValue as null (and don't set group) to delete the flag from the region. | 3.3.1 | Yes
|
| sk_region_info() | array | region, world | PluginInternalException | Given a region name, returns an array of information about that region. See More... | 3.2.0 | Yes
|
| sk_region_intersect() | array | world, region1, [array(region2, [regionN...])] | PluginInternalException | Returns an array of regions names which intersect with defined region. You can pass an array of regions to verify or omit this parameter and all regions in selected world will be checked. | 3.2.0 | Yes
|
| sk_region_overlaps() | boolean | world, region1, array(region2, [regionN...]) | PluginInternalException | Returns true or false whether or not the specified regions overlap. | 3.2.0 | Yes
|
| sk_region_remmember() | void | region, [world], [member1] region, [world], [array(member1, memberN, ...)] |
InvalidWorldException |
Remove member(s) from given region. | 3.3.1 | Yes
|
| sk_region_remove() | void | [world], name | InvalidWorldException |
Remove existed region. | 3.3.1 | Yes
|
| sk_region_remowner() | void | region, [world], [owner1] region, [world], [array(owner1, ownerN, ...)] |
InvalidWorldException |
Remove owner(s) from given region. | 3.3.1 | Yes
|
| sk_region_setparent() | void | world, region, [parentRegion] | InvalidWorldException |
Sets parent region for a given region. | 3.3.1 | Yes
|
| sk_region_setpriority() | void | [world], region, priority | InvalidWorldException |
Sets priority for a given region. | 3.3.1 | Yes
|
| sk_region_update() | void | [world], name, array(locationArrayPos1, locationArrayPos2, [[locationArrayPosN]...]) | InvalidWorldException |
Updates the location of a given region to the new location. Other properties of the region, like owners, members, priority, etc are unaffected. | 3.3.1 | Yes
|
| sk_region_volume() | int | region, world | PluginInternalException | Returns the volume of the given region in the given world. | 3.2.0 | Yes
|
| sk_regions_at() | mixed | Locationarray | CastException |
Returns a list of regions at the specified location. If regions are found, an array of region names are returned, otherwise, an empty array is returned. | 3.2.0 | Yes
|
Errors in documentation
Please note that this documentation is generated automatically, if you notice an error in the documentation, please file a bug report for the plugin itself! For information on undocumented functions, see this page
| |||||||||||||||||||||||