Class StandardRequestManager
java.lang.Object
com.minecolonies.core.colony.requestsystem.management.manager.StandardRequestManager
- All Implemented Interfaces:
IRequestManager,ITickable,IStandardRequestManager,net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
Main class of the request system. Default implementation of the IRequestManager interface.
Uses
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidassignRequest(@NotNull IToken<?> token) Method used to assign a request to a resolver.<T extends IRequestable>
@NotNull IToken<?>createAndAssignRequest(@NotNull IRequester requester, T object) Method used to create and immediately assign a request.<T extends IRequestable>
@NotNull IToken<?>createRequest(@NotNull IRequester requester, T object) Method to create a request for a given objectvoiddeserialize(IFactoryController controller, net.minecraft.network.FriendlyByteBuf buffer) deserialize this request manager from the giveFriendlyByteBufvoiddeserializeNBT(net.minecraft.nbt.CompoundTag nbt) Method used to deserialize the data inside the given nbt tag into this request system.@NotNull IColonyThe colony this manager manages the requests for.int@NotNull IDataStoreManagerGet the data store manager.@NotNull IFactoryControllerMethod used to get the FactoryController of the RequestManager.@NotNull IPlayerRequestResolverGet the player resolve.@NotNull IProviderResolverAssignmentDataStore@Nullable IRequest<?>getRequestForToken(@NotNull IToken<?> token) Method to get a request for a given token.@NotNull IRequestIdentitiesDataStore@NotNull IRequestResolverIdentitiesDataStore@Nullable IRequestResolver<?>getResolverForRequest(@NotNull IToken<?> requestToken) Method to get a resolver for a given request.@NotNull IRequestResolver<?>getResolverForToken(@NotNull IToken<?> token) Method to get a resolver from its token.@NotNull IRetryingRequestResolverGet the retrying request resolver.booleanisDirty()Check if the request manager is dirty.voidLog a debug message.voidMark the request manager and colony as dirty.voidonColonyUpdate(@NotNull Predicate<IRequest<?>> shouldTriggerReassign) Method used to reassign requests based on a predicate.voidonProviderAddedToColony(@NotNull IRequestResolverProvider provider) Method used to indicate to this manager that a new Provider has been added to the colony.voidonProviderRemovedFromColony(@NotNull IRequestResolverProvider provider) Method used to indicate to this manager that Provider has been removed from the colony.voidonRequesterRemovedFromColony(@NotNull IRequester requester) Method used to indicate to this manager that a Requster has been removed from the colony.voidoverruleRequest(@NotNull IToken<?> token, @Nullable net.minecraft.world.item.ItemStack stack) Method used to overrule a request.@Nullable IToken<?>reassignRequest(@NotNull IToken<?> token, @NotNull Collection<IToken<?>> resolverTokenBlackList) Method used to reassign a given request.voidreset()Called to reset the RS.voidserialize(IFactoryController controller, net.minecraft.network.FriendlyByteBuf buffer) serialize this request manager to the giveFriendlyByteBufnet.minecraft.nbt.CompoundTagMethod used to serialize the current request system to NBT.voidsetCurrentVersion(int currentVersion) voidsetDirty(boolean isDirty) Sets if dirty and needs to be updated.voidtick()Default parameterless ticking implementation.voidupdateRequestState(@NotNull IToken<?> token, @NotNull RequestState state) Method to update the state of a given request.
-
Constructor Details
-
StandardRequestManager
-
-
Method Details
-
getColony
The colony this manager manages the requests for.- Specified by:
getColonyin interfaceIRequestManager- Returns:
- The colony this manager manages the requests for.
-
getFactoryController
Method used to get the FactoryController of the RequestManager.- Specified by:
getFactoryControllerin interfaceIRequestManager- Returns:
- The FactoryController of this RequestManager.
-
createRequest
@NotNull public <T extends IRequestable> @NotNull IToken<?> createRequest(@NotNull @NotNull IRequester requester, @NotNull T object) Method to create a request for a given object- Specified by:
createRequestin interfaceIRequestManager- Type Parameters:
T- The type of request.- Parameters:
requester- The requester.object- The Object that is being requested.- Returns:
- The token representing the request.
- Throws:
IllegalArgumentException- is thrown when this manager cannot produce a request for the given types.
-
markDirty
public void markDirty()Mark the request manager and colony as dirty.- Specified by:
markDirtyin interfaceIRequestManager
-
isDirty
public boolean isDirty()Check if the request manager is dirty.- Specified by:
isDirtyin interfaceIRequestManager- Returns:
- true if so.
-
setDirty
public void setDirty(boolean isDirty) Description copied from interface:IRequestManagerSets if dirty and needs to be updated.- Specified by:
setDirtyin interfaceIRequestManager- Parameters:
isDirty- true if so.
-
assignRequest
Method used to assign a request to a resolver.- Specified by:
assignRequestin interfaceIRequestManager- Parameters:
token- The token of the request to assign.- Throws:
IllegalArgumentException- when the token is not registered to a request, or is already assigned to a resolver.
-
createAndAssignRequest
@NotNull public <T extends IRequestable> @NotNull IToken<?> createAndAssignRequest(@NotNull @NotNull IRequester requester, @NotNull T object) Method used to create and immediately assign a request.- Specified by:
createAndAssignRequestin interfaceIRequestManager- Type Parameters:
T- The type of the requestable- Parameters:
requester- The requester of the requestable.object- The requestable- Returns:
- The token that represents the request.
- Throws:
IllegalArgumentException- when either createRequest or assignRequest have thrown an IllegalArgumentException
-
reassignRequest
@Nullable public @Nullable IToken<?> reassignRequest(@NotNull @NotNull IToken<?> token, @NotNull @NotNull Collection<IToken<?>> resolverTokenBlackList) Description copied from interface:IRequestManagerMethod used to reassign a given request.- Specified by:
reassignRequestin interfaceIRequestManager- Parameters:
token- The token of the request that should be reassigned.resolverTokenBlackList- the blacklist.- Returns:
- The token of the resolver that has gotten the assignment, null if none was found.
-
getRequestForToken
@Nullable public @Nullable IRequest<?> getRequestForToken(@NotNull @NotNull IToken<?> token) throws IllegalArgumentException Description copied from interface:IRequestManagerMethod to get a request for a given token.- Specified by:
getRequestForTokenin interfaceIRequestManager- Parameters:
token- The token to get a request for.- Returns:
- The request of the given type for that token.
- Throws:
IllegalArgumentException- when the token does not produce a request of the given type T.
-
getResolverForToken
@NotNull public @NotNull IRequestResolver<?> getResolverForToken(@NotNull @NotNull IToken<?> token) throws IllegalArgumentException Description copied from interface:IRequestManagerMethod to get a resolver from its token.- Specified by:
getResolverForTokenin interfaceIRequestManager- Parameters:
token- the token.- Returns:
- The resolver registered with the given token.
- Throws:
IllegalArgumentException- when the token is unknown.
-
getResolverForRequest
@Nullable public @Nullable IRequestResolver<?> getResolverForRequest(@NotNull @NotNull IToken<?> requestToken) throws IllegalArgumentException Description copied from interface:IRequestManagerMethod to get a resolver for a given request.- Specified by:
getResolverForRequestin interfaceIRequestManager- Parameters:
requestToken- The token of the request to get resolver for.- Returns:
- Null if the request is not yet resolved, or else the assigned resolver.
- Throws:
IllegalArgumentException- Thrown when the token is unknown.
-
updateRequestState
public void updateRequestState(@NotNull @NotNull IToken<?> token, @NotNull @NotNull RequestState state) Method to update the state of a given request.- Specified by:
updateRequestStatein interfaceIRequestManager- Parameters:
token- The token that represents a given request to update.state- The new state of that request.- Throws:
IllegalArgumentException- when the token is unknown to this manager.
-
onProviderAddedToColony
Method used to indicate to this manager that a new Provider has been added to the colony.- Specified by:
onProviderAddedToColonyin interfaceIRequestManager- Parameters:
provider- The new provider.
-
overruleRequest
public void overruleRequest(@NotNull @NotNull IToken<?> token, @Nullable @Nullable net.minecraft.world.item.ItemStack stack) Description copied from interface:IRequestManagerMethod used to overrule a request. Updates the state and sets the delivery if applicable.- Specified by:
overruleRequestin interfaceIRequestManager- Parameters:
token- The token of the request that is being overruled.stack- The stack that should be treated as delivery. If no delivery is possible, this is null.
-
onProviderRemovedFromColony
public void onProviderRemovedFromColony(@NotNull @NotNull IRequestResolverProvider provider) throws IllegalArgumentException Method used to indicate to this manager that Provider has been removed from the colony.- Specified by:
onProviderRemovedFromColonyin interfaceIRequestManager- Parameters:
provider- The removed provider.- Throws:
IllegalArgumentException- is thrown when no provider with the same token is registered.
-
onRequesterRemovedFromColony
public void onRequesterRemovedFromColony(@NotNull @NotNull IRequester requester) throws IllegalArgumentException Description copied from interface:IRequestManagerMethod used to indicate to this manager that a Requster has been removed from the colony.- Specified by:
onRequesterRemovedFromColonyin interfaceIRequestManager- Parameters:
requester- The removed requester.- Throws:
IllegalArgumentException- is thrown when no requester with the same token is registered.
-
onColonyUpdate
Method used to reassign requests based on a predicate.- Specified by:
onColonyUpdatein interfaceIRequestManager- Parameters:
shouldTriggerReassign- The predicate to determine if the request should be reassigned.
-
getPlayerResolver
Get the player resolve.- Specified by:
getPlayerResolverin interfaceIRequestManager- Returns:
- the player resolver object.
-
getRetryingRequestResolver
Description copied from interface:IRequestManagerGet the retrying request resolver.- Specified by:
getRetryingRequestResolverin interfaceIRequestManager- Returns:
- The retrying request resolver.
-
getDataStoreManager
Description copied from interface:IRequestManagerGet the data store manager.- Specified by:
getDataStoreManagerin interfaceIRequestManager- Returns:
- The data store manager.
-
reset
public void reset()Description copied from interface:IRequestManagerCalled to reset the RS.- Specified by:
resetin interfaceIRequestManager
-
serializeNBT
public net.minecraft.nbt.CompoundTag serializeNBT()Method used to serialize the current request system to NBT.- Specified by:
serializeNBTin interfacenet.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>- Returns:
- The NBTData that describes the current request system
-
deserializeNBT
public void deserializeNBT(net.minecraft.nbt.CompoundTag nbt) Method used to deserialize the data inside the given nbt tag into this request system.- Specified by:
deserializeNBTin interfacenet.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>- Parameters:
nbt- The data to deserialize.
-
serialize
Description copied from interface:IRequestManagerserialize this request manager to the giveFriendlyByteBuf- Specified by:
serializein interfaceIRequestManager- Parameters:
controller- the controller.buffer- theFriendlyByteBufto serialize to.
-
deserialize
public void deserialize(IFactoryController controller, net.minecraft.network.FriendlyByteBuf buffer) Description copied from interface:IRequestManagerdeserialize this request manager from the giveFriendlyByteBuf- Specified by:
deserializein interfaceIRequestManager- Parameters:
controller- the controller.buffer- theFriendlyByteBufto deserialize from.
-
log
Description copied from interface:IRequestManagerLog a debug message.- Specified by:
login interfaceIRequestManager- Parameters:
message- the message to log.
-
tick
public void tick()Description copied from interface:ITickableDefault parameterless ticking implementation. -
getRequestIdentitiesDataStore
- Specified by:
getRequestIdentitiesDataStorein interfaceIStandardRequestManager
-
getRequestResolverIdentitiesDataStore
@NotNull public @NotNull IRequestResolverIdentitiesDataStore getRequestResolverIdentitiesDataStore()- Specified by:
getRequestResolverIdentitiesDataStorein interfaceIStandardRequestManager
-
getProviderResolverAssignmentDataStore
@NotNull public @NotNull IProviderResolverAssignmentDataStore getProviderResolverAssignmentDataStore()- Specified by:
getProviderResolverAssignmentDataStorein interfaceIStandardRequestManager
-
getRequestResolverRequestAssignmentDataStore
@NotNull public @NotNull IRequestResolverRequestAssignmentDataStore getRequestResolverRequestAssignmentDataStore()- Specified by:
getRequestResolverRequestAssignmentDataStorein interfaceIStandardRequestManager
-
getRequestableTypeRequestResolverAssignmentDataStore
@NotNull public @NotNull IRequestableTypeRequestResolverAssignmentDataStore getRequestableTypeRequestResolverAssignmentDataStore()- Specified by:
getRequestableTypeRequestResolverAssignmentDataStorein interfaceIStandardRequestManager
-
getProviderHandler
- Specified by:
getProviderHandlerin interfaceIStandardRequestManager
-
getRequestHandler
- Specified by:
getRequestHandlerin interfaceIStandardRequestManager
-
getResolverHandler
- Specified by:
getResolverHandlerin interfaceIStandardRequestManager
-
getTokenHandler
- Specified by:
getTokenHandlerin interfaceIStandardRequestManager
-
getUpdateHandler
- Specified by:
getUpdateHandlerin interfaceIStandardRequestManager
-
getCurrentVersion
public int getCurrentVersion()- Specified by:
getCurrentVersionin interfaceIStandardRequestManager
-
setCurrentVersion
public void setCurrentVersion(int currentVersion) - Specified by:
setCurrentVersionin interfaceIStandardRequestManager
-