Class SoundCompat
java.lang.Object
tech.guilhermekaua.spigotboot.core.spigot.utils.SoundCompat
Cross-version
Sound resolution. Sound is an enum up to MC 1.21.2 and an
interface (registry type) from 1.21.3 on; this resolves a sound from a config string and
back without a compile-time assumption about its shape.-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable org.bukkit.SoundResolves a sound from a config value — an enum constant name (e.g.static @NotNull StringtoKey(@NotNull org.bukkit.Sound sound) Serializes a sound back to a stable config string: the enum name on enum builds, else the namespaced key (e.g.
-
Method Details
-
resolve
Resolves a sound from a config value — an enum constant name (e.g.ENTITY_PLAYER_LEVELUP) or a namespaced key (e.g.minecraft:entity.player.levelup).Note: bare enum-constant names (e.g.
ENTITY_PLAYER_LEVELUP) are only accepted on enum-Soundservers (MC <= 1.21.2); on interface-Soundservers (>= 1.21.3) supply a namespaced key (e.g.minecraft:entity.player.levelup).- Parameters:
value- the config value- Returns:
- the resolved sound, or
nullif unknown
-
toKey
Serializes a sound back to a stable config string: the enum name on enum builds, else the namespaced key (e.g.minecraft:entity.player.levelup).- Parameters:
sound- the sound- Returns:
- the config string
-