public interface ContextManager
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.Playernet.md_5.bungee.api.connection.ProxiedPlayerorg.spongepowered.api.service.permission.Subjectcn.nukkit.Playercom.velocitypowered.api.proxy.Player| Modifier and Type | Method and Description |
|---|---|
@NonNull ImmutableContextSet |
getContext(@NonNull Object subject)
Queries the ContextManager for current context values for the subject.
|
@NonNull Optional<ImmutableContextSet> |
getContext(@NonNull User user)
Queries the ContextManager for current context values for the given User.
|
@NonNull ContextSetFactory |
getContextSetFactory()
Gets the
ContextSetFactory, responsible for creating
ContextSet instances. |
@NonNull QueryOptions |
getQueryOptions(@NonNull Object subject)
Obtains current
QueryOptions for the subject. |
@NonNull Optional<QueryOptions> |
getQueryOptions(@NonNull User user)
Obtains current
QueryOptions for the given User. |
@NonNull ImmutableContextSet |
getStaticContext()
Gets the contexts from the static calculators in this manager.
|
@NonNull QueryOptions |
getStaticQueryOptions()
Gets the static query options, using the registered static context calculators.
|
default void |
invalidateCache(@NonNull Object subject)
Deprecated.
|
QueryOptions.Builder |
queryOptionsBuilder(@NonNull QueryMode mode)
Creates a new
QueryOptions.Builder. |
void |
registerCalculator(@NonNull ContextCalculator<?> calculator)
Registers a context calculator with the manager.
|
void |
signalContextUpdate(@NonNull Object subject)
Signal to the
ContextManager that a subjects
current contexts have changed. |
void |
unregisterCalculator(@NonNull ContextCalculator<?> calculator)
Unregisters a context calculator with the manager.
|
@NonNull ImmutableContextSet getContext(@NonNull Object subject)
subject - the subject@NonNull Optional<ImmutableContextSet> getContext(@NonNull User 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().
user - the user@NonNull ImmutableContextSet getStaticContext()
Static calculators provide the same context for all subjects, and are marked as such when registered.
QueryOptions.Builder queryOptionsBuilder(@NonNull QueryMode mode)
QueryOptions.Builder.mode - the mode@NonNull QueryOptions getQueryOptions(@NonNull Object subject)
QueryOptions for the subject.subject - the subject@NonNull Optional<QueryOptions> getQueryOptions(@NonNull User user)
QueryOptions 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 QueryOptions instance regardless, you should
initially try this method, and then fallback on getStaticQueryOptions().
user - the user@NonNull QueryOptions getStaticQueryOptions()
void registerCalculator(@NonNull ContextCalculator<?> calculator)
calculator - the calculatorvoid unregisterCalculator(@NonNull ContextCalculator<?> calculator)
calculator - the calculatorvoid signalContextUpdate(@NonNull Object subject)
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.
subject - the subject@NonNull ContextSetFactory getContextSetFactory()
ContextSetFactory, responsible for creating
ContextSet instances.@Deprecated default void invalidateCache(@NonNull Object subject)
signalContextUpdate(Object)subject - the subject