Interface IRequestManager
- All Superinterfaces:
net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>,ITickable
- All Known Subinterfaces:
IStandardRequestManager
- All Known Implementing Classes:
AbstractWrappedRequestManager,StandardRequestManager,WrappedBlacklistAssignmentRequestManager,WrappedStaticStateRequestManager
public interface IRequestManager
extends net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>, ITickable
Interface used to describe classes that function as managers for requests inside a colony. Extends INBTSerializable to allow for easy reading and writing from NBT.
-
Method Summary
Modifier and TypeMethodDescriptionvoidassignRequest(@NotNull IToken<?> token) Method used to assign a request to a resolver.default <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 giveFriendlyByteBuf@NotNull IColonyThe colony this manager manages the requests for.@NotNull IDataStoreManagerGet the data store manager.@NotNull IFactoryControllerMethod used to get the FactoryController of the RequestManager.@NotNull IPlayerRequestResolverGet the player resolve.@Nullable IRequest<?>getRequestForToken(@NotNull IToken<?> token) Method to get a request for a given token.@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()Checks if dirty and needs to be updated.voidLog a debug message.voidMarks this manager dirty.voidonColonyUpdate(@NotNull Predicate<IRequest<?>> shouldTriggerReassign) Method used to indicate that a colony has updated their available items.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 giveFriendlyByteBufvoidsetDirty(boolean isDirty) Sets if dirty and needs to be updated.voidupdateRequestState(@NotNull IToken<?> token, @NotNull RequestState state) Method to update the state of a given request.Methods inherited from interface net.minecraftforge.common.util.INBTSerializable
deserializeNBT, serializeNBT
-
Method Details
-
getColony
The colony this manager manages the requests for.- Returns:
- The colony this manager manages the requests for.
-
getFactoryController
Method used to get the FactoryController of the RequestManager.- Returns:
- The FactoryController of this RequestManager.
-
createRequest
@NotNull <T extends IRequestable> @NotNull IToken<?> createRequest(@NotNull @NotNull IRequester requester, @NotNull T object) throws IllegalArgumentException Method to create a request for a given object- 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.
-
assignRequest
Method used to assign a request to a resolver.- 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 default <T extends IRequestable> @NotNull IToken<?> createAndAssignRequest(@NotNull @NotNull IRequester requester, @NotNull T object) throws IllegalArgumentException Method used to create and immediately assign a request.- 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 @Nullable IToken<?> reassignRequest(@NotNull @NotNull IToken<?> token, @NotNull @NotNull Collection<IToken<?>> resolverTokenBlackList) throws IllegalArgumentException Method used to reassign a given request.- 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.
- Throws:
IllegalArgumentException- when the token is not known to this manager.
-
getRequestForToken
@Nullable @Nullable IRequest<?> getRequestForToken(@NotNull @NotNull IToken<?> token) throws IllegalArgumentException Method to get a request for a given token.- 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 @NotNull IRequestResolver<?> getResolverForToken(@NotNull @NotNull IToken<?> token) throws IllegalArgumentException Method to get a resolver from its token.- Parameters:
token- the token.- Returns:
- The resolver registered with the given token.
- Throws:
IllegalArgumentException- when the token is unknown.
-
getResolverForRequest
@Nullable @Nullable IRequestResolver<?> getResolverForRequest(@NotNull @NotNull IToken<?> requestToken) throws IllegalArgumentException Method to get a resolver for a given request.- 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
@NotNull void updateRequestState(@NotNull @NotNull IToken<?> token, @NotNull @NotNull RequestState state) throws IllegalArgumentException Method to update the state of a given request.- 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.
-
overruleRequest
void overruleRequest(@NotNull @NotNull IToken<?> token, @Nullable @Nullable net.minecraft.world.item.ItemStack stack) throws IllegalArgumentException Method used to overrule a request. Updates the state and sets the delivery if applicable.- 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.- Throws:
IllegalArgumentException- Thrown when either token does not match to a request.
-
onProviderAddedToColony
void onProviderAddedToColony(@NotNull @NotNull IRequestResolverProvider provider) throws IllegalArgumentException Method used to indicate to this manager that a new Provider has been added to the colony.- Parameters:
provider- The new provider.- Throws:
IllegalArgumentException- is thrown when a provider with the same token is already registered.
-
onRequesterRemovedFromColony
void onRequesterRemovedFromColony(@NotNull @NotNull IRequester requester) throws IllegalArgumentException Method used to indicate to this manager that a Requster has been removed from the colony.- Parameters:
requester- The removed requester.- Throws:
IllegalArgumentException- is thrown when no requester with the same token is registered.
-
onProviderRemovedFromColony
void onProviderRemovedFromColony(@NotNull @NotNull IRequestResolverProvider provider) throws IllegalArgumentException Method used to indicate to this manager that Provider has been removed from the colony.- Parameters:
provider- The removed provider.- Throws:
IllegalArgumentException- is thrown when no provider with the same token is registered.
-
onColonyUpdate
Method used to indicate that a colony has updated their available items.- Parameters:
shouldTriggerReassign- The request assigned
-
getPlayerResolver
Get the player resolve.- Returns:
- the player resolver object.
-
getRetryingRequestResolver
Get the retrying request resolver.- Returns:
- The retrying request resolver.
-
getDataStoreManager
Get the data store manager.- Returns:
- The data store manager.
-
reset
void reset()Called to reset the RS. -
isDirty
boolean isDirty()Checks if dirty and needs to be updated.- Returns:
- true if so.
-
setDirty
void setDirty(boolean isDirty) Sets if dirty and needs to be updated.- Parameters:
isDirty- true if so.
-
markDirty
void markDirty()Marks this manager dirty. -
log
Log a debug message.- Parameters:
message- the message to log.
-
serialize
serialize this request manager to the giveFriendlyByteBuf- Parameters:
controller- the controller.buffer- theFriendlyByteBufto serialize to.
-
deserialize
deserialize this request manager from the giveFriendlyByteBuf- Parameters:
controller- the controller.buffer- theFriendlyByteBufto deserialize from.
-