Class StructureFinder
For example, given a set of structures with the names "myDoor", "myPortcullis", "flagThatIsMine", this can be used to
retrieve "myDoor" and "myPortcullis" from a search input of "my" (provided both structures are owned by the
ICommandSender responsible for the search request.)
This class uses a RollingCache to keep track of provided
inputs. This allows both narrowing the search results from new input and rolling back to previous states (e.g. when
fixing typos) without causing new database requests. For example, assume we have an input of "My" and some returned
results "MyPortcullis" and "MyWindmill". If the next input is then "MyW", the finder will return only "MyWindmill"
without querying the database again.
The finder uses the command sender to determine which structures are visible to the user if the command sender is a player. If the command sender is the console, all structures are visible.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents a minimal description of a structure. -
Method Summary
Modifier and TypeMethodDescriptionGets all structures that have been found using the given search parameters as aStructureRetriever.asRetriever(boolean fullMatch) Gets all structures that have been found using the given search parameters as aStructureRetriever.Gets the identifiers of all the structures that have been found using the given search parameters.getStructureIdentifiers(boolean fullMatch) Gets the identifiers of all the structures that have been found using the given search parameters.Tries to get all identifiers of structures that have been found, if any.getStructureIdentifiersIfAvailable(boolean fullMatch) Tries to get all identifiers of structures that have been found, if any.Gets all structures that have been found using the given search parameters.getStructures(boolean fullMatch) Gets all structures that have been found using the given search parameters as a list ofStructures.Optional<it.unimi.dsi.fastutil.longs.LongSet> Gets the UIDs of all the structures that have been found using the given search parameters.Optional<it.unimi.dsi.fastutil.longs.LongSet> getStructureUIDs(boolean fullMatch) Gets the UIDs of all the structures that have been found using the given search parameters.processInput(String input, Collection<Property<?>> properties) Processes the given input.
-
Method Details
-
processInput
Processes the given input.If the new input starts with the last input, the new input is used to narrow down the search results.
If the new input does not start with the last input, an attempt is made to roll back the search results to a previous state where the last input was a prefix of the new input. If this is not possible, the search is restarted.
- Parameters:
input- The input to process.properties-- Returns:
- The current instance of this class.
-
getStructureIdentifiersIfAvailable
Tries to get all identifiers of structures that have been found, if any.This method will return an empty optional if the search is still active on another thread.
This method uses the default value for fullMatch. See
DEFAULT_FULL_MATCH.This is a shortcut for
getStructureIdentifiersIfAvailable(boolean).- Returns:
- A list of all structure identifiers (i.e. names or UIDs) of structures that have been found if the search has returned any results. If the search is still active on another thread, this will return an empty optional.
-
getStructureIdentifiersIfAvailable
Tries to get all identifiers of structures that have been found, if any.This method will return an empty optional if the search is still active on another thread.
- Parameters:
fullMatch- When true, only the entries that have a complete match are returned. E.g. for an input of "door", "door" would be returned, but "door1" would not. Gets the UIDs of all the structures that have been found so far. Defaults to false.- Returns:
- A list of all structure identifiers (i.e. names or UIDs) of structures that have been found if the search has returned any results. If the search is still active on another thread, this will return an empty optional.
-
getStructureIdentifiers
Gets the identifiers of all the structures that have been found using the given search parameters.This method uses the default value for fullMatch. See
DEFAULT_FULL_MATCH.This is a shortcut for
getStructureIdentifiers(boolean).- Returns:
- A list of all identifiers that match the given search parameters. An identifier here can refer to both
-
getStructureIdentifiers
Gets the identifiers of all the structures that have been found using the given search parameters.- Parameters:
fullMatch- When true, only the entries that have a complete match are returned. E.g. for an input of "door", "door" would be returned, but "door1" would not. Gets the UIDs of all the structures that have been found so far. Defaults to false.- Returns:
- A list of all identifiers that match the given search parameters. An identifier here can refer to both the UIDs or the names of the structures that match the query.
-
getStructureUIDs
Gets the UIDs of all the structures that have been found using the given search parameters.This method uses the default value for fullMatch. See
DEFAULT_FULL_MATCH.This is a shortcut for
getStructureUIDs(boolean).- Returns:
- All structure UIDs that have been found if any have been found.
-
getStructureUIDs
Gets the UIDs of all the structures that have been found using the given search parameters.- Parameters:
fullMatch- When true, only the entries that have a complete match are returned. E.g. for an input of "door", "door" would be returned, but "door1" would not. Gets the UIDs of all the structures that have been found so far. Defaults to false.- Returns:
- All structure UIDs that have been found if any have been found.
-
getStructures
Gets all structures that have been found using the given search parameters.This method uses the default value for fullMatch. See
DEFAULT_FULL_MATCH.This is a shortcut for
getStructures(boolean).- Returns:
- A list of all structures that match the given search parameters.
-
asRetriever
Gets all structures that have been found using the given search parameters as aStructureRetriever.- Parameters:
fullMatch- When true, only the entries that have a complete match are returned. E.g. for an input of "door", "door" would be returned, but "door1" would not. Gets the UIDs of all the structures that have been found so far. Defaults to false.- Returns:
- The result as a
StructureRetriever.
-
asRetriever
Gets all structures that have been found using the given search parameters as aStructureRetriever.This method uses the default value for fullMatch. See
DEFAULT_FULL_MATCH.This is a shortcut for
asRetriever(boolean).- Returns:
- The result as a
StructureRetriever.
-
getStructures
Gets all structures that have been found using the given search parameters as a list ofStructures.- Parameters:
fullMatch- When true, only the entries that have a complete match are returned. E.g. for an input of "door", "door" would be returned, but "door1" would not. Gets the UIDs of all the structures that have been found so far. Defaults to false.- Returns:
- A list of all structures that match the given search parameters.
-