CommandAPI 9.7.0
An API for the command UI introduced in Minecraft 1.13
dev.jorel.commandapi.wrappers.MathOperation Enum Reference

A representation of the math operations for the Minecraft scoreboard. More...

Public Member Functions

 MathOperation (String stringValue, BinaryOperator< Float > application)
 Construct a MathOperation with its respective Minecraft string value. More...
 
String toString ()
 Returns the Minecraft string value of this MathOperation. More...
 
int apply (int val1, int val2)
 Applies the current MathOperation to two ints. More...
 
float apply (float val1, float val2)
 Applies the current MathOperation to two floats. More...
 

Static Public Member Functions

static MathOperation fromString (String input)
 Creates a MathOperation from the Minecraft string representation (e.g. More...
 

Public Attributes

 ADD =("+=", (val1, val2) -> val1 + val2)
 Addition of two values (+=)
 
 ASSIGN =("=", (val1, val2) -> val2)
 Assignment of a value (=)
 
 DIVIDE =("/=", (val1, val2) -> val1 / val2)
 Division of a value by another value (/=)
 
 MAX =(">", Math::max)
 The maximum value of two values (>)
 
 MIN =("<", Math::min)
 The minimum value of two values (<)
 
 MOD =("%=", (val1, val2) -> val1 % val2)
 Modulo of a value by another value (%=)
 
 MULTIPLY =("*=", (val1, val2) -> val1 * val2)
 Multiplication of a value by another value (*=)
 
 SUBTRACT =("-=", (val1, val2) -> val1 - val2)
 Subtraction of a value by another value (-=)
 
 SWAP =("><", (val1, val2) -> val2)
 Swap the results of two values (><)
 

Detailed Description

A representation of the math operations for the Minecraft scoreboard.

Constructor & Destructor Documentation

◆ MathOperation()

dev.jorel.commandapi.wrappers.MathOperation.MathOperation ( String  stringValue,
BinaryOperator< Float >  application 
)

Construct a MathOperation with its respective Minecraft string value.

Parameters
stringValue

Member Function Documentation

◆ apply() [1/2]

float dev.jorel.commandapi.wrappers.MathOperation.apply ( float  val1,
float  val2 
)

Applies the current MathOperation to two floats.

Parameters
val1the base float to operate on
val2the new value to operate with
Returns
a float that is the result of applying this math operation

◆ apply() [2/2]

int dev.jorel.commandapi.wrappers.MathOperation.apply ( int  val1,
int  val2 
)

Applies the current MathOperation to two ints.

Parameters
val1the base int to operate on
val2the new value to operate with
Returns
a int that is the result of applying this math operation

◆ fromString()

static MathOperation dev.jorel.commandapi.wrappers.MathOperation.fromString ( String  input)
static

Creates a MathOperation from the Minecraft string representation (e.g.

"=" or "/=")

Parameters
inputthe string to convert to
Returns
a MathOperation instance which represents the provided string
Exceptions
IllegalArgumentExceptionif the input is not a valid MathOperation

◆ toString()

String dev.jorel.commandapi.wrappers.MathOperation.toString ( )

Returns the Minecraft string value of this MathOperation.

Returns
the Minecraft string value of this MathOperation