Class StructureTargetCommand
- Direct Known Subclasses:
AddOwner,Delete,Info,Lock,MovePowerBlock,RemoveOwner,SetBlocksToMove,SetOpenDirection,SetOpenStatus
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final recordA simple description of a structure. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final StructureAttributeprotected final StructureRetrieverFields inherited from class nl.pim16aap2.animatedarchitecture.core.commands.BaseCommand
localizer, textFactory -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStructureTargetCommand(ICommandSender commandSender, ILocalizer localizer, ITextFactory textFactory, StructureRetriever structureRetriever, StructureAttribute structureAttribute) protectedStructureTargetCommand(ICommandSender commandSender, ILocalizer localizer, ITextFactory textFactory, StructureRetriever structureRetriever, StructureAttribute structureAttribute, boolean sendUpdatedInfo, @Nullable CommandFactory commandFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected final CompletableFuture<?> executeCommand(PermissionsStatus permissions) Executes the command.Gets all required properties for this command.protected final StructureTargetCommand.StructureDescription@Nullable StructureThe result of thestructureRetriever.protected voidCalled byhandleDatabaseActionResult(DatabaseManager.ActionResult)when the database action was cancelled.protected voidCalled byhandleDatabaseActionResult(DatabaseManager.ActionResult)when the database action failed.protected final voidHandles the results of a database action by informing the user of any non-success states.protected voidCalled byhandleDatabaseActionResult(DatabaseManager.ActionResult)when the database action was successful.protected booleanhasRequiredProperties(Structure structure, List<Property<?>> requiredProperties) Checks if theStructurehas all the required properties.protected booleanChecks if execution of this command is allowed for the givenStructure.protected voidnotifyMissingProperties(Structure structure) Notifies theICommandSenderthat the targetedStructureis missing required properties.protected abstract CompletableFuture<?> performAction(Structure structure) Performs the action of this command on theStructure.protected voidsendUpdatedInfo(Structure structure) Sends the updated info of the structure to theICommandSender.voidsetRetrieverResult(@Nullable Structure retrieverResult) The result of thestructureRetriever.Methods inherited from class nl.pim16aap2.animatedarchitecture.core.commands.BaseCommand
availableForNonPlayers, availableForPlayers, getCommand, getCommandSender, getStructure, hasAccessToAttribute, hasPermission, run, startExecution, toString, validInput
-
Field Details
-
structureRetriever
-
structureAttribute
-
-
Constructor Details
-
StructureTargetCommand
@Contract("_, _, _, _, _, true, null -> fail") protected StructureTargetCommand(ICommandSender commandSender, ILocalizer localizer, ITextFactory textFactory, StructureRetriever structureRetriever, StructureAttribute structureAttribute, boolean sendUpdatedInfo, @Nullable @Nullable CommandFactory commandFactory) -
StructureTargetCommand
protected StructureTargetCommand(ICommandSender commandSender, ILocalizer localizer, ITextFactory textFactory, StructureRetriever structureRetriever, StructureAttribute structureAttribute)
-
-
Method Details
-
executeCommand
Description copied from class:BaseCommandExecutes the command. This method is only called ifBaseCommand.validInput()andBaseCommand.hasPermission()are true.Note that this method is called asynchronously.
- Specified by:
executeCommandin classBaseCommand- Parameters:
permissions- Whether theICommandSenderhas user and/or admin permissions.- Returns:
- The future of the command execution.
-
sendUpdatedInfo
Sends the updated info of the structure to theICommandSender.Only applies if
sendUpdatedInfois true.- Parameters:
structure- The structure to send the updated info of.
-
notifyMissingProperties
Notifies theICommandSenderthat the targetedStructureis missing required properties.- Parameters:
structure- TheStructurethat is missing the required properties.
-
isAllowed
Checks if execution of this command is allowed for the givenStructure.- Parameters:
structure- TheStructurethat is the target for this command.bypassPermission- Whether theICommandSenderhas bypass access.- Returns:
- True if execution of this command is allowed.
-
hasRequiredProperties
Checks if theStructurehas all the required properties. -
performAction
Performs the action of this command on theStructure.- Parameters:
structure- TheStructureto perform the action on.- Returns:
- The future of the command execution.
-
getRetrievedStructureDescription
- Returns:
- The structure description of the
retrieverResult.
-
getRequiredProperties
Gets all required properties for this command.If targeted structure does not have all required properties, the command will not be executed.
By default, this returns an empty list. Subclasses that require specific properties should override this method.
- Returns:
- A list of all required properties.
-
handleDatabaseActionCancelled
protected void handleDatabaseActionCancelled()Called byhandleDatabaseActionResult(DatabaseManager.ActionResult)when the database action was cancelled. -
handleDatabaseActionSuccess
protected void handleDatabaseActionSuccess()Called byhandleDatabaseActionResult(DatabaseManager.ActionResult)when the database action was successful. -
handleDatabaseActionFail
protected void handleDatabaseActionFail()Called byhandleDatabaseActionResult(DatabaseManager.ActionResult)when the database action failed. -
handleDatabaseActionResult
Handles the results of a database action by informing the user of any non-success states.To customize the handling, you can override
handleDatabaseActionFail(),handleDatabaseActionCancelled(), orhandleDatabaseActionSuccess().- Parameters:
result- The result obtained from the database.
-
getStructureRetriever
-
getStructureAttribute
-
getRetrieverResult
The result of thestructureRetriever.This will not be available until after
executeCommand(PermissionsStatus)has started, but beforeperformAction(Structure)is called.Even after the result has been set, it may still be null in case no doors were found.
-
setRetrieverResult
The result of thestructureRetriever.This will not be available until after
executeCommand(PermissionsStatus)has started, but beforeperformAction(Structure)is called.Even after the result has been set, it may still be null in case no doors were found.
-