use of com.minecolonies.api.util.constant.TranslationConstants.OUT_OF_COLONY in project minecolonies by Minecolonies.
the class WorkManager method addWorkOrder.
/**
* Adds work order to the work manager.
*
* @param order Order adding.
* @param readingFromNbt if being read from NBT.
*/
@Override
public void addWorkOrder(@NotNull final IWorkOrder order, final boolean readingFromNbt) {
dirty = true;
if (!(order instanceof WorkOrderMiner)) {
for (final IWorkOrder or : workOrders.values()) {
if (or.getLocation().equals(order.getLocation()) && or.getStructureName().equals(order.getStructureName())) {
Log.getLogger().warn("Avoiding adding duplicate workOrder");
removeWorkOrder(or);
break;
}
}
if (!readingFromNbt && !isWorkOrderWithinColony(order)) {
MessageUtils.format(OUT_OF_COLONY, order.getDisplayName(), order.getLocation().getX(), order.getLocation().getZ()).sendTo(colony).forAllPlayers();
return;
}
}
if (order.getID() == 0) {
topWorkOrderId++;
order.setID(topWorkOrderId);
}
if (!readingFromNbt) {
final StructureName structureName = new StructureName(order.getStructureName());
if (order instanceof WorkOrderBuilding) {
final int level = order.getTargetLevel();
AdvancementUtils.TriggerAdvancementPlayersForColony(colony, player -> AdvancementTriggers.CREATE_BUILD_REQUEST.trigger(player, structureName, level));
} else if (order instanceof WorkOrderDecoration) {
AdvancementUtils.TriggerAdvancementPlayersForColony(colony, player -> AdvancementTriggers.CREATE_BUILD_REQUEST.trigger(player, structureName, 0));
}
}
workOrders.put(order.getID(), order);
order.onAdded(colony, readingFromNbt);
}
Aggregations