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.Subjectnet.minecraft.server.network.ServerPlayerEntity(Fabric)cn.nukkit.Playercom.velocitypowered.api.proxy.Player
-
Method Summary
Modifier and TypeMethodDescriptiongetContext(@NonNull Object subject) Queries the ContextManager for current context values for the subject.getContext(@NonNull User user) Queries the ContextManager for current context values for the given User.Gets theContextSetFactory, responsible for creatingContextSetinstances.getQueryOptions(@NonNull Object subject) Obtains currentQueryOptionsfor the subject.getQueryOptions(@NonNull User user) Obtains currentQueryOptionsfor the given User.Gets the contexts from the static calculators in this manager.Gets the static query options, using the registered static context calculators.default voidinvalidateCache(@NonNull Object subject) Deprecated.Creates a newQueryOptions.Builder.voidregisterCalculator(@NonNull ContextCalculator<?> calculator) Registers a context calculator with the manager.voidsignalContextUpdate(@NonNull Object subject) Signal to theContextManagerthat asubjects current contexts have changed.voidunregisterCalculator(@NonNull ContextCalculator<?> calculator) Unregisters a context calculator with the manager.
-
Method Details
-
getContext
Queries the ContextManager for current context values for the subject.- Parameters:
subject- the subject- Returns:
- the applicable context for the subject
-
getContext
Queries the ContextManager for current context values for the given User.This will only return a value if the player corresponding to the
Useris online.If you need to obtain a
ImmutableContextSetinstance regardless, you should initially try this method, and then fallback ongetStaticContext().- 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
-
queryOptionsBuilder
Creates a newQueryOptions.Builder.- Parameters:
mode- the mode- Returns:
- a new query options builder
-
getQueryOptions
Obtains currentQueryOptionsfor the subject.- Parameters:
subject- the subject- Returns:
- the query options for the subject
-
getQueryOptions
Obtains currentQueryOptionsfor the given User.This will only return a value if the player corresponding to the
Useris online.If you need to obtain a
QueryOptionsinstance regardless, you should initially try this method, and then fallback ongetStaticQueryOptions().- Parameters:
user- the user- Returns:
- the query options for the subject
-
getStaticQueryOptions
@NonNull QueryOptions getStaticQueryOptions()Gets the static query options, using the registered static context calculators.- Returns:
- the current static query options
-
registerCalculator
Registers a context calculator with the manager.- Parameters:
calculator- the calculator
-
unregisterCalculator
Unregisters a context calculator with the manager.- Parameters:
calculator- the calculator
-
signalContextUpdate
Signal to theContextManagerthat asubjects 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
-
getContextSetFactory
Gets theContextSetFactory, responsible for creatingContextSetinstances.- Returns:
- the context set factory
-
invalidateCache
Deprecated.UsesignalContextUpdate(Object)insteadInvalidates the lookup cache for a given subject- Parameters:
subject- the subject
-
signalContextUpdate(Object)instead