Class GameplayHook<R,V>

java.lang.Object
dev.itsharshxd.zentrix.api.scenario.hook.GameplayHook<R,V>
Type Parameters:
R - the request type handed to handlers
V - the value type a handler may substitute

public final class GameplayHook<R,V> extends Object
A typed decision point in Zentrix's default gameplay that a scenario may take over.

Each hook pairs a request type with a result type. A scenario registers a GameplayHookHandler for the hook through its game context; Zentrix consults the registered handlers, highest scenario priority first, whenever it reaches that decision point. The first handler that does not pass decides the outcome, so a combination of scenarios always resolves the same way.

The built-in hooks live in GameplayHooks. A scenario may also define its own hook and dispatch it itself, which is how mechanics Zentrix never anticipated — custom roles, bosses, objectives, gravity or crafting systems — stay composable between scenarios.

Since:
1.6.0
  • Method Details

    • of

      @NotNull public static <R, V> @NotNull GameplayHook<R,V> of(@NotNull @NotNull String id, @NotNull @NotNull Class<R> requestType, @NotNull @NotNull Class<V> valueType)
      Creates a hook key.

      Addon hooks should namespace their id, for example myaddon:boss-spawn, so two addons cannot collide.

      Parameters:
      id - the stable hook identifier
      requestType - the request type handed to handlers
      valueType - the value type a handler may substitute
    • id

      @NotNull public @NotNull String id()
    • requestType

      @NotNull public @NotNull Class<R> requestType()
    • valueType

      @NotNull public @NotNull Class<V> valueType()
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object