Interface IRequestManager

All Superinterfaces:
net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>, ITickable
All Known Subinterfaces:
IStandardRequestManager
All Known Implementing Classes:
AbstractWrappedRequestManager, StandardRequestManager, WrappedBlacklistAssignmentRequestManager, WrappedStaticStateRequestManager

public interface IRequestManager extends net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>, ITickable
Interface used to describe classes that function as managers for requests inside a colony. Extends INBTSerializable to allow for easy reading and writing from NBT.
  • Method Details

    • getColony

      @NotNull @NotNull IColony getColony()
      The colony this manager manages the requests for.
      Returns:
      The colony this manager manages the requests for.
    • getFactoryController

      @NotNull @NotNull IFactoryController getFactoryController()
      Method used to get the FactoryController of the RequestManager.
      Returns:
      The FactoryController of this RequestManager.
    • createRequest

      @NotNull <T extends IRequestable> @NotNull IToken<?> createRequest(@NotNull @NotNull IRequester requester, @NotNull T object) throws IllegalArgumentException
      Method to create a request for a given object
      Type Parameters:
      T - The type of request.
      Parameters:
      requester - The requester.
      object - The Object that is being requested.
      Returns:
      The token representing the request.
      Throws:
      IllegalArgumentException - is thrown when this manager cannot produce a request for the given types.
    • assignRequest

      @NotNull void assignRequest(@NotNull @NotNull IToken<?> token) throws IllegalArgumentException
      Method used to assign a request to a resolver.
      Parameters:
      token - The token of the request to assign.
      Throws:
      IllegalArgumentException - when the token is not registered to a request, or is already assigned to a resolver.
    • createAndAssignRequest

      @NotNull default <T extends IRequestable> @NotNull IToken<?> createAndAssignRequest(@NotNull @NotNull IRequester requester, @NotNull T object) throws IllegalArgumentException
      Method used to create and immediately assign a request.
      Type Parameters:
      T - The type of the requestable
      Parameters:
      requester - The requester of the requestable.
      object - The requestable
      Returns:
      The token that represents the request.
      Throws:
      IllegalArgumentException - when either createRequest or assignRequest have thrown an IllegalArgumentException
    • reassignRequest

      @Nullable @Nullable IToken<?> reassignRequest(@NotNull @NotNull IToken<?> token, @NotNull @NotNull Collection<IToken<?>> resolverTokenBlackList) throws IllegalArgumentException
      Method used to reassign a given request.
      Parameters:
      token - The token of the request that should be reassigned.
      resolverTokenBlackList - the blacklist.
      Returns:
      The token of the resolver that has gotten the assignment, null if none was found.
      Throws:
      IllegalArgumentException - when the token is not known to this manager.
    • getRequestForToken

      @Nullable @Nullable IRequest<?> getRequestForToken(@NotNull @NotNull IToken<?> token) throws IllegalArgumentException
      Method to get a request for a given token.
      Parameters:
      token - The token to get a request for.
      Returns:
      The request of the given type for that token.
      Throws:
      IllegalArgumentException - when the token does not produce a request of the given type T.
    • getResolverForToken

      @NotNull @NotNull IRequestResolver<?> getResolverForToken(@NotNull @NotNull IToken<?> token) throws IllegalArgumentException
      Method to get a resolver from its token.
      Parameters:
      token - the token.
      Returns:
      The resolver registered with the given token.
      Throws:
      IllegalArgumentException - when the token is unknown.
    • getResolverForRequest

      @Nullable @Nullable IRequestResolver<?> getResolverForRequest(@NotNull @NotNull IToken<?> requestToken) throws IllegalArgumentException
      Method to get a resolver for a given request.
      Parameters:
      requestToken - The token of the request to get resolver for.
      Returns:
      Null if the request is not yet resolved, or else the assigned resolver.
      Throws:
      IllegalArgumentException - Thrown when the token is unknown.
    • updateRequestState

      @NotNull void updateRequestState(@NotNull @NotNull IToken<?> token, @NotNull @NotNull RequestState state) throws IllegalArgumentException
      Method to update the state of a given request.
      Parameters:
      token - The token that represents a given request to update.
      state - The new state of that request.
      Throws:
      IllegalArgumentException - when the token is unknown to this manager.
    • overruleRequest

      void overruleRequest(@NotNull @NotNull IToken<?> token, @Nullable @Nullable net.minecraft.world.item.ItemStack stack) throws IllegalArgumentException
      Method used to overrule a request. Updates the state and sets the delivery if applicable.
      Parameters:
      token - The token of the request that is being overruled.
      stack - The stack that should be treated as delivery. If no delivery is possible, this is null.
      Throws:
      IllegalArgumentException - Thrown when either token does not match to a request.
    • onProviderAddedToColony

      void onProviderAddedToColony(@NotNull @NotNull IRequestResolverProvider provider) throws IllegalArgumentException
      Method used to indicate to this manager that a new Provider has been added to the colony.
      Parameters:
      provider - The new provider.
      Throws:
      IllegalArgumentException - is thrown when a provider with the same token is already registered.
    • onRequesterRemovedFromColony

      void onRequesterRemovedFromColony(@NotNull @NotNull IRequester requester) throws IllegalArgumentException
      Method used to indicate to this manager that a Requster has been removed from the colony.
      Parameters:
      requester - The removed requester.
      Throws:
      IllegalArgumentException - is thrown when no requester with the same token is registered.
    • onProviderRemovedFromColony

      void onProviderRemovedFromColony(@NotNull @NotNull IRequestResolverProvider provider) throws IllegalArgumentException
      Method used to indicate to this manager that Provider has been removed from the colony.
      Parameters:
      provider - The removed provider.
      Throws:
      IllegalArgumentException - is thrown when no provider with the same token is registered.
    • onColonyUpdate

      void onColonyUpdate(@NotNull @NotNull Predicate<IRequest<?>> shouldTriggerReassign)
      Method used to indicate that a colony has updated their available items.
      Parameters:
      shouldTriggerReassign - The request assigned
    • getPlayerResolver

      @NotNull @NotNull IPlayerRequestResolver getPlayerResolver()
      Get the player resolve.
      Returns:
      the player resolver object.
    • getRetryingRequestResolver

      @NotNull @NotNull IRetryingRequestResolver getRetryingRequestResolver()
      Get the retrying request resolver.
      Returns:
      The retrying request resolver.
    • getDataStoreManager

      @NotNull @NotNull IDataStoreManager getDataStoreManager()
      Get the data store manager.
      Returns:
      The data store manager.
    • reset

      void reset()
      Called to reset the RS.
    • isDirty

      boolean isDirty()
      Checks if dirty and needs to be updated.
      Returns:
      true if so.
    • setDirty

      void setDirty(boolean isDirty)
      Sets if dirty and needs to be updated.
      Parameters:
      isDirty - true if so.
    • markDirty

      void markDirty()
      Marks this manager dirty.
    • log

      void log(String message)
      Log a debug message.
      Parameters:
      message - the message to log.
    • serialize

      void serialize(IFactoryController controller, net.minecraft.network.FriendlyByteBuf buffer)
      serialize this request manager to the give FriendlyByteBuf
      Parameters:
      controller - the controller.
      buffer - the FriendlyByteBuf to serialize to.
    • deserialize

      void deserialize(IFactoryController controller, net.minecraft.network.FriendlyByteBuf buffer)
      deserialize this request manager from the give FriendlyByteBuf
      Parameters:
      controller - the controller.
      buffer - the FriendlyByteBuf to deserialize from.