use of com.minecolonies.api.colony.requestsystem.requestable.deliveryman.IDeliverymanRequestable in project minecolonies by ldtteam.
the class WindowHutCrafterTaskModule method onOpened.
@Override
public void onOpened() {
super.onOpened();
final List<IToken<?>> tasks = new ArrayList<>();
for (final WorkerBuildingModuleView moduleView : buildingView.getModuleViews(WorkerBuildingModuleView.class)) {
for (final int citizenId : moduleView.getAssignedCitizens()) {
ICitizenDataView citizen = buildingView.getColony().getCitizen(citizenId);
if (citizen != null) {
if (citizen.getJobView() instanceof CrafterJobView) {
tasks.addAll(((CrafterJobView) citizen.getJobView()).getDataStore().getQueue());
} else if (citizen.getJobView() instanceof DmanJobView) {
tasks.addAll(((DmanJobView) citizen.getJobView()).getDataStore().getQueue());
}
}
}
}
final ScrollingList deliveryList = findPaneOfTypeByID(LIST_TASKS, ScrollingList.class);
deliveryList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
tasks.removeIf(token -> buildingView.getColony().getRequestManager().getRequestForToken(token) == null);
return tasks.size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
final IRequest<?> request = buildingView.getColony().getRequestManager().getRequestForToken(tasks.get(index));
final IRequest<?> parent = buildingView.getColony().getRequestManager().getRequestForToken(request.getParent());
if (parent != null) {
rowPane.findPaneOfTypeByID(REQUESTER, Text.class).setText(request.getRequester().getRequesterDisplayName(buildingView.getColony().getRequestManager(), request).getString() + " ->");
rowPane.findPaneOfTypeByID(PARENT, Text.class).setText(parent.getRequester().getRequesterDisplayName(buildingView.getColony().getRequestManager(), parent));
} else {
rowPane.findPaneOfTypeByID(REQUESTER, Text.class).setText(request.getRequester().getRequesterDisplayName(buildingView.getColony().getRequestManager(), request));
rowPane.findPaneOfTypeByID(PARENT, Text.class).clearText();
}
rowPane.findPaneOfTypeByID(REQUEST_SHORT_DETAIL, Text.class).setText(request.getShortDisplayString().getString().replace("§f", ""));
if (request.getRequest() instanceof IDeliverymanRequestable) {
rowPane.findPaneOfTypeByID(REQUEST_PRIORITY, Text.class).setText(LanguageHandler.format(COM_MINECOLONIES_COREMOD_ENTITY_DELIVERYMAN_PRIORITY) + ((IDeliverymanRequestable) (request.getRequest())).getPriority());
}
final Image logo = rowPane.findPaneOfTypeByID(DELIVERY_IMAGE, Image.class);
logo.setImage(request.getDisplayIcon());
}
});
}
Aggregations