Class EventValues

java.lang.Object
ua.mcchickenstudio.opencreative.coding.values.EventValues

public final class EventValues extends Object

EventValues

This class represents registry of event values, that can register new event values for coding.

To get instance use getInstance(). To add custom event value create a class, that extends one of prepared: TextEventValue, NumberEventValue, VectorEventValue, LocationEventValue, ItemEventValue, BooleanEventValue, and register it with registerEventValue(EventValue) method.

  • Constructor Details

    • EventValues

      public EventValues()
  • Method Details

    • getInstance

      @NotNull public static @NotNull EventValues getInstance()
      Returns instance of event values controller class.
      Returns:
      instance of event values.
    • registerEventValue

      public void registerEventValue(@NotNull @NotNull EventValue value)
      Registers event value, that will be replaced in coding.
      Parameters:
      value - event value to register.
    • registerEventValue

      public void registerEventValue(@NotNull @NotNull EventValue... values)
      Registers event values, that will be replaced in coding.
      Parameters:
      values - event values to register.
    • unregisterEventValue

      public void unregisterEventValue(@NotNull @NotNull EventValue value)
      Unregisters event value if list contains it.
      Parameters:
      value - event value to unregister.
    • getEventValues

      @NotNull public @NotNull List<EventValue> getEventValues()
      Returns a copy of list that contains all registered event values.
      Returns:
      event values list.
    • getByCategories

      @NotNull public @NotNull List<EventValue> getByCategories(@NotNull @NotNull MenusCategory menusCategory)
      Returns list of event values, that have same menu category.
      Parameters:
      menusCategory - menu category.
      Returns:
      list of event values with specified menu category.
    • getCategories

      @NotNull public @NotNull List<MenusCategory> getCategories()
      Returns list of all menu categories of all event values.
      Returns:
      list of menu categories.
    • exists

      public boolean exists(@NotNull @NotNull String id)
      Checks if event value with specified ID exists in registry.
      Parameters:
      id - id of event value.
      Returns:
      true - exists, false - not exists.
    • exists

      public boolean exists(@NotNull @NotNull Class<? extends EventValue> clazz)
      Checks if event value with specified class exists in registry.
      Parameters:
      clazz - class of event value.
      Returns:
      true - exists, false - not exists.
    • getByClass

      @Nullable public @Nullable EventValue getByClass(@NotNull @NotNull Class<? extends EventValue> clazz)
      Returns event value from registry by specified class if it exists, otherwise will return null.
      Parameters:
      clazz - class to get event value.
      Returns:
      event value - if exists, or null - not exists.
    • getById

      @Nullable public @Nullable EventValue getById(@NotNull @NotNull String id)
      Returns event value from registry by specified id if it exists, otherwise will return null.
      Parameters:
      id - id to get event value.
      Returns:
      event value - if exists, or null - not exists.
    • getValue

      @Nullable public @Nullable Object getValue(@NotNull @NotNull String id, @NotNull @NotNull ActionsHandler handler, @NotNull @NotNull Action action, @Nullable @Nullable org.bukkit.entity.Entity entity)
      Returns replaced value of event value if it exists, otherwise it will return null.

      Replaced value can also be null by some conditions.

      Parameters:
      id - id of event value.
      handler - handler of action.
      action - action, where it executes.
      entity - entity, or null.
      Returns:
      value of event value, or null.
    • getValue

      @Nullable public @Nullable Object getValue(@NotNull @NotNull Class<? extends EventValue> clazz, @NotNull @NotNull ActionsHandler handler, @NotNull @NotNull Action action, @NotNull @NotNull org.bukkit.entity.Entity entity)
      Returns replaced value of event value if it exists, otherwise it will return null.

      Replaced value can also be null by some conditions.

      Parameters:
      clazz - class of event value.
      handler - handler of action.
      action - action, where it executes.
      entity - entity, or null.
      Returns:
      value of event value, or null.