Search in sources :

Example 1 with Pickup

use of com.minecolonies.api.colony.requestsystem.requestable.deliveryman.Pickup in project minecolonies by Minecolonies.

the class AbstractBuilding method createPickupRequest.

@Override
public boolean createPickupRequest(final int scaledPriority) {
    if (scaledPriority < 0 || scaledPriority > getPlayerActionPriority(true)) {
        return false;
    }
    final List<IToken<?>> reqs = new ArrayList<>(getOpenRequestsByRequestableType().getOrDefault(TypeConstants.PICKUP, Collections.emptyList()));
    if (!reqs.isEmpty()) {
        for (final IToken<?> req : reqs) {
            final IRequest<?> request = colony.getRequestManager().getRequestForToken(req);
            if (request != null && request.getState() == RequestState.IN_PROGRESS) {
                final IRequestResolver<?> resolver = colony.getRequestManager().getResolverForRequest(req);
                if (resolver instanceof IPlayerRequestResolver || resolver instanceof IRetryingRequestResolver) {
                    colony.getRequestManager().reassignRequest(req, Collections.emptyList());
                }
            }
        }
        return false;
    }
    createRequest(new Pickup(scaledPriority), true);
    return true;
}
Also used : IToken(com.minecolonies.api.colony.requestsystem.token.IToken) Pickup(com.minecolonies.api.colony.requestsystem.requestable.deliveryman.Pickup) IPlayerRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.player.IPlayerRequestResolver) IRetryingRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.retrying.IRetryingRequestResolver)

Example 2 with Pickup

use of com.minecolonies.api.colony.requestsystem.requestable.deliveryman.Pickup in project minecolonies by ldtteam.

the class AbstractBuilding method createPickupRequest.

@Override
public boolean createPickupRequest(final int scaledPriority) {
    if (scaledPriority < 0 || scaledPriority > getPlayerActionPriority(true)) {
        return false;
    }
    final List<IToken<?>> reqs = new ArrayList<>(getOpenRequestsByRequestableType().getOrDefault(TypeConstants.PICKUP, Collections.emptyList()));
    if (!reqs.isEmpty()) {
        for (final IToken<?> req : reqs) {
            final IRequest<?> request = colony.getRequestManager().getRequestForToken(req);
            if (request != null && request.getState() == RequestState.IN_PROGRESS) {
                final IRequestResolver<?> resolver = colony.getRequestManager().getResolverForRequest(req);
                if (resolver instanceof IPlayerRequestResolver || resolver instanceof IRetryingRequestResolver) {
                    colony.getRequestManager().reassignRequest(req, Collections.emptyList());
                }
            }
        }
        return false;
    }
    createRequest(new Pickup(scaledPriority), true);
    return true;
}
Also used : IToken(com.minecolonies.api.colony.requestsystem.token.IToken) Pickup(com.minecolonies.api.colony.requestsystem.requestable.deliveryman.Pickup) IPlayerRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.player.IPlayerRequestResolver) IRetryingRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.retrying.IRetryingRequestResolver)

Aggregations

Pickup (com.minecolonies.api.colony.requestsystem.requestable.deliveryman.Pickup)2 IPlayerRequestResolver (com.minecolonies.api.colony.requestsystem.resolver.player.IPlayerRequestResolver)2 IRetryingRequestResolver (com.minecolonies.api.colony.requestsystem.resolver.retrying.IRetryingRequestResolver)2 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)2