java.lang.Object
tech.guilhermekaua.spigotboot.core.spigot.utils.SoundCompat

public final class SoundCompat extends Object
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 Type
    Method
    Description
    static @Nullable org.bukkit.Sound
    resolve(@NotNull String value)
    Resolves a sound from a config value — an enum constant name (e.g.
    static @NotNull String
    toKey(@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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • resolve

      @Nullable public static @Nullable org.bukkit.Sound resolve(@NotNull @NotNull String value)
      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-Sound servers (MC <= 1.21.2); on interface-Sound servers (>= 1.21.3) supply a namespaced key (e.g. minecraft:entity.player.levelup).

      Parameters:
      value - the config value
      Returns:
      the resolved sound, or null if unknown
    • toKey

      @NotNull public static @NotNull String toKey(@NotNull @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. minecraft:entity.player.levelup).
      Parameters:
      sound - the sound
      Returns:
      the config string