Interface GameplayHookService
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 Summary
Modifier and TypeMethodDescription@NotNull Collection<GameplayHook<?, ?>> The decision points any addon currently handles.<R,V> @NotNull Registration register(@NotNull org.bukkit.plugin.Plugin owner, @NotNull GameplayHook<R, V> hook, int priority, @NotNull GameplayHookHandler<R, V> handler) Registers a handler for one decision point in every match.
-
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 enabledhook- the decision pointpriority- the order among addon handlers, higher firsthandler- the handler- Returns:
- the registration, to unregister it early
- Throws:
IllegalArgumentException- when the owner is not enabled
-
getHandledHooks
The decision points any addon currently handles.
-