Interface GameplayHookService


public interface GameplayHookService
Gameplay hooks for ordinary addons, consulted in every running match without being a selected scenario.

The decision points are the same GameplayHooks scenarios use, with the same request and outcome rules. A handler registered here is consulted for a decision only after every active scenario of that match passed, so selected scenarios keep deciding first exactly as before. Among addon handlers, a higher priority is asked first and equal priorities keep registration order; the first answer that does not pass decides and the rest are not asked.

Handlers run on the thread of the decision - the main thread for every built-in hook - and must decide quickly. A handler that throws is treated as passing and the failure is logged under its owner; it stays registered. Registrations end on their own when the owning plugin disables. Lookups resolve the match from the request's player, block or entity, so a handler only ever sees decisions inside running Zentrix matches.


 ZentrixAPI.get().getGameplayHookService().register(this, GameplayHooks.PLAYER_DAMAGE, 0,
     request -> request.cause().equals("FALL") ? HookOutcome.cancel() : HookOutcome.pass());
 
Since:
1.8.0
  • Method Details

    • register

      @NotNull <R, V> @NotNull Registration register(@NotNull @NotNull org.bukkit.plugin.Plugin owner, @NotNull @NotNull GameplayHook<R,V> hook, int priority, @NotNull @NotNull GameplayHookHandler<R,V> handler)
      Registers a handler for one decision point in every match.
      Parameters:
      owner - the plugin the registration belongs to; it must be enabled
      hook - the decision point
      priority - the order among addon handlers, higher first
      handler - the handler
      Returns:
      the registration, to unregister it early
      Throws:
      IllegalArgumentException - when the owner is not enabled
    • getHandledHooks

      @NotNull @NotNull Collection<GameplayHook<?,?>> getHandledHooks()
      The decision points any addon currently handles.