Package com.ldtteam.structurize.storage
Class StructurePacks
java.lang.Object
com.ldtteam.structurize.storage.StructurePacks
Class that contains all the structurepacks of the instance.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe representation of a structure pack category (a folder). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic @Nullable StructurePackMetaDeprecated.-> Don't read/write directly, go through methods. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidReset pack state.static voiddiscoverPackAtPath(Path element, boolean immutable, List<String> modList, boolean clientPack, String owner) Discover a structure pack at a given path.static voidEnsure that we have a selected pack.static PathfindBlueprint(String structurePackId, String name) Find a blueprint by name.static BlueprintfindBlueprint(String pack, Path subPath, Predicate<Blueprint> blueprintPredicate) Find blueprint at path.static BlueprintfindBlueprint(String structurePackId, Predicate<Blueprint> blueprintPredicate) Find a blueprint by name.findBlueprint(Path subPath, String name) Find blueprint at path.static CompletableFuture<Path>findBlueprintFuture(String structurePackId, String name) Find a blueprint future.static CompletableFuture<Blueprint>findBlueprintFuture(String structurePackId, Predicate<Blueprint> blueprintPredicate) Find the blueprint asyncstatic @Nullable BlueprintgetBlueprint(String structurePackId, String subPath) Get a blueprint directly (careful IO, might be slow).static @Nullable BlueprintgetBlueprint(String structurePackId, String subPath, boolean suppressError) Get a blueprint directly (careful IO, might be slow).static BlueprintgetBlueprint(String pack, Path path) Get the blueprint directly with a path.static BlueprintgetBlueprint(String pack, Path path, boolean suppressError) Get the blueprint directly with a path.static byte[]getBlueprintData(String structurePackId, String subPath) Get blueprint data directly (careful IO, might be slow).static CompletableFuture<byte[]>getBlueprintDataFuture(String structurePackId, String subPath) Get a blueprint data future.static CompletableFuture<Blueprint>getBlueprintFuture(String structurePackId, String subPath) Get a blueprint future.static CompletableFuture<Blueprint>getBlueprintFuture(String structurePackId, String subPath, boolean suppressError) Get a blueprint future.static CompletableFuture<Blueprint>getBlueprintFuture(String packName, Path path) Get the blueprint directly with a path.static CompletableFuture<Blueprint>getBlueprintFuture(String packName, Path path, boolean suppressError) Get the blueprint directly with a path.getBlueprints(String structurePackId, String subPath) Get a list of blueprints directly (careful IO, might be slow).static CompletableFuture<List<Blueprint>>getBlueprintsFuture(String structurePackId, String subPath) Get a list blueprint future.static List<StructurePacks.Category>getCategories(String structurePackId, String subPath) Get a list of categories of a specific sub-path of a given structure pack.static CompletableFuture<List<StructurePacks.Category>>getCategoriesFuture(String structurePackId, String subPath) Get a list of categories of a specific sub-path of a given structure pack.static Collection<StructurePackMeta>Get the list of pack meta.static @Nullable StructurePackMetaGet the currently selected pack.static @Nullable StructurePackMetagetStructurePack(String key) Query a structure pack for a key.static booleanCheck if the pack exists.static StructurePackMetaremovePack(String name) Remove a specific pack.static voidConclude loading.storeBlueprint(String packName, net.minecraft.nbt.CompoundTag compoundTag, Path path) Store a blueprint at a given path.static voidswitchSelectedPack(StructurePackMeta packMeta) Set the currently selected pack.static voidswitchSelectedPack(String packName) Set the currently selected pack.static booleanBlocks the current thread until loading has finished
-
Field Details
-
selectedPack
Deprecated.-> Don't read/write directly, go through methods. 1.22 will make this a string.Selected pack on the client.
-
-
Constructor Details
-
StructurePacks
public StructurePacks()
-
-
Method Details
-
waitUntilFinishedLoading
public static boolean waitUntilFinishedLoading()Blocks the current thread until loading has finished- Returns:
- true if finished; false if interrupted before finishing
-
setFinishedLoading
public static void setFinishedLoading()Conclude loading. -
getPackMetas
Get the list of pack meta.- Returns:
- the pack meta set.
-
getStructurePack
Query a structure pack for a key.- Parameters:
key- the used key.- Returns:
- the pack or null.
-
clearPacks
public static void clearPacks()Reset pack state. -
removePack
Remove a specific pack.- Parameters:
name- the packname.
-
getBlueprintFuture
public static CompletableFuture<Blueprint> getBlueprintFuture(String structurePackId, String subPath) Get a blueprint future.- Parameters:
structurePackId- the structure pack the blueprint is in.subPath- the path of the specific blueprint in the pack.- Returns:
- the blueprint future (might contain null).
-
getBlueprintDataFuture
public static CompletableFuture<byte[]> getBlueprintDataFuture(String structurePackId, String subPath) Get a blueprint data future.- Parameters:
structurePackId- the structure pack the blueprint is in.subPath- the path of the specific blueprint in the pack.- Returns:
- the blueprint data future (might contain null).
-
findBlueprintFuture
Find a blueprint future.- Parameters:
structurePackId- the structure pack the blueprint is in.name- the filename.- Returns:
- the blueprint future (might contain null).
-
getBlueprintsFuture
public static CompletableFuture<List<Blueprint>> getBlueprintsFuture(String structurePackId, String subPath) Get a list blueprint future.- Parameters:
structurePackId- the structure pack the blueprint is in.subPath- the path of the set of blueprints (usually a folder).- Returns:
- the blueprints list (might be empty).
-
getCategoriesFuture
public static CompletableFuture<List<StructurePacks.Category>> getCategoriesFuture(String structurePackId, String subPath) Get a list of categories of a specific sub-path of a given structure pack.- Parameters:
structurePackId- the id of the pack.subPath- the sub-path.- Returns:
- the list of categories.
-
getBlueprintFuture
Get the blueprint directly with a path.- Parameters:
packName- the pack we're looking in.path- the path to search for.- Returns:
- the blueprint.
-
findBlueprintFuture
public static CompletableFuture<Blueprint> findBlueprintFuture(String structurePackId, Predicate<Blueprint> blueprintPredicate) Find the blueprint async- Parameters:
blueprintPredicate- the predicate to define the blueprint we're looking for.- Returns:
- the blueprint future.
-
getBlueprintFuture
public static CompletableFuture<Blueprint> getBlueprintFuture(String structurePackId, String subPath, boolean suppressError) Get a blueprint future.- Parameters:
structurePackId- the structure pack the blueprint is in.subPath- the path of the specific blueprint in the pack.suppressError- log exception or not.- Returns:
- the blueprint future (might contain null).
-
getBlueprintFuture
public static CompletableFuture<Blueprint> getBlueprintFuture(String packName, Path path, boolean suppressError) Get the blueprint directly with a path.- Parameters:
packName- the pack we're looking in.path- the path to search for.suppressError- log exception or not.- Returns:
- the blueprint.
-
getBlueprint
Get a blueprint directly (careful IO, might be slow).- Parameters:
structurePackId- the structure pack the blueprint is in.subPath- the folder containing the blueprints.- Returns:
- the blueprint or null.
-
getBlueprint
Get the blueprint directly with a path.- Parameters:
pack- the pack this belongs to.path- the path to search for.- Returns:
- the blueprint.
-
findBlueprint
Find a blueprint by name.- Parameters:
structurePackId- the pack to search in.name- the name we're searching for.- Returns:
- the path or null.
-
findBlueprint
Find blueprint at path. Recursively goes through folder structure.- Parameters:
subPath- the sub path to check.name- the name of the file we're looking for.- Returns:
- the path of the file or null.
-
findBlueprint
public static Blueprint findBlueprint(String structurePackId, Predicate<Blueprint> blueprintPredicate) Find a blueprint by name.- Parameters:
structurePackId- the pack to search in.blueprintPredicate- matches the blueprint.- Returns:
- the blueprint or null.
-
findBlueprint
public static Blueprint findBlueprint(String pack, Path subPath, Predicate<Blueprint> blueprintPredicate) Find blueprint at path. Recursively goes through folder structure.- Parameters:
pack- the pack we're looking in.subPath- the sub path to check.blueprintPredicate- matches the blueprint.- Returns:
- the path of the file or null.
-
getBlueprint
@Nullable public static @Nullable Blueprint getBlueprint(String structurePackId, String subPath, boolean suppressError) Get a blueprint directly (careful IO, might be slow).- Parameters:
structurePackId- the structure pack the blueprint is in.subPath- the folder containing the blueprints.suppressError- log exception or not.- Returns:
- the blueprint or null.
-
getBlueprint
Get the blueprint directly with a path.- Parameters:
pack- the pack this belongs to.path- the path to search for.suppressError- log exception or not.- Returns:
- the blueprint.
-
getBlueprintData
Get blueprint data directly (careful IO, might be slow).- Parameters:
structurePackId- the structure pack the blueprint is in.subPath- the folder containing the blueprints.- Returns:
- the blueprint data in a byte array or null.
-
getBlueprints
Get a list of blueprints directly (careful IO, might be slow).- Parameters:
structurePackId- the structure pack the blueprint is in.subPath- the folder containing the blueprints.- Returns:
- the list of blueprints or empty
-
getCategories
Get a list of categories of a specific sub-path of a given structure pack. This has IO, this may be slow.- Parameters:
structurePackId- the id of the pack.subPath- the sub-path.- Returns:
- the list of categories.
-
discoverPackAtPath
public static void discoverPackAtPath(Path element, boolean immutable, List<String> modList, boolean clientPack, String owner) Discover a structure pack at a given path.- Parameters:
element- the path to check for.immutable- if jar (true), else false.modList- the list of mods loaded on this instance.clientPack- if this is a client pac.
-
storeBlueprint
public static Future<Blueprint> storeBlueprint(String packName, net.minecraft.nbt.CompoundTag compoundTag, Path path) Store a blueprint at a given path.- Parameters:
packName- the pack we're storing it in.compoundTag- compound to store.path- path to store it at.
-
hasPack
Check if the pack exists.- Parameters:
key- the pack id to check.- Returns:
- true if so.
-
getSelectedPack
Get the currently selected pack.- Returns:
- the random pack.
-
switchSelectedPack
Set the currently selected pack.- Parameters:
packMeta- the new pack meta.
-
switchSelectedPack
Set the currently selected pack.- Parameters:
packName- the new pack name.
-
ensureSelectedPack
public static void ensureSelectedPack()Ensure that we have a selected pack.
-