Class EventValue

java.lang.Object
ua.mcchickenstudio.opencreative.coding.values.EventValue
All Implemented Interfaces:
ExtensionContent
Direct Known Subclasses:
BooleanEventValue, ItemEventValue, ListEventValue, LocationEventValue, NumberEventValue, TextEventValue, TransferKeyValue, VectorEventValue

public abstract class EventValue extends Object implements ExtensionContent

EventValue

This class represents a value, that can be got from event, actions handler, action and target.

To create custom event value create a class, that extends one of prepared: TextEventValue, NumberEventValue, VectorEventValue, LocationEventValue, ItemEventValue, BooleanEventValue and register with EventValues.registerEventValue(EventValue).

  • Constructor Details

    • EventValue

      public EventValue(@NotNull @NotNull String id, @NotNull @NotNull org.bukkit.inventory.ItemStack displayIcon, @NotNull @NotNull MenusCategory category)
      Constructor of event value.
      Parameters:
      id - short id of event value that will be used in signs and translations.

      It must be lower-snake-cased, for example: "nickname", "entity_health". If some of registered event values has same ID as new, it will be not added.

      displayIcon - icon of event value that will be displayed in event values list.
      category - category of event value for event values list.
  • Method Details

    • getDisplayIcon

      @NotNull public @NotNull org.bukkit.inventory.ItemStack getDisplayIcon()
      Returns an icon that will be used in event values menus.
      Returns:
      icon of event value to display.
    • getCategory

      @NotNull public @NotNull MenusCategory getCategory()
      Returns a category, that event value belongs to.
      Returns:
      category where event value will be able.
    • getValue

      @Nullable public abstract @Nullable Object getValue(@NotNull @NotNull ActionsHandler handler, @NotNull @NotNull Action action, @Nullable @Nullable org.bukkit.entity.Entity entity)
      Returns a value that will be set instead of event value name tag item.
      Parameters:
      handler - handler of action to get value.
      action - action to get value.
      entity - entity to get value, can be null.
      Returns:
      string, number, boolean, item, location, vector, or null.
    • getName

      @NotNull public @NotNull String getName()
      Returns name of event value for displaying in registry by converting id. Not used in menus.
      Specified by:
      getName in interface ExtensionContent
      Returns:
      display name of event value.
    • getID

      @NotNull public final @NotNull String getID()
      Returns id of event value, that will be used to find it in registry.
      Returns:
      id of event value.
    • getLocaleName

      @NotNull public @NotNull String getLocaleName()
      Returns localized name of event value, that will be used in menus.
      Returns:
      localized name.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object