Class StructureRetriever
Once a StructureRetriever is created, it can be used to retrieve the structure(s) it references using any of
the getStructure methods.
For example:
// Get the referenced structure if there is exactly 1 match.
final CompletableFuture<Optional<Structure>> result =
structureRetriever.getStructure();
// Get the referenced structure if there is exactly 1 match that the player is an admin of.
final CompletableFuture<Optional<Structure>> result =
structureRetriever.getStructure(player, PermissionLevel.ADMIN);
// Get the referenced structure that the player is the creator of. If there is more than 1 match, the player
// will be asked to select one (if supported).
final CompletableFuture<Optional<Structure>> result =
structureRetriever.getStructureInteractive(player, PermissionLevel.CREATOR);
// Get all structures that match the description.
final CompletableFuture<List<Structure>> result =
structureRetriever.getStructures();
// Get all structures that match the description and that the player is a user of.
final CompletableFuture<List<Structure>> result =
structureRetriever.getStructures(player, PermissionLevel.USER);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract CompletableFuture<Optional<Structure>> Gets the structure that is referenced by thisStructureRetrieverif exactly 1 structure matches the description.abstract CompletableFuture<Optional<Structure>> getStructure(IPlayer player, PermissionLevel permissionLevel) Gets the structure that is referenced by thisStructureRetrieverand owned by the provided player if exactly 1 structure matches the description.getStructure(ICommandSender commandSender, PermissionLevel permissionLevel) Gets the structure referenced by thisStructureRetriever.getStructureInteractive(IPlayer player, PermissionLevel permissionLevel) Attempts to retrieve a structure from its specification (seegetStructure(IPlayer, PermissionLevel)).Gets all structures referenced by thisStructureRetriever.getStructures(IPlayer player, PermissionLevel permissionLevel) Gets all structures referenced by thisStructureRetrieverwhere the provided player is a (co)owner of with any permission level.getStructures(ICommandSender commandSender, PermissionLevel permissionLevel) Gets all structures referenced by thisStructureRetriever.
-
Constructor Details
-
StructureRetriever
public StructureRetriever()
-
-
Method Details
-
getStructure
Gets the structure that is referenced by thisStructureRetrieverif exactly 1 structure matches the description.In case the structure is referenced by its name, there may be more than one match (names are not unique). When this happens, no structures are returned.
getStructureInteractive(IPlayer, PermissionLevel)can be used to interactively request the user to select a structure if more than 1 match is found.- Returns:
- The
Structureif it can be found.
-
getStructure
public abstract CompletableFuture<Optional<Structure>> getStructure(IPlayer player, PermissionLevel permissionLevel) Gets the structure that is referenced by thisStructureRetrieverand owned by the provided player if exactly 1 structure matches the description.In case the structure is referenced by its name, there may be more than one match (names are not unique). When this happens, no structures are returned.
getStructureInteractive(IPlayer, PermissionLevel)can be used to interactively request the user to select a structure if more than 1 match is found.- Parameters:
player- TheIPlayerthat owns the structure.permissionLevel- The maximumPermissionLevelof the player for the structure to be returned.- Returns:
- The
Structureif it can be found.
-
getStructure
public CompletableFuture<Optional<Structure>> getStructure(ICommandSender commandSender, PermissionLevel permissionLevel) Gets the structure referenced by thisStructureRetriever.If the
ICommandSenderis a player, seegetStructure(IPlayer, PermissionLevel), otherwise seegetStructure().getStructureInteractive(IPlayer, PermissionLevel)can be used to interactively request the user to select a structure if more than 1 match is found.- Parameters:
commandSender- TheICommandSenderfor whom to retrieve the structures.permissionLevel- The maximumPermissionLevelof the player for the structure to be returned.- Returns:
- The structure referenced by this
StructureRetriever.
-
getStructureInteractive
public CompletableFuture<Optional<Structure>> getStructureInteractive(IPlayer player, PermissionLevel permissionLevel) Attempts to retrieve a structure from its specification (seegetStructure(IPlayer, PermissionLevel)).If more than 1 match was found, the player will be asked to specify which one they asked for specifically.
The amount of time to wait (when required) is determined by
IConfig.specificationTimeout().See
DelayedStructureSpecificationInputRequest.Not every implementation of
StructureRetrieversupports this method, in which case it will return the same asgetStructure(IPlayer, PermissionLevel)(e.g. when retrieving a structure by its UID).- Parameters:
player- The player for whom to get the structure.permissionLevel- The maximumPermissionLevelof the player for the structure to be returned.- Returns:
- The structure as specified by this
StructureRetrieverand with user input in case more than one match was found.
-
getStructures
Gets all structures referenced by thisStructureRetriever.- Returns:
- All structures referenced by this
StructureRetriever.
-
getStructures
public CompletableFuture<List<Structure>> getStructures(IPlayer player, PermissionLevel permissionLevel) Gets all structures referenced by thisStructureRetrieverwhere the provided player is a (co)owner of with any permission level.- Parameters:
player- TheIPlayerthat owns all matching structures.permissionLevel- The maximumPermissionLevelof the player for the structures to be returned.- Returns:
- All structures referenced by this
StructureRetriever.
-
getStructures
public CompletableFuture<List<Structure>> getStructures(ICommandSender commandSender, PermissionLevel permissionLevel) Gets all structures referenced by thisStructureRetriever.If the
ICommandSenderis a player, seegetStructures(IPlayer, PermissionLevel), otherwise seegetStructures().- Parameters:
commandSender- TheICommandSenderfor whom to retrieve the structures.permissionLevel- The maximumPermissionLevelof the player for the structures to be returned.- Returns:
- The structures referenced by this
StructureRetriever.
-