Class WorkManager

java.lang.Object
com.minecolonies.core.colony.workorders.WorkManager
All Implemented Interfaces:
IWorkManager

public class WorkManager extends Object implements IWorkManager
Handles work orders for a colony.
  • Constructor Details

    • WorkManager

      public WorkManager(Colony c)
      Constructor, saves reference to the colony.
      Parameters:
      c - Colony the work manager is for.
  • Method Details

    • removeWorkOrder

      public void removeWorkOrder(@Nullable @Nullable IServerWorkOrder order)
      Removes a work order from the work manager.
      Specified by:
      removeWorkOrder in interface IWorkManager
      Parameters:
      order - IWorkOrder to remove.
    • removeWorkOrder

      public void removeWorkOrder(int orderId)
      Removes a work order from the work manager.
      Specified by:
      removeWorkOrder in interface IWorkManager
      Parameters:
      orderId - ID of the order to remove
    • getWorkOrder

      @Nullable public <W extends IServerWorkOrder> W getWorkOrder(int id, @NotNull @NotNull Class<W> type)
      Get a work order of the specified id, as a specific type.
      Specified by:
      getWorkOrder in interface IWorkManager
      Type Parameters:
      W - the type of work order to return.
      Parameters:
      id - the id of the work order.
      type - the class of the expected type of the work order.
      Returns:
      the work order of the specified id, or null if it was not found or is of an incompatible type.
    • getWorkOrder

      public IServerWorkOrder getWorkOrder(int id)
      Get a work order of the specified id.
      Specified by:
      getWorkOrder in interface IWorkManager
      Parameters:
      id - the id of the work order.
      Returns:
      the work order of the specified id, or null.
    • getUnassignedWorkOrder

      @Nullable public <W extends IServerWorkOrder> W getUnassignedWorkOrder(@NotNull @NotNull Class<W> type)
      Get an unclaimed work order of a specified type.
      Specified by:
      getUnassignedWorkOrder in interface IWorkManager
      Type Parameters:
      W - the type of work order to return.
      Parameters:
      type - the class of the type of work order to find.
      Returns:
      an unclaimed work order of the given type, or null if no unclaimed work order of the type was found.
    • getWorkOrdersOfType

      public <W extends IServerWorkOrder> List<W> getWorkOrdersOfType(@NotNull @NotNull Class<W> type)
      Get all work orders of a specified type.
      Specified by:
      getWorkOrdersOfType in interface IWorkManager
      Type Parameters:
      W - the type of work order to return.
      Parameters:
      type - the class of the type of work order to find.
      Returns:
      a list of all work orders of the given type.
    • getWorkOrders

      @NotNull public @NotNull Map<Integer,IServerWorkOrder> getWorkOrders()
      Get all work orders.
      Specified by:
      getWorkOrders in interface IWorkManager
      Returns:
      a list of all work orders.
    • clearWorkForCitizen

      public void clearWorkForCitizen(@NotNull @NotNull ICitizenData citizen)
      When a citizen is removed, unclaim any Work Orders that were claimed by that citizen.
      Specified by:
      clearWorkForCitizen in interface IWorkManager
      Parameters:
      citizen - Citizen to unclaim work for.
    • write

      public void write(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Save the Work Manager.
      Specified by:
      write in interface IWorkManager
      Parameters:
      compound - Compound to save to.
    • read

      public void read(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Restore the Work Manager.
      Specified by:
      read in interface IWorkManager
      Parameters:
      compound - Compound to read from.
    • addWorkOrder

      public void addWorkOrder(@NotNull @NotNull IServerWorkOrder order, boolean readingFromNbt)
      Adds work order to the work manager.
      Specified by:
      addWorkOrder in interface IWorkManager
      Parameters:
      order - Order adding.
      readingFromNbt - if being read from NBT.
    • onColonyTick

      public void onColonyTick(@NotNull @NotNull IColony colony)
      Process updates on the Colony Tick. Currently, does periodic Work Order cleanup.
      Specified by:
      onColonyTick in interface IWorkManager
      Parameters:
      colony - the colony being ticked.
    • getOrderedList

      public <W extends IServerWorkOrder> List<W> getOrderedList(Class<W> type, net.minecraft.core.BlockPos builder)
      Get an ordered list by priority of the work orders.
      Specified by:
      getOrderedList in interface IWorkManager
      Type Parameters:
      W - the type.
      Parameters:
      builder - the builder wanting to claim it.
      type - the type of workOrder which is required.
      Returns:
      the list.
    • getOrderedList

      public List<IServerWorkOrder> getOrderedList(@NotNull @NotNull Predicate<IServerWorkOrder> predicate, net.minecraft.core.BlockPos builder)
      Get an ordered list by priority of the work orders.
      Specified by:
      getOrderedList in interface IWorkManager
      Parameters:
      builder - the builder wanting to claim it.
      predicate - a predicate to check each item against
      Returns:
      the list.
    • isDirty

      public boolean isDirty()
      Checks if changes has been made.
      Specified by:
      isDirty in interface IWorkManager
      Returns:
      true if so.
    • setDirty

      public void setDirty(boolean dirty)
      Sets if changes has been made.
      Specified by:
      setDirty in interface IWorkManager
      Parameters:
      dirty - true if so. False to reset.
    • getColony

      public IColony getColony()
      Description copied from interface: IWorkManager
      Get the colony where this work order has been made.
      Specified by:
      getColony in interface IWorkManager
      Returns:
      the colony.