Class PrefabStore

java.lang.Object
com.hypixel.hytale.server.core.prefab.PrefabStore

public class PrefabStore extends Object
  • Field Details

    • PREFAB_FILTER

      public static final Predicate<Path> PREFAB_FILTER
    • LARGE_PREFAB_BLOCK_THRESHOLD

      public static final int LARGE_PREFAB_BLOCK_THRESHOLD
      Prefabs with at least this many blocks save as .lpf instead of .prefab.json: the binary format avoids the JSON encode cost and on-disk size that get punishing at this scale.
      See Also:
    • PREFABS_PATH

      public static final Path PREFABS_PATH
  • Method Details

    • getServerPrefab

      @Nonnull public BlockSelection getServerPrefab(@Nonnull String key)
    • getPrefab

      @Nonnull public BlockSelection getPrefab(@Nonnull Path path)
    • isPrefabFileName

      public static boolean isPrefabFileName(@Nonnull String fileName)
      Returns whether fileName names a prefab: a .prefab.json, or a .lpf that is not the generated .prefab.json.lpf load cache.
    • stripPrefabSuffix

      @Nonnull public static String stripPrefabSuffix(@Nonnull String fileName)
      Strips the prefab suffix from fileName, for display names and prefab keys.
    • prefabExists

      public boolean prefabExists(@Nonnull Path path)
      Returns whether a prefab exists at path, checking both the .prefab.json and .lpf forms.
    • deletePrefab

      public boolean deletePrefab(@Nonnull Path path) throws IOException
      Deletes a prefab at path, removing whichever of the .prefab.json / .lpf forms exists on disk.
      Returns:
      true if a file was deleted.
      Throws:
      IOException
    • getServerPrefabsPath

      public Path getServerPrefabsPath()
    • getServerPrefabDir

      @Nonnull public Map<Path, BlockSelection> getServerPrefabDir(@Nonnull String key)
    • getPrefabDir

      @Nonnull public Map<Path, BlockSelection> getPrefabDir(@Nonnull Path dir)
    • saveServerPrefab

      public void saveServerPrefab(@Nonnull String key, @Nonnull BlockSelection prefab)
    • saveWorldGenPrefab

      public void saveWorldGenPrefab(@Nonnull String key, @Nonnull BlockSelection prefab, boolean overwrite)
    • savePrefab

      @Nonnull public Path savePrefab(@Nonnull Path path, @Nonnull BlockSelection prefab, boolean overwrite)
    • savePrefab

      @Nonnull public Path savePrefab(@Nonnull Path path, @Nonnull BlockSelection prefab, boolean overwrite, @Nonnull PrefabFormat format)
      Returns:
      the path actually written, which is the .lpf or the .prefab.json form depending on format and the block count.
    • getWorldGenPrefabsPath

      @Nonnull public Path getWorldGenPrefabsPath()
    • getAssetRootPath

      public Path getAssetRootPath()
    • getWorldGenPrefabsPath

      @Nonnull public Path getWorldGenPrefabsPath(@Nullable String name)
    • saveServerPrefab

      public void saveServerPrefab(@Nonnull String key, @Nonnull BlockSelection prefab, boolean overwrite)
    • saveServerPrefab

      @Nonnull public Path saveServerPrefab(@Nonnull String key, @Nonnull BlockSelection prefab, boolean overwrite, @Nonnull PrefabFormat format)
    • getAssetPrefabsPath

      @Nonnull public Path getAssetPrefabsPath()
    • getAssetPrefabsPathForPack

      @Nonnull public Path getAssetPrefabsPathForPack(@Nonnull AssetPack pack)
    • getAllAssetPrefabPaths

      @Nonnull public List<PrefabStore.AssetPackPrefabPath> getAllAssetPrefabPaths()
    • getAllBrowsablePrefabPaths

      @Nonnull public List<PrefabStore.AssetPackPrefabPath> getAllBrowsablePrefabPaths()
      Returns all prefab paths that should be shown in the prefab browser: all asset packs plus the server prefabs directory (if it exists).
    • getAssetPrefabFromAnyPack

      @Nullable public BlockSelection getAssetPrefabFromAnyPack(@Nonnull String key)
    • findAssetPrefabPath

      @Nullable public Path findAssetPrefabPath(@Nonnull String key)
      Finds a prefab's canonical .prefab.json path within any asset pack, even if it only exists on disk as a sibling .lpf (as large prefabs do). Callers that need to load the prefab (e.g. getPrefab(Path) or PrefabBufferUtil.loadBuffer(Path)) resolve the .lpf sibling themselves from the returned path.
    • findBrowsablePrefabPath

      @Nullable public Path findBrowsablePrefabPath(@Nonnull String key)
      Resolves a prefab key against every browsable location (all asset packs, then the server directory). The .prefab.json or .lpf suffix is optional; a sibling .lpf is preferred over .prefab.json when both exist. Returns null if no matching file exists.
    • listBrowsablePrefabKeys

      @Nonnull public List<String> listBrowsablePrefabKeys()
      Lists every browsable prefab as a key without its .prefab.json/.lpf suffix, for command suggestions.
    • findAssetPackForPrefabPath

      @Nullable public AssetPack findAssetPackForPrefabPath(@Nonnull Path prefabPath)
    • getRelativePrefabPath

      @Nonnull public Path getRelativePrefabPath(@Nonnull Path absolutePrefabPath)
    • getAssetPrefab

      @Nonnull public BlockSelection getAssetPrefab(@Nonnull String key)
    • getAssetPrefabDir

      @Nonnull public Map<Path, BlockSelection> getAssetPrefabDir(@Nonnull String key)
    • saveAssetPrefab

      public void saveAssetPrefab(@Nonnull String key, @Nonnull BlockSelection prefab)
    • saveAssetPrefab

      public void saveAssetPrefab(@Nonnull String key, @Nonnull BlockSelection prefab, boolean overwrite)
    • savePrefabToPack

      public void savePrefabToPack(@Nonnull AssetPack pack, @Nonnull String key, @Nonnull BlockSelection prefab, boolean overwrite)
    • savePrefabToPack

      @Nonnull public Path savePrefabToPack(@Nonnull AssetPack pack, @Nonnull String key, @Nonnull BlockSelection prefab, boolean overwrite, @Nonnull PrefabFormat format)
    • getPrefabsPathForPack

      @Nonnull public Path getPrefabsPathForPack(@Nullable AssetPack pack)
    • getWorldGenPrefab

      @Nonnull public BlockSelection getWorldGenPrefab(@Nonnull String key)
    • getWorldGenPrefab

      @Nonnull public BlockSelection getWorldGenPrefab(@Nonnull Path prefabsPath, @Nonnull String key)
    • getWorldGenPrefabDir

      @Nonnull public Map<Path, BlockSelection> getWorldGenPrefabDir(@Nonnull String key)
    • saveWorldGenPrefab

      public void saveWorldGenPrefab(@Nonnull String key, @Nonnull BlockSelection prefab)
    • get

      public static PrefabStore get()