Enum Class MathOperation

java.lang.Object
java.lang.Enum<MathOperation>
dev.jorel.commandapi.wrappers.MathOperation
All Implemented Interfaces:
Serializable, Comparable<MathOperation>, Constable

public enum MathOperation extends Enum<MathOperation>
A representation of the math operations for the Minecraft scoreboard
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Addition of two values (+=)
    Assignment of a value (=)
    Division of a value by another value (/=)
    The maximum value of two values (>)
    The minimum value of two values (<)
    Modulo of a value by another value (%=)
    Multiplication of a value by another value (*=)
    Subtraction of a value by another value (-=)
    Swap the results of two values (><)
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    apply(float val1, float val2)
    Applies the current MathOperation to two floats
    int
    apply(int val1, int val2)
    Applies the current MathOperation to two ints
    Creates a MathOperation from the Minecraft string representation (e.g.
    Returns the Minecraft string value of this MathOperation
    Returns the enum constant of this class with the specified name.
    static MathOperation[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • ADD

      public static final MathOperation ADD
      Addition of two values (+=)
    • ASSIGN

      public static final MathOperation ASSIGN
      Assignment of a value (=)
    • DIVIDE

      public static final MathOperation DIVIDE
      Division of a value by another value (/=)
    • MAX

      public static final MathOperation MAX
      The maximum value of two values (>)
    • MIN

      public static final MathOperation MIN
      The minimum value of two values (<)
    • MOD

      public static final MathOperation MOD
      Modulo of a value by another value (%=)
    • MULTIPLY

      public static final MathOperation MULTIPLY
      Multiplication of a value by another value (*=)
    • SUBTRACT

      public static final MathOperation SUBTRACT
      Subtraction of a value by another value (-=)
    • SWAP

      public static final MathOperation SWAP
      Swap the results of two values (><)
  • Method Details

    • values

      public static MathOperation[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static MathOperation valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • toString

      public String toString()
      Returns the Minecraft string value of this MathOperation
      Overrides:
      toString in class Enum<MathOperation>
      Returns:
      the Minecraft string value of this MathOperation
    • fromString

      public static MathOperation fromString(String input)
      Creates a MathOperation from the Minecraft string representation (e.g. "=" or "/=")
      Parameters:
      input - the string to convert to
      Returns:
      a MathOperation instance which represents the provided string
      Throws:
      IllegalArgumentException - if the input is not a valid MathOperation
    • apply

      public int apply(int val1, int val2)
      Applies the current MathOperation to two ints
      Parameters:
      val1 - the base int to operate on
      val2 - the new value to operate with
      Returns:
      a int that is the result of applying this math operation
    • apply

      public float apply(float val1, float val2)
      Applies the current MathOperation to two floats
      Parameters:
      val1 - the base float to operate on
      val2 - the new value to operate with
      Returns:
      a float that is the result of applying this math operation