Class SoundFile
java.lang.Object
de.mrjulsen.dragnsounds.core.filesystem.SoundFile
This object contains information about one specific sound file on the server. While most of the values are read-only, addons can use the metadata to store additional information (such as visibility to other players, etc.)
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Data collection to create a new sound file on the server. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic SoundFile
client
(SoundLocation location, String id) int
void
deserializeNbt
(net.minecraft.nbt.CompoundTag nbt, net.minecraft.world.level.Level level) boolean
static SoundFile
fromNbt
(net.minecraft.nbt.CompoundTag nbt, net.minecraft.world.level.Level level) Returns the file object of this sound.A shortcut to get the audio channels.A shortcut to a default metadata value.getId()
getInfo()
Additional data about this file.getMetadataSafe
(String key) A safe method to get the metadata of the sound file.getPath()
getPath
(SoundLocation location, String soundFileId) hash()
int
hashCode()
of
(SoundLocation location, String id) Get aSoundFile
object by location and filename (Id).void
removeMetadata
(Set<String> keys) Update the metadata of this file.static void
removeMetadataInternal
(SoundLocation location, String id, Set<String> keys) net.minecraft.nbt.CompoundTag
toString()
void
updateMetadata
(Map<String, String> meta) Update the metadata of this file.static void
updateMetadataInternal
(SoundLocation location, String id, Map<String, String> meta) void
Called on the server-side after loading the file.
-
Field Details
-
META_DISPLAY_NAME
Default metadata key to get the display name of the file which is stored in the metadata. (because it is not read-only)- See Also:
-
META_DEFAULT_KEYS
-
CURRENT_VERSION
protected static final int CURRENT_VERSION- See Also:
-
DEFAULT_AUDIO_FILE_EXTENSION
- See Also:
-
metadata
-
-
Method Details
-
currentVersion
public int currentVersion() -
getMetadata
Additional data about this file. Addons can use this to store their own info about sound files.- Returns:
- A copy of the metadata of this file. (Not the actual object to prevent changes)
- Related:
updateMetadata(...)
- Add or replace metadata entries.,removeMetadata(...)
- Remove metadata entries.
-
updateMetadata
Update the metadata of this file. The data will be send to the server and applied there.- Parameters:
meta
- The collection of the new keys and values. This is NOT the completeMap
containing ALL metadata entries, but only a collection of the changes. New keys will be added and existing ones will be replaced.- Related:
removeMetadata(...)
- Remove metadata entries.
-
removeMetadata
Update the metadata of this file. The data will be send to the server and applied there.- Parameters:
keys
- A collection of metadata keys that should be removed from the list.- API Note:
- You CANNOT remove any of the built-in metadata entries, such as
META_DISPLAY_NAME
, as they are changeable, but not optional. You can add these keys to theSet
, but they get removed while processing. - Related:
updateMetadata(...)
- Add or replace metadata entries.,META_DEFAULT_KEYS
- Contains all built-in metadata keys.
-
getMetadataSafe
A safe method to get the metadata of the sound file.- Parameters:
key
- The key name of the metadata entry.- Returns:
- The metadata string value or an empty string if the metadata entry does not exist.
-
getLocation
- Returns:
- The location where the sound file is saved.
-
getId
- Returns:
- The id of the sound and the name of the sound file on disk.
-
hash
- Returns:
- The file hash value.
-
getInfo
- Returns:
- Some additional read-only information about the file itself, such as the owner or the upload timestamp. It also contains shortcuts to important information for better performance. These values are changed automatically when the file hash changes.
-
getPath
- Returns:
- An
Optional
containing the path to the sound file or an emptyOptional
if the path is invalid or there is an error while generating the path.
-
getPath
-
getAsFile
Returns the file object of this sound.- Returns:
- The file, if available.
- Valid on side:
- Server
-
getDisplayName
A shortcut to a default metadata value.- Returns:
- The display name of the file.
- API Note:
- Metadata key:
META_DISPLAY_NAME
-
getAudioChannels
A shortcut to get the audio channels.- Returns:
- Audio channels enum value.
-
serializeNbt
public net.minecraft.nbt.CompoundTag serializeNbt() -
deserializeNbt
public void deserializeNbt(net.minecraft.nbt.CompoundTag nbt, net.minecraft.world.level.Level level) -
fromNbt
public static SoundFile fromNbt(net.minecraft.nbt.CompoundTag nbt, net.minecraft.world.level.Level level) -
validateHash
public void validateHash()Called on the server-side after loading the file. Do not call this by yourself! -
of
Get aSoundFile
object by location and filename (Id).- Parameters:
location
- The location where the sound is saved at.id
- The if of the sound file (filename on disk without extension)- Returns:
- The
SoundFile
, if available. - Valid on side:
- Server
-
client
-
hashCode
public int hashCode() -
equals
-
toString
-
updateMetadataInternal
public static void updateMetadataInternal(SoundLocation location, String id, Map<String, String> meta) throws IOException- Throws:
IOException
-
removeMetadataInternal
public static void removeMetadataInternal(SoundLocation location, String id, Set<String> keys) throws IOException - Throws:
IOException
-