Class StrictStoredContext

java.lang.Object
com.pixelmonmod.pixelmon.api.context.StoredContext
com.pixelmonmod.pixelmon.api.context.StrictStoredContext

public final class StrictStoredContext extends StoredContext
This is a "strict" implementation of StoredContext that only allows immutable context keys to be set and retrieved.
This is only intended to be used internally for code usages of context. For example, the battle engine.
Whereas, the StoredContext is intended to be used for the public facing API, and pipelines such as the NPC and Research pipelines where a user might want to set a context key that is mutable, or that is not registered in the code.
  • Method Details

    • setContext

      public <A> StoredContext setContext(ContextKey<A> key, @Nullable A value)
      Description copied from class: StoredContext
      Sets the context key with the given value
      Overrides:
      setContext in class StoredContext
      Type Parameters:
      A - The type of the key and value
      Parameters:
      key - The key
      value - The value being set
      Returns:
      The context instance
    • getNullableContext

      @Nullable public <A> A getNullableContext(ContextKey<A> key)
      Description copied from class: StoredContext
      Gets the value stored by a given context key for this stored context
      Overrides:
      getNullableContext in class StoredContext
      Type Parameters:
      A - The type of the key and value
      Parameters:
      key - The key to check for
      Returns:
      The potential value stored
    • getContext

      public <A> Optional<A> getContext(ContextKey<A> key)
      Description copied from class: StoredContext
      Gets the value stored by a given context key for this stored context
      Overrides:
      getContext in class StoredContext
      Type Parameters:
      A - The type of the key and value
      Parameters:
      key - The key to check for
      Returns:
      The potential value stored
    • withPlayer

      public StoredContext withPlayer(net.minecraft.server.level.ServerPlayer player)
      Description copied from class: StoredContext
      Adds the generic contexts for the player
      Overrides:
      withPlayer in class StoredContext
      Parameters:
      player - The player for adding the generic contexts
      Returns:
      The context instance
    • setContext

      public <A> StoredContext setContext(net.minecraft.resources.ResourceLocation key, @Nullable A value)
      Description copied from class: StoredContext
      Sets the context key with the given value
      Overrides:
      setContext in class StoredContext
      Type Parameters:
      A - The type of the key and value
      Parameters:
      key - The key
      value - The value being set
      Returns:
      The context instance
    • getNullableContext

      @Nullable public <A> A getNullableContext(net.minecraft.resources.ResourceLocation key)
      Description copied from class: StoredContext
      Gets the value stored by a given context key for this stored context
      Overrides:
      getNullableContext in class StoredContext
      Type Parameters:
      A - The type of the key and value
      Parameters:
      key - The key to check for
      Returns:
      The potential value stored
    • getContext

      public <A> Optional<A> getContext(net.minecraft.resources.ResourceLocation key)
      Description copied from class: StoredContext
      Gets the value stored by a given context key for this stored context
      Overrides:
      getContext in class StoredContext
      Type Parameters:
      A - The type of the key and value
      Parameters:
      key - The key to check for
      Returns:
      The potential value stored