Interface ActionContext


public interface ActionContext
An action as it runs: who runs it, from which page, and its values: a form's fields, a button's View.Button.with(String, Object), or what a view's script sent.
  • Method Details

    • viewer

      Viewer viewer()
      Returns:
      who runs the action
    • page

      String page()
      Returns:
      the page it was run from, empty when it is not known
    • has

      boolean has(String name)
      Parameters:
      name - a value's name
      Returns:
      whether the action came with that value
    • string

      @Nullable String string(String name)
      Parameters:
      name - a value's name
      Returns:
      the value as text, or null when there is none
    • string

      String string(String name, String fallback)
      Parameters:
      name - a value's name
      fallback - what to answer when there is none
      Returns:
      the value as text
    • integer

      long integer(String name, long fallback)
      Parameters:
      name - a value's name
      fallback - what to answer when there is none, or it is not a whole number
      Returns:
      the value as a whole number
    • decimal

      double decimal(String name, double fallback)
      Parameters:
      name - a value's name
      fallback - what to answer when there is none, or it is not a number
      Returns:
      the value as a number
    • bool

      boolean bool(String name)
      Parameters:
      name - a value's name
      Returns:
      the value as a boolean: true for a switch turned on, or the text true
    • input

      Map<String,Object> input()
      Returns:
      every value: strings, numbers (Double), booleans, and lists or maps of them from a view's script
    • player

      @Nullable Player player(String name)
      Parameters:
      name - the name of a value holding a player's name or id
      Returns:
      that player, when they are online
    • global

      <T> CompletableFuture<T> global(Supplier<T> task)
      Work on the global region thread, the one of world-wide state.
      Type Parameters:
      T - what it gives
      Parameters:
      task - the work
      Returns:
      a future of what it gives
    • entity

      <T> CompletableFuture<T> entity(Entity entity, Supplier<T> task)
      Work on the thread of an entity's region, the one allowed to change it. The future fails when the entity is gone.
      Type Parameters:
      T - what it gives
      Parameters:
      entity - the entity
      task - the work
      Returns:
      a future of what it gives
    • region

      <T> CompletableFuture<T> region(Location location, Supplier<T> task)
      Work on the thread of the region of a place.
      Type Parameters:
      T - what it gives
      Parameters:
      location - the place
      task - the work
      Returns:
      a future of what it gives