Class AbstractWarehouseRequestResolver
- All Implemented Interfaces:
IRequester,IRequestResolver<IDeliverable>
- Direct Known Subclasses:
WarehouseConcreteRequestResolver,WarehouseRequestResolver
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractWarehouseRequestResolver(@NotNull ILocation location, @NotNull IToken<?> token) -
Method Summary
Modifier and TypeMethodDescriptionattemptResolveRequest(@NotNull IRequestManager manager, @NotNull IRequest<? extends IDeliverable> request) Method used to attempt a resolving operation.booleancanResolveRequest(@NotNull IRequestManager manager, IRequest<? extends IDeliverable> requestToCheck) A PreCheck used to determine if this request resolver is able to resolve a given request.getFollowupRequestForCompletion(@NotNull IRequestManager manager, @NotNull IRequest<? extends IDeliverable> completedRequest) intThe priority of this resolver.@NotNull net.minecraft.network.chat.MutableComponentgetRequesterDisplayName(@NotNull IRequestManager manager, @NotNull IRequest<?> request) Gets the name of the requester that requested the request given by the token.com.google.common.reflect.TypeToken<? extends IDeliverable>Used to determine which type of requests can be resolved by this Resolver.intgetSuitabilityMetric(@NotNull IRequestManager manager, @NotNull IRequest<? extends IDeliverable> request) Check how suitable this resolver is for the request.protected abstract intgetWarehouseInternalCount(BuildingWareHouse wareHouse, IRequest<? extends IDeliverable> requestToCheck) Override to implement specific warehouse counting rules.booleanisRequestChainValid(@NotNull IRequestManager manager, IRequest<?> requestToCheck) Use to verify that a request chain is valid, and doesn't contain recursive cycles.booleanisValid()If this resolver has valid data in it.voidonAssignedRequestBeingCancelled(@NotNull IRequestManager manager, @NotNull IRequest<? extends IDeliverable> request) Indicates that an assigned request has been cancelled.voidonAssignedRequestCancelled(@NotNull IRequestManager manager, @NotNull IRequest<? extends IDeliverable> request) Indicates that an assigned request has been cancelled.voidonRequestedRequestCancelled(@NotNull IRequestManager manager, @NotNull IRequest<?> request) Method called by the request system to notify this requester that a request has been overruled.voidonRequestedRequestComplete(@NotNull IRequestManager manager, @NotNull IRequest<?> request) Method called by the request system to notify this requester that a request is complete.voidresolveRequest(@NotNull IRequestManager manager, @NotNull IRequest<? extends IDeliverable> request) Method used to resolve a given request.Methods inherited from class com.minecolonies.core.colony.requestsystem.resolvers.core.AbstractRequestResolver
getId, getLocationMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.requestsystem.resolver.IRequestResolver
onColonyUpdate, onRequestAssigned
-
Constructor Details
-
AbstractWarehouseRequestResolver
-
-
Method Details
-
getRequestType
Description copied from interface:IRequestResolverUsed to determine which type of requests can be resolved by this Resolver.- Returns:
- The class that represents this Type of Request this resolver can resolve.
-
getWarehouseInternalCount
protected abstract int getWarehouseInternalCount(BuildingWareHouse wareHouse, IRequest<? extends IDeliverable> requestToCheck) Override to implement specific warehouse counting rules.- Parameters:
wareHouse- the warehouse to check.requestToCheck- the requested item.- Returns:
- the available quantity.
-
canResolveRequest
public boolean canResolveRequest(@NotNull @NotNull IRequestManager manager, IRequest<? extends IDeliverable> requestToCheck) Description copied from interface:IRequestResolverA PreCheck used to determine if this request resolver is able to resolve a given request. Should quickly and cheaply check if this resolver COULD resolve this request.- Parameters:
manager- The manager that is checking if this resolver could resolve that request.requestToCheck- The request to check.- Returns:
- True when this resolver COULD resolve the given request, false when not.
-
isRequestChainValid
public boolean isRequestChainValid(@NotNull @NotNull IRequestManager manager, IRequest<?> requestToCheck) Use to verify that a request chain is valid, and doesn't contain recursive cycles.- Parameters:
manager-requestToCheck-- Returns:
-
attemptResolveRequest
@Nullable public @Nullable List<IToken<?>> attemptResolveRequest(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends IDeliverable> request) Description copied from interface:IRequestResolverMethod used to attempt a resolving operation.When this attempt was successful a List with tokens of required requests is returned. This list maybe empty. The list should indicate all sub requests that should be fullfilled before the @code{resolve(IRequest request)} method is called.
When this attempt was not successful, eg. this resolver could not schedule a crafting operation, a Null object should be returned. In that case the next resolver will be tried by the manager.
IT IS VITAL THAT THE REQUEST RETURNED ARE NOT YET ASSIGNED. SIMULATION AND OTHER STRATEGIES WILL FAIL ELSE! THE MANAGER GIVEN WILL HANDLE ASSIGNING HIMSELF!
- Parameters:
manager- The manager that is attempting to resolve using this resolver.request- The request to resolve.- Returns:
- The tokens of required requests if the attempt was successful (an empty list is allowed to indicate no requirements), null if the attempt failed.
-
resolveRequest
public void resolveRequest(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends IDeliverable> request) Description copied from interface:IRequestResolverMethod used to resolve a given request. Is called the moment all Child requests are resolved.The resolver should update the state through the given manager.
When this method is called all requirements need be fullfilled for this resolver. If this is not the case it will throw a RunTimeException
- Parameters:
manager- The manager that is resolving this request, under normal conditions this is the colony manager.request- The request to resolve.
-
getFollowupRequestForCompletion
@Nullable public @Nullable List<IRequest<?>> getFollowupRequestForCompletion(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends IDeliverable> completedRequest) -
onAssignedRequestBeingCancelled
public void onAssignedRequestBeingCancelled(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends IDeliverable> request) Description copied from interface:IRequestResolverIndicates that an assigned request has been cancelled. Is called before graph is updated.- Parameters:
manager- The manager that indicates the cancellingrequest- The request that has been cancelled.
-
onAssignedRequestCancelled
public void onAssignedRequestCancelled(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends IDeliverable> request) Description copied from interface:IRequestResolverIndicates that an assigned request has been cancelled. Is called after the graph has been updated.- Parameters:
manager- The manager that indicates the cancellingrequest- The request that has been cancelled.
-
onRequestedRequestComplete
public void onRequestedRequestComplete(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<?> request) Description copied from interface:IRequesterMethod called by the request system to notify this requester that a request is complete.- Parameters:
manager- the request manager.request- the request.
-
onRequestedRequestCancelled
public void onRequestedRequestCancelled(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<?> request) Description copied from interface:IRequesterMethod called by the request system to notify this requester that a request has been overruled.- Parameters:
manager- the request manager.request- the request.
-
getRequesterDisplayName
@NotNull public @NotNull net.minecraft.network.chat.MutableComponent getRequesterDisplayName(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<?> request) Description copied from interface:IRequesterGets the name of the requester that requested the request given by the token.- Specified by:
getRequesterDisplayNamein interfaceIRequester- Overrides:
getRequesterDisplayNamein classAbstractRequestResolver<IDeliverable>- Parameters:
manager- the request manager.request- the request for which the name of the requester is retrieved- Returns:
- The display name of the requester.
-
getPriority
public int getPriority()Description copied from interface:IRequestResolverThe priority of this resolver. The higher the priority the earlier this resolver is called.- Specified by:
getPriorityin interfaceIRequestResolver<IDeliverable>- Overrides:
getPriorityin classAbstractRequestResolver<IDeliverable>- Returns:
- The priority of this resolver.
-
isValid
public boolean isValid()Description copied from interface:IRequestResolverIf this resolver has valid data in it.- Returns:
- true if so.
-
getSuitabilityMetric
public int getSuitabilityMetric(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<? extends IDeliverable> request) Description copied from interface:IRequestResolverCheck how suitable this resolver is for the request.- Specified by:
getSuitabilityMetricin interfaceIRequestResolver<IDeliverable>- Overrides:
getSuitabilityMetricin classAbstractRequestResolver<IDeliverable>- Parameters:
manager- the req manager.request- the request to check.- Returns:
- the suitability metric (an int for easy comparison).
-