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 Summary
Modifier and TypeMethodDescriptiondefault @Nullable StockActoractor()Returns the initiator of the change, if known.static @NotNull StockEvent.CauseCreates the simple implementation ofStockEvent.Causethat implementsname()static @NotNull StockEvent.Causecreate(@NotNull String name, @Nullable StockActor actor) Creates a named cause with an optional initiator.@NotNull Stringname()Gets the string that indicates the cause.
-
Method Details
-
create
Creates the simple implementation ofStockEvent.Causethat implementsname()- Parameters:
name- the cause that indicates why theStockEventwas called- Returns:
- a
StockEvent.Causeinstance
-
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 changedactor- the initiator, if known- Returns:
- the cause
-
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
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
nullif not attributed
-