Interface IRequest<R extends IRequestable>

Type Parameters:
R - The type of request, eg ItemStack, FluidStack etc.
All Known Implementing Classes:
AbstractRequest, StandardRequests.AbstractCraftingRequest, StandardRequests.BurnableRequest, StandardRequests.DeliveryRequest, StandardRequests.FoodRequest, StandardRequests.ItemStackListRequest, StandardRequests.ItemStackRequest, StandardRequests.ItemTagRequest, StandardRequests.MinStackRequest, StandardRequests.PickupRequest, StandardRequests.PrivateCraftingRequest, StandardRequests.PublicCraftingRequest, StandardRequests.SmeltAbleOreRequest, StandardRequests.ToolRequest

public interface IRequest<R extends IRequestable>
Used to represent requests, of type R, made to the internal market of the colony.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends IToken<?>>
    void
    addChild(T child)
    Method used to add a single Child.
    <T extends IToken<?>>
    void
    addChildren(@NotNull Collection<T> children)
    Method to add multiple children in a single call.
    <T extends IToken<?>>
    void
    addChildren(@NotNull T... children)
    Method to add multiple children in a single call.
    void
    addDelivery(@NotNull List<net.minecraft.world.item.ItemStack> list)
    Adds a list of stacks as a delivery to this request.
    void
    addDelivery(@NotNull net.minecraft.world.item.ItemStack stack)
    Adds a single stack as a delivery to this request.
    boolean
    Method used to indicate that the result of this request can be delivered.
    void
    childStateUpdated(@NotNull IRequestManager manager, @NotNull IToken<?> child)
    Method called by a child state to indicate that its state has been updated.
    @NotNull com.google.common.collect.ImmutableCollection<IToken<?>>
    Method to get the children of this request.
    @NotNull com.google.common.collect.ImmutableList<net.minecraft.world.item.ItemStack>
    Method to get the ItemStacks used for the delivery.
    @NotNull net.minecraft.resources.ResourceLocation
    Method used to get a ResourceLocation that is displayed instead of the getDisplayStacks(), when getDisplayStacks() returns an empty list.
    @NotNull List<net.minecraft.world.item.ItemStack>
    Method used to get a List of ItemStacks that represents the stack.
    <T extends IToken<?>>
    T
    The unique token representing the request outside of the management system.
    @NotNull net.minecraft.network.chat.Component
    Method used to get a Component that can be displayed to the Player and describes so that the player can complete it.
    <T extends IToken<?>>
    T
    Returns the parent of this request.
    Return the object that is actually requested.
    @NotNull IRequester
    The element of the colony that requested this request.
    <T> @NotNull Optional<T>
    Get a request of a specific type.
    List<net.minecraft.network.chat.MutableComponent>
    Get the resolver tooltip for a request.
    Returns the result of this request.
    @NotNull net.minecraft.network.chat.Component
    Method used to get a Component that can be displayed to the Player and describes the request in short.
    @NotNull RequestState
    Returns the current state of the request.
    Method to get the assigning strategy for this request.
    Set<com.google.common.reflect.TypeToken<?>>
    Get all super classes of this type (cached value).
    @NotNull com.google.common.reflect.TypeToken<? extends R>
    Used to determine which type of request this is.
    boolean
    Method to check if this request has children.
    boolean
    Returns true if this request has a parent, false if not.
    boolean
    Method used to check if the result has been set.
    void
    overrideCurrentDeliveries(@NotNull com.google.common.collect.ImmutableList<net.minecraft.world.item.ItemStack> stacks)
    Sets the deliveries of this request to the given stacks
    <T extends IToken<?>>
    void
    removeChild(T child)
    Method used to remove a single Child.
    <T extends IToken<?>>
    void
    removeChildren(@NotNull Collection<T> children)
    Method to remove multiple children in a single call.
    <T extends IToken<?>>
    void
    removeChildren(@NotNull T... children)
    Method to remove multiple children in a single call.
    void
    Reset the deliveries of the request.
    <T extends IToken<?>>
    void
    setParent(T parent)
    Method used to set the parent of a request.
    void
    setResult(R result)
    Setter for the result of the request.
    void
    setState(@NotNull IRequestManager manager, @NotNull RequestState state)
    Setter for the current state of this request.
  • Method Details

    • getStrategy

      default AssigningStrategy getStrategy()
      Method to get the assigning strategy for this request.
      Returns:
      The assigning strategy for this request.
    • getId

      <T extends IToken<?>> T getId()
      The unique token representing the request outside of the management system.
      Type Parameters:
      T - generic token.
      Returns:
      the token representing the request outside of the management system.
    • getType

      @NotNull @NotNull com.google.common.reflect.TypeToken<? extends R> getType()
      Used to determine which type of request this is. Only RequestResolvers for this Type are then used to resolve the this.
      Returns:
      The class that represents this Type of Request.
    • getState

      @NotNull @NotNull RequestState getState()
      Returns the current state of the request.
      Returns:
      The current state.
    • setState

      void setState(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull RequestState state)
      Setter for the current state of this request. It is not recommended to call this method from outside of the request management system.
      Parameters:
      manager - the request manager.
      state - The new state of this request.
    • getRequester

      @NotNull @NotNull IRequester getRequester()
      The element of the colony that requested this request.
      Returns:
      The requester of this request.
    • getRequest

      @NotNull R getRequest()
      Return the object that is actually requested. A RequestResolver can compare this object however way it sees fit.

      During the resolving process this object is called multiple times. But at least twice. A cached implementation is preferred.

      Returns:
      The object that is actually requested.
    • getResult

      @Nullable R getResult()
      Returns the result of this request.
      Returns:
      The result of this request, or null if it is not available.
    • setResult

      void setResult(@NotNull R result)
      Setter for the result of the request.
      Parameters:
      result - The new result of this request.
    • hasResult

      boolean hasResult()
      Method used to check if the result has been set.
      Returns:
      True when the result has been set, false when not.
    • getParent

      @Nullable <T extends IToken<?>> T getParent()
      Returns the parent of this request. If this is set it means that this request is part of request chain.
      Type Parameters:
      T - generic token.
      Returns:
      The parent of this request, or null if it has no parent.
    • setParent

      <T extends IToken<?>> void setParent(@Nullable T parent)
      Method used to set the parent of a request.
      Type Parameters:
      T - generic token.
      Parameters:
      parent - The new parent, or null to clear the existing one.
    • hasParent

      boolean hasParent()
      Returns true if this request has a parent, false if not.
      Returns:
      true if this request has a parent, false if not.
    • addChild

      <T extends IToken<?>> void addChild(@NotNull T child)
      Method used to add a single Child.
      Type Parameters:
      T - generic token.
      Parameters:
      child - The new child request to add.
    • addChildren

      <T extends IToken<?>> void addChildren(@NotNull @NotNull T... children)
      Method to add multiple children in a single call.
      Type Parameters:
      T - generic token.
      Parameters:
      children - An array of children to add.
    • addChildren

      <T extends IToken<?>> void addChildren(@NotNull @NotNull Collection<T> children)
      Method to add multiple children in a single call.
      Type Parameters:
      T - generic token.
      Parameters:
      children - A collection of children to add.
    • removeChild

      <T extends IToken<?>> void removeChild(@NotNull T child)
      Method used to remove a single Child.
      Type Parameters:
      T - generic token.
      Parameters:
      child - The new child request to remove.
    • removeChildren

      <T extends IToken<?>> void removeChildren(@NotNull @NotNull T... children)
      Method to remove multiple children in a single call.
      Type Parameters:
      T - generic token.
      Parameters:
      children - An array of children to remove.
    • removeChildren

      <T extends IToken<?>> void removeChildren(@NotNull @NotNull Collection<T> children)
      Method to remove multiple children in a single call.
      Type Parameters:
      T - generic token.
      Parameters:
      children - A collection of children to remove.
    • hasChildren

      boolean hasChildren()
      Method to check if this request has children.
      Returns:
      true if it has children.
    • getChildren

      @NotNull @NotNull com.google.common.collect.ImmutableCollection<IToken<?>> getChildren()
      Method to get the children of this request. Immutable.
      Returns:
      An immutable collection of the children of this request.
    • childStateUpdated

      void childStateUpdated(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IToken<?> child)
      Method called by a child state to indicate that its state has been updated.
      Parameters:
      manager - The manager that caused the update on the child.
      child - The child that was updated.
    • canBeDelivered

      boolean canBeDelivered()
      Method used to indicate that the result of this request can be delivered.
      Returns:
      True for requests that can be delivered, false when not.
    • getDeliveries

      @NotNull @NotNull com.google.common.collect.ImmutableList<net.minecraft.world.item.ItemStack> getDeliveries()
      Method to get the ItemStacks used for the delivery.
      Returns:
      The ItemStacks that the Deliveryman transports around. AbstractCollection.isEmpty() means no delivery possible.
    • overrideCurrentDeliveries

      void overrideCurrentDeliveries(@NotNull @NotNull com.google.common.collect.ImmutableList<net.minecraft.world.item.ItemStack> stacks)
      Sets the deliveries of this request to the given stacks
      Parameters:
      stacks - The stacks that will be the deliveries.
    • addDelivery

      void addDelivery(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Adds a single stack as a delivery to this request.
      Parameters:
      stack - The stack that should be treated as a new delivery.
    • addDelivery

      void addDelivery(@NotNull @NotNull List<net.minecraft.world.item.ItemStack> list)
      Adds a list of stacks as a delivery to this request.
      Parameters:
      list - The list of stacks that should be treated as a new delivery.
    • getShortDisplayString

      @NotNull @NotNull net.minecraft.network.chat.Component getShortDisplayString()
      Method used to get a Component that can be displayed to the Player and describes the request in short. Should represent the request, in case the player needs to fulfill it, or information about this request is required.
      Returns:
      The text that describes this Request.
    • getLongDisplayString

      @NotNull @NotNull net.minecraft.network.chat.Component getLongDisplayString()
      Method used to get a Component that can be displayed to the Player and describes so that the player can complete it. Should represent the request, in case the player needs to fulfill it, or information about this request is required.
      Returns:
      The text that describes this Request.
    • getDisplayStacks

      @NotNull @NotNull List<net.minecraft.world.item.ItemStack> getDisplayStacks()
      Method used to get a List of ItemStacks that represents the stack. This list is used in GUI to show what the request is. If an empty list is returned then no stack is shown. If a list with multiple stacks is returned it will switch between the stacks once every second unless the player holds the shift key.
      Returns:
      A List of ItemStacks that represents this request.
    • getDisplayIcon

      @NotNull @NotNull net.minecraft.resources.ResourceLocation getDisplayIcon()
      Method used to get a ResourceLocation that is displayed instead of the getDisplayStacks(), when getDisplayStacks() returns an empty list.
      Returns:
      The ResourceLocation of the Image dat is displayed when their are no DisplayStacks.
    • getRequestOfType

      @NotNull <T> @NotNull Optional<T> getRequestOfType(Class<T> tClass)
      Get a request of a specific type.
      Type Parameters:
      T - the type.
      Parameters:
      tClass - the class of it.
      Returns:
      the request of this particular type.
    • getSuperClasses

      Set<com.google.common.reflect.TypeToken<?>> getSuperClasses()
      Get all super classes of this type (cached value).
      Returns:
      an immutable copy of the set.
    • getResolverToolTip

      List<net.minecraft.network.chat.MutableComponent> getResolverToolTip(IColonyView colony)
      Get the resolver tooltip for a request.
      Parameters:
      colony - the colony view to obtain information if necessary.
      Returns:
      a list of strings or empty.
    • resetDeliveries

      void resetDeliveries()
      Reset the deliveries of the request.