Class WorkManager
java.lang.Object
com.minecolonies.core.colony.workorders.WorkManager
- All Implemented Interfaces:
IWorkManager
Handles work orders for a colony.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWorkOrder(@NotNull IServerWorkOrder order, boolean readingFromNbt) Adds work order to the work manager.voidclearWorkForCitizen(@NotNull ICitizenData citizen) When a citizen is removed, unclaim any Work Orders that were claimed by that citizen.Get the colony where this work order has been made.<W extends IServerWorkOrder>
List<W> getOrderedList(Class<W> type, net.minecraft.core.BlockPos builder) Get an ordered list by priority of the work orders.getOrderedList(@NotNull Predicate<IServerWorkOrder> predicate, net.minecraft.core.BlockPos builder) Get an ordered list by priority of the work orders.<W extends IServerWorkOrder>
WgetUnassignedWorkOrder(@NotNull Class<W> type) Get an unclaimed work order of a specified type.getWorkOrder(int id) Get a work order of the specified id.<W extends IServerWorkOrder>
WgetWorkOrder(int id, @NotNull Class<W> type) Get a work order of the specified id, as a specific type.@NotNull Map<Integer, IServerWorkOrder> Get all work orders.<W extends IServerWorkOrder>
List<W> getWorkOrdersOfType(@NotNull Class<W> type) Get all work orders of a specified type.booleanisDirty()Checks if changes has been made.voidonColonyTick(@NotNull IColony colony) Process updates on the Colony Tick.voidread(@NotNull net.minecraft.nbt.CompoundTag compound) Restore the Work Manager.voidremoveWorkOrder(int orderId) Removes a work order from the work manager.voidremoveWorkOrder(@Nullable IServerWorkOrder order) Removes a work order from the work manager.voidsetDirty(boolean dirty) Sets if changes has been made.voidwrite(@NotNull net.minecraft.nbt.CompoundTag compound) Save the Work Manager.
-
Constructor Details
-
WorkManager
Constructor, saves reference to the colony.- Parameters:
c- Colony the work manager is for.
-
-
Method Details
-
removeWorkOrder
Removes a work order from the work manager.- Specified by:
removeWorkOrderin interfaceIWorkManager- Parameters:
order-IWorkOrderto remove.
-
removeWorkOrder
public void removeWorkOrder(int orderId) Removes a work order from the work manager.- Specified by:
removeWorkOrderin interfaceIWorkManager- 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:
getWorkOrderin interfaceIWorkManager- 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
Get a work order of the specified id.- Specified by:
getWorkOrderin interfaceIWorkManager- 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:
getUnassignedWorkOrderin interfaceIWorkManager- 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
Get all work orders of a specified type.- Specified by:
getWorkOrdersOfTypein interfaceIWorkManager- 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
Get all work orders.- Specified by:
getWorkOrdersin interfaceIWorkManager- Returns:
- a list of all work orders.
-
clearWorkForCitizen
When a citizen is removed, unclaim any Work Orders that were claimed by that citizen.- Specified by:
clearWorkForCitizenin interfaceIWorkManager- Parameters:
citizen- Citizen to unclaim work for.
-
write
public void write(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Save the Work Manager.- Specified by:
writein interfaceIWorkManager- Parameters:
compound- Compound to save to.
-
read
public void read(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Restore the Work Manager.- Specified by:
readin interfaceIWorkManager- Parameters:
compound- Compound to read from.
-
addWorkOrder
Adds work order to the work manager.- Specified by:
addWorkOrderin interfaceIWorkManager- Parameters:
order- Order adding.readingFromNbt- if being read from NBT.
-
onColonyTick
Process updates on the Colony Tick. Currently, does periodic Work Order cleanup.- Specified by:
onColonyTickin interfaceIWorkManager- 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:
getOrderedListin interfaceIWorkManager- Type Parameters:
W- the type.- Parameters:
type- the type of workOrder which is required.builder- the builder wanting to claim it.- 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:
getOrderedListin interfaceIWorkManager- Parameters:
predicate- a predicate to check each item againstbuilder- the builder wanting to claim it.- Returns:
- the list.
-
isDirty
public boolean isDirty()Checks if changes has been made.- Specified by:
isDirtyin interfaceIWorkManager- Returns:
- true if so.
-
setDirty
public void setDirty(boolean dirty) Sets if changes has been made.- Specified by:
setDirtyin interfaceIWorkManager- Parameters:
dirty- true if so. False to reset.
-
getColony
Description copied from interface:IWorkManagerGet the colony where this work order has been made.- Specified by:
getColonyin interfaceIWorkManager- Returns:
- the colony.
-