Interface ProvideServiceEvent<T>

  • Type Parameters:
    T - The service to provide.
    All Superinterfaces:
    Event, GenericEvent<T>, LifecycleEvent
    All Known Subinterfaces:
    ProvideServiceEvent.EngineScoped<T>, ProvideServiceEvent.GameScoped<T>

    public interface ProvideServiceEvent<T>
    extends GenericEvent<T>, LifecycleEvent
    An event that allows plugins to suggest their own implementation for a given service.

    Service providers should not construct the service object prior to selection. Instead, they should wait for if, and only if, their service factory as supplied in suggest(Supplier) has been called. Further, each plugin may only supply one service provider for each service.

    It is not guaranteed that this event will fire for the indicated service for a plugin that registers this listener. This may happen if the server is configured to select a particular service, or that another plugin has already been offered the chance to provide the implementation and has done so.

    • Method Detail

      • suggest

        void suggest​(Supplier<T> serviceFactory)
        Provides a suggestion for the given service. This may only be called once by any given plugin for a given service and event.
        Parameters:
        serviceFactory - A Supplier that can construct the service if this service is selected