Search in sources :

Example 1 with ColonyViewWorkOrderMessage

use of com.minecolonies.coremod.network.messages.client.colony.ColonyViewWorkOrderMessage in project minecolonies by Minecolonies.

the class ColonyPackageManager method sendWorkOrderPackets.

@Override
public void sendWorkOrderPackets() {
    final IWorkManager workManager = colony.getWorkManager();
    if (workManager.isDirty() || !newSubscribers.isEmpty()) {
        final Set<ServerPlayerEntity> players = new HashSet<>();
        players.addAll(closeSubscribers);
        players.addAll(newSubscribers);
        List<IWorkOrder> workOrders = new ArrayList<>(workManager.getWorkOrders().values());
        players.forEach(player -> Network.getNetwork().sendToPlayer(new ColonyViewWorkOrderMessage(colony, workOrders), player));
        workManager.setDirty(false);
    }
}
Also used : IWorkManager(com.minecolonies.api.colony.workorders.IWorkManager) IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) ArrayList(java.util.ArrayList) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ColonyViewWorkOrderMessage(com.minecolonies.coremod.network.messages.client.colony.ColonyViewWorkOrderMessage) HashSet(java.util.HashSet)

Example 2 with ColonyViewWorkOrderMessage

use of com.minecolonies.coremod.network.messages.client.colony.ColonyViewWorkOrderMessage in project minecolonies by ldtteam.

the class ColonyPackageManager method sendWorkOrderPackets.

@Override
public void sendWorkOrderPackets() {
    final IWorkManager workManager = colony.getWorkManager();
    if (workManager.isDirty() || !newSubscribers.isEmpty()) {
        final Set<ServerPlayerEntity> players = new HashSet<>();
        players.addAll(closeSubscribers);
        players.addAll(newSubscribers);
        List<IWorkOrder> workOrders = new ArrayList<>();
        for (final IWorkOrder workOrder : workManager.getWorkOrders().values()) {
            if (!(workOrder instanceof WorkOrderBuildMiner)) {
                workOrders.add(workOrder);
            }
        }
        players.forEach(player -> Network.getNetwork().sendToPlayer(new ColonyViewWorkOrderMessage(colony, workOrders), player));
        workManager.setDirty(false);
    }
}
Also used : IWorkManager(com.minecolonies.api.colony.workorders.IWorkManager) IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) ArrayList(java.util.ArrayList) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ColonyViewWorkOrderMessage(com.minecolonies.coremod.network.messages.client.colony.ColonyViewWorkOrderMessage) WorkOrderBuildMiner(com.minecolonies.coremod.colony.workorders.WorkOrderBuildMiner) HashSet(java.util.HashSet)

Aggregations

IWorkManager (com.minecolonies.api.colony.workorders.IWorkManager)2 IWorkOrder (com.minecolonies.api.colony.workorders.IWorkOrder)2 ColonyViewWorkOrderMessage (com.minecolonies.coremod.network.messages.client.colony.ColonyViewWorkOrderMessage)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 WorkOrderBuildMiner (com.minecolonies.coremod.colony.workorders.WorkOrderBuildMiner)1