Interface StockEvent.Cause

All Known Subinterfaces:
StickCause
All Known Implementing Classes:
CommandCauses.AdminGive, CommandCauses.AdminReset, CommandCauses.AdminSet, CommandCauses.AdminTake, CommandCauses.Give, CommandCauses.Receive, CraftCause, GuiCauses.Deposit, GuiCauses.Withdraw, StickCauses.BlockItem, StickCauses.BlockPlace, StickCauses.Brewer, StickCauses.Container, StickCauses.Furnace, StickCauses.ItemBreak, StickCauses.ItemConsume, StickCauses.ProjectileLaunch, StickCauses.Resurrect, StickCauses.ShootBow
Enclosing class:
StockEvent

public static interface StockEvent.Cause
An interface that indicates why the StockEvent was called.

By implementing this interface, StockEvent.Cause can have additional information.

If no additional information is needed, an instance can be created via create(String).

  • Method Details

    • create

      @NotNull static @NotNull StockEvent.Cause create(@NotNull @NotNull String name)
      Creates the simple implementation of StockEvent.Cause that implements name()
      Parameters:
      name - the cause that indicates why the StockEvent was called
      Returns:
      a StockEvent.Cause instance
    • create

      @NotNull static @NotNull StockEvent.Cause create(@NotNull @NotNull String name, @Nullable @Nullable StockActor actor)
      Creates a named cause with an optional initiator.
      Parameters:
      name - the reason the stock changed
      actor - the initiator, if known
      Returns:
      the cause
    • name

      @NotNull @NotNull String name()
      Gets the string that indicates the cause.

      This method returns a string that is a concise representation of the "cause".

      For example, an API call is "api", and a player's stock deposit/withdrawal is "deposit" or "withdraw".

      Returns:
      the string that indicates the cause
    • actor

      @Nullable default @Nullable StockActor actor()
      Returns the initiator of the change, if known. This method may be called asynchronously and must not consult mutable player or world state.
      Returns:
      the initiator, or null if not attributed