Class AbstractRequest<R extends IRequestable>
java.lang.Object
com.minecolonies.core.colony.requestsystem.requests.AbstractRequest<R>
- Type Parameters:
R- The type of request this is.
- All Implemented Interfaces:
IRequest<R>
- Direct Known Subclasses:
StandardRequests.AbstractCraftingRequest,StandardRequests.BurnableRequest,StandardRequests.DeliveryRequest,StandardRequests.FoodRequest,StandardRequests.ItemStackListRequest,StandardRequests.ItemStackRequest,StandardRequests.ItemTagRequest,StandardRequests.MinStackRequest,StandardRequests.PickupRequest,StandardRequests.SmeltAbleOreRequest,StandardRequests.ToolRequest
Abstract skeleton implementation of a request.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.minecraft.resources.ResourceLocationDefault display icon (none). -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRequest(@NotNull IRequester requester, @NotNull IToken<?> token, @NotNull RequestState state, R requested) protectedAbstractRequest(@NotNull IRequester requester, @NotNull IToken<?> token, R requested) -
Method Summary
Modifier and TypeMethodDescription<T extends IToken<?>>
voidaddChild(T child) Method used to add a single Child.<T extends IToken<?>>
voidaddChildren(@NotNull Collection<T> children) Method to add multiple children in a single call.<T extends IToken<?>>
voidaddChildren(T... children) Method to add multiple children in a single call.voidaddDelivery(@NotNull List<net.minecraft.world.item.ItemStack> list) Adds a list of stacks as a delivery to this request.voidaddDelivery(@NotNull net.minecraft.world.item.ItemStack stack) Adds a single stack as a delivery to this request.booleanMethod used to indicate that the result of this request can be delivered.voidchildStateUpdated(@NotNull IRequestManager manager, @NotNull IToken<?> child) Method called by a child state to indicate that its state has been updated.boolean@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.ResourceLocationMethod used to get a ResourceLocation that is displayed instead of theIRequest.getDisplayStacks(), whenIRequest.getDisplayStacks()returns an empty list.List<net.minecraft.world.item.ItemStack> Method used to get a List of ItemStacks that represents the stack.<T extends IToken<?>>
TgetId()The unique token representing the request outside of the management system.@NotNull net.minecraft.network.chat.ComponentMethod used to get aComponentthat can be displayed to the Player and describes so that the player can complete it.<T extends IToken<?>>
TReturns the parent of this request.Return the object that is actually requested.@NotNull IRequesterThe location of the requester.<T> @NotNull Optional<T> getRequestOfType(Class<T> tClass) Get a request of a specific type.List<net.minecraft.network.chat.MutableComponent> getResolverToolTip(IColonyView colony) Get the resolver tooltip for a request.Returns the result of this request.@NotNull RequestStategetState()Returns the current state of the request.Set<com.google.common.reflect.TypeToken<?>> Get all super classes of this type (cached value).@NotNull com.google.common.reflect.TypeToken<? extends R> getType()Used to determine which type of request this is.booleanMethod to check if this request has children.inthashCode()booleanReturns true if this request has a parent, false if not.booleanMethod used to check if the result has been set.voidoverrideCurrentDeliveries(@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<?>>
voidremoveChild(T child) Method used to remove a single Child.<T extends IToken<?>>
voidremoveChildren(@NotNull Collection<T> children) Method to remove multiple children in a single call.<T extends IToken<?>>
voidremoveChildren(T... children) Method to remove multiple children in a single call.voidReset the deliveries of the request.<T extends IToken<?>>
voidsetParent(T parent) Method used to set the parent of a request.voidSetter for the result of the request.voidsetState(@NotNull IRequestManager manager, @NotNull RequestState state) Setter for the current state of this request.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.requestsystem.request.IRequest
getShortDisplayString, getStrategy
-
Field Details
-
MISSING
public static final net.minecraft.resources.ResourceLocation MISSINGDefault display icon (none).
-
-
Constructor Details
-
AbstractRequest
protected AbstractRequest(@NotNull @NotNull IRequester requester, @NotNull @NotNull IToken<?> token, @NotNull R requested) -
AbstractRequest
protected AbstractRequest(@NotNull @NotNull IRequester requester, @NotNull @NotNull IToken<?> token, @NotNull @NotNull RequestState state, @NotNull R requested)
-
-
Method Details
-
getType
Used to determine which type of request this is. Only RequestResolvers for this Type are then used to resolve the this.- Specified by:
getTypein interfaceIRequest<R extends IRequestable>- Returns:
- The class that represents this Type of Request.
-
getRequester
The location of the requester. Is generally used in getDelivery requests to produce a getDelivery for a result from this request.- Specified by:
getRequesterin interfaceIRequest<R extends IRequestable>- Returns:
- The location of requester of this request.
-
getId
The unique token representing the request outside of the management system.- Specified by:
getIdin interfaceIRequest<R extends IRequestable>- Type Parameters:
T- generic token.- Returns:
- the token representing the request outside of the management system.
-
getState
Returns the current state of the request.- Specified by:
getStatein interfaceIRequest<R extends IRequestable>- Returns:
- The current state.
-
setState
public void setState(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull RequestState state) Setter for the current state of this request.The implementing class is responsible for propagating the state change to its parent, if needed.
- Specified by:
setStatein interfaceIRequest<R extends IRequestable>- Parameters:
manager- The request manager that updated the state.state- The new state of this request.
-
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.
- Specified by:
getRequestin interfaceIRequest<R extends IRequestable>- Returns:
- The object that is actually requested.
-
getResult
Returns the result of this request.- Specified by:
getResultin interfaceIRequest<R extends IRequestable>- Returns:
- The result of this request, or null if it is not available.
-
setResult
Setter for the result of the request.- Specified by:
setResultin interfaceIRequest<R extends IRequestable>- Parameters:
result- The new result of this request.
-
hasResult
public boolean hasResult()Method used to check if the result has been set.- Specified by:
hasResultin interfaceIRequest<R extends IRequestable>- Returns:
- True when the result has been set, false when not.
-
getParent
Returns the parent of this request. If this is set it means that this request is part of request chain.- Specified by:
getParentin interfaceIRequest<R extends IRequestable>- Type Parameters:
T- generic token.- Returns:
- The parent of this request, or null if it has no parent.
-
setParent
Method used to set the parent of a request.- Specified by:
setParentin interfaceIRequest<R extends IRequestable>- Type Parameters:
T- generic token.- Parameters:
parent- The new parent, or null to clear the existing one.
-
hasParent
public boolean hasParent()Returns true if this request has a parent, false if not.- Specified by:
hasParentin interfaceIRequest<R extends IRequestable>- Returns:
- true if this request has a parent, false if not.
-
addChild
Method used to add a single Child.- Specified by:
addChildin interfaceIRequest<R extends IRequestable>- Type Parameters:
T- generic token.- Parameters:
child- The new child request to add.
-
addChildren
Method to add multiple children in a single call.- Specified by:
addChildrenin interfaceIRequest<R extends IRequestable>- Type Parameters:
T- generic token.- Parameters:
children- An array of children to add.
-
addChildren
Method to add multiple children in a single call.- Specified by:
addChildrenin interfaceIRequest<R extends IRequestable>- Type Parameters:
T- generic token.- Parameters:
children- A collection of children to add.
-
removeChild
Method used to remove a single Child.- Specified by:
removeChildin interfaceIRequest<R extends IRequestable>- Type Parameters:
T- generic token.- Parameters:
child- The new child request to remove.
-
removeChildren
Method to remove multiple children in a single call.- Specified by:
removeChildrenin interfaceIRequest<R extends IRequestable>- Type Parameters:
T- generic token.- Parameters:
children- An array of children to remove.
-
removeChildren
Method to remove multiple children in a single call.- Specified by:
removeChildrenin interfaceIRequest<R extends IRequestable>- Type Parameters:
T- generic token.- Parameters:
children- A collection of children to remove.
-
hasChildren
public boolean hasChildren()Method to check if this request has children.- Specified by:
hasChildrenin interfaceIRequest<R extends IRequestable>- Returns:
- true if it has children.
-
getChildren
Method to get the children of this request. Immutable.- Specified by:
getChildrenin interfaceIRequest<R extends IRequestable>- Returns:
- An immutable collection of the children of this request.
-
childStateUpdated
public void childStateUpdated(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IToken<?> child) Method called by a child state to indicate that its state has been updated.- Specified by:
childStateUpdatedin interfaceIRequest<R extends IRequestable>- Parameters:
manager- The manager that caused the update on the child.child- The child that was updated.
-
canBeDelivered
public boolean canBeDelivered()Method used to indicate that the result of this request can be delivered.- Specified by:
canBeDeliveredin interfaceIRequest<R extends IRequestable>- Returns:
- True for requests that can be delivered, false when not.
-
getDeliveries
@NotNull public @NotNull com.google.common.collect.ImmutableList<net.minecraft.world.item.ItemStack> getDeliveries()Description copied from interface:IRequestMethod to get the ItemStacks used for the delivery.- Specified by:
getDeliveriesin interfaceIRequest<R extends IRequestable>- Returns:
- The ItemStacks that the Deliveryman transports around.
AbstractCollection.isEmpty()means no delivery possible.
-
overrideCurrentDeliveries
public void overrideCurrentDeliveries(@NotNull @NotNull com.google.common.collect.ImmutableList<net.minecraft.world.item.ItemStack> stacks) Description copied from interface:IRequestSets the deliveries of this request to the given stacks- Specified by:
overrideCurrentDeliveriesin interfaceIRequest<R extends IRequestable>- Parameters:
stacks- The stacks that will be the deliveries.
-
addDelivery
public void addDelivery(@NotNull @NotNull net.minecraft.world.item.ItemStack stack) Description copied from interface:IRequestAdds a single stack as a delivery to this request.- Specified by:
addDeliveryin interfaceIRequest<R extends IRequestable>- Parameters:
stack- The stack that should be treated as a new delivery.
-
addDelivery
Description copied from interface:IRequestAdds a list of stacks as a delivery to this request.- Specified by:
addDeliveryin interfaceIRequest<R extends IRequestable>- Parameters:
list- The list of stacks that should be treated as a new delivery.
-
resetDeliveries
public void resetDeliveries()Description copied from interface:IRequestReset the deliveries of the request.- Specified by:
resetDeliveriesin interfaceIRequest<R extends IRequestable>
-
getLongDisplayString
@NotNull public @NotNull net.minecraft.network.chat.Component getLongDisplayString()Description copied from interface:IRequestMethod used to get aComponentthat 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.- Specified by:
getLongDisplayStringin interfaceIRequest<R extends IRequestable>- Returns:
- The text that describes this Request.
-
getDisplayIcon
@NotNull public @NotNull net.minecraft.resources.ResourceLocation getDisplayIcon()Description copied from interface:IRequestMethod used to get a ResourceLocation that is displayed instead of theIRequest.getDisplayStacks(), whenIRequest.getDisplayStacks()returns an empty list.- Specified by:
getDisplayIconin interfaceIRequest<R extends IRequestable>- Returns:
- The ResourceLocation of the Image dat is displayed when their are no DisplayStacks.
-
getResolverToolTip
Description copied from interface:IRequestGet the resolver tooltip for a request.- Specified by:
getResolverToolTipin interfaceIRequest<R extends IRequestable>- Parameters:
colony- the colony view to obtain information if necessary.- Returns:
- a list of strings or empty.
-
getDisplayStacks
Description copied from interface:IRequestMethod 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.- Specified by:
getDisplayStacksin interfaceIRequest<R extends IRequestable>- Returns:
- A List of ItemStacks that represents this request.
-
getRequestOfType
Description copied from interface:IRequestGet a request of a specific type.- Specified by:
getRequestOfTypein interfaceIRequest<R extends IRequestable>- Type Parameters:
T- the type.- Parameters:
tClass- the class of it.- Returns:
- the request of this particular type.
-
equals
-
hashCode
public int hashCode() -
getSuperClasses
Description copied from interface:IRequestGet all super classes of this type (cached value).- Specified by:
getSuperClassesin interfaceIRequest<R extends IRequestable>- Returns:
- an immutable copy of the set.
-