Class Arguments

java.lang.Object
ua.mcchickenstudio.opencreative.coding.arguments.Arguments

public class Arguments extends Object

Arguments

This class represents an arguments holder, that stores arguments for actions and conditions.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Arguments(@NotNull Planet planet)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull List<Argument>
    Returns list of stored arguments.
    @NotNull org.bukkit.Material
    getBlockMaterial(@NotNull String path, @NotNull org.bukkit.Material defaultValue, @NotNull Action action)
    Returns block material value stored in arguments.
    boolean
    getBoolean(@NotNull String path, boolean defaultValue, @NotNull Action action)
    Returns boolean value stored in arguments.
    final @NotNull List<Boolean>
    getBooleanList(@NotNull String path, @NotNull Action action)
    Returns list with booleans stored in arguments.
    char
    getCharacter(@NotNull String path, char defaultValue, @NotNull Action action)
    Returns character value stored in arguments.
    @NotNull org.bukkit.Color
    getColor(@NotNull String path, org.bukkit.Color defaultValue, @NotNull Action action)
    Returns color value stored in arguments.
    @NotNull net.kyori.adventure.text.Component
    getComponent(@NotNull String path, @NotNull net.kyori.adventure.text.Component defaultValue, @NotNull Action action)
    Returns component value stored in arguments.
    final @NotNull List<net.kyori.adventure.text.Component>
    getComponentList(@NotNull String path, @NotNull Action action)
    Returns list with components stored in arguments.
    double
    getDouble(@NotNull String path, double defaultValue, @NotNull Action action)
    Returns double value stored in arguments.
    @NotNull org.bukkit.entity.EntityType
    getEntityType(@NotNull String path, @NotNull org.bukkit.entity.EntityType defaultValue, @NotNull Action action)
    Returns entity type stored in arguments.
    float
    getFloat(@NotNull String path, float defaultValue, @NotNull Action action)
    Returns float value stored in arguments.
    int
    getInt(@NotNull String path, int defaultValue, @NotNull Action action)
    Returns integer number value stored in arguments.
    @NotNull org.bukkit.inventory.ItemStack
    getItem(@NotNull String path, @NotNull org.bukkit.inventory.ItemStack defaultValue, @NotNull Action action)
    Returns item value stored in arguments.
    final @NotNull List<org.bukkit.inventory.ItemStack>
    getItemList(@NotNull String path, @NotNull Action action)
    Returns list with items stored in arguments.
    final <T> List<T>
    getList(@NotNull String path, @NotNull Action action)
    Returns list with values stored in arguments.
    @NotNull org.bukkit.Location
    getLocation(@NotNull String path, @NotNull org.bukkit.Location defaultValue, @NotNull Action action)
    Returns location value stored in arguments.
    final @NotNull List<org.bukkit.Location>
    getLocationList(@NotNull String path, @NotNull Action action)
    Returns list with locations stored in arguments.
    long
    getLong(@NotNull String path, long defaultValue, @NotNull Action action)
    Returns long number value stored in arguments.
    final @NotNull Map<Object,Object>
    getMap(@NotNull String path, @NotNull Action action)
    Returns map of values stored in arguments.
    @NotNull org.bukkit.Material
    getMaterial(@NotNull String path, @NotNull org.bukkit.Material defaultValue, @NotNull Action action)
    Returns material value stored in arguments.
    final @NotNull List<Double>
    getNumbersList(@NotNull String path, @NotNull Action action)
    Returns list with double numbers stored in arguments.
    @NotNull org.bukkit.Particle
    getParticle(@NotNull String path, @NotNull org.bukkit.Particle defaultValue, @NotNull Action action)
    Returns particle value stored in arguments.
    @NotNull String
    getText(@NotNull String path, @NotNull String defaultValue, @NotNull Action action)
    Returns text value stored in arguments.
    final @NotNull List<String>
    getTextList(@NotNull String path, @NotNull Action action)
    Returns list with texts stored in arguments.
    @NotNull Object
    getValue(String path, Action action)
    Returns value stored in arguments.
    @Nullable VariableLink
    getVariableLink(@NotNull String path, @NotNull Action action)
    Returns variable link stored in arguments.
    final @NotNull List<VariableLink>
    getVarLinksList(@NotNull String path, @NotNull Action action)
    Returns list with variable links stored in arguments.
    @NotNull org.bukkit.util.Vector
    getVector(String path, org.bukkit.util.Vector defaultValue, Action action)
    Returns vector value stored in arguments.
    final void
    load(@NotNull org.bukkit.configuration.ConfigurationSection section)
    Loads arguments from action's arguments section.
    boolean
    parseObject(Object object, boolean defaultValue)
    Parses object into boolean number and returns it, or default value.
    double
    parseObject(Object object, double defaultValue)
    Parses object into double number and returns it, or default value.
    float
    parseObject(Object object, float defaultValue)
    Parses object into float number and returns it, or default value.
    int
    parseObject(Object object, int defaultValue)
    Parses object into integer number and returns it, or default value.
    long
    parseObject(Object object, long defaultValue)
    Parses object into long number and returns it, or default value.
    final boolean
    pathExists(@NotNull String path)
    Checks whether argument exists.
    void
    removeArgumentValue(@NotNull String... paths)
    Removes stored argument.
    void
    setArgumentValue(@NotNull String path, @NotNull ValueType type, @NotNull Object value)
    Sets argument value by key.
    net.kyori.adventure.text.Component
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Arguments

      public Arguments(@NotNull @NotNull Planet planet)
  • Method Details

    • load

      public final void load(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection section)
      Loads arguments from action's arguments section.
      Parameters:
      section - arguments section of action.
    • pathExists

      public final boolean pathExists(@NotNull @NotNull String path)
      Checks whether argument exists.
      Parameters:
      path - key of argument.
      Returns:
      true - exists, false - not.
    • getMap

      @NotNull public final @NotNull Map<Object,Object> getMap(@NotNull @NotNull String path, @NotNull @NotNull Action action)
      Returns map of values stored in arguments.
      Parameters:
      path - key of argument.
      action - action, that will be used for parsing variables.
      Returns:
      map of values, or empty map - if not found.
    • getList

      public final <T> List<T> getList(@NotNull @NotNull String path, @NotNull @NotNull Action action)
      Returns list with values stored in arguments.
      Type Parameters:
      T - class of required values.
      Parameters:
      path - key of argument.
      action - action, that will be used for parsing variables.
      Returns:
      list with values, or empty list - if not found.
    • getVarLinksList

      @NotNull public final @NotNull List<VariableLink> getVarLinksList(@NotNull @NotNull String path, @NotNull @NotNull Action action)
      Returns list with variable links stored in arguments.
      Parameters:
      path - key of argument.
      action - action, that will be used for parsing variables.
      Returns:
      list with variable links, or empty list - if not found.
    • getBooleanList

      @NotNull public final @NotNull List<Boolean> getBooleanList(@NotNull @NotNull String path, @NotNull @NotNull Action action)
      Returns list with booleans stored in arguments.
      Parameters:
      path - key of argument.
      action - action, that will be used for parsing variables.
      Returns:
      list with booleans, or empty list - if not found.
    • getTextList

      @NotNull public final @NotNull List<String> getTextList(@NotNull @NotNull String path, @NotNull @NotNull Action action)
      Returns list with texts stored in arguments.
      Parameters:
      path - key of argument.
      action - action, that will be used for parsing variables.
      Returns:
      list with texts, or empty list - if not found.
    • getComponentList

      @NotNull public final @NotNull List<net.kyori.adventure.text.Component> getComponentList(@NotNull @NotNull String path, @NotNull @NotNull Action action)
      Returns list with components stored in arguments.
      Parameters:
      path - key of argument.
      action - action, that will be used for parsing variables.
      Returns:
      list with components, or empty list - if not found.
    • getNumbersList

      @NotNull public final @NotNull List<Double> getNumbersList(@NotNull @NotNull String path, @NotNull @NotNull Action action)
      Returns list with double numbers stored in arguments.
      Parameters:
      path - key of argument.
      action - action, that will be used for parsing variables.
      Returns:
      list with doubles, or empty list - if not found.
    • getItemList

      @NotNull public final @NotNull List<org.bukkit.inventory.ItemStack> getItemList(@NotNull @NotNull String path, @NotNull @NotNull Action action)
      Returns list with items stored in arguments.
      Parameters:
      path - key of argument.
      action - action, that will be used for parsing variables.
      Returns:
      list with items, or empty list - if not found.
    • getLocationList

      @NotNull public final @NotNull List<org.bukkit.Location> getLocationList(@NotNull @NotNull String path, @NotNull @NotNull Action action)
      Returns list with locations stored in arguments.
      Parameters:
      path - key of argument.
      action - action, that will be used for parsing variables.
      Returns:
      list with locations, or empty list - if not found.
    • getVariableLink

      @Nullable public @Nullable VariableLink getVariableLink(@NotNull @NotNull String path, @NotNull @NotNull Action action)
      Returns variable link stored in arguments.
      Parameters:
      path - key of argument, that stores boolean value.
      action - action, that asks for variable link.
      Returns:
      variable link, or null - if not found.
    • getMaterial

      @NotNull public @NotNull org.bukkit.Material getMaterial(@NotNull @NotNull String path, @NotNull @NotNull org.bukkit.Material defaultValue, @NotNull @NotNull Action action)
      Returns material value stored in arguments.
      Parameters:
      path - key of argument, that stores material value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getBlockMaterial

      @NotNull public @NotNull org.bukkit.Material getBlockMaterial(@NotNull @NotNull String path, @NotNull @NotNull org.bukkit.Material defaultValue, @NotNull @NotNull Action action)
      Returns block material value stored in arguments.
      Parameters:
      path - key of argument, that stores block material value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getItem

      @NotNull public @NotNull org.bukkit.inventory.ItemStack getItem(@NotNull @NotNull String path, @NotNull @NotNull org.bukkit.inventory.ItemStack defaultValue, @NotNull @NotNull Action action)
      Returns item value stored in arguments.
      Parameters:
      path - key of argument, that stores item value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getBoolean

      public boolean getBoolean(@NotNull @NotNull String path, boolean defaultValue, @NotNull @NotNull Action action)
      Returns boolean value stored in arguments.
      Parameters:
      path - key of argument, that stores boolean value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getValue

      @NotNull public @NotNull Object getValue(String path, Action action)
      Returns value stored in arguments.
      Parameters:
      path - key of argument, that stores long number value.
      action - action, that asks for value.
      Returns:
      argument value, or empty text "" - if not found.
    • getInt

      public int getInt(@NotNull @NotNull String path, int defaultValue, @NotNull @NotNull Action action)
      Returns integer number value stored in arguments.
      Parameters:
      path - key of argument, that stores integer number value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getLong

      public long getLong(@NotNull @NotNull String path, long defaultValue, @NotNull @NotNull Action action)
      Returns long number value stored in arguments.
      Parameters:
      path - key of argument, that stores long number value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getColor

      @NotNull public @NotNull org.bukkit.Color getColor(@NotNull @NotNull String path, org.bukkit.Color defaultValue, @NotNull @NotNull Action action)
      Returns color value stored in arguments.
      Parameters:
      path - key of argument, that stores color value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getFloat

      public float getFloat(@NotNull @NotNull String path, float defaultValue, @NotNull @NotNull Action action)
      Returns float value stored in arguments.
      Parameters:
      path - key of argument, that stores float value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getDouble

      public double getDouble(@NotNull @NotNull String path, double defaultValue, @NotNull @NotNull Action action)
      Returns double value stored in arguments.
      Parameters:
      path - key of argument, that stores double value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getText

      @NotNull public @NotNull String getText(@NotNull @NotNull String path, @NotNull @NotNull String defaultValue, @NotNull @NotNull Action action)
      Returns text value stored in arguments.
      Parameters:
      path - key of argument, that stores text value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getEntityType

      @NotNull public @NotNull org.bukkit.entity.EntityType getEntityType(@NotNull @NotNull String path, @NotNull @NotNull org.bukkit.entity.EntityType defaultValue, @NotNull @NotNull Action action)
      Returns entity type stored in arguments.
      Parameters:
      path - key of argument, that stores entity type value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getComponent

      @NotNull public @NotNull net.kyori.adventure.text.Component getComponent(@NotNull @NotNull String path, @NotNull @NotNull net.kyori.adventure.text.Component defaultValue, @NotNull @NotNull Action action)
      Returns component value stored in arguments.
      Parameters:
      path - key of argument, that stores component value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • textToComponent

      public net.kyori.adventure.text.Component textToComponent(String text)
    • getParticle

      @NotNull public @NotNull org.bukkit.Particle getParticle(@NotNull @NotNull String path, @NotNull @NotNull org.bukkit.Particle defaultValue, @NotNull @NotNull Action action)
      Returns particle value stored in arguments.
      Parameters:
      path - key of argument, that stores particle value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getCharacter

      public char getCharacter(@NotNull @NotNull String path, char defaultValue, @NotNull @NotNull Action action)
      Returns character value stored in arguments.
      Parameters:
      path - key of argument, that stores character value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getLocation

      @NotNull public @NotNull org.bukkit.Location getLocation(@NotNull @NotNull String path, @NotNull @NotNull org.bukkit.Location defaultValue, @NotNull @NotNull Action action)
      Returns location value stored in arguments.
      Parameters:
      path - key of argument, that stores location value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • getVector

      @NotNull public @NotNull org.bukkit.util.Vector getVector(String path, org.bukkit.util.Vector defaultValue, Action action)
      Returns vector value stored in arguments.
      Parameters:
      path - key of argument, that stores vector value.
      defaultValue - default value.
      action - action, that asks for value.
      Returns:
      argument value, or default value - if argument is empty or not found.
    • parseObject

      public int parseObject(Object object, int defaultValue)
      Parses object into integer number and returns it, or default value.
      Parameters:
      object - object to parse.
      defaultValue - default value.
      Returns:
      parsed integer number from object, or default value.
    • parseObject

      public long parseObject(Object object, long defaultValue)
      Parses object into long number and returns it, or default value.
      Parameters:
      object - object to parse.
      defaultValue - default value.
      Returns:
      parsed long number from object, or default value.
    • parseObject

      public boolean parseObject(Object object, boolean defaultValue)
      Parses object into boolean number and returns it, or default value.
      Parameters:
      object - object to parse.
      defaultValue - default value.
      Returns:
      parsed boolean number from object, or default value.
    • parseObject

      public float parseObject(Object object, float defaultValue)
      Parses object into float number and returns it, or default value.
      Parameters:
      object - object to parse.
      defaultValue - default value.
      Returns:
      parsed float number from object, or default value.
    • parseObject

      public double parseObject(Object object, double defaultValue)
      Parses object into double number and returns it, or default value.
      Parameters:
      object - object to parse.
      defaultValue - default value.
      Returns:
      parsed double number from object, or default value.
    • setArgumentValue

      public void setArgumentValue(@NotNull @NotNull String path, @NotNull @NotNull ValueType type, @NotNull @NotNull Object value)
      Sets argument value by key.
      Parameters:
      path - key of argument.
      type - type of value.
      value - new value.
    • removeArgumentValue

      public void removeArgumentValue(@NotNull @NotNull String... paths)
      Removes stored argument.
      Parameters:
      paths - keys of arguments.
    • getArgumentList

      @NotNull public @NotNull List<Argument> getArgumentList()
      Returns list of stored arguments.
      Returns:
      list of arguments.