use of com.minecolonies.api.colony.requestsystem.request.IRequest 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);
}
use of com.minecolonies.api.colony.requestsystem.request.IRequest in project minecolonies by Minecolonies.
the class WindowClipBoard method cancel.
private void cancel(@NotNull final Button button) {
final int row = resourceList.getListElementIndexByPane(button);
if (getOpenRequests().size() > row && row >= 0) {
@NotNull final IRequest request = getOpenRequests().get(row);
MineColonies.getNetwork().sendToServer(new UpdateRequestStateMessage(colonyId, request.getToken(), RequestState.CANCELLED, null));
}
}
Aggregations