Interface ContextManager
-
public interface ContextManagerManagesContextCalculators, and calculates applicable contexts for a given type.This interface accepts
Objecttypes 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
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description @NonNull ImmutableContextSetgetContext(@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 ContextSetFactorygetContextSetFactory()Gets theContextSetFactory, responsible for creatingContextSetinstances.@NonNull QueryOptionsgetQueryOptions(@NonNull Object subject)Obtains currentQueryOptionsfor the subject.@NonNull Optional<QueryOptions>getQueryOptions(@NonNull User user)Obtains currentQueryOptionsfor the given User.@NonNull ImmutableContextSetgetStaticContext()Gets the contexts from the static calculators in this manager.@NonNull QueryOptionsgetStaticQueryOptions()Gets the static query options, using the registered static context calculators.default voidinvalidateCache(@NonNull Object subject)Deprecated.UsesignalContextUpdate(Object)instead@NonNull QueryOptions.BuilderqueryOptionsBuilder(@NonNull QueryMode mode)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 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
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
@NonNull QueryOptions.Builder queryOptionsBuilder(@NonNull QueryMode mode)
Creates a newQueryOptions.Builder.- Parameters:
mode- the mode- Returns:
- a new query options builder
-
getQueryOptions
@NonNull QueryOptions getQueryOptions(@NonNull Object subject)
Obtains currentQueryOptionsfor the subject.- Parameters:
subject- the subject- Returns:
- the query options for the subject
-
getQueryOptions
@NonNull Optional<QueryOptions> getQueryOptions(@NonNull User user)
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
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 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
@Internal @NonNull ContextSetFactory getContextSetFactory()
Gets theContextSetFactory, responsible for creatingContextSetinstances.- Returns:
- the context set factory
-
invalidateCache
@Deprecated default void invalidateCache(@NonNull Object subject)
Deprecated.UsesignalContextUpdate(Object)insteadInvalidates the lookup cache for a given subject- Parameters:
subject- the subject
-
-