use of com.minecolonies.api.colony.requestsystem.resolver.IRequestResolver in project minecolonies by Minecolonies.
the class BuildingWareHouse method getResolvers.
@Override
public ImmutableCollection<IRequestResolver<?>> getResolvers() {
final ImmutableCollection<IRequestResolver<?>> supers = super.getResolvers();
final ImmutableList.Builder<IRequestResolver<?>> builder = ImmutableList.builder();
builder.addAll(supers);
builder.add(new WarehouseRequestResolver(getRequester().getRequesterLocation(), getColony().getRequestManager().getFactoryController().getNewInstance(TypeConstants.ITOKEN)));
return builder.build();
}
use of com.minecolonies.api.colony.requestsystem.resolver.IRequestResolver in project minecolonies by Minecolonies.
the class RequestHandler method reassignRequest.
/**
* Method used to reassign the request to a resolver that is not in the given blacklist.
* Cancels the request internally without notify the requester, and attempts a reassign. If the reassignment failed, it is assigned back to the orignal resolver.
*
* @param manager The manager that is reassigning a request.
* @param request The request that is being reassigned.
* @param resolverTokenBlackList The blacklist to which not to assign the request.
* @return The token of the resolver that has gotten the request assigned, null if none was found.
*
* @throws IllegalArgumentException Thrown when something went wrong.
*/
public static IToken<?> reassignRequest(final IStandardRequestManager manager, final IRequest<?> request, final Collection<IToken<?>> resolverTokenBlackList) {
// Get the current resolver
IRequestResolver currentResolver = null;
if (RequestHandler.isAssigned(manager, request.getToken())) {
currentResolver = ResolverHandler.getResolverForRequest(manager, request);
}
IToken<?> parent = null;
if (request.hasParent()) {
parent = request.getParent();
}
// Cancel the request to restart the search
processInternalCancellation(manager, request.getToken());
if (currentResolver != null) {
if (manager.getRequestResolverRequestAssignmentDataStore().getAssignments().containsKey(currentResolver.getRequesterId())) {
manager.getRequestResolverRequestAssignmentDataStore().getAssignments().get(currentResolver.getRequesterId()).remove(request.getToken());
if (manager.getRequestResolverRequestAssignmentDataStore().getAssignments().get(currentResolver.getRequesterId()).isEmpty()) {
manager.getRequestResolverRequestAssignmentDataStore().getAssignments().remove(currentResolver.getRequesterId());
}
}
}
manager.updateRequestState(request.getToken(), RequestState.REPORTED);
IToken<?> resolver = assignRequest(manager, request, resolverTokenBlackList);
if (parent != null) {
request.setParent(parent);
final IRequest parentRequest = RequestHandler.getRequest(manager, parent);
parentRequest.addChild(request.getToken());
}
return resolver;
}
Aggregations