Interface ContextManager


  • public interface ContextManager
    Manages ContextCalculators, and calculates applicable contexts for a given type.

    This interface accepts Object types as a parameter to avoid having to depend on specific server implementations. In all cases, the "player" or "subject" type for the platform must be used.

    Specifically:

    • org.bukkit.entity.Player
    • net.md_5.bungee.api.connection.ProxiedPlayer
    • org.spongepowered.api.service.permission.Subject
    • net.minecraft.server.network.ServerPlayerEntity (Fabric)
    • cn.nukkit.Player
    • com.velocitypowered.api.proxy.Player
    • Method Detail

      • getContext

        @NonNull ImmutableContextSet getContext​(@NonNull Object subject)
        Queries the ContextManager for current context values for the subject.
        Parameters:
        subject - the subject
        Returns:
        the applicable context for the subject
      • getContext

        @NonNull Optional<ImmutableContextSet> getContext​(@NonNull User user)
        Queries the ContextManager for current context values for the given User.

        This will only return a value if the player corresponding to the User is online.

        If you need to obtain a ImmutableContextSet instance regardless, you should initially try this method, and then fallback on getStaticContext().

        Parameters:
        user - the user
        Returns:
        the applicable context for the subject
      • getStaticContext

        @NonNull ImmutableContextSet getStaticContext()
        Gets the contexts from the static calculators in this manager.

        Static calculators provide the same context for all subjects, and are marked as such when registered.

        Returns:
        the current active static contexts
      • getStaticQueryOptions

        @NonNull QueryOptions getStaticQueryOptions()
        Gets the static query options, using the registered static context calculators.
        Returns:
        the current static query options
      • registerCalculator

        void registerCalculator​(@NonNull ContextCalculator<?> calculator)
        Registers a context calculator with the manager.
        Parameters:
        calculator - the calculator
      • unregisterCalculator

        void unregisterCalculator​(@NonNull ContextCalculator<?> calculator)
        Unregisters a context calculator with the manager.
        Parameters:
        calculator - the calculator
      • signalContextUpdate

        void signalContextUpdate​(@NonNull Object subject)
        Signal to the ContextManager that a subjects current contexts have changed.

        It is not strictly necessary to make a call to this method every time a context changes.

        Parameters:
        subject - the subject
        Since:
        5.2