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.
-
Feldübersicht
Modifizierer und TypFeldBeschreibungstatic final int
The current version of the index file save format.static final String
-
Konstruktorübersicht
KonstruktorBeschreibungIndexFile
(SoundLocation location, boolean readOnly) Get the index file of the given location. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
Registers the given sound file in the index file so it can be accessed later.void
Checks all entries and removes files that no longer exist at the current location.void
close()
int
count()
boolean
Deletes the sound file from the disk and from the index file.void
deserializeNbt
(net.minecraft.nbt.CompoundTag nbt) static boolean
existsIn
(SoundLocation location) Checks if an index file exists at the given location.Generates a new id that doesn't already exist at this location.getAll()
getSoundFile
(String soundId) Get the sound file with the given id at the current location of the index file.boolean
Checks if the sound file exists.boolean
Checks if a sound file with the given id exists.boolean
static IndexFile
open
(SoundLocation location, boolean readOnly) Open the index file at the given location.void
save()
Saves the changed index file to disk.net.minecraft.nbt.CompoundTag
-
Felddetails
-
INDEX_FILENAME
- Siehe auch:
-
DATA_VERSION
public static final int DATA_VERSIONThe current version of the index file save format.- Siehe auch:
-
-
Konstruktordetails
-
IndexFile
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
- Gibt zurück:
- The location of this file.
-
add
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
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
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
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
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
- 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
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
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
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 Schnittstellede.mrjulsen.mcdragonlib.data.INBTSerializable
-
deserializeNbt
public void deserializeNbt(net.minecraft.nbt.CompoundTag nbt) - Angegeben von:
deserializeNbt
in Schnittstellede.mrjulsen.mcdragonlib.data.INBTSerializable
-
close
public void close()- Angegeben von:
close
in SchnittstelleAutoCloseable
-
count
public int count()- Gibt zurück:
- The amount of registered files.
-