Klasse IndexFile

java.lang.Object
de.mrjulsen.dragnsounds.core.filesystem.IndexFile
Alle implementierten Schnittstellen:
de.mrjulsen.mcdragonlib.data.INBTSerializable, AutoCloseable

public class IndexFile extends Object implements de.mrjulsen.mcdragonlib.data.INBTSerializable, AutoCloseable
A file containing information about all custom sound files in the same directory. Files that are not registered in this index file cannot be accessed.
  • Felddetails

    • INDEX_FILENAME

      public static final String INDEX_FILENAME
      Siehe auch:
    • DATA_VERSION

      public static final int DATA_VERSION
      The current version of the index file save format.
      Siehe auch:
  • Konstruktordetails

    • IndexFile

      public IndexFile(SoundLocation location, boolean readOnly) throws IOException
      Get the index file of the given location.
      Parameter:
      location - The target directory location.
      Löst aus:
      IOException
  • Methodendetails

    • checkAndRepair

      public void checkAndRepair()
      Checks all entries and removes files that no longer exist at the current location.
    • getLocation

      public SoundLocation getLocation()
      Gibt zurück:
      The location of this file.
    • add

      public void add(SoundFile file)
      Registers the given sound file in the index file so it can be accessed later. This is very important, otherwise the sound file gets lost and may be deleted.
      Parameter:
      file - The sound file to register.
      API Note:
      Cannot be used in read-only mode!
    • has

      public boolean has(String soundId)
      Checks if a sound file with the given id exists.
      Parameter:
      soundId - The id of the custom sound file you want to check.
      Gibt zurück:
      true if the file exists, false otherwise.
    • has

      public boolean has(File file)
      Checks if the sound file exists.
      Parameter:
      file - The file you want to check.
      Gibt zurück:
      true if the file exists, false otherwise.
    • delete

      public boolean delete(String soundId)
      Deletes the sound file from the disk and from the index file.
      Parameter:
      soundId - The id of the custom sound file.
      Gibt zurück:
      Whether the action was successfull.
      API Note:
      Cannot be used in read-only mode!
    • getSoundFile

      public SoundFile getSoundFile(String soundId)
      Get the sound file with the given id at the current location of the index file.
      Parameter:
      soundId - The id of the cusotm sound file.
      Gibt zurück:
      The SoundFile if available, null otherwise.
    • getAll

      public SoundFile[] getAll()
      Gibt zurück:
      A list of all registered sound files that also exist on disk.
    • isReadOnly

      public boolean isReadOnly()
      Gibt zurück:
      If this instance of the file is read-only.
    • save

      public void save()
      Saves the changed index file to disk. Run this every time after changing some values. You can also use try-with-resources which saves the changed index file automatically.
      API Note:
      Cannot be used in read-only mode!
    • open

      public static IndexFile open(SoundLocation location, boolean readOnly) throws IOException
      Open the index file at the given location. If no index file exists, a new one will be created (only in memory, not on disk).
      Parameter:
      location - The location of the index file.
      readOnly - If the instance should be read-only. Use this whenever possible to make the file accessible for other processes.
      Gibt zurück:
      The index file.
      Löst aus:
      IOException
    • existsIn

      public static boolean existsIn(SoundLocation location)
      Checks if an index file exists at the given location.
      Parameter:
      location - The location to check.
      Gibt zurück:
      true if there is an index file at this location.
    • generateId

      public String generateId()
      Generates a new id that doesn't already exist at this location.
      Gibt zurück:
      The new id.
    • serializeNbt

      public net.minecraft.nbt.CompoundTag serializeNbt()
      Angegeben von:
      serializeNbt in Schnittstelle de.mrjulsen.mcdragonlib.data.INBTSerializable
    • deserializeNbt

      public void deserializeNbt(net.minecraft.nbt.CompoundTag nbt)
      Angegeben von:
      deserializeNbt in Schnittstelle de.mrjulsen.mcdragonlib.data.INBTSerializable
    • close

      public void close()
      Angegeben von:
      close in Schnittstelle AutoCloseable
    • count

      public int count()
      Gibt zurück:
      The amount of registered files.