Class AbstractWrappedRequestManager

java.lang.Object
com.minecolonies.core.colony.requestsystem.management.manager.wrapped.AbstractWrappedRequestManager
All Implemented Interfaces:
IRequestManager, ITickable, net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
Direct Known Subclasses:
WrappedBlacklistAssignmentRequestManager, WrappedStaticStateRequestManager

public abstract class AbstractWrappedRequestManager extends Object implements IRequestManager
Wrapper class for a Manager. Subclasses of this have custom behaviour on at least one method.
  • Field Details

  • Constructor Details

    • AbstractWrappedRequestManager

      public AbstractWrappedRequestManager(@NotNull @NotNull IStandardRequestManager wrappedManager)
  • Method Details

    • getColony

      @NotNull public @NotNull IColony getColony()
      The colony this manager manages the requests for.
      Specified by:
      getColony in interface IRequestManager
      Returns:
      The colony this manager manages the requests for.
    • getFactoryController

      @NotNull public @NotNull IFactoryController getFactoryController()
      Method used to get the FactoryController of the RequestManager.
      Specified by:
      getFactoryController in interface IRequestManager
      Returns:
      The FactoryController of this RequestManager.
    • createRequest

      @NotNull public <T extends IRequestable> @NotNull IToken<?> createRequest(@NotNull @NotNull IRequester requester, @NotNull T object) throws IllegalArgumentException
      Method to create a request for a given object
      Specified by:
      createRequest in interface IRequestManager
      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

      public void assignRequest(@NotNull @NotNull IToken<?> token) throws IllegalArgumentException
      Method used to assign a request to a resolver.
      Specified by:
      assignRequest in interface IRequestManager
      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 public <T extends IRequestable> @NotNull IToken<?> createAndAssignRequest(@NotNull @NotNull IRequester requester, @NotNull T object) throws IllegalArgumentException
      Method used to create and immediately assign a request.
      Specified by:
      createAndAssignRequest in interface IRequestManager
      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

      public IToken<?> reassignRequest(@NotNull @NotNull IToken<?> token, @NotNull @NotNull Collection<IToken<?>> resolverTokenBlackList) throws IllegalArgumentException
      Description copied from interface: IRequestManager
      Method used to reassign a given request.
      Specified by:
      reassignRequest in interface IRequestManager
      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 public @Nullable IRequest<?> getRequestForToken(@NotNull @NotNull IToken<?> token) throws IllegalArgumentException
      Method to get a request for a given token.
      Specified by:
      getRequestForToken in interface IRequestManager
      Parameters:
      token - The token to get a request for.
      Returns:
      The request of the given type for that token.
      Throws:
      IllegalArgumentException - when either their is no request with that token, or the token does not produce a request of the given type T.
    • getResolverForToken

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

      @Nullable public @Nullable IRequestResolver<?> getResolverForRequest(@NotNull @NotNull IToken<?> requestToken) throws IllegalArgumentException
      Method to get a resolver for a given request.
      Specified by:
      getResolverForRequest in interface IRequestManager
      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

      public void updateRequestState(@NotNull @NotNull IToken<?> token, @NotNull @NotNull RequestState state) throws IllegalArgumentException
      Method to update the state of a given request.
      Specified by:
      updateRequestState in interface IRequestManager
      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

      public void overruleRequest(@NotNull @NotNull IToken<?> token, @Nullable @Nullable net.minecraft.world.item.ItemStack stack) throws IllegalArgumentException
      Description copied from interface: IRequestManager
      Method used to overrule a request. Updates the state and sets the delivery if applicable.
      Specified by:
      overruleRequest in interface IRequestManager
      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

      public 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.
      Specified by:
      onProviderAddedToColony in interface IRequestManager
      Parameters:
      provider - The new provider.
      Throws:
      IllegalArgumentException - is thrown when a provider with the same token is already registered.
    • onProviderRemovedFromColony

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

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

      @NotNull public @NotNull IPlayerRequestResolver getPlayerResolver()
      Description copied from interface: IRequestManager
      Get the player resolve.
      Specified by:
      getPlayerResolver in interface IRequestManager
      Returns:
      the player resolver object.
    • getRetryingRequestResolver

      @NotNull public @NotNull IRetryingRequestResolver getRetryingRequestResolver()
      Description copied from interface: IRequestManager
      Get the retrying request resolver.
      Specified by:
      getRetryingRequestResolver in interface IRequestManager
      Returns:
      The retrying request resolver.
    • serializeNBT

      public net.minecraft.nbt.CompoundTag serializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider)
      Specified by:
      serializeNBT in interface net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
    • deserializeNBT

      public void deserializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag nbt)
      Specified by:
      deserializeNBT in interface net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
    • serialize

      public void serialize(IFactoryController controller, net.minecraft.network.RegistryFriendlyByteBuf buffer)
      Description copied from interface: IRequestManager
      serialize this request manager to the give RegistryFriendlyByteBuf
      Specified by:
      serialize in interface IRequestManager
      Parameters:
      controller - the controller.
      buffer - the RegistryFriendlyByteBuf to serialize to.
    • deserialize

      public void deserialize(IFactoryController controller, net.minecraft.network.RegistryFriendlyByteBuf buffer)
      Description copied from interface: IRequestManager
      deserialize this request manager from the give RegistryFriendlyByteBuf
      Specified by:
      deserialize in interface IRequestManager
      Parameters:
      controller - the controller.
      buffer - the RegistryFriendlyByteBuf to deserialize from.
    • tick

      public void tick()
      Description copied from interface: ITickable
      Default parameterless ticking implementation.
      Specified by:
      tick in interface ITickable
    • getDataStoreManager

      @NotNull public @NotNull IDataStoreManager getDataStoreManager()
      Description copied from interface: IRequestManager
      Get the data store manager.
      Specified by:
      getDataStoreManager in interface IRequestManager
      Returns:
      The data store manager.
    • reset

      public void reset()
      Description copied from interface: IRequestManager
      Called to reset the RS.
      Specified by:
      reset in interface IRequestManager
    • isDirty

      public boolean isDirty()
      Description copied from interface: IRequestManager
      Checks if dirty and needs to be updated.
      Specified by:
      isDirty in interface IRequestManager
      Returns:
      true if so.
    • setDirty

      public void setDirty(boolean isDirty)
      Description copied from interface: IRequestManager
      Sets if dirty and needs to be updated.
      Specified by:
      setDirty in interface IRequestManager
      Parameters:
      isDirty - true if so.
    • markDirty

      public void markDirty()
      Description copied from interface: IRequestManager
      Marks this manager dirty.
      Specified by:
      markDirty in interface IRequestManager
    • onColonyUpdate

      public void onColonyUpdate(@NotNull @NotNull Predicate<IRequest<?>> shouldTriggerReassign)
      Description copied from interface: IRequestManager
      Method used to indicate that a colony has updated their available items.
      Specified by:
      onColonyUpdate in interface IRequestManager
      Parameters:
      shouldTriggerReassign - The request assigned
    • log

      public void log(String message)
      Description copied from interface: IRequestManager
      Log a debug message.
      Specified by:
      log in interface IRequestManager
      Parameters:
      message - the message to log.