Skip to content

Docs꞉ Parameter

Arie edited this page Dec 6, 2023 · 37 revisions

A - Getting started with Parameters
B - Parameters & Overloads
⠀⠀1. Input types
⠀⠀2. List of Parameters
⠀⠀3. Overloads
C - Parameter priority [Important]
D - How to add parameter to your commands
⠀⠀- Meow

A - Getting started with Parameters

In PocketMine-MP, CommandParameter represents a single parameter of the command overload; it accepts a certain type of input value. It has a name and type that has auto-complete and displays client-side when the player enters commands.

With Ovommand, parameters are divided into separate classes that integrate support features and parse the received command results into data automatically.
Eg:

/difficulty <difficulty: string> [test: bool]
/difficulty <difficulty: int>

where /difficulty is the command name with the slash, difficulty is the name of the parameter and (int or string) is the type of that parameter.

The above commands can be recreated using the following codes:

class TestCMD extends BaseCommand{
	public function prepare() : void{
		$this->registerParameters(0,
			new EnumParameter("difficulty", ),
		);
		$this->registerParameters(1,
			new EnumParameter("difficulty", ),
		);
	}
}
//TODO: UPDATE LATER
//NOTE: FAILED EXAMPLE

B - Parameters & Overloads:

1. Input types

Type Description Supported
int A 32-bit integer, (1, 2, 3, -1, 21). true
float Must be a floating point number. (1, 2.3, 4, 5.6) true
x y z 3 floats separated by spaces to specify coordinates.
Each value can also have a tilde (~), which indicates no change from the execution origin on that axis, or a tilde followed by a number (~5) to indicate the number of blocks away from the execution origin on that axis.
true
string Either a single word or text within "quotation marks". true
message Text that does not need to be in quotation marks. true
json JSON-formatted text. false
target Either a player name or a target selector. true
enum Enum registered by EnumManager or Default Vanilla Enums. true

Note: x y z once have caret (^), the rest have to be caret otherwise a BrokenSyntaxResult would be returned! table sucks with long descriptions

2. List of Parameters

Name Type Return
IntParameter int ValueResult or BrokenSyntaxResult if failed
FloatParameter float ValueResult or BrokenSyntaxResult if failed
StringParameter string ValueResult or BrokenSyntaxResult if failed
TextParameter message ValueResult or BrokenSyntaxResult if failed
EnumParameter enum ValueResult or BrokenSyntaxResult if failed
BooleanParameter enum ValueResult or BrokenSyntaxResult if failed
PositionParameter x y z CoordinateResult or BrokenSyntaxResult if failed
BlockPositionParameter x y z CoordinateResult or BrokenSyntaxResult if failed
TargetParameter target TargetResult or BrokenSyntaxResult if failed

3. Overloads

C - Parameter priority

Some parameters have higher priority than others with the auto-complete & hint. This is mostly a bug that mojang don't bother to fix. Have fun and suffer C:

you can make a bug report and hope for the best...

Eg:
Target has higher priority than a lot of parameters
String has higher priority than some
Position has equal priority to String

Soft enums will break the auto-hint!

In short, those parameters require data-type input such as int, string, etc... most likely to have higher priority than those which have hardcoded value

TODO: Make a list for this issue

D - How to add parameter to your commands

Read Docs꞉ Getting Started with Ovommand before continuing with these following steps.


ovo_warning
This wiki is under construction....