use of com.minecolonies.api.colony.requestsystem.requestable.crafting.PublicCrafting in project minecolonies by Minecolonies.
the class PublicWorkerCraftingProductionResolver method resolveForBuilding.
@Override
public void resolveForBuilding(@NotNull final IRequestManager manager, @NotNull final IRequest<? extends PublicCrafting> request, @NotNull final AbstractBuilding building) {
if (manager.getColony().getWorld().isClientSide) {
return;
}
final ICitizenData freeCrafter = building.getModuleMatching(CraftingWorkerBuildingModule.class, m -> m.getJobEntry() == getJobEntry()).getAssignedCitizen().stream().filter(c -> c.getJob() instanceof AbstractJobCrafter && ((AbstractJobCrafter<?, ?>) c.getJob()).getAssignedTasks().contains(request.getId())).findFirst().orElse(null);
if (freeCrafter == null) {
onAssignedRequestBeingCancelled(manager, request);
return;
}
final AbstractJobCrafter<?, ?> job = (AbstractJobCrafter<?, ?>) freeCrafter.getJob();
job.onTaskBeingResolved(request.getId());
}
use of com.minecolonies.api.colony.requestsystem.requestable.crafting.PublicCrafting in project minecolonies by ldtteam.
the class PublicWorkerCraftingProductionResolver method resolveForBuilding.
@Override
public void resolveForBuilding(@NotNull final IRequestManager manager, @NotNull final IRequest<? extends PublicCrafting> request, @NotNull final AbstractBuilding building) {
if (manager.getColony().getWorld().isClientSide) {
return;
}
final ICitizenData freeCrafter = building.getModuleMatching(CraftingWorkerBuildingModule.class, m -> m.getJobEntry() == getJobEntry()).getAssignedCitizen().stream().filter(c -> c.getJob() instanceof AbstractJobCrafter && ((AbstractJobCrafter<?, ?>) c.getJob()).getAssignedTasks().contains(request.getId())).findFirst().orElse(null);
if (freeCrafter == null) {
onAssignedRequestBeingCancelled(manager, request);
return;
}
final AbstractJobCrafter<?, ?> job = (AbstractJobCrafter<?, ?>) freeCrafter.getJob();
job.onTaskBeingResolved(request.getId());
}
use of com.minecolonies.api.colony.requestsystem.requestable.crafting.PublicCrafting in project minecolonies by ldtteam.
the class PublicWorkerCraftingProductionResolver method onAssignedToThisResolverForBuilding.
@Override
protected void onAssignedToThisResolverForBuilding(@NotNull final IRequestManager manager, @NotNull final IRequest<? extends PublicCrafting> request, final boolean simulation, @NotNull final AbstractBuilding building) {
if (manager.getColony().getWorld().isClientSide) {
return;
}
final ICitizenData freeCrafter = building.getModuleMatching(CraftingWorkerBuildingModule.class, m -> m.getJobEntry() == getJobEntry()).getAssignedCitizen().stream().filter(c -> c.getJob() instanceof AbstractJobCrafter).min(Comparator.comparing((ICitizenData c) -> ((AbstractJobCrafter<?, ?>) c.getJob()).getTaskQueue().size() + ((AbstractJobCrafter<?, ?>) c.getJob()).getAssignedTasks().size())).orElse(null);
if (freeCrafter == null) {
onAssignedRequestBeingCancelled(manager, request);
return;
}
final AbstractJobCrafter<?, ?> job = (AbstractJobCrafter<?, ?>) freeCrafter.getJob();
job.onTaskBeingScheduled(request.getId());
}
Aggregations