use of com.minecolonies.api.colony.requestsystem.resolver.player.IPlayerRequestResolver in project minecolonies by Minecolonies.
the class WindowClipBoard method getOpenRequests.
private ImmutableList<IRequest> getOpenRequests() {
final ArrayList<IRequest> requests = Lists.newArrayList();
final ColonyView view = ColonyManager.getColonyView(colonyId);
if (view == null) {
return ImmutableList.of();
}
final IPlayerRequestResolver resolver = view.getRequestManager().getPlayerResolver();
final IRetryingRequestResolver retryingRequestResolver = view.getRequestManager().getRetryingRequestResolver();
final Set<IToken> requestTokens = new HashSet<>();
requestTokens.addAll(resolver.getAllAssignedRequests());
requestTokens.addAll(retryingRequestResolver.getAllAssignedRequests());
requests.addAll(requestTokens.stream().map(view.getRequestManager()::getRequestForToken).filter(Objects::nonNull).collect(Collectors.toSet()));
final BlockPos playerPos = Minecraft.getMinecraft().player.getPosition();
requests.sort(Comparator.comparing((IRequest request) -> request.getRequester().getDeliveryLocation().getInDimensionLocation().getDistance(playerPos.getX(), playerPos.getY(), playerPos.getZ())).thenComparingInt(request -> request.getToken().hashCode()));
return ImmutableList.copyOf(requests);
}
Aggregations